Index: include/tuple =================================================================== --- include/tuple +++ include/tuple @@ -512,7 +512,7 @@ public: template ::value)...>::value + __all<__dependent_is_default_constructible<_Tp, _Dummy>::value...>::value >::type> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() Index: include/type_traits =================================================================== --- include/type_traits +++ include/type_traits @@ -2646,6 +2646,11 @@ : public is_constructible<_Tp> {}; +template +struct _LIBCPP_TYPE_VIS_ONLY __dependent_is_default_constructible + : public is_default_constructible<_Tp> + {}; + // is_copy_constructible template Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp =================================================================== --- test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp +++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp @@ -33,6 +33,15 @@ ThrowingDefault() { } }; +template +struct IllFormedDefaultImp { + IllFormedDefaultImp(T x) : value(x) {} + constexpr IllFormedDefaultImp() {} + T value; +}; + +typedef IllFormedDefaultImp IllFormedDefault; + int main() { { @@ -87,5 +96,13 @@ assert(std::get<0>(t) == 0); assert(std::get<1>(t) == nullptr); } + { + // Check that the SFINAE on the default constructor is not evaluted when + // it isn't needed. If the default constructor is evaluted then this test + // should fail to compile. + int x = 0; + IllFormedDefault v(x); + std::tuple t(v); + } #endif }