Home | History | Annotate | Download | only in futures.promise
      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-no-exceptions
     11 // UNSUPPORTED: libcpp-has-no-threads
     12 // UNSUPPORTED: c++98, c++03
     13 
     14 // <future>
     15 
     16 // class promise<R>
     17 
     18 // void promise<void>::set_value();
     19 
     20 #include <future>
     21 #include <cassert>
     22 
     23 int main()
     24 {
     25     {
     26         typedef void T;
     27         std::promise<T> p;
     28         std::future<T> f = p.get_future();
     29         p.set_value();
     30         f.get();
     31         try
     32         {
     33             p.set_value();
     34             assert(false);
     35         }
     36         catch (const std::future_error& e)
     37         {
     38             assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
     39         }
     40     }
     41 }
     42