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: c++03, c++11, c++14, c++17, c++20
10
11// <flat_map>
12
13// Test CTAD on cases where deduction should fail.
14
15#include <flat_map>
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
25using P = std::pair<int, long>;
26using PC = std::pair<const int, long>;
27
28template <class... Args>
29concept CanDeductFlatMultimap = requires { std::flat_multimap{std::declval<Args>()...}; };
30
31static_assert(CanDeductFlatMultimap<std::vector<int>, std::vector<int>>);
32
33// cannot deduce Key and T from nothing
34static_assert(!CanDeductFlatMultimap<>);
35
36// cannot deduce Key and T from just (KeyContainer), even if it's a container of pairs
37static_assert(!CanDeductFlatMultimap<std::vector<std::pair<int, int>>>);
38
39// cannot deduce Key and T from just (KeyContainer, Allocator)
40static_assert(!CanDeductFlatMultimap<std::vector<int>, std::allocator<std::pair<const int, int>>>);
41
42// cannot deduce Key and T from just (Compare)
43static_assert(!CanDeductFlatMultimap<std::less<int>>);
44
45// cannot deduce Key and T from just (Compare, Allocator)
46static_assert(!CanDeductFlatMultimap<std::less<int>, std::allocator<PC>>);
47
48// cannot deduce Key and T from just (Allocator)
49static_assert(!CanDeductFlatMultimap<std::allocator<PC>>);
50
51// cannot convert from some arbitrary unrelated type
52static_assert(!CanDeductFlatMultimap<NotAnAllocator>);
53

source code of libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/deduct.compile.pass.cpp