From 51072bd6bf79ef2bc6a922079bff57c31c1effbc Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:47:26 +0000 Subject: Vendor import of libc++ release_39 branch r276489: https://llvm.org/svn/llvm-project/libcxx/branches/release_39@276489 --- .../tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp') 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 + // // template class tuple; @@ -14,7 +16,9 @@ // template // 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 #include @@ -24,6 +28,18 @@ #include "../alloc_first.h" #include "../alloc_last.h" +template +struct NonDefaultConstructible { + constexpr NonDefaultConstructible() { + static_assert(!std::is_same::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(v, v); + std::tuple t2(42, 42); + } } -- cgit v1.2.3