| 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 | |
| 11 | // <future> |
| 12 | |
| 13 | // class packaged_task<R(ArgTypes...)> |
| 14 | // template <class F, class Allocator> |
| 15 | // packaged_task(allocator_arg_t, const Allocator& a, F&& f); |
| 16 | // These constructors shall not participate in overload resolution if |
| 17 | // decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>. |
| 18 | |
| 19 | #include <cassert> |
| 20 | #include <future> |
| 21 | #include <memory> |
| 22 | #include <type_traits> |
| 23 | |
| 24 | #include "test_allocator.h" |
| 25 | |
| 26 | struct A {}; |
| 27 | using PT = std::packaged_task<A(int, char)>; |
| 28 | using VPT = volatile std::packaged_task<A(int, char)>; |
| 29 | |
| 30 | static_assert(!std::is_constructible<PT, std::allocator_arg_t, test_allocator<A>, VPT>::value, "" ); |
| 31 | |
| 32 | using PA = std::packaged_task<A(int)>; |
| 33 | using PI = std::packaged_task<int(int)>; |
| 34 | |
| 35 | static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&>::value, "" ); |
| 36 | static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&&>::value, "" ); |
| 37 | static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&>::value, "" ); |
| 38 | static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&&>::value, "" ); |
| 39 | |
| 40 | #if TEST_STD_VER >= 17 // packaged_task allocator support was removed in C++17 (LWG 2921) |
| 41 | static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, const PI&>); |
| 42 | static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>); |
| 43 | static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>); |
| 44 | static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>); |
| 45 | #else |
| 46 | static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&>::value, "" ); |
| 47 | static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>::value, "" ); |
| 48 | static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>::value, "" ); |
| 49 | static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>::value, "" ); |
| 50 | #endif |
| 51 | |