1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
10 // UNSUPPORTED: no-threads
15 // class shared_future<R>
22 #include "test_macros.h"
23 #include "test_allocator.h"
27 test_allocator_statistics alloc_stats
;
28 assert(alloc_stats
.alloc_count
== 0);
31 std::shared_future
<T
> f
;
33 std::promise
<T
> p(std::allocator_arg
, test_allocator
<T
>(&alloc_stats
));
34 assert(alloc_stats
.alloc_count
== 1);
36 assert(alloc_stats
.alloc_count
== 1);
39 assert(alloc_stats
.alloc_count
== 1);
42 assert(alloc_stats
.alloc_count
== 0);
45 std::shared_future
<T
> f
;
47 std::promise
<T
> p(std::allocator_arg
, test_allocator
<int>(&alloc_stats
));
48 assert(alloc_stats
.alloc_count
== 1);
50 assert(alloc_stats
.alloc_count
== 1);
53 assert(alloc_stats
.alloc_count
== 1);
56 assert(alloc_stats
.alloc_count
== 0);
59 std::shared_future
<T
> f
;
61 std::promise
<T
> p(std::allocator_arg
, test_allocator
<T
>(&alloc_stats
));
62 assert(alloc_stats
.alloc_count
== 1);
64 assert(alloc_stats
.alloc_count
== 1);
67 assert(alloc_stats
.alloc_count
== 1);
70 assert(alloc_stats
.alloc_count
== 0);