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