blob: 18f87c596a0059846f5dc44e47c6aee7fbf66bb6 [file] [log] [blame]
Howard Hinnantf39daa82010-08-28 21:01:06 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantf39daa82010-08-28 21:01:06 +00007//
8//===----------------------------------------------------------------------===//
Jonathan Roelofs8d86b2e2014-09-05 19:45:05 +00009//
10// UNSUPPORTED: libcpp-has-no-threads
Howard Hinnantf39daa82010-08-28 21:01:06 +000011
12// <future>
13
14// class promise<R>
15
16// void promise<R&>::set_value_at_thread_exit(R& r);
17
18#include <future>
19#include <memory>
20#include <cassert>
21
22int i = 0;
23
Howard Hinnant932209b2011-05-17 23:32:48 +000024void func(std::promise<int&> p)
Howard Hinnantf39daa82010-08-28 21:01:06 +000025{
26 p.set_value_at_thread_exit(i);
27 i = 4;
28}
29
30int main()
31{
32 {
33 std::promise<int&> p;
34 std::future<int&> f = p.get_future();
35 std::thread(func, std::move(p)).detach();
36 assert(f.get() == 4);
37 }
38}