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<R&>::set_value(R& r); 15 16#include <future> 17#include <cassert> 18 19int main() 20{ 21 { 22 typedef int& T; 23 int i = 3; 24 std::promise<T> p; 25 std::future<T> f = p.get_future(); 26 p.set_value(i); 27 int& j = f.get(); 28 assert(j == 3); 29 ++i; 30 assert(j == 4); 31 try 32 { 33 p.set_value(i); 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