brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 1161fe6 Raw
44 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: c++03, c++11, c++14, c++17, c++2010 11// <flat_set>12 13// Test CTAD on cases where deduction should fail.14 15#include <flat_set>16#include <functional>17#include <memory>18#include <utility>19#include <vector>20 21struct NotAnAllocator {22  friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }23};24 25template <class... Args>26concept CanDeductFlatSet = requires { std::flat_set(std::declval<Args>()...); };27 28static_assert(CanDeductFlatSet<std::vector<int>>);29 30// cannot deduce Key and T from nothing31static_assert(!CanDeductFlatSet<>);32 33// cannot deduce Key and T from just (Compare)34static_assert(!CanDeductFlatSet<std::less<int>>);35 36// cannot deduce Key and T from just (Compare, Allocator)37static_assert(!CanDeductFlatSet<std::less<int>, std::allocator<int>>);38 39// cannot deduce Key and T from just (Allocator)40static_assert(!CanDeductFlatSet<std::allocator<int>>);41 42// cannot convert from some arbitrary unrelated type43static_assert(!CanDeductFlatSet<NotAnAllocator>);44