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_value_at_thread_exit(const R& r);
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_value_at_thread_exit(i);
23 }
24 
main()25 int main()
26 {
27     {
28         std::promise<int> p;
29         std::future<int> f = p.get_future();
30         std::thread(func, std::move(p)).detach();
31         assert(f.get() == 5);
32     }
33 }
34