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-has-no-threads
     11 
     12 // <future>
     13 
     14 // class promise<R>
     15 
     16 // void promise::set_value_at_thread_exit(const R& r);
     17 
     18 #include <future>
     19 #include <cassert>
     20 
     21 void func(std::promise<int> p)
     22 {
     23     const int i = 5;
     24     p.set_value_at_thread_exit(i);
     25 }
     26 
     27 int main()
     28 {
     29     {
     30         std::promise<int> p;
     31         std::future<int> f = p.get_future();
     32         std::thread(func, std::move(p)).detach();
     33         assert(f.get() == 5);
     34     }
     35 }
     36