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