• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <future>
11 
12 // class promise<R>
13 
14 // void promise::set_exception_at_thread_exit(exception_ptr p);
15 
16 #include <future>
17 #include <cassert>
18 
func(std::promise<int> p)19 void func(std::promise<int> p)
20 {
21     const int i = 5;
22     p.set_exception_at_thread_exit(std::make_exception_ptr(3));
23 }
24 
main()25 int main()
26 {
27     {
28         typedef int T;
29         std::promise<T> p;
30         std::future<T> f = p.get_future();
31         std::thread(func, std::move(p)).detach();
32         try
33         {
34             f.get();
35             assert(false);
36         }
37         catch (int i)
38         {
39             assert(i == 3);
40         }
41     }
42 }
43