diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 895f5813b4..779ab60956 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -1850,7 +1850,7 @@ namespace ranges { template requires indirectly_movable<_It1, _It2> _NODISCARD constexpr _It2 _Move_backward_common(const _It1 _First, _It1 _Last, _It2 _Result) { - if constexpr (_Can_memmove_in_move<_It1, _It2>) { + if constexpr (_Memmove_in_move_is_safe<_It1, _It2>) { if (!_STD is_constant_evaluated()) { return _Copy_backward_memmove(_First, _Last, _Result); } @@ -2217,7 +2217,7 @@ namespace ranges { template _NODISCARD _CONSTEXPR20 bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _First2, const _InIt2 _Last2, _Pr _Pred) { // compare [_First1, ...) to [_First2, _Last2) - if constexpr (_Can_memcmp_in_equal<_InIt1, _InIt2, _Pr>) { + if constexpr (_Memcmp_in_equal_is_safe<_InIt1, _InIt2, _Pr>) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -2238,7 +2238,7 @@ _NODISCARD _CONSTEXPR20 bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _F return true; } #else // ^^^ _HAS_IF_CONSTEXPR ^^^ // vvv !_HAS_IF_CONSTEXPR vvv -template , int> = 0> +template , int> = 0> bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _First2, const _InIt2 _Last2, _Pr _Pred) { // compare [_First1, ...) to [_First2, _Last2), no special optimization for (; _First2 != _Last2; ++_First1, (void) ++_First2) { @@ -2250,7 +2250,7 @@ bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _First2, const _InIt2 _Las return true; } -template , int> = 0> +template , int> = 0> bool _Equal_rev_pred_unchecked(const _InIt1 _First1, const _InIt2 _First2, const _InIt2 _Last2, _Pr) { // compare [_First1, ...) to [_First2, _Last2), memcmp optimization const auto _First1_ch = reinterpret_cast(_First1); @@ -2391,7 +2391,7 @@ namespace ranges { // clang-format off template concept _Equal_rev_pred_can_memcmp = is_same_v<_Pj1, identity> && is_same_v<_Pj2, identity> - && is_same_v<_Se2, _It2> && _Can_memcmp_in_equal<_It1, _It2, _Pr>; + && is_same_v<_Se2, _It2> && _Memcmp_in_equal_is_safe<_It1, _It2, _Pr>; template _Se2, class _Pr, class _Pj1, class _Pj2> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> @@ -3938,7 +3938,7 @@ namespace ranges { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _ULast = _Get_unwrapped(_STD move(_Last)); - if constexpr (_Can_memset_in_fill) { + if constexpr (_Memset_in_fill_is_safe) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -3978,7 +3978,7 @@ namespace ranges { constexpr _It operator()(_It _First, iter_difference_t<_It> _Count, const _Ty& _Value) const { if (_Count > 0) { auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); - if constexpr (_Can_memset_in_fill) { + if constexpr (_Memset_in_fill_is_safe) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated diff --git a/stl/inc/memory b/stl/inc/memory index f77b03f06b..7670f03485 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -107,7 +107,7 @@ namespace ranges { _STL_INTERNAL_STATIC_ASSERT(_No_throw_sentinel_for<_OSe, _Out>); _STL_INTERNAL_STATIC_ASSERT(constructible_from, iter_reference_t<_It>>); - if constexpr (is_same_v<_Se, _It> && _Can_memmove_in_uninitialized_copy<_It, _Out>) { + if constexpr (is_same_v<_Se, _It> && _Memmove_in_uninitialized_copy_is_safe<_It, _Out>) { return _Copy_memcpy_common(_IFirst, _ILast, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -137,7 +137,7 @@ _NoThrowFwdIt uninitialized_copy_n(const _InIt _First, const _Diff _Count_raw, _ auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); - if constexpr (_Can_memmove_in_uninitialized_copy) { + if constexpr (_Memmove_in_uninitialized_copy_is_safe) { _UDest = _Copy_memmove(_UFirst, _UFirst + _Count, _UDest); } else { _Uninitialized_backout _Backout{_UDest}; @@ -181,8 +181,9 @@ _NoThrowFwdIt uninitialized_copy_n(const _InIt _First, const _Diff _Count_raw, _ auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); - _Seek_wrapped(_Dest, _Uninitialized_copy_n_unchecked2(_UFirst, _Count, _UDest, - bool_constant<_Can_memmove_in_uninitialized_copy>{})); + _Seek_wrapped( + _Dest, _Uninitialized_copy_n_unchecked2(_UFirst, _Count, _UDest, + bool_constant<_Memmove_in_uninitialized_copy_is_safe>{})); return _Dest; } #endif // _HAS_IF_CONSTEXPR @@ -212,7 +213,7 @@ namespace ranges { auto _IFirst = _Get_unwrapped_n(_STD move(_First1), _Count); auto _OFirst = _Get_unwrapped(_STD move(_First2)); const auto _OLast = _Get_unwrapped(_STD move(_Last2)); - if constexpr (_Can_memmove_in_uninitialized_copy<_It, _Out>) { + if constexpr (_Memmove_in_uninitialized_copy_is_safe<_It, _Out>) { _OFirst = _Copy_memcpy_common(_IFirst, _IFirst + _Count, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -299,7 +300,7 @@ namespace ranges { _STL_INTERNAL_STATIC_ASSERT(_No_throw_sentinel_for<_OSe, _Out>); _STL_INTERNAL_STATIC_ASSERT(constructible_from, iter_rvalue_reference_t<_It>>); - if constexpr (is_same_v<_Se, _It> && _Can_memmove_in_uninitialized_move<_It, _Out>) { + if constexpr (is_same_v<_Se, _It> && _Memmove_in_uninitialized_move_is_safe<_It, _Out>) { return _Copy_memcpy_common(_IFirst, _ILast, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -328,7 +329,7 @@ pair<_InIt, _NoThrowFwdIt> uninitialized_move_n(_InIt _First, const _Diff _Count auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); - if constexpr (_Can_memmove_in_uninitialized_move) { + if constexpr (_Memmove_in_uninitialized_move_is_safe) { _UDest = _Copy_memmove(_UFirst, _UFirst + _Count, _UDest); _UFirst += _Count; } else { @@ -373,7 +374,7 @@ namespace ranges { auto _IFirst = _Get_unwrapped_n(_STD move(_First1), _Count); auto _OFirst = _Get_unwrapped(_STD move(_First2)); const auto _OLast = _Get_unwrapped(_STD move(_Last2)); - if constexpr (_Can_memmove_in_uninitialized_move<_It, _Out>) { + if constexpr (_Memmove_in_uninitialized_move_is_safe<_It, _Out>) { _OFirst = _Copy_memcpy_common(_IFirst, _IFirst + _Count, _OFirst, _OLast); } else { _Uninitialized_backout _Backout{_STD move(_OFirst)}; @@ -426,7 +427,7 @@ namespace ranges { _STL_INTERNAL_STATIC_ASSERT(_No_throw_sentinel_for<_Se, _It>); _STL_INTERNAL_STATIC_ASSERT(constructible_from, const _Ty&>); - if constexpr (_Can_memset_in_fill<_It, _Ty>) { + if constexpr (_Memset_in_fill_is_safe<_It, _Ty>) { const auto _OFinal = _RANGES next(_OFirst, _STD move(_OLast)); const auto _Diff = static_cast(_OFinal - _OFirst); _Fill_memset(_OFirst, _Val, _Diff); @@ -458,7 +459,7 @@ _NoThrowFwdIt uninitialized_fill_n(_NoThrowFwdIt _First, const _Diff _Count_raw, } auto _UFirst = _Get_unwrapped_n(_First, _Count); - if constexpr (_Can_memset_in_fill<_Unwrapped_n_t, _Tval>) { + if constexpr (_Memset_in_fill_is_safe<_Unwrapped_n_t, _Tval>) { _Fill_memset(_UFirst, _Val, static_cast(_Count)); _UFirst += _Count; } else { @@ -505,7 +506,7 @@ _NoThrowFwdIt uninitialized_fill_n(_NoThrowFwdIt _First, const _Diff _Count_raw, auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); _Seek_wrapped(_First, _Uninitialized_fill_n_unchecked1(_STD move(_UFirst), _Count, _Val, - bool_constant<_Can_memset_in_fill<_Unwrapped_t<_NoThrowFwdIt>, _Tval>>{})); + bool_constant<_Memset_in_fill_is_safe<_Unwrapped_t<_NoThrowFwdIt>, _Tval>>{})); return _First; } #endif // _HAS_IF_CONSTEXPR @@ -527,7 +528,7 @@ namespace ranges { } auto _UFirst = _Get_unwrapped_n(_STD move(_First), _Count); - if constexpr (_Can_memset_in_fill<_It, _Ty>) { + if constexpr (_Memset_in_fill_is_safe<_It, _Ty>) { _Fill_memset(_UFirst, _Val, static_cast(_Count)); _Seek_wrapped(_First, _UFirst + _Count); } else { @@ -2359,7 +2360,7 @@ void _Uninitialized_fill_multidimensional_n(_Ty* const _Out, const size_t _Size, _Uninitialized_copy_multidimensional(_Val, _Out[_Idx]); // intentionally copy, not fill } _Guard._Target = nullptr; - } else if constexpr (_Can_memset_in_fill<_Ty*, _Ty>) { + } else if constexpr (_Memset_in_fill_is_safe<_Ty*, _Ty>) { _Fill_memset(_Out, _Val, _Size); } else { _Uninitialized_rev_destroying_backout _Backout{_Out}; @@ -2682,7 +2683,8 @@ void _Uninitialized_fill_multidimensional_n_al(_Ty* const _Out, const size_t _Si _Uninitialized_copy_multidimensional_al(_Val, _Out[_Idx], _Al); // intentionally copy, not fill } _Guard._Target = nullptr; - } else if constexpr (_Can_memset_in_fill<_Ty*, _Ty> && _Uses_default_construct<_Alloc, _Ty*, const _Ty&>::value) { + } else if constexpr (_Memset_in_fill_is_safe<_Ty*, + _Ty> && _Uses_default_construct<_Alloc, _Ty*, const _Ty&>::value) { _Fill_memset(_Out, _Val, _Size); } else { _Uninitialized_rev_destroying_backout_al _Backout{_Out, _Al}; diff --git a/stl/inc/vector b/stl/inc/vector index 6a72a54a1c..5a20178c26 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -636,7 +636,7 @@ private: const auto _Oldcapacity = static_cast(_My_data._Myend - _Myfirst); #if _HAS_IF_CONSTEXPR - if constexpr (conjunction_v>, + if constexpr (conjunction_v>, _Uses_default_construct<_Alty, _Ty*, _Ty>, _Uses_default_destroy<_Alty, _Ty*>>) { if (_Newsize > _Oldcapacity) { _Clear_and_reserve_geometric(_Newsize); @@ -1108,7 +1108,7 @@ private: _My_data._Orphan_all(); #if _HAS_IF_CONSTEXPR - if constexpr (conjunction_v>, + if constexpr (conjunction_v>, _Uses_default_construct<_Alty, _Ty*, decltype(*_First)>, _Uses_default_destroy<_Alty, _Ty*>>) { const auto _Oldcapacity = static_cast(_Myend - _Myfirst); diff --git a/stl/inc/xmemory b/stl/inc/xmemory index eb6962bba0..d10cb91aab 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -1480,7 +1480,7 @@ namespace ranges { template _NoThrowFwdIt _Uninitialized_move_unchecked(_InIt _First, const _InIt _Last, _NoThrowFwdIt _Dest) { // move [_First, _Last) to raw [_Dest, ...) - if constexpr (_Can_memmove_in_uninitialized_move<_InIt, _NoThrowFwdIt>) { + if constexpr (_Memmove_in_uninitialized_move_is_safe<_InIt, _NoThrowFwdIt>) { return _Copy_memmove(_First, _Last, _Dest); } else { _Uninitialized_backout<_NoThrowFwdIt> _Backout{_Dest}; @@ -1514,7 +1514,7 @@ template _NoThrowFwdIt _Uninitialized_move_unchecked(_InIt _First, const _InIt _Last, _NoThrowFwdIt _Dest) { // move [_First, _Last) to raw [_Dest, ...), choose optimization return _Uninitialized_move_unchecked1( - _First, _Last, _Dest, bool_constant<_Can_memmove_in_uninitialized_move<_InIt, _NoThrowFwdIt>>{}); + _First, _Last, _Dest, bool_constant<_Memmove_in_uninitialized_move_is_safe<_InIt, _NoThrowFwdIt>>{}); } #endif // _HAS_IF_CONSTEXPR @@ -1562,7 +1562,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_copy( auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); - if constexpr (conjunction_v>, + if constexpr (conjunction_v>, _Uses_default_construct<_Alloc, _Ptrval, decltype(*_UFirst)>>) { _Copy_memmove(_UFirst, _ULast, _Unfancy(_Dest)); _Dest += _ULast - _UFirst; @@ -1610,7 +1610,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_copy( using _Ptrval = typename _Alloc::value_type*; return _Uninitialized_copy_al_unchecked(_UFirst, _ULast, _Dest, _Al, - bool_constant>, + bool_constant>, _Uses_default_construct<_Alloc, _Ptrval, decltype(*_UFirst)>>>{}); } #endif // _HAS_IF_CONSTEXPR @@ -1624,7 +1624,7 @@ _NoThrowFwdIt uninitialized_copy(const _InIt _First, const _InIt _Last, _NoThrow auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); auto _UDest = _Get_unwrapped_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast)); - if constexpr (_Can_memmove_in_uninitialized_copy) { + if constexpr (_Memmove_in_uninitialized_copy_is_safe) { _UDest = _Copy_memmove(_UFirst, _ULast, _UDest); } else { _Uninitialized_backout _Backout{_UDest}; @@ -1664,8 +1664,9 @@ _NoThrowFwdIt uninitialized_copy(const _InIt _First, const _InIt _Last, _NoThrow auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); auto _UDest = _Get_unwrapped_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast)); - _Seek_wrapped(_Dest, _Uninitialized_copy_unchecked(_UFirst, _ULast, _UDest, - bool_constant<_Can_memmove_in_uninitialized_copy>{})); + _Seek_wrapped( + _Dest, _Uninitialized_copy_unchecked(_UFirst, _ULast, _UDest, + bool_constant<_Memmove_in_uninitialized_copy_is_safe>{})); return _Dest; } #endif // _HAS_IF_CONSTEXPR @@ -1680,7 +1681,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_move( using _Ptrval = typename _Alloc::value_type*; auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); - if constexpr (conjunction_v>, + if constexpr (conjunction_v>, _Uses_default_construct<_Alloc, _Ptrval, decltype(_STD move(*_UFirst))>>) { _Copy_memmove(_UFirst, _ULast, _Unfancy(_Dest)); return _Dest + (_ULast - _UFirst); @@ -1729,7 +1730,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_move( using _Ptrval = typename _Alloc::value_type*; _Seek_wrapped(_Dest, _Uninitialized_move_al_unchecked(_UFirst, _ULast, _UDest, _Al, - bool_constant < _Can_memmove_in_uninitialized_move && _Uses_default_construct<_Alloc, _Ptrval, decltype(_STD move(*_UFirst))>::value > {})); return _Dest; } @@ -1742,7 +1743,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_fill_n( _Alloc_ptr_t<_Alloc> _First, _Alloc_size_t<_Alloc> _Count, const typename _Alloc::value_type& _Val, _Alloc& _Al) { // copy _Count copies of _Val to raw _First, using _Al using _Ty = typename _Alloc::value_type; - if constexpr (_Can_memset_in_fill<_Ty*, _Ty> && _Uses_default_construct<_Alloc, _Ty*, _Ty>::value) { + if constexpr (_Memset_in_fill_is_safe<_Ty*, _Ty> && _Uses_default_construct<_Alloc, _Ty*, _Ty>::value) { _Fill_memset(_Unfancy(_First), _Val, static_cast(_Count)); return _First + _Count; } else { @@ -1781,7 +1782,7 @@ _Alloc_ptr_t<_Alloc> _Uninitialized_fill_n(_Alloc_ptr_t<_Alloc> _First, const _A // copy _Count copies of _Val to raw _First, using _Al using _Ty = typename _Alloc::value_type; return _Uninit_alloc_fill_n1(_First, _Count, _Val, _Al, - bool_constant < _Can_memset_in_fill<_Ty*, _Ty> && _Uses_default_construct<_Alloc, _Ty*, _Ty>::value > {}); + bool_constant < _Memset_in_fill_is_safe<_Ty*, _Ty> && _Uses_default_construct<_Alloc, _Ty*, _Ty>::value > {}); } #endif // _HAS_IF_CONSTEXPR @@ -1793,7 +1794,7 @@ void uninitialized_fill(const _NoThrowFwdIt _First, const _NoThrowFwdIt _Last, c _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); - if constexpr (_Can_memset_in_fill<_Unwrapped_t, _Tval>) { + if constexpr (_Memset_in_fill_is_safe<_Unwrapped_t, _Tval>) { _Fill_memset(_UFirst, _Val, static_cast(_ULast - _UFirst)); } else { _Uninitialized_backout<_Unwrapped_t> _Backout{_UFirst}; @@ -1830,7 +1831,7 @@ void uninitialized_fill(const _NoThrowFwdIt _First, const _NoThrowFwdIt _Last, c _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); _Uninitialized_fill_unchecked(_UFirst, _Get_unwrapped(_Last), _Val, - bool_constant<_Can_memset_in_fill<_Unwrapped_t, _Tval>>{}); + bool_constant<_Memset_in_fill_is_safe<_Unwrapped_t, _Tval>>{}); } #endif // _HAS_IF_CONSTEXPR diff --git a/stl/inc/xutility b/stl/inc/xutility index b0b8b76313..4d5903e200 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -4392,17 +4392,19 @@ _INLINE_VAR constexpr bool _Can_memop, _IterDest, _Ca _Can_memop<_IterSource, _IterDest, _Cat>; template -_INLINE_VAR constexpr bool _Can_memmove_in_copy = _Can_memop, _IterDest, _Memop_cat::_Copy>; +_INLINE_VAR constexpr bool _Memmove_in_copy_is_safe = + _Can_memop, _IterDest, _Memop_cat::_Copy>; template -_INLINE_VAR constexpr bool _Can_memmove_in_uninitialized_copy = +_INLINE_VAR constexpr bool _Memmove_in_uninitialized_copy_is_safe = _Can_memop, _IterDest, _Memop_cat::_Copy_uninitialized>; template -_INLINE_VAR constexpr bool _Can_memmove_in_move = _Can_memop, _IterDest, _Memop_cat::_Move>; +_INLINE_VAR constexpr bool _Memmove_in_move_is_safe = + _Can_memop, _IterDest, _Memop_cat::_Move>; template -_INLINE_VAR constexpr bool _Can_memmove_in_uninitialized_move = +_INLINE_VAR constexpr bool _Memmove_in_uninitialized_move_is_safe = _Can_memop, _IterDest, _Memop_cat::_Move_uninitialized>; template @@ -4440,7 +4442,7 @@ template _CONSTEXPR20 _OutIt _Copy_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest) { // copy [_First, _Last) to [_Dest, ...) // note: _Copy_unchecked has callers other than the copy family - if constexpr (_Can_memmove_in_copy<_InIt, _OutIt>) { + if constexpr (_Memmove_in_copy_is_safe<_InIt, _OutIt>) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4476,7 +4478,7 @@ template _OutIt _Copy_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest) { // copy [_First, _Last) to [_Dest, ...) // note: _Copy_unchecked has callers other than the copy family - return _Copy_unchecked1(_First, _Last, _Dest, bool_constant<_Can_memmove_in_copy<_InIt, _OutIt>>{}); + return _Copy_unchecked1(_First, _Last, _Dest, bool_constant<_Memmove_in_copy_is_safe<_InIt, _OutIt>>{}); } #endif // _HAS_IF_CONSTEXPR @@ -4510,7 +4512,7 @@ _CONSTEXPR20 _OutIt copy_n(_InIt _First, _Diff _Count_raw, _OutIt _Dest) { if (0 < _Count) { auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); - if constexpr (_Can_memmove_in_copy) { + if constexpr (_Memmove_in_copy_is_safe) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4571,7 +4573,7 @@ _OutIt copy_n(_InIt _First, _Diff _Count_raw, _OutIt _Dest) { // copy [_First, _ auto _UFirst = _Get_unwrapped_n(_First, _Count); auto _UDest = _Get_unwrapped_n(_Dest, _Count); _Seek_wrapped(_Dest, _Copy_n_unchecked4(_UFirst, _Count, _UDest, - bool_constant<_Can_memmove_in_copy>{})); + bool_constant<_Memmove_in_copy_is_safe>{})); } return _Dest; @@ -4609,7 +4611,7 @@ _BidIt2 _Copy_backward_memmove(move_iterator<_BidIt1> _First, move_iterator<_Bid template _NODISCARD _CONSTEXPR20 _BidIt2 _Copy_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { // copy [_First, _Last) backwards to [..., _Dest) - if constexpr (_Can_memmove_in_copy<_BidIt1, _BidIt2>) { + if constexpr (_Memmove_in_copy_is_safe<_BidIt1, _BidIt2>) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4659,7 +4661,7 @@ _BidIt2 copy_backward(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { // copy [_ const auto _ULast = _Get_unwrapped(_Last); auto _UDest = _Get_unwrapped_n(_Dest, -_Idl_distance<_BidIt1>(_UFirst, _ULast)); _Seek_wrapped(_Dest, _Copy_backward_unchecked(_UFirst, _ULast, _UDest, - bool_constant<_Can_memmove_in_copy>{})); + bool_constant<_Memmove_in_copy_is_safe>{})); return _Dest; } #endif // _HAS_IF_CONSTEXPR @@ -4679,7 +4681,7 @@ template _CONSTEXPR20 _OutIt _Move_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest) { // move [_First, _Last) to [_Dest, ...) // note: _Move_unchecked has callers other than the move family - if constexpr (_Can_memmove_in_move<_InIt, _OutIt>) { + if constexpr (_Memmove_in_move_is_safe<_InIt, _OutIt>) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4715,7 +4717,7 @@ template _OutIt _Move_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest) { // move [_First, _Last) to [_Dest, ...), choose optimization // note: _Move_unchecked has callers other than the move family - return _Move_unchecked1(_First, _Last, _Dest, bool_constant<_Can_memmove_in_move<_InIt, _OutIt>>{}); + return _Move_unchecked1(_First, _Last, _Dest, bool_constant<_Memmove_in_move_is_safe<_InIt, _OutIt>>{}); } #endif // _HAS_IF_CONSTEXPR @@ -4747,7 +4749,7 @@ template _CONSTEXPR20 _BidIt2 _Move_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { // move [_First, _Last) backwards to [..., _Dest) // note: _Move_backward_unchecked has callers other than the move_backward family - if constexpr (_Can_memmove_in_move<_BidIt1, _BidIt2>) { + if constexpr (_Memmove_in_move_is_safe<_BidIt1, _BidIt2>) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4783,7 +4785,7 @@ template _BidIt2 _Move_backward_unchecked(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest) { // move [_First, _Last) backwards to [..., _Dest), choose optimization // note: _Move_backward_unchecked has callers other than the move_backward family - return _Move_backward_unchecked1(_First, _Last, _Dest, bool_constant<_Can_memmove_in_move<_BidIt1, _BidIt2>>{}); + return _Move_backward_unchecked1(_First, _Last, _Dest, bool_constant<_Memmove_in_move_is_safe<_BidIt1, _BidIt2>>{}); } #endif // _HAS_IF_CONSTEXPR @@ -4836,14 +4838,14 @@ struct _Is_character_or_byte_or_bool : true_type {}; template <> struct _Is_character_or_byte_or_bool : true_type {}; -// _Can_memset_in_fill determines if _FwdIt and _Ty are eligible for memset optimization in fill +// _Memset_in_fill_is_safe determines if _FwdIt and _Ty are eligible for memset optimization in fill template > -_INLINE_VAR constexpr bool _Can_memset_in_fill = conjunction_v, +_INLINE_VAR constexpr bool _Memset_in_fill_is_safe = conjunction_v, _Is_character_or_byte_or_bool<_Unwrap_enum_t>>>, is_assignable<_Iter_ref_t<_FwdIt>, const _Ty&>>; template -_INLINE_VAR constexpr bool _Can_memset_in_fill<_FwdIt, _Ty, false> = false; +_INLINE_VAR constexpr bool _Memset_in_fill_is_safe<_FwdIt, _Ty, false> = false; template void _Fill_memset(_DestTy* const _Dest, const _Ty _Val, const size_t _Count) { @@ -4861,7 +4863,7 @@ _CONSTEXPR20 void fill(const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) } else { auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); - if constexpr (_Can_memset_in_fill) { + if constexpr (_Memset_in_fill_is_safe) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4895,7 +4897,7 @@ template void fill(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // copy _Val through [_First, _Last) _Adl_verify_range(_First, _Last); _Fill_unchecked1(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Val, - bool_constant<_Can_memset_in_fill<_Unwrapped_t, _Ty>>{}); + bool_constant<_Memset_in_fill_is_safe<_Unwrapped_t, _Ty>>{}); } #endif // _HAS_IF_CONSTEXPR @@ -4922,7 +4924,7 @@ _CONSTEXPR20 _OutIt fill_n(_OutIt _Dest, const _Diff _Count_raw, const _Ty& _Val return _Last; } else { auto _UDest = _Get_unwrapped_n(_Dest, _Count); - if constexpr (_Can_memset_in_fill) { + if constexpr (_Memset_in_fill_is_safe) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -4969,7 +4971,7 @@ _OutIt fill_n(_OutIt _Dest, const _Diff _Count_raw, const _Ty& _Val) { if (0 < _Count) { auto _UDest = _Get_unwrapped_n(_Dest, _Count); _Seek_wrapped(_Dest, - _Fill_n_unchecked2(_UDest, _Count, _Val, bool_constant<_Can_memset_in_fill>{})); + _Fill_n_unchecked2(_UDest, _Count, _Val, bool_constant<_Memset_in_fill_is_safe>{})); } return _Dest; @@ -5052,7 +5054,7 @@ template _INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred = _Can_memcmp_elements<_Elem1, _Elem2> // && _Pred_is_consistent_with_memcmp<_Elem1, _Elem2, _Pr>; -// _Can_memcmp_in_equal<_Iter1, _Iter2, _Pr> reports whether we can activate the memcmp optimization +// _Memcmp_in_equal_is_safe<_Iter1, _Iter2, _Pr> reports whether we can activate the memcmp optimization // for arbitrary iterators and predicates. // It ignores top-level constness on the iterators and on the elements. template @@ -5061,7 +5063,7 @@ _INLINE_VAR constexpr bool _Equal_memcmp_is_safe_helper = _Iterators_are_contigu remove_const_t>>, _Pr>; template -_INLINE_VAR constexpr bool _Can_memcmp_in_equal = +_INLINE_VAR constexpr bool _Memcmp_in_equal_is_safe = _Equal_memcmp_is_safe_helper, remove_const_t<_Iter2>, _Pr>; #if _HAS_IF_CONSTEXPR @@ -5072,7 +5074,7 @@ _NODISCARD _CONSTEXPR20 bool equal(const _InIt1 _First1, const _InIt1 _Last1, co auto _UFirst1 = _Get_unwrapped(_First1); const auto _ULast1 = _Get_unwrapped(_Last1); auto _UFirst2 = _Get_unwrapped_n(_First2, _Idl_distance<_InIt1>(_UFirst1, _ULast1)); - if constexpr (_Can_memcmp_in_equal) { + if constexpr (_Memcmp_in_equal_is_safe) { #ifdef __cpp_lib_is_constant_evaluated if (!_STD is_constant_evaluated()) #endif // __cpp_lib_is_constant_evaluated @@ -5093,7 +5095,7 @@ _NODISCARD _CONSTEXPR20 bool equal(const _InIt1 _First1, const _InIt1 _Last1, co return true; } #else // ^^^ _HAS_IF_CONSTEXPR / !_HAS_IF_CONSTEXPR vvv -template , int> = 0> +template , int> = 0> bool _Equal_unchecked(_InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { // compare [_First1, _Last1) to [_First2, ...), no special optimization for (; _First1 != _Last1; ++_First1, (void) ++_First2) { @@ -5105,7 +5107,7 @@ bool _Equal_unchecked(_InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _ return true; } -template , int> = 0> +template , int> = 0> bool _Equal_unchecked(const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2, _Pr) { // compare [_First1, _Last1) to [_First2, ...), memcmp optimization const auto _First1_ch = reinterpret_cast(_First1); diff --git a/tests/std/tests/VSO_0180469_ptr_cat/test.cpp b/tests/std/tests/VSO_0180469_ptr_cat/test.cpp index ed6ad8137c..e30b3656a9 100644 --- a/tests/std/tests/VSO_0180469_ptr_cat/test.cpp +++ b/tests/std/tests/VSO_0180469_ptr_cat/test.cpp @@ -31,13 +31,13 @@ void assert_same() { template struct test_ptr_cat_helper { - static constexpr bool CopyReallyTrivial = _Can_memmove_in_uninitialized_copy; - static constexpr bool CopyTriviallyCopyable = _Can_memmove_in_copy; + static constexpr bool CopyReallyTrivial = _Memmove_in_uninitialized_copy_is_safe; + static constexpr bool CopyTriviallyCopyable = _Memmove_in_copy_is_safe; STATIC_ASSERT(Expected == CopyReallyTrivial + CopyTriviallyCopyable); STATIC_ASSERT(!CopyReallyTrivial || CopyTriviallyCopyable); - static constexpr bool MoveReallyTrivial = _Can_memmove_in_uninitialized_move; - static constexpr bool MoveTriviallyCopyable = _Can_memmove_in_move; + static constexpr bool MoveReallyTrivial = _Memmove_in_uninitialized_move_is_safe; + static constexpr bool MoveTriviallyCopyable = _Memmove_in_move_is_safe; STATIC_ASSERT(Expected == MoveReallyTrivial + MoveTriviallyCopyable); STATIC_ASSERT(!MoveReallyTrivial || MoveTriviallyCopyable); }; @@ -234,104 +234,106 @@ void ptr_cat_test_cases() { template void test_case_Equal_memcmp_is_safe_comparator() { // Default case - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); // Adding const should not change the answer - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); // Top level const should not change the answer - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == Expected); // Adding volatile anywhere should explode - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); - STATIC_ASSERT(_Can_memcmp_in_equal == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); #ifdef __cpp_lib_concepts // contiguous iterators should not change the answer if constexpr (!is_same_v && !is_same_v) { // vector::iterator is not contiguous - STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename vector::iterator, Pr> == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal::const_iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename vector::iterator, + Pr> == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::const_iterator, typename vector::const_iterator, Pr> == Expected); } - STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename array::iterator, Pr> == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal::const_iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename array::iterator, + Pr> == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::const_iterator, typename array::const_iterator, Pr> == Expected); // Mixing contiguous iterators should not change the answer if constexpr (!is_same_v && !is_same_v) { - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename vector::const_iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename vector::const_iterator, Pr> == Expected); } if constexpr (!is_same_v) { - STATIC_ASSERT(_Can_memcmp_in_equal::const_iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::const_iterator, typename vector::const_iterator, Pr> == Expected); } if constexpr (!is_same_v) { - STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename array::iterator, Pr> == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename array::const_iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename array::iterator, Pr> == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, + typename array::const_iterator, Pr> == Expected); } // span iterators are contiguous - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, Pr> == Expected); STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename span::iterator, Pr> == Expected); + _Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == Expected); STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename span::iterator, Pr> == Expected); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, + _Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == Expected); + STATIC_ASSERT( + _Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == Expected); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == Expected); // contiguous iterators to volatile should explode STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename span::iterator, Pr> == false); + _Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); STATIC_ASSERT( - _Can_memcmp_in_equal::iterator, typename span::iterator, Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, - Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, - Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, - Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, + _Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, + typename span::iterator, Pr> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, + typename span::iterator, Pr> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, - Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename span::iterator, - Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, + typename span::iterator, Pr> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, + typename span::iterator, Pr> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, + typename span::iterator, Pr> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, + STATIC_ASSERT(_Memcmp_in_equal_is_safe::iterator, typename span::iterator, Pr> == false); #endif // __cpp_lib_concepts // Non-contiguous iterators should explode - STATIC_ASSERT(_Can_memcmp_in_equal::iterator, typename list::iterator, Pr> == false); + STATIC_ASSERT( + _Memcmp_in_equal_is_safe::iterator, typename list::iterator, Pr> == false); } template @@ -343,15 +345,15 @@ void test_case_Equal_memcmp_is_safe() { #endif // __cpp_lib_concepts // equal_to< some other T > should explode - STATIC_ASSERT(_Can_memcmp_in_equal>> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe>> == false); // Non equal_to comparison functions should explode auto lambda = [](Elem1*, Elem2*) { return false; }; - STATIC_ASSERT(_Can_memcmp_in_equal == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe == false); // equal_to should not explode - STATIC_ASSERT(_Can_memcmp_in_equal> == (Expected && is_same_v) ); + STATIC_ASSERT(_Memcmp_in_equal_is_safe> == (Expected && is_same_v) ); // But again, not volatile - STATIC_ASSERT(_Can_memcmp_in_equal> == false); - STATIC_ASSERT(_Can_memcmp_in_equal> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe> == false); + STATIC_ASSERT(_Memcmp_in_equal_is_safe> == false); } void equal_safe_test_cases() {