Home | History | Annotate | Download | only in futures.promise
      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 // UNSUPPORTED: libcpp-no-exceptions
     11 // UNSUPPORTED: libcpp-has-no-threads
     12 // UNSUPPORTED: c++98, c++03
     13 
     14 // <future>
     15 
     16 // class promise<R>
     17 
     18 // void promise::set_exception_at_thread_exit(exception_ptr p);
     19 
     20 #include <future>
     21 #include <cassert>
     22 
     23 void func(std::promise<int> p)
     24 {
     25     p.set_exception_at_thread_exit(std::make_exception_ptr(3));
     26 }
     27 
     28 int main()
     29 {
     30     {
     31         typedef int T;
     32         std::promise<T> p;
     33         std::future<T> f = p.get_future();
     34         std::thread(func, std::move(p)).detach();
     35         try
     36         {
     37             f.get();
     38             assert(false);
     39         }
     40         catch (int i)
     41         {
     42             assert(i == 3);
     43         }
     44     }
     45 }
     46