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

source code of libcxx/test/std/containers/container.adaptors/stack/stack.cons/deduct.verify.cpp