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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289158 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -477,6 +477,12 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
|
||||
|
||||
base base_;
|
||||
|
||||
#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
|
||||
static constexpr bool _EnableImplicitReducedArityExtension = true;
|
||||
#else
|
||||
static constexpr bool _EnableImplicitReducedArityExtension = false;
|
||||
#endif
|
||||
|
||||
template <class ..._Args>
|
||||
struct _PackExpandsToThisTuple : false_type {};
|
||||
|
||||
@@ -703,11 +709,17 @@ public:
|
||||
) {}
|
||||
|
||||
template <class ..._Up,
|
||||
bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
|
||||
typename enable_if
|
||||
<
|
||||
_CheckArgsConstructor<
|
||||
sizeof...(_Up) <= sizeof...(_Tp)
|
||||
&& !_PackExpandsToThisTuple<_Up...>::value
|
||||
sizeof...(_Up) == sizeof...(_Tp)
|
||||
&& !_PackIsTuple
|
||||
>::template __enable_implicit<_Up...>() ||
|
||||
_CheckArgsConstructor<
|
||||
_EnableImplicitReducedArityExtension
|
||||
&& sizeof...(_Up) < sizeof...(_Tp)
|
||||
&& !_PackIsTuple
|
||||
>::template __enable_implicit<_Up...>(),
|
||||
bool
|
||||
>::type = false
|
||||
@@ -735,7 +747,12 @@ public:
|
||||
_CheckArgsConstructor<
|
||||
sizeof...(_Up) <= sizeof...(_Tp)
|
||||
&& !_PackExpandsToThisTuple<_Up...>::value
|
||||
>::template __enable_explicit<_Up...>(),
|
||||
>::template __enable_explicit<_Up...>() ||
|
||||
_CheckArgsConstructor<
|
||||
!_EnableImplicitReducedArityExtension
|
||||
&& sizeof...(_Up) < sizeof...(_Tp)
|
||||
&& !_PackExpandsToThisTuple<_Up...>()
|
||||
>::template __enable_implicit<_Up...>(),
|
||||
bool
|
||||
>::type = false
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user