Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / thread / futures / futures.promise / set_lvalue.pass.cpp
blobf61eee8f779c95c234e2a00d7e9f7cac6dcbe497
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-threads
10 // UNSUPPORTED: c++03
12 // <future>
14 // class promise<R>
16 // void promise<R&>::set_value(R& r);
18 #include <future>
19 #include <cassert>
21 #include "test_macros.h"
23 int main(int, char**)
26 typedef int& T;
27 int i = 3;
28 std::promise<T> p;
29 std::future<T> f = p.get_future();
30 p.set_value(i);
31 int& j = f.get();
32 assert(j == 3);
33 ++i;
34 assert(j == 4);
35 #ifndef TEST_HAS_NO_EXCEPTIONS
36 try
38 p.set_value(i);
39 assert(false);
41 catch (const std::future_error& e)
43 assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
45 #endif
48 return 0;