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