Home | History | Annotate | Download | only in stack.cons
      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 // <stack>
     11 // UNSUPPORTED: c++98, c++03, c++11, c++14
     12 // UNSUPPORTED: libcpp-no-deduction-guides
     13 
     14 
     15 // template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
     16 //    vector(InputIterator, InputIterator, Allocator = Allocator())
     17 //    -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
     18 //
     19 
     20 
     21 #include <stack>
     22 #include <list>
     23 #include <iterator>
     24 #include <cassert>
     25 #include <cstddef>
     26 
     27 
     28 int main()
     29 {
     30 //  Test the explicit deduction guides
     31     {
     32 //  stack(const Container&, const Alloc&);
     33 //  The '45' is not an allocator
     34     std::stack stk(std::list<int>({1,2,3}), 45);  // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'stack'}}
     35     }
     36 
     37     {
     38 //  stack(const stack&, const Alloc&);
     39 //  The '45' is not an allocator
     40     std::stack<int> source;
     41     std::stack stk(source, 45);  // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'stack'}}
     42     }
     43 
     44 //  Test the implicit deduction guides
     45     {
     46 //  stack (allocator &)
     47     std::stack stk((std::allocator<int>()));  // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'stack'}}
     48 //  Note: The extra parens are necessary, since otherwise clang decides it is a function declaration.
     49 //  Also, we can't use {} instead of parens, because that constructs a
     50 //      stack<allocator<int>, allocator<allocator<int>>>
     51     }
     52 
     53 }
     54