Index: include/__tuple =================================================================== --- include/__tuple +++ include/__tuple @@ -468,14 +468,10 @@ >; struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail { - template - static constexpr bool __enable_default() { return false; } - template - static constexpr bool __enable_explicit() { return false; } - template - static constexpr bool __enable_implicit() { return false; } - template - static constexpr bool __enable_assign() { return false; } + template using __enable_default = false_type; + template using __enable_explicit = false_type; + template using __enable_implicit = false_type; + template using __enable_assign = false_type; }; #endif Index: include/tuple =================================================================== --- include/tuple +++ include/tuple @@ -491,13 +491,10 @@ struct _CheckArgsConstructor { template - static constexpr bool __enable_default() { - return __all::value...>::value; - } + using __enable_default = __all::value...>; template - static constexpr bool __enable_explicit() { - return + using __enable_explicit = integral_constant, typename __make_tuple_types::type - >::value; - } + >::value + >; template - static constexpr bool __enable_implicit() { - return + using __enable_implicit = integral_constant, typename __make_tuple_types::type - >::value; - } + >::value + >; }; template { template - static constexpr bool __enable_implicit() { - return __tuple_convertible<_Tuple, tuple>::value; - } + using __enable_implicit = __tuple_convertible<_Tuple, tuple>; template - static constexpr bool __enable_explicit() { - return __tuple_constructible<_Tuple, tuple>::value - && !__tuple_convertible<_Tuple, tuple>::value; - } + using __enable_explicit = integral_constant::value + && !__tuple_convertible<_Tuple, tuple>::value>; }; template @@ -577,21 +570,18 @@ >; template - static constexpr bool __enable_implicit() { - return __lazy_and< + using __enable_implicit = + __lazy_and< __tuple_convertible<_Tuple, tuple>, _PreferTupleLikeConstructor<_Tuple> - >::value; - } + >; template - static constexpr bool __enable_explicit() { - return __lazy_and< + using __enable_explicit = __lazy_and< __tuple_constructible<_Tuple, tuple>, _PreferTupleLikeConstructor<_Tuple>, __lazy_not<__tuple_convertible<_Tuple, tuple>> - >::value; - } + >; }; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -605,7 +595,7 @@ public: template ::template __enable_default<_Tp...>() + _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>::value >::type> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() @@ -632,7 +622,7 @@ < _CheckArgsConstructor< _Dummy - >::template __enable_implicit<_Tp...>(), + >::template __enable_implicit<_Tp...>::value, bool >::type = false > @@ -650,7 +640,7 @@ < _CheckArgsConstructor< _Dummy - >::template __enable_explicit<_Tp...>(), + >::template __enable_explicit<_Tp...>::value, bool >::type = false > @@ -668,7 +658,7 @@ < _CheckArgsConstructor< _Dummy - >::template __enable_implicit<_Tp...>(), + >::template __enable_implicit<_Tp...>::value, bool >::type = false > @@ -687,7 +677,7 @@ < _CheckArgsConstructor< _Dummy - >::template __enable_explicit<_Tp...>(), + >::template __enable_explicit<_Tp...>::value, bool >::type = false > @@ -708,7 +698,7 @@ _CheckArgsConstructor< sizeof...(_Up) <= sizeof...(_Tp) && !_PackExpandsToThisTuple<_Up...>::value - >::template __enable_implicit<_Up...>(), + >::template __enable_implicit<_Up...>::value, bool >::type = false > @@ -735,7 +725,7 @@ _CheckArgsConstructor< sizeof...(_Up) <= sizeof...(_Tp) && !_PackExpandsToThisTuple<_Up...>::value - >::template __enable_explicit<_Up...>(), + >::template __enable_explicit<_Up...>::value, bool >::type = false > @@ -763,7 +753,7 @@ _CheckArgsConstructor< sizeof...(_Up) == sizeof...(_Tp) && !_PackExpandsToThisTuple<_Up...>::value - >::template __enable_implicit<_Up...>(), + >::template __enable_implicit<_Up...>::value, bool >::type = false > @@ -782,7 +772,7 @@ _CheckArgsConstructor< sizeof...(_Up) == sizeof...(_Tp) && !_PackExpandsToThisTuple<_Up...>::value - >::template __enable_explicit<_Up...>(), + >::template __enable_explicit<_Up...>::value, bool >::type = false > @@ -802,7 +792,7 @@ _CheckTupleLikeConstructor< __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value && !_PackExpandsToThisTuple<_Tuple>::value - >::template __enable_implicit<_Tuple>(), + >::template __enable_implicit<_Tuple>::value, bool >::type = false > @@ -816,7 +806,7 @@ _CheckTupleLikeConstructor< __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value && !_PackExpandsToThisTuple<_Tuple>::value - >::template __enable_explicit<_Tuple>(), + >::template __enable_explicit<_Tuple>::value, bool >::type = false > @@ -830,7 +820,7 @@ < _CheckTupleLikeConstructor< __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value - >::template __enable_implicit<_Tuple>(), + >::template __enable_implicit<_Tuple>::value, bool >::type = false > @@ -843,7 +833,7 @@ < _CheckTupleLikeConstructor< __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value - >::template __enable_explicit<_Tuple>(), + >::template __enable_explicit<_Tuple>::value, bool >::type = false > Index: include/utility =================================================================== --- include/utility +++ include/utility @@ -350,26 +350,23 @@ struct _CheckArgs { template - static constexpr bool __enable_default() { - return is_default_constructible<_U1>::value - && is_default_constructible<_U2>::value; - } + using __enable_default = integral_constant::value + && is_default_constructible<_U2>::value>; template - static constexpr bool __enable_explicit() { - return is_constructible::value + using __enable_explicit = integral_constant::value && is_constructible::value && (!is_convertible<_U1, first_type>::value - || !is_convertible<_U2, second_type>::value); - } + || !is_convertible<_U2, second_type>::value)>; template - static constexpr bool __enable_implicit() { - return is_constructible::value + using __enable_implicit = integral_constant::value && is_constructible::value && is_convertible<_U1, first_type>::value - && is_convertible<_U2, second_type>::value; - } + && is_convertible<_U2, second_type>::value>; }; template @@ -378,20 +375,15 @@ struct _CheckTupleLikeConstructor { template - static constexpr bool __enable_implicit() { - return __tuple_convertible<_Tuple, pair>::value; - } + using __enable_implicit = __tuple_convertible<_Tuple, pair>; template - static constexpr bool __enable_explicit() { - return __tuple_constructible<_Tuple, pair>::value - && !__tuple_convertible<_Tuple, pair>::value; - } + using __enable_explicit = integral_constant::value + && !__tuple_convertible<_Tuple, pair>::value>; template - static constexpr bool __enable_assign() { - return __tuple_assignable<_Tuple, pair>::value; - } + using __enable_assign = __tuple_assignable<_Tuple, pair>; }; template @@ -403,69 +395,69 @@ >::type; template::template __enable_default<_T1, _T2>() + _CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} template ::template __enable_explicit<_T1 const&, _T2 const&>() + _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {} template::template __enable_implicit<_T1 const&, _T2 const&>() + _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {} template() + _CheckArgs::template __enable_explicit<_U1, _U2>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(_U1&& __u1, _U2&& __u2) : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} template() + _CheckArgs::template __enable_implicit<_U1, _U2>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_U1&& __u1, _U2&& __u2) : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} template() + _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(pair<_U1, _U2> const& __p) : first(__p.first), second(__p.second) {} template() + _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(pair<_U1, _U2> const& __p) : first(__p.first), second(__p.second) {} template() + _CheckArgs::template __enable_explicit<_U1, _U2>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(pair<_U1, _U2>&&__p) : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} template() + _CheckArgs::template __enable_implicit<_U1, _U2>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(pair<_U1, _U2>&& __p) : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} template::template __enable_explicit<_Tuple>() + _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit pair(_Tuple&& __p) @@ -473,7 +465,7 @@ second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} template::template __enable_implicit<_Tuple>() + _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>::value > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair(_Tuple&& __p) @@ -515,7 +507,7 @@ } template ::template __enable_assign() + _CheckTLC<_Tuple>::template __enable_assign<_Tuple>::value > = false> _LIBCPP_INLINE_VISIBILITY pair& operator=(_Tuple&& __p) { Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR29123_implicit_ctor_accepted.pass.cpp =================================================================== --- /dev/null +++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR29123_implicit_ctor_accepted.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03 + +// + +// template class tuple; + +// template +// tuple(Up&&...); + +// See PR29123. + + +#include +#include +#include +// repro.cpp +// this is minimized code from folly library +#include +template +struct Optional { + // implicit + Optional() {} + Optional(const Value& newValue) {} +}; + +struct dynamic { + // implicit + template dynamic(T t); +}; + +using Tup = std::tuple; +using Opt = Optional; + +Opt get() { return {}; } + +int main() { + Optional x = get(); +}