Howard Hinnant | f39daa8 | 2010-08-28 21:01:06 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | f39daa8 | 2010-08-28 21:01:06 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 9 | // |
| 10 | // UNSUPPORTED: libcpp-has-no-threads |
Howard Hinnant | f39daa8 | 2010-08-28 21:01:06 +0000 | [diff] [blame] | 11 | |
| 12 | // <future> |
| 13 | |
| 14 | // class promise<R> |
| 15 | |
| 16 | // void promise::set_exception_at_thread_exit(exception_ptr p); |
| 17 | |
| 18 | #include <future> |
| 19 | #include <cassert> |
| 20 | |
Howard Hinnant | 932209b | 2011-05-17 23:32:48 +0000 | [diff] [blame] | 21 | void func(std::promise<int> p) |
Howard Hinnant | f39daa8 | 2010-08-28 21:01:06 +0000 | [diff] [blame] | 22 | { |
| 23 | const int i = 5; |
| 24 | p.set_exception_at_thread_exit(std::make_exception_ptr(3)); |
| 25 | } |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | { |
| 30 | typedef int T; |
| 31 | std::promise<T> p; |
| 32 | std::future<T> f = p.get_future(); |
| 33 | std::thread(func, std::move(p)).detach(); |
| 34 | try |
| 35 | { |
| 36 | f.get(); |
| 37 | assert(false); |
| 38 | } |
| 39 | catch (int i) |
| 40 | { |
| 41 | assert(i == 3); |
| 42 | } |
| 43 | } |
| 44 | } |