1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // UNSUPPORTED: no-exceptions 10 // UNSUPPORTED: no-threads 11 // UNSUPPORTED: c++03 12 13 // <future> 14 15 // class promise<R> 16 17 // void promise<void>::set_value(); 18 19 #include <future> 20 #include <cassert> 21 22 #include "test_macros.h" 23 main(int,char **)24int main(int, char**) 25 { 26 { 27 typedef void T; 28 std::promise<T> p; 29 std::future<T> f = p.get_future(); 30 p.set_value(); 31 f.get(); 32 try 33 { 34 p.set_value(); 35 assert(false); 36 } 37 catch (const std::future_error& e) 38 { 39 assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); 40 } 41 } 42 43 return 0; 44 } 45