diff --git a/include/memory b/include/memory index e7fb9d12..565aa7d5 100644 --- a/include/memory +++ b/include/memory @@ -596,6 +596,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include #include <__functional_base> #include +#include #if defined(_LIBCPP_NO_EXCEPTIONS) #include #endif @@ -608,12 +609,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); _LIBCPP_BEGIN_NAMESPACE_STD -// allocator_arg_t - -struct _LIBCPP_VISIBLE allocator_arg_t { }; - -extern const allocator_arg_t allocator_arg; - // addressof template @@ -1570,58 +1565,6 @@ private: {return __a;} }; -// uses_allocator - -template -struct __has_allocator_type -{ -private: - struct __two {char _; char __;}; - template static __two __test(...); - template static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template ::value> -struct __uses_allocator - : public integral_constant::value> -{ -}; - -template -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template -struct _LIBCPP_VISIBLE uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#ifndef _LIBCPP_HAS_NO_VARIADICS - -// uses-allocator construction - -template -struct __uses_alloc_ctor_imp -{ - static const bool __ua = uses_allocator<_Tp, _Alloc>::value; - static const bool __ic = - is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const int value = __ua ? 2 - __ic : 0; -}; - -template -struct __uses_alloc_ctor - : integral_constant::value> - {}; - -#endif // _LIBCPP_HAS_NO_VARIADICS - // allocator template @@ -1940,6 +1883,21 @@ public: return *this; } +#ifndef _LIBCPP_HAS_NO_VARIADICS + + template + _LIBCPP_INLINE_VISIBILITY + __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + tuple<_Args1...> __first_args, + tuple<_Args2...> __second_args, + __tuple_indices<_I1...>, + __tuple_indices<_I2...>) + : __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), + __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + {} + +#endif // _LIBCPP_HAS_NO_VARIADICS + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2020,6 +1978,21 @@ public: return *this; } +#ifndef _LIBCPP_HAS_NO_VARIADICS + + template + _LIBCPP_INLINE_VISIBILITY + __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + tuple<_Args1...> __first_args, + tuple<_Args2...> __second_args, + __tuple_indices<_I1...>, + __tuple_indices<_I2...>) + : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), + __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + {} + +#endif // _LIBCPP_HAS_NO_VARIADICS + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2101,6 +2074,22 @@ public: return *this; } +#ifndef _LIBCPP_HAS_NO_VARIADICS + + template + _LIBCPP_INLINE_VISIBILITY + __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + tuple<_Args1...> __first_args, + tuple<_Args2...> __second_args, + __tuple_indices<_I1...>, + __tuple_indices<_I2...>) + : _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...), + __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...) + + {} + +#endif // _LIBCPP_HAS_NO_VARIADICS + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2179,6 +2168,21 @@ public: return *this; } +#ifndef _LIBCPP_HAS_NO_VARIADICS + + template + _LIBCPP_INLINE_VISIBILITY + __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + tuple<_Args1...> __first_args, + tuple<_Args2...> __second_args, + __tuple_indices<_I1...>, + __tuple_indices<_I2...>) + : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), + _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) + {} + +#endif // _LIBCPP_HAS_NO_VARIADICS + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2251,6 +2255,20 @@ public: base::operator=(_VSTD::move(__p)); return *this; } + +#ifndef _LIBCPP_HAS_NO_VARIADICS + + template + _LIBCPP_INLINE_VISIBILITY + __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, + tuple<_Args2...> __second_args) + : base(__pc, __first_args, __second_args, + typename __make_tuple_indices::type(), + typename __make_tuple_indices::type()) + {} + +#endif // _LIBCPP_HAS_NO_VARIADICS + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -3365,7 +3383,8 @@ public: template _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) - : __data_(_VSTD::move(__a), _Tp(_VSTD::forward<_Args>(__args)...)) {} + : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), + _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} #else // _LIBCPP_HAS_NO_VARIADICS diff --git a/include/tuple b/include/tuple index 9ae0587a..d5c6ad0b 100644 --- a/include/tuple +++ b/include/tuple @@ -116,8 +116,9 @@ template #include <__config> #include <__tuple> #include -#include #include +#include <__functional_base> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -125,6 +126,64 @@ template _LIBCPP_BEGIN_NAMESPACE_STD +// allocator_arg_t + +struct _LIBCPP_VISIBLE allocator_arg_t { }; + +extern const allocator_arg_t allocator_arg; + +// uses_allocator + +template +struct __has_allocator_type +{ +private: + struct __two {char _; char __;}; + template static __two __test(...); + template static char __test(typename _Up::allocator_type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + +template ::value> +struct __uses_allocator + : public integral_constant::value> +{ +}; + +template +struct __uses_allocator<_Tp, _Alloc, false> + : public false_type +{ +}; + +template +struct _LIBCPP_VISIBLE uses_allocator + : public __uses_allocator<_Tp, _Alloc> +{ +}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +// uses-allocator construction + +template +struct __uses_alloc_ctor_imp +{ + static const bool __ua = uses_allocator<_Tp, _Alloc>::value; + static const bool __ic = + is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; + static const int value = __ua ? 2 - __ic : 0; +}; + +template +struct __uses_alloc_ctor + : integral_constant::value> + {}; + +#endif // _LIBCPP_HAS_NO_VARIADICS + #ifndef _LIBCPP_HAS_NO_VARIADICS // tuple_size diff --git a/include/utility b/include/utility index 2efea284..7facea3a 100644 --- a/include/utility +++ b/include/utility @@ -306,7 +306,7 @@ struct _LIBCPP_VISIBLE pair - template + template _LIBCPP_INLINE_VISIBILITY pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)