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