diff --git a/include/tuple b/include/tuple index 93518d8b..21fa900d 100644 --- a/include/tuple +++ b/include/tuple @@ -511,8 +511,8 @@ class _LIBCPP_TYPE_VIS_ONLY tuple typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; public: - template ::value)...>::value + template , _Dummy>::value...>::value >::type> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR tuple() diff --git a/include/type_traits b/include/type_traits index 52fb5902..1820bb2e 100644 --- a/include/type_traits +++ b/include/type_traits @@ -216,6 +216,9 @@ template struct __void_t { typedef void type; }; #endif +template +struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {}; + template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; template diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp index 8578d7fe..d282c9c6 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp @@ -35,6 +35,16 @@ struct ThrowingDefault { ThrowingDefault() { } }; +struct IllFormedDefault { + IllFormedDefault(int x) : value(x) {} + template + constexpr IllFormedDefault() { + static_assert(Pred, + "The default constructor should not be instantiated"); + } + int value; +}; + int main() { { @@ -89,5 +99,12 @@ int main() 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. + IllFormedDefault v(0); + std::tuple t(v); + } #endif }