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<void>::set_value(); 15 16 #include <future> 17 #include <cassert> 18 main()19int main() 20 { 21 { 22 typedef void T; 23 std::promise<T> p; 24 std::future<T> f = p.get_future(); 25 p.set_value(); 26 f.get(); 27 try 28 { 29 p.set_value(); 30 assert(false); 31 } 32 catch (const std::future_error& e) 33 { 34 assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); 35 } 36 } 37 } 38