1f7558068SNikolas Klauser //===----------------------------------------------------------------------===// 2f7558068SNikolas Klauser // 3f7558068SNikolas Klauser // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4f7558068SNikolas Klauser // See https://llvm.org/LICENSE.txt for license information. 5f7558068SNikolas Klauser // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6f7558068SNikolas Klauser // 7f7558068SNikolas Klauser //===----------------------------------------------------------------------===// 8f7558068SNikolas Klauser // 9a7f9895cSLouis Dionne // UNSUPPORTED: no-threads 10f7558068SNikolas Klauser 11f7558068SNikolas Klauser // <future> 12f7558068SNikolas Klauser 13f7558068SNikolas Klauser // class packaged_task<R(ArgTypes...)> 14f7558068SNikolas Klauser // template <class F, class Allocator> 15f7558068SNikolas Klauser // packaged_task(allocator_arg_t, const Allocator& a, F&& f); 16f7558068SNikolas Klauser // These constructors shall not participate in overload resolution if 17f7558068SNikolas Klauser // decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>. 18f7558068SNikolas Klauser 19f7558068SNikolas Klauser #include <cassert> 20f7558068SNikolas Klauser #include <future> 21*3a0ef2a2SA. Jiang #include <memory> 22*3a0ef2a2SA. Jiang #include <type_traits> 23f7558068SNikolas Klauser 24f7558068SNikolas Klauser #include "test_allocator.h" 25f7558068SNikolas Klauser 26f7558068SNikolas Klauser struct A {}; 27f7558068SNikolas Klauser using PT = std::packaged_task<A(int, char)>; 28f7558068SNikolas Klauser using VPT = volatile std::packaged_task<A(int, char)>; 29f7558068SNikolas Klauser 30f7558068SNikolas Klauser static_assert(!std::is_constructible<PT, std::allocator_arg_t, test_allocator<A>, VPT>::value, ""); 31f7558068SNikolas Klauser 32f7558068SNikolas Klauser using PA = std::packaged_task<A(int)>; 33f7558068SNikolas Klauser using PI = std::packaged_task<int(int)>; 34f7558068SNikolas Klauser 35f7558068SNikolas Klauser static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&>::value, ""); 36f7558068SNikolas Klauser static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&&>::value, ""); 37f7558068SNikolas Klauser static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&>::value, ""); 38f7558068SNikolas Klauser static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&&>::value, ""); 39f7558068SNikolas Klauser 40*3a0ef2a2SA. Jiang #if TEST_STD_VER >= 17 // packaged_task allocator support was removed in C++17 (LWG 2921) 41*3a0ef2a2SA. Jiang static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, const PI&>); 42*3a0ef2a2SA. Jiang static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>); 43*3a0ef2a2SA. Jiang static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>); 44*3a0ef2a2SA. Jiang static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>); 45*3a0ef2a2SA. Jiang #else 46f7558068SNikolas Klauser static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&>::value, ""); 47f7558068SNikolas Klauser static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>::value, ""); 48f7558068SNikolas Klauser static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>::value, ""); 49f7558068SNikolas Klauser static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>::value, ""); 50*3a0ef2a2SA. Jiang #endif 51