summaryrefslogtreecommitdiff
path: root/test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:07:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:07:56 +0000
commitf36202620b428c45a1c8d91743727c9313424fb2 (patch)
tree14928d8970ba4890a6370aca4c38fc832d45f21f /test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp
parent0294ba5648d889e48ffee8ddad25944e258940ae (diff)
Notes
Diffstat (limited to 'test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp')
-rw-r--r--test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp b/test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp
new file mode 100644
index 0000000000000..e54b51084430b
--- /dev/null
+++ b/test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcpp-no-deduction-guides
+
+
+// template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
+// vector(InputIterator, InputIterator, Allocator = Allocator())
+// -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
+//
+
+
+#include <stack>
+#include <list>
+#include <iterator>
+#include <cassert>
+#include <cstddef>
+
+
+int main()
+{
+// Test the explicit deduction guides
+ {
+// stack(const Container&, const Alloc&);
+// The '45' is not an allocator
+ 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'}}
+ }
+
+ {
+// stack(const stack&, const Alloc&);
+// The '45' is not an allocator
+ std::stack<int> source;
+ std::stack stk(source, 45); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'stack'}}
+ }
+
+// Test the implicit deduction guides
+ {
+// stack (allocator &)
+ std::stack stk((std::allocator<int>())); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'stack'}}
+// Note: The extra parens are necessary, since otherwise clang decides it is a function declaration.
+// Also, we can't use {} instead of parens, because that constructs a
+// stack<allocator<int>, allocator<allocator<int>>>
+ }
+
+}