diff options
Diffstat (limited to 'libcxx/include/utility')
| -rw-r--r-- | libcxx/include/utility | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/libcxx/include/utility b/libcxx/include/utility index 64599c8d55d..c90d049cf7b 100644 --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -69,7 +69,7 @@ struct pair pair(const pair&) = default; pair(pair&&) = default; - constexpr pair(); + explicit(see-below) constexpr pair(); explicit(see-below) pair(const T1& x, const T2& y); // constexpr in C++14 template <class U, class V> explicit(see-below) pair(U&& x, V&& y); // constexpr in C++14 template <class U, class V> explicit(see-below) pair(const pair<U, V>& p); // constexpr in C++14 @@ -99,7 +99,7 @@ template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); -struct piecewise_construct_t { }; +struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); template <class T> struct tuple_size; @@ -276,7 +276,7 @@ template <class _Tp> constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { r template <class _Tp> void as_const(const _Tp&&) = delete; #endif -struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { }; +struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { explicit piecewise_construct_t() = default; }; #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); #else @@ -335,9 +335,21 @@ struct _LIBCPP_TEMPLATE_VIS pair struct _CheckArgs { template <class _U1, class _U2> - static constexpr bool __enable_default() { + static constexpr bool __enable_explicit_default() { return is_default_constructible<_U1>::value - && is_default_constructible<_U2>::value; + && is_default_constructible<_U2>::value + && !__enable_implicit_default<_U1, _U2>(); + } + + template <class _U1, class _U2> + static constexpr bool __enable_implicit_default() { + // In C++03, there's no way to implement the resolution of LWG2510. +#ifdef _LIBCPP_CXX03_LANG + return true; +#else + return __is_implicitly_default_constructible<_U1>::value + && __is_implicitly_default_constructible<_U2>::value; +#endif } template <class _U1, class _U2> @@ -388,7 +400,15 @@ struct _LIBCPP_TEMPLATE_VIS pair >::type; template<bool _Dummy = true, _EnableB< - _CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>() + _CheckArgsDep<_Dummy>::template __enable_explicit_default<_T1, _T2>() + > = false> + explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && + is_nothrow_default_constructible<second_type>::value) + : first(), second() {} + + template<bool _Dummy = true, _EnableB< + _CheckArgsDep<_Dummy>::template __enable_implicit_default<_T1, _T2>() > = false> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && |

