diff options
Diffstat (limited to 'libcxx/include/memory')
| -rw-r--r-- | libcxx/include/memory | 95 |
1 files changed, 29 insertions, 66 deletions
diff --git a/libcxx/include/memory b/libcxx/include/memory index 45e032ae96f..34c3e0c0d8d 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -2180,6 +2180,7 @@ public: // Tag used to default initialize one or both of the pair's elements. struct __default_init_tag {}; +struct __value_init_tag {}; template <class _Tp, int _Idx, bool _CanBeEmptyBase = @@ -2189,34 +2190,31 @@ struct __compressed_pair_elem { typedef _Tp& reference; typedef const _Tp& const_reference; -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {} - _LIBCPP_INLINE_VISIBILITY constexpr + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem(__default_init_tag) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __compressed_pair_elem(__value_init_tag) : __value_() {} template <class _Up, class = typename enable_if< !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value >::type> _LIBCPP_INLINE_VISIBILITY - constexpr explicit + _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) : __value_(_VSTD::forward<_Up>(__u)) { } + +#ifndef _LIBCPP_CXX03_LANG template <class... _Args, size_t... _Indexes> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indexes...>) : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} -#else - _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {} - _LIBCPP_INLINE_VISIBILITY - __compressed_pair_elem(__default_init_tag) {} - _LIBCPP_INLINE_VISIBILITY - __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {} #endif + _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; } _LIBCPP_INLINE_VISIBILITY const_reference __get() const _NOEXCEPT { return __value_; } @@ -2232,28 +2230,27 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { typedef const _Tp& const_reference; typedef _Tp __value_type; -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __compressed_pair_elem(__default_init_tag) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __compressed_pair_elem(__value_init_tag) : __value_type() {} template <class _Up, class = typename enable_if< !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value >::type> _LIBCPP_INLINE_VISIBILITY - constexpr explicit + _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) : __value_type(_VSTD::forward<_Up>(__u)) {} +#ifndef _LIBCPP_CXX03_LANG template <class... _Args, size_t... _Indexes> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indexes...>) : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} -#else - _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {} - _LIBCPP_INLINE_VISIBILITY - __compressed_pair_elem(_ParamT __p) - : __value_type(std::forward<_ParamT>(__p)) {} #endif _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; } @@ -2261,9 +2258,6 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { const_reference __get() const _NOEXCEPT { return *this; } }; -// Tag used to construct the second element of the compressed pair. -struct __second_tag {}; - template <class _T1, class _T2> class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __compressed_pair_elem<_T2, 1> { @@ -2280,33 +2274,21 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, "implementation for this configuration"); public: -#ifndef _LIBCPP_CXX03_LANG - template <bool _Dummy = true, + template <bool _Dummy = true, class = typename enable_if< __dependent_type<is_default_constructible<_T1>, _Dummy>::value && __dependent_type<is_default_constructible<_T2>, _Dummy>::value >::type > _LIBCPP_INLINE_VISIBILITY - constexpr __compressed_pair() {} - - template <class _Tp, typename enable_if<!is_same<typename decay<_Tp>::type, - __compressed_pair>::value, - bool>::type = true> - _LIBCPP_INLINE_VISIBILITY constexpr explicit - __compressed_pair(_Tp&& __t) - : _Base1(std::forward<_Tp>(__t)), _Base2() {} - - template <class _Tp> - _LIBCPP_INLINE_VISIBILITY constexpr - __compressed_pair(__second_tag, _Tp&& __t) - : _Base1(), _Base2(std::forward<_Tp>(__t)) {} + _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} template <class _U1, class _U2> - _LIBCPP_INLINE_VISIBILITY constexpr + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair(_U1&& __t1, _U2&& __t2) : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} +#ifndef _LIBCPP_CXX03_LANG template <class... _Args1, class... _Args2> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, @@ -2315,21 +2297,6 @@ public: typename __make_tuple_indices<sizeof...(_Args1)>::type()), _Base2(__pc, _VSTD::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {} - -#else - _LIBCPP_INLINE_VISIBILITY - __compressed_pair() {} - - _LIBCPP_INLINE_VISIBILITY explicit - __compressed_pair(_T1 __t1) : _Base1(_VSTD::forward<_T1>(__t1)) {} - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair(__second_tag, _T2 __t2) - : _Base1(), _Base2(_VSTD::forward<_T2>(__t2)) {} - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair(_T1 __t1, _T2 __t2) - : _Base1(_VSTD::forward<_T1>(__t1)), _Base2(_VSTD::forward<_T2>(__t2)) {} #endif _LIBCPP_INLINE_VISIBILITY @@ -2510,17 +2477,17 @@ public: template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > _LIBCPP_INLINE_VISIBILITY - explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p) {} + explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __default_init_tag()) {} template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > @@ -2562,7 +2529,7 @@ public: typename enable_if<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, __nat>::type = __nat()) _NOEXCEPT - : __ptr_(__p.release()) {} + : __ptr_(__p.release(), __default_init_tag()) {} #endif _LIBCPP_INLINE_VISIBILITY @@ -2733,19 +2700,19 @@ public: template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template <class _Pp, bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy>, class = _EnableIfPointerConvertible<_Pp> > _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT - : __ptr_(__p) {} + : __ptr_(__p, __default_init_tag()) {} template <class _Pp, bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >, @@ -3589,24 +3556,20 @@ class __shared_ptr_emplace { __compressed_pair<_Alloc, _Tp> __data_; public: -#ifndef _LIBCPP_HAS_NO_VARIADICS _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a) - : __data_(_VSTD::move(__a)) {} + : __data_(_VSTD::move(__a), __value_init_tag()) {} + +#ifndef _LIBCPP_HAS_NO_VARIADICS template <class ..._Args> _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} - #else // _LIBCPP_HAS_NO_VARIADICS - _LIBCPP_INLINE_VISIBILITY - __shared_ptr_emplace(_Alloc __a) - : __data_(__a) {} - template <class _A0> _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a, _A0& __a0) |

