brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · a3bdd45 Raw
51 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10 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 if17//    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 26struct A {};27using PT  = std::packaged_task<A(int, char)>;28using VPT = volatile std::packaged_task<A(int, char)>;29 30static_assert(!std::is_constructible<PT, std::allocator_arg_t, test_allocator<A>, VPT>::value, "");31 32using PA = std::packaged_task<A(int)>;33using PI = std::packaged_task<int(int)>;34 35static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&>::value, "");36static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&&>::value, "");37static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&>::value, "");38static_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)41static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, const PI&>);42static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>);43static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>);44static_assert(!std::is_constructible_v<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>);45#else46static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&>::value, "");47static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>::value, "");48static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>::value, "");49static_assert(std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>::value, "");50#endif51