llvm-project
69 строк · 2.7 Кб
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
10
11// <set>
12
13// template<class InputIterator,
14// class Compare = less<iter-value-type<InputIterator>>,
15// class Allocator = allocator<iter-value-type<InputIterator>>>
16// multiset(InputIterator, InputIterator,
17// Compare = Compare(), Allocator = Allocator())
18// -> multiset<iter-value-type<InputIterator>, Compare, Allocator>;
19// template<class Key, class Compare = less<Key>,
20// class Allocator = allocator<Key>>
21// multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
22// -> multiset<Key, Compare, Allocator>;
23// template<class InputIterator, class Allocator>
24// multiset(InputIterator, InputIterator, Allocator)
25// -> multiset<iter-value-type<InputIterator>,
26// less<iter-value-type<InputIterator>>, Allocator>;
27// template<class Key, class Allocator>
28// multiset(initializer_list<Key>, Allocator)
29// -> multiset<Key, less<Key>, Allocator>;
30
31#include <functional>
32#include <set>
33#include <type_traits>
34
35struct NotAnAllocator {
36friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
37};
38
39int main(int, char **) {
40{
41// cannot deduce Key from nothing
42std::multiset s;
43// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}multiset'}}
44}
45{
46// cannot deduce Key from just (Compare)
47std::multiset s(std::less<int>{});
48// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}multiset'}}
49}
50{
51// cannot deduce Key from just (Compare, Allocator)
52std::multiset s(std::less<int>{}, std::allocator<int>{});
53// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}multiset'}}
54}
55{
56// cannot deduce Key from multiset(Allocator)
57std::multiset s(std::allocator<int>{});
58// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}multiset'}}
59}
60{
61// since we have parens, not braces, this deliberately does not find the
62// initializer_list constructor
63NotAnAllocator a;
64std::multiset s(a);
65// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}multiset'}}
66}
67
68return 0;
69}
70