summaryrefslogtreecommitdiff
path: root/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp')
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
index 39776822cbda4..4da5fc7f83979 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <tuple>
// template <class... Types> class tuple;
@@ -14,7 +16,9 @@
// template <class Alloc>
// tuple(allocator_arg_t, const Alloc& a);
-// UNSUPPORTED: c++98, c++03
+// NOTE: this constructor does not currently support tags derived from
+// allocator_arg_t because libc++ has to deduce the parameter as a template
+// argument. See PR27684 (https://llvm.org/bugs/show_bug.cgi?id=27684)
#include <tuple>
#include <cassert>
@@ -24,6 +28,18 @@
#include "../alloc_first.h"
#include "../alloc_last.h"
+template <class T = void>
+struct NonDefaultConstructible {
+ constexpr NonDefaultConstructible() {
+ static_assert(!std::is_same<T, T>::value, "Default Ctor instantiated");
+ }
+
+ explicit constexpr NonDefaultConstructible(int) {}
+};
+
+
+struct DerivedFromAllocArgT : std::allocator_arg_t {};
+
int main()
{
{
@@ -78,4 +94,14 @@ int main()
assert(!alloc_last::allocator_constructed);
assert(std::get<2>(t) == alloc_last());
}
+ {
+ // Test that the uses-allocator default constructor does not evaluate
+ // it's SFINAE when it otherwise shouldn't be selected. Do this by
+ // using 'NonDefaultConstructible' which will cause a compile error
+ // if std::is_default_constructible is evaluated on it.
+ using T = NonDefaultConstructible<>;
+ T v(42);
+ std::tuple<T, T> t(v, v);
+ std::tuple<T, T> t2(42, 42);
+ }
}