blob: 5e57692563d88f05fb5618c76c03fc2070d5d15b [file] [log] [blame]
Howard Hinnantf39daa82010-08-28 21:01:06 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantf39daa82010-08-28 21:01:06 +00007//
8//===----------------------------------------------------------------------===//
Jonathan Roelofs8d86b2e2014-09-05 19:45:05 +00009//
10// UNSUPPORTED: libcpp-has-no-threads
Howard Hinnantf39daa82010-08-28 21:01:06 +000011
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 Hinnant932209b2011-05-17 23:32:48 +000021void func(std::promise<int> p)
Howard Hinnantf39daa82010-08-28 21:01:06 +000022{
23 const int i = 5;
24 p.set_exception_at_thread_exit(std::make_exception_ptr(3));
25}
26
27int 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}