diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-12-08 23:57:08 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-12-08 23:57:08 +0000 |
commit | bd688258baf97e840c2bd0c4c307503042b1620c (patch) | |
tree | cbb8347d38586b15fa0b624fb0dfa7cb83844194 /libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr | |
parent | 568196bf7b6eb3528df71d017c59cbf25ad63141 (diff) | |
download | bcm5719-llvm-bd688258baf97e840c2bd0c4c307503042b1620c.tar.gz bcm5719-llvm-bd688258baf97e840c2bd0c4c307503042b1620c.zip |
Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.
This patch removes libc++'s tuple extension which allowed it to be
constructed from fewer initializers than elements; with the remaining
elements being default constructed. However the implicit version of
this extension breaks conforming code. For example:
int fun(std::string);
int fun(std::tuple<std::string, int>);
int x = fun("hello"); // ambigious
Because existing code may already depend on this extension it can be re-enabled
by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION.
Note that the explicit version of this extension is still supported,
although it's somewhat less useful than the implicit one.
llvm-svn: 289158
Diffstat (limited to 'libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr')
-rw-r--r-- | libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp index 9adbc540617..06284df5664 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp @@ -21,6 +21,7 @@ #include <type_traits> #include "test_macros.h" +#include "test_convertible.hpp" #include "MoveOnly.h" #if TEST_STD_VER > 11 @@ -124,17 +125,23 @@ int main() // extensions #ifdef _LIBCPP_VERSION { - std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0), - MoveOnly(1)); + using E = MoveOnly; + using Tup = std::tuple<E, E, E>; + // Test that the reduced arity initialization extension is only + // allowed on the explicit constructor. + static_assert(test_convertible<Tup, E, E, E>(), ""); + + Tup t(E(0), E(1)); + static_assert(!test_convertible<Tup, E, E>(), ""); assert(std::get<0>(t) == 0); assert(std::get<1>(t) == 1); assert(std::get<2>(t) == MoveOnly()); - } - { - std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0)); + + Tup t2(E(0)); + static_assert(!test_convertible<Tup, E>(), ""); assert(std::get<0>(t) == 0); - assert(std::get<1>(t) == MoveOnly()); - assert(std::get<2>(t) == MoveOnly()); + assert(std::get<1>(t) == E()); + assert(std::get<2>(t) == E()); } #endif #if TEST_STD_VER > 11 |