зеркало из https://github.com/microsoft/STL.git
Use `int = 0` SFINAE in `<memory>` to improve compiler throughput (#2124)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
This commit is contained in:
Родитель
fef8191adb
Коммит
22d6408f24
|
@ -855,12 +855,6 @@ private:
|
|||
_Callable _Callee;
|
||||
};
|
||||
|
||||
#ifdef __CUDACC__ // TRANSITION, CUDA
|
||||
#define _USE_FUNCTION_INT_0_SFINAE 0
|
||||
#else
|
||||
#define _USE_FUNCTION_INT_0_SFINAE 1
|
||||
#endif // __CUDACC__
|
||||
|
||||
template <class _Ret, class... _Types>
|
||||
class _Func_class : public _Arg_types<_Types...> {
|
||||
public:
|
||||
|
@ -1044,11 +1038,7 @@ public:
|
|||
this->_Reset_copy(_Right);
|
||||
}
|
||||
|
||||
#if _USE_FUNCTION_INT_0_SFINAE
|
||||
template <class _Fx, typename _Mybase::template _Enable_if_callable_t<_Fx, function> = 0>
|
||||
#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv
|
||||
template <class _Fx, class = typename _Mybase::template _Enable_if_callable_t<_Fx, function>>
|
||||
#endif // _USE_FUNCTION_INT_0_SFINAE
|
||||
function(_Fx&& _Func) {
|
||||
this->_Reset(_STD forward<_Fx>(_Func));
|
||||
}
|
||||
|
@ -1065,11 +1055,7 @@ public:
|
|||
this->_Reset_alloc(_Right, _Ax);
|
||||
}
|
||||
|
||||
#if _USE_FUNCTION_INT_0_SFINAE
|
||||
template <class _Fx, class _Alloc, typename _Mybase::template _Enable_if_callable_t<_Fx, function> = 0>
|
||||
#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv
|
||||
template <class _Fx, class _Alloc, class = typename _Mybase::template _Enable_if_callable_t<_Fx, function>>
|
||||
#endif // _USE_FUNCTION_INT_0_SFINAE
|
||||
function(allocator_arg_t, const _Alloc& _Ax, _Fx&& _Func) {
|
||||
this->_Reset_alloc(_STD forward<_Fx>(_Func), _Ax);
|
||||
}
|
||||
|
@ -1099,11 +1085,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
#if _USE_FUNCTION_INT_0_SFINAE
|
||||
template <class _Fx, typename _Mybase::template _Enable_if_callable_t<_Fx, function> = 0>
|
||||
#else // ^^^ _USE_FUNCTION_INT_0_SFINAE // !_USE_FUNCTION_INT_0_SFINAE vvv
|
||||
template <class _Fx, class = typename _Mybase::template _Enable_if_callable_t<_Fx, function>>
|
||||
#endif // _USE_FUNCTION_INT_0_SFINAE
|
||||
function& operator=(_Fx&& _Func) {
|
||||
function(_STD forward<_Fx>(_Func)).swap(*this);
|
||||
return *this;
|
||||
|
|
|
@ -3272,23 +3272,39 @@ public:
|
|||
template <class _Uty, class _Is_nullptr = is_same<_Uty, nullptr_t>>
|
||||
using _Enable_ctor_reset =
|
||||
enable_if_t<is_same_v<_Uty, pointer> //
|
||||
|| _Is_nullptr::value //
|
||||
|| (is_same_v<pointer, element_type*> //
|
||||
&& is_pointer_v<_Uty> //
|
||||
&& is_convertible_v<remove_pointer_t<_Uty> (*)[], element_type (*)[]>)>; // TRANSITION, GH-248
|
||||
|| _Is_nullptr::value //
|
||||
|| (is_same_v<pointer, element_type*> //
|
||||
&& is_pointer_v<_Uty> //
|
||||
&& is_convertible_v<remove_pointer_t<_Uty> (*)[], element_type (*)[]>),
|
||||
int>;
|
||||
|
||||
#ifdef _M_CEE // TRANSITION, VSO-1595465
|
||||
template <class _Uty, class _Dx2 = _Dx, _Unique_ptr_enable_default_t<_Dx2> = 0, class = _Enable_ctor_reset<_Uty>>
|
||||
_CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) {}
|
||||
#else // ^^^ workaround / no workaround vvv
|
||||
template <class _Uty, class _Dx2 = _Dx, _Unique_ptr_enable_default_t<_Dx2> = 0, _Enable_ctor_reset<_Uty> = 0>
|
||||
#endif // ^^^ no workaround ^^^
|
||||
_CONSTEXPR23 explicit unique_ptr(_Uty _Ptr) noexcept : _Mypair(_Zero_then_variadic_args_t{}, _Ptr) {
|
||||
}
|
||||
|
||||
template <class _Uty, class _Dx2 = _Dx, enable_if_t<is_constructible_v<_Dx2, const _Dx2&>, int> = 0,
|
||||
#ifdef _M_CEE // TRANSITION, VSO-1595465
|
||||
class = _Enable_ctor_reset<_Uty>>
|
||||
_CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) {}
|
||||
#else // ^^^ workaround / no workaround vvv
|
||||
_Enable_ctor_reset<_Uty> = 0>
|
||||
#endif // ^^^ no workaround ^^^
|
||||
_CONSTEXPR23 unique_ptr(_Uty _Ptr, const _Dx& _Dt) noexcept : _Mypair(_One_then_variadic_args_t{}, _Dt, _Ptr) {
|
||||
}
|
||||
|
||||
template <class _Uty, class _Dx2 = _Dx,
|
||||
enable_if_t<conjunction_v<negation<is_reference<_Dx2>>, is_constructible<_Dx2, _Dx2>>, int> = 0,
|
||||
#ifdef _M_CEE // TRANSITION, VSO-1595465
|
||||
class = _Enable_ctor_reset<_Uty>>
|
||||
#else // ^^^ workaround / no workaround vvv
|
||||
_Enable_ctor_reset<_Uty> = 0>
|
||||
#endif // ^^^ no workaround ^^^
|
||||
_CONSTEXPR23 unique_ptr(_Uty _Ptr, _Dx&& _Dt) noexcept
|
||||
: _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) {}
|
||||
: _Mypair(_One_then_variadic_args_t{}, _STD move(_Dt), _Ptr) {
|
||||
}
|
||||
|
||||
template <class _Uty, class _Dx2 = _Dx,
|
||||
enable_if_t<conjunction_v<is_reference<_Dx2>, is_constructible<_Dx2, remove_reference_t<_Dx2>>>, int> = 0>
|
||||
|
@ -3312,15 +3328,26 @@ public:
|
|||
class _UP_element_type = typename unique_ptr<_Uty, _Ex>::element_type>
|
||||
using _Enable_conversion = enable_if_t<
|
||||
conjunction_v<is_array<_Uty>, is_same<pointer, element_type*>, is_same<_UP_pointer, _UP_element_type*>,
|
||||
is_convertible<_UP_element_type (*)[], element_type (*)[]>, _More>>; // TRANSITION, GH-248
|
||||
is_convertible<_UP_element_type (*)[], element_type (*)[]>, _More>,
|
||||
int>;
|
||||
|
||||
template <class _Uty, class _Ex,
|
||||
#ifdef _M_CEE // TRANSITION, VSO-1595465
|
||||
class = _Enable_conversion<_Uty, _Ex,
|
||||
conditional_t<is_reference_v<_Dx>, is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>>>
|
||||
#else // ^^^ workaround / no workaround vvv
|
||||
_Enable_conversion<_Uty, _Ex, conditional_t<is_reference_v<_Dx>, is_same<_Ex, _Dx>, is_convertible<_Ex, _Dx>>> =
|
||||
0>
|
||||
#endif // ^^^ no workaround ^^^
|
||||
_CONSTEXPR23 unique_ptr(unique_ptr<_Uty, _Ex>&& _Right) noexcept
|
||||
: _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) {}
|
||||
: _Mypair(_One_then_variadic_args_t{}, _STD forward<_Ex>(_Right.get_deleter()), _Right.release()) {
|
||||
}
|
||||
|
||||
#ifdef _M_CEE // TRANSITION, VSO-1595465
|
||||
template <class _Uty, class _Ex, class = _Enable_conversion<_Uty, _Ex, is_assignable<_Dx&, _Ex>>>
|
||||
#else // ^^^ workaround / no workaround vvv
|
||||
template <class _Uty, class _Ex, _Enable_conversion<_Uty, _Ex, is_assignable<_Dx&, _Ex>> = 0>
|
||||
#endif // ^^^ no workaround ^^^
|
||||
_CONSTEXPR23 unique_ptr& operator=(unique_ptr<_Uty, _Ex>&& _Right) noexcept {
|
||||
reset(_Right.release());
|
||||
_Mypair._Get_first() = _STD forward<_Ex>(_Right._Mypair._Get_first());
|
||||
|
@ -3374,7 +3401,11 @@ public:
|
|||
return _STD exchange(_Mypair._Myval2, nullptr);
|
||||
}
|
||||
|
||||
#ifdef _M_CEE // TRANSITION, VSO-1595465
|
||||
template <class _Uty, class = _Enable_ctor_reset<_Uty, false_type>>
|
||||
#else // ^^^ workaround / no workaround vvv
|
||||
template <class _Uty, _Enable_ctor_reset<_Uty, false_type> = 0>
|
||||
#endif // ^^^ no workaround ^^^
|
||||
_CONSTEXPR23 void reset(_Uty _Ptr) noexcept {
|
||||
pointer _Old = _STD exchange(_Mypair._Myval2, _Ptr);
|
||||
if (_Old) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче