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 future_error 13 14 // const char* what() const throw(); 15 16 #include <future> 17 #include <cstring> 18 #include <cassert> 19 20 int main() 21 { 22 { 23 std::future_error f(std::make_error_code(std::future_errc::broken_promise)); 24 assert(std::strcmp(f.what(), "The associated promise has been destructed prior " 25 "to the associated state becoming ready.") == 0); 26 } 27 { 28 std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved)); 29 assert(std::strcmp(f.what(), "The future has already been retrieved from " 30 "the promise or packaged_task.") == 0); 31 } 32 { 33 std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied)); 34 assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0); 35 } 36 { 37 std::future_error f(std::make_error_code(std::future_errc::no_state)); 38 assert(std::strcmp(f.what(), "Operation not permitted on an object without " 39 "an associated state.") == 0); 40 } 41 } 42