deduct.fail.cpp (1567B)
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <queue> 11 // UNSUPPORTED: c++98, c++03, c++11, c++14 12 // UNSUPPORTED: libcpp-no-deduction-guides 13 14 #include <queue> 15 #include <list> 16 #include <iterator> 17 #include <cassert> 18 #include <cstddef> 19 20 21 int main() 22 { 23 // Test the explicit deduction guides 24 { 25 // queue(const Container&, const Alloc&); 26 // The '45' is not an allocator 27 std::queue que(std::list<int>{1,2,3}, 45); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'queue'}} 28 } 29 30 { 31 // queue(const queue&, const Alloc&); 32 // The '45' is not an allocator 33 std::queue<int> source; 34 std::queue que(source, 45); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'queue'}} 35 } 36 37 // Test the implicit deduction guides 38 { 39 // queue (allocator &) 40 std::queue que((std::allocator<int>())); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'queue'}} 41 // Note: The extra parens are necessary, since otherwise clang decides it is a function declaration. 42 // Also, we can't use {} instead of parens, because that constructs a 43 // stack<allocator<int>, allocator<allocator<int>>> 44 } 45 46 }