From 954f424920eec7f6da4e7ca3dde5f5b7981b76bd Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 18:51:05 +0300 Subject: [PATCH 01/73] [[nodiscard]] messages Partly addresses #271 --- stl/inc/algorithm | 397 +++++++++++++++++++++++----------------- stl/inc/any | 21 ++- stl/inc/array | 192 +++++++++---------- stl/inc/atomic | 60 +++--- stl/inc/barrier | 4 +- stl/inc/bit | 28 +-- stl/inc/latch | 4 +- stl/inc/mutex | 61 +++--- stl/inc/semaphore | 16 +- stl/inc/shared_mutex | 43 ++--- stl/inc/source_location | 12 +- stl/inc/thread | 47 ++--- stl/inc/vector | 48 ++--- stl/inc/yvals_core.h | 88 +++++++++ 14 files changed, 589 insertions(+), 432 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 7c7b95bb9ae..e835990302f 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -373,11 +373,12 @@ namespace ranges { #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt find_if( + _ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { // find first element that satisfies !_Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -394,11 +395,12 @@ _NODISCARD _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _ #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt find_if_not( + _ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find first satisfying _Pred with successor _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -417,16 +419,19 @@ _NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, } template -_NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, const _FwdIt _Last) { // find first matching successor +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find( + const _FwdIt _First, const _FwdIt _Last) { // find first matching successor return _STD adjacent_find(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt adjacent_find( + _ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept +/* terminates */ { // find first matching successor return _STD adjacent_find(_STD forward<_ExPo>(_Exec), _First, _Last, equal_to{}); } @@ -440,7 +445,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_binary_predicate, projected<_It, _Pj>> _Pr = ranges::equal_to> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Adjacent_find_unchecked( @@ -453,7 +459,8 @@ namespace ranges { template , _Pj>, projected, _Pj>> _Pr = ranges::equal_to> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Adjacent_find_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_iterator(_Range, _STD move(_UResult)); @@ -492,7 +499,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD constexpr iter_difference_t<_It> operator()( + _NODISCARD_PURE_ALGORITHM constexpr iter_difference_t<_It> operator()( _It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_unchecked( @@ -501,7 +508,7 @@ namespace ranges { template requires indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { return _Count_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); } // clang-format on @@ -529,7 +536,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { // count elements satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -546,7 +553,7 @@ _NODISCARD _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, #if _HAS_CXX17 template = 0> -_NODISCARD _Iter_diff_t<_FwdIt> count_if( +_NODISCARD_PURE_ALGORITHM _Iter_diff_t<_FwdIt> count_if( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 @@ -558,7 +565,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr iter_difference_t<_It> operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr iter_difference_t<_It> operator()( + _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_if_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -566,7 +574,8 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Count_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -594,7 +603,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( + _InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, ...) mismatch _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -612,19 +622,20 @@ _NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, const _InI #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( + const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { // return [_First1, _Last1)/[_First2, ...) mismatch return _STD mismatch(_First1, _Last1, _First2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, ...) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -634,7 +645,7 @@ _NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, _Last2) mismatch _Adl_verify_range(_First1, _Last1); @@ -667,19 +678,20 @@ _NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( + _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // return [_First1, _Last1)/[_First2, _Last2) mismatch return _STD mismatch(_First1, _Last1, _First2, _Last2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, _Last2) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -737,7 +749,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -763,7 +775,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { using _Size1 = _Make_unsigned_like_t>; @@ -787,7 +799,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( + _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, ...) _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -811,7 +824,7 @@ _NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _Fw } template -_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { // test if [_First1, _Last1) == permuted [_First2, ...) return _STD is_permutation(_First1, _Last1, _First2, equal_to<>{}); } @@ -870,7 +883,7 @@ _CONSTEXPR20 bool _Is_permutation_unchecked(_FwdIt1 _First1, _FwdIt1 _Last1, _Fw } template -_NODISCARD _CONSTEXPR20 bool is_permutation( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, _Last2) _Adl_verify_range(_First1, _Last1); @@ -880,7 +893,8 @@ _NODISCARD _CONSTEXPR20 bool is_permutation( } template -_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( + _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { // test if [_First1, _Last1) == permuted [_First2, _Last2) return _STD is_permutation(_First1, _Last1, _First2, _Last2, equal_to<>{}); } @@ -899,8 +913,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_equivalence_relation, projected<_It2, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_STD move(_First1)); @@ -925,7 +939,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { const auto _Count = _RANGES distance(_Range1); @@ -1117,7 +1131,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool all_of(_InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool all_of( + _InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); @@ -1132,7 +1147,7 @@ _NODISCARD _CONSTEXPR20 bool all_of(_InIt _First, _InIt _Last, _Pr _Pred) { // t #if _HAS_CXX17 template = 0> -_NODISCARD bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1143,7 +1158,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _All_of_unchecked( @@ -1152,7 +1167,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _All_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1178,7 +1193,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if any element satisfies _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1194,7 +1209,8 @@ _NODISCARD _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _ #if _HAS_CXX17 template = 0> -_NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool any_of( + _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1205,7 +1221,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Any_of_unchecked( @@ -1214,7 +1230,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Any_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1240,7 +1256,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if no elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1256,7 +1272,8 @@ _NODISCARD _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr #if _HAS_CXX17 template = 0> -_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool none_of( + _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1267,7 +1284,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _None_of_unchecked( @@ -1276,7 +1293,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _None_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1665,7 +1682,7 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if [_First, _Last) partitioned by _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1692,7 +1709,8 @@ _NODISCARD _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Las #if _HAS_CXX17 template = 0> -_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool is_partitioned( + _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1703,7 +1721,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Is_partitioned_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1711,7 +1729,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Is_partitioned_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1748,7 +1766,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find beginning of false partition in [_First, _Last) _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1779,7 +1797,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); if constexpr (sized_sentinel_for<_Se, _It>) { @@ -1796,7 +1814,8 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { if constexpr (sized_range<_Rng>) { const auto _Length = _RANGES distance(_Range); auto _UFirst = _Partition_point_n_unchecked(_Ubegin(_Range), _Length, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1891,8 +1910,8 @@ _NODISCARD _CONSTEXPR20 bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _F } template -_NODISCARD _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, - const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, + const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_First1); @@ -1935,12 +1954,12 @@ _NODISCARD _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHays #if _HAS_CXX17 template = 0> -_NODISCARD _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, +_NODISCARD_PURE_ALGORITHM _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First1, const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) { // find first [_First2, _Last2) match return _STD search(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -1948,22 +1967,22 @@ _NODISCARD _CONSTEXPR20 _FwdItHaystack search( #if _HAS_CXX17 template = 0> -_NODISCARD _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, const _FwdItHaystack _Last1, - const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, + const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { // find first [_First2, _Last2) match return _STD search(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First, const _FwdItHaystack _Last, const _Searcher& _Search) { // find _Search's pattern in [_First, _Last) return _Search(_First, _Last).first; } template -_NODISCARD _CONSTEXPR20 _FwdIt search_n( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) { // find first _Count * _Val satisfying _Pred const _Algorithm_int_t<_Diff> _Count = _Count_raw; @@ -2036,19 +2055,21 @@ _NODISCARD _CONSTEXPR20 _FwdIt search_n( #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, +_NODISCARD_PURE_ALGORITHM _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, + const _Ty& _Val, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdIt search_n(const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( + const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { // find first _Count * _Val match return _STD search_n(_First, _Last, _Count, _Val, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, +_NODISCARD_PURE_ALGORITHM _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) noexcept /* terminates */ { // find first _Count * _Val match return _STD search_n(_STD forward<_ExPo>(_Exec), _First, _Last, _Count, _Val, equal_to{}); } @@ -2064,7 +2085,7 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); @@ -2089,7 +2110,7 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, + _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); @@ -2218,7 +2239,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // find last [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); @@ -2299,7 +2320,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt1 find_end( } template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 const _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) { // find last [_First2, _Last2) match return _STD find_end(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -2307,11 +2328,12 @@ _NODISCARD _CONSTEXPR20 _FwdIt1 find_end( #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt1 find_end( +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_end( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt1 find_end(_ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_end( + _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // find last [_First2, _Last2) match return _STD find_end(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } @@ -2428,7 +2450,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2458,7 +2480,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr borrowed_subrange_t<_Rng1> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (random_access_range<_Rng1> && sized_range<_Rng1> && random_access_range<_Rng2> && sized_range<_Rng2>) { @@ -2483,7 +2505,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // look for one of [_First2, _Last2) satisfying _Pred with element _Adl_verify_range(_First1, _Last1); @@ -2506,18 +2528,21 @@ _NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of( } template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, + const _FwdIt2 _First2, const _FwdIt2 _Last2) { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_First1, _Last1, _First2, _Last2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, + const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of( + _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } @@ -2533,7 +2558,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2549,7 +2574,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr borrowed_iterator_t<_Rng1> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); @@ -3412,11 +3437,11 @@ _FwdIt2 remove_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _P #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt remove( +_NODISCARD_REMOVE_ALGORITHM _FwdIt remove( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept; // terminates template = 0> -_NODISCARD _FwdIt remove_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_REMOVE_ALGORITHM _FwdIt remove_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -3428,7 +3453,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Val, _Pass_fn(_Proj)); @@ -3439,7 +3464,7 @@ namespace ranges { template requires permutable> && indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()( + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { auto _UResult = _Remove_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); @@ -3480,7 +3505,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_if_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -3492,7 +3518,7 @@ namespace ranges { template , _Pj>> _Pr> requires permutable> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { auto _UResult = _Remove_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_subrange>(_Range, _STD move(_UResult)); @@ -3650,7 +3676,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // remove each satisfying _Pred with previous _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -3675,20 +3701,20 @@ _NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { } template -_NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous +_NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous return _STD unique(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALGORITHM _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // remove each satisfying _Pred with previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALGORITHM _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // remove each matching previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last); @@ -3703,7 +3729,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_equivalence_relation> _Pr = ranges::equal_to> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Unique_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -3715,7 +3742,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::equal_to> requires permutable> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Unique_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_subrange>(_Range, _STD move(_UResult)); @@ -5694,7 +5721,7 @@ _CONSTEXPR20 _RanIt _Is_heap_until_unchecked(_RanIt _First, _RanIt _Last, _Pr _P } template -_NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { // find extent of range that is a heap _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Is_heap_until_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); @@ -5702,7 +5729,7 @@ _NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _P } template -_NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // test if range is a heap _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -5711,34 +5738,37 @@ _NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { } template -_NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_First, _Last, less<>{}); } template -_NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap( + _RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< return _STD is_heap(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _RanIt is_heap_until( + _ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept +/* terminates */ { // test if range is a heap return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // test if range is a heap ordered by operator< return _STD is_heap(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -5775,7 +5805,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _ULast = _Get_unwrapped(_STD move(_Last)); @@ -5787,7 +5818,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); const auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -5803,7 +5834,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _Size = _RANGES distance(_UFirst, _Get_unwrapped(_STD move(_Last))); @@ -5815,7 +5847,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_iterator(_Range, _STD move(_UResult)); @@ -5931,7 +5964,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()( + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -5944,7 +5977,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = @@ -5960,7 +5993,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find first element that _Val is before _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -5982,7 +6015,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _T } template -_NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find first element that _Val is before return _STD upper_bound(_First, _Last, _Val, less<>{}); } @@ -6018,7 +6051,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()( + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6030,7 +6063,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = _Upper_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -6045,7 +6078,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( + _FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find range equivalent to _Val _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6082,7 +6116,7 @@ _NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _ } template -_NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find range equivalent to _Val return _STD equal_range(_First, _Last, _Val, less<>{}); } @@ -6151,7 +6185,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // test if _Val equivalent to some element _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6161,7 +6195,7 @@ _NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _T } template -_NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // test if _Val equivalent to some element return _STD binary_search(_First, _Last, _Val, less<>{}); } @@ -6174,7 +6208,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6187,7 +6221,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); const auto _UFirst = _RANGES _Lower_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -8229,7 +8264,8 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes( + _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -8253,14 +8289,15 @@ _NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _Fir } template -_NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) return _STD includes(_First1, _Last1, _First2, _Last2, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept +_NODISCARD_PURE_ALGORITHM bool includes( + _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8270,7 +8307,8 @@ _NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _Firs } template = 0> -_NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD_PURE_ALGORITHM bool includes( + _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8288,7 +8326,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -8300,7 +8339,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Includes_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); @@ -8916,27 +8955,28 @@ constexpr _FwdIt _Max_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Max_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element return _STD max_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last); @@ -8970,7 +9010,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -8979,7 +9020,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9007,27 +9049,29 @@ constexpr _FwdIt _Min_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt min_element( + _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Min_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element return _STD min_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last); @@ -9061,7 +9105,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9070,7 +9115,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9122,7 +9168,7 @@ constexpr pair<_FwdIt, _FwdIt> _Minmax_element_unchecked(_FwdIt _First, _FwdIt _ } template -_NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest and largest elements _Adl_verify_range(_First, _Last); const auto _Result = _Minmax_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred)); @@ -9132,14 +9178,14 @@ _NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _ } template -_NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { // find smallest and largest elements return _STD minmax_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release @@ -9147,7 +9193,8 @@ _NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _L } template = 0> -_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept +/* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release return _STD minmax_element(_First, _Last); @@ -9212,7 +9259,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr minmax_element_result<_It> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_element_result<_It> operator()( _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9225,7 +9272,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr minmax_element_result> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_element_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9243,14 +9290,14 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/largest const _Ty* _Res = _Max_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { // return leftmost/largest return (_STD max) (_Ilist, less<>{}); } @@ -9269,7 +9316,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr const _Ty& operator()( + _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Left), _STD invoke(_Proj, _Right))) { return _Right; @@ -9280,7 +9327,8 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr _Ty operator()(initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _Ty operator()( + initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, @@ -9292,7 +9340,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( @@ -9319,14 +9367,14 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/smallest const _Ty* _Res = _Min_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { // return leftmost/smallest return (_STD min) (_Ilist, less<>{}); } @@ -9339,7 +9387,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr const _Ty& operator()( + _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return _Right; @@ -9350,7 +9398,8 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr _Ty operator()(initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _Ty operator()( + initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, @@ -9362,7 +9411,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( @@ -9389,7 +9438,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept( +_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept( noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) { @@ -9400,14 +9449,14 @@ _NODISCARD constexpr pair minmax(const _Ty& _Left, const } template -_NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return {leftmost/smallest, rightmost/largest} pair _Res = _Minmax_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return pair<_Ty, _Ty>(*_Res.first, *_Res.second); } template -_NODISCARD constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( +_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( noexcept(_Right < _Left)) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_Right < _Left) { @@ -9419,7 +9468,7 @@ _NODISCARD constexpr pair minmax(const _Ty& _Left, const } template -_NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { // return {leftmost/smallest, rightmost/largest} return _STD minmax(_Ilist, less<>{}); } @@ -9435,7 +9484,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr minmax_result operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_result operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return {_Right, _Left}; @@ -9446,7 +9495,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr minmax_result<_Ty> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_result<_Ty> operator()( initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); @@ -9460,7 +9509,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr minmax_result> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { // clang-format on auto _UFirst = _Ubegin(_Range); @@ -9737,7 +9786,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find extent of range that is ordered by predicate _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -9756,7 +9805,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last } template -_NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // test if range is ordered by predicate _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -9765,34 +9814,37 @@ _NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { } template -_NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { // find extent of range that is ordered by operator< return _STD is_sorted_until(_First, _Last, less<>{}); } template -_NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted( + _FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< return _STD is_sorted(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt is_sorted_until( + _ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // test if range is ordered by predicate return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find extent of range that is ordered by operator< return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // test if range is ordered by operator< return _STD is_sorted(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -9805,7 +9857,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); const auto _ULast = _Get_unwrapped(_STD move(_Last)); const auto _UFirst = @@ -9815,7 +9868,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _ULast = _Uend(_Range); const auto _UFirst = _Is_sorted_until_unchecked(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _UFirst == _ULast; @@ -9830,7 +9883,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Is_sorted_until_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -9840,7 +9894,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UFirst = _Is_sorted_until_unchecked(_Get_unwrapped(_First), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -9854,7 +9909,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp( + const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { // returns _Val constrained to [_Min_val, _Max_val] #if _ITERATOR_DEBUG_LEVEL == 2 if (_DEBUG_LT_PRED(_Pred, _Max_val, _Min_val)) { @@ -9875,7 +9931,7 @@ _NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, cons } template -_NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { +_NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { // returns _Val constrained to [_Min_val, _Max_val] return _STD clamp(_Val, _Min_val, _Max_val, less{}); } @@ -9888,7 +9944,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr const _Ty& operator()( + _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( const _Ty& _Val, const _Ty& _Lo, const _Ty& _Hi, _Pr _Pred = {}, _Pj _Proj = {}) const { _STL_ASSERT(!_STD invoke(_Pred, _STD invoke(_Proj, _Hi), _STD invoke(_Proj, _Lo)), "The lower bound cannot be greater than the upper bound in a call to std::ranges::clamp " @@ -9915,7 +9971,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -9928,7 +9985,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Lexicographical_compare_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); diff --git a/stl/inc/any b/stl/inc/any index 8f4ba7cc292..17f3f2d2e33 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -33,7 +33,7 @@ _STD_BEGIN class bad_any_cast : public bad_cast { // thrown by failed any_cast public: - _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD_PURE_METHOD const char* __CLR_OR_THIS_CALL what() const noexcept override { return "Bad any_cast"; } }; @@ -225,11 +225,11 @@ public: } // Observers [any.observers] - _NODISCARD bool has_value() const noexcept { + _NODISCARD_PURE_METHOD bool has_value() const noexcept { return _Storage._TypeData != 0; } - _NODISCARD const type_info& type() const noexcept { + _NODISCARD_PURE_METHOD const type_info& type() const noexcept { // if *this contains a value of type T, return typeid(T); otherwise typeid(void) const type_info* const _Info = _TypeInfo(); if (_Info) { @@ -358,17 +358,18 @@ inline void swap(any& _Left, any& _Right) noexcept { } template -_NODISCARD any make_any(_Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... +_NODISCARD_PURE_FUNCTION any make_any( + _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... return any{in_place_type<_ValueType>, _STD forward<_Types>(_Args)...}; } template -_NODISCARD any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { +_NODISCARD_PURE_FUNCTION any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Ilist and _Args... return any{in_place_type<_ValueType>, _Ilist, _STD forward<_Types>(_Args)...}; } template -_NODISCARD const _ValueType* any_cast(const any* const _Any) noexcept { +_NODISCARD_PURE_FUNCTION const _ValueType* any_cast(const any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -383,7 +384,7 @@ _NODISCARD const _ValueType* any_cast(const any* const _Any) noexcept { } } template -_NODISCARD _ValueType* any_cast(any* const _Any) noexcept { +_NODISCARD_PURE_FUNCTION _ValueType* any_cast(any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -399,7 +400,7 @@ _NODISCARD _ValueType* any_cast(any* const _Any) noexcept { } template -_NODISCARD remove_cv_t<_Ty> any_cast(const any& _Any) { +_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(const any& _Any) { static_assert(is_constructible_v, const _Remove_cvref_t<_Ty>&>, "any_cast(const any&) requires remove_cv_t to be constructible from " "const remove_cv_t>&"); @@ -412,7 +413,7 @@ _NODISCARD remove_cv_t<_Ty> any_cast(const any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD remove_cv_t<_Ty> any_cast(any& _Any) { +_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>&>, "any_cast(any&) requires remove_cv_t to be constructible from remove_cv_t>&"); @@ -424,7 +425,7 @@ _NODISCARD remove_cv_t<_Ty> any_cast(any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD remove_cv_t<_Ty> any_cast(any&& _Any) { +_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any&& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>>, "any_cast(any&&) requires remove_cv_t to be constructible from remove_cv_t>"); diff --git a/stl/inc/array b/stl/inc/array index c417a1826b4..128e0242abf 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -48,11 +48,11 @@ public: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg + _Off) {} - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { return *_Ptr; } - _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { return _Ptr; } @@ -83,7 +83,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -94,46 +94,46 @@ public: return *this; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { return _Ptr - _Right._Ptr; } - _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return _Ptr[_Off]; } - _NODISCARD _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { return _Ptr <=> _Right._Ptr; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { return _Ptr < _Right._Ptr; } - _NODISCARD _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -158,11 +158,11 @@ private: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg), _Idx(_Off) {} - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { return *operator->(); } - _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { _STL_VERIFY(_Ptr, "cannot dereference value-initialized array iterator"); _STL_VERIFY(_Idx < _Size, "cannot dereference out of range array iterator"); return _Ptr + _Idx; @@ -214,7 +214,7 @@ private: return *this; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -224,50 +224,50 @@ private: return *this += -_Off; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_Idx - _Right._Idx); } - _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return *(*this + _Off); } - _NODISCARD _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx == _Right._Idx; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx <=> _Right._Idx; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx < _Right._Idx; } - _NODISCARD _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -307,7 +307,7 @@ constexpr void _Verify_range( #endif // _ITERATOR_DEBUG_LEVEL != 0 template -_NODISCARD _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_const_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -320,7 +320,7 @@ struct pointer_traits<_Array_const_iterator<_Ty, _Size>> { using element_type = const _Ty; using difference_type = ptrdiff_t; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_FUNCTION static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -346,11 +346,11 @@ public: _CONSTEXPR17 explicit _Array_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Mybase(_Parg, _Off) {} - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { return const_cast(_Mybase::operator->()); } @@ -381,7 +381,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -394,13 +394,13 @@ public: using _Mybase::operator-; - _NODISCARD _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -412,7 +412,7 @@ public: }; template -_NODISCARD _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -425,7 +425,7 @@ struct pointer_traits<_Array_iterator<_Ty, _Size>> { using element_type = _Ty; using difference_type = ptrdiff_t; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_FUNCTION static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -462,51 +462,51 @@ public: _Swap_ranges_unchecked(_Elems, _Elems + _Size, _Other._Elems); } - _NODISCARD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator begin() noexcept { return iterator(_Elems, 0); } - _NODISCARD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator(_Elems, 0); } - _NODISCARD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator end() noexcept { return iterator(_Elems, _Size); } - _NODISCARD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator(_Elems, _Size); } - _NODISCARD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -526,19 +526,19 @@ public: return _Elems + _Size; } - _NODISCARD constexpr size_type size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type size() const noexcept { return _Size; } - _NODISCARD constexpr size_type max_size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type max_size() const noexcept { return _Size; } - _NODISCARD constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_METHOD_ARRAY constexpr bool empty() const noexcept { return false; } - _NODISCARD _CONSTEXPR17 reference at(size_type _Pos) { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference at(size_type _Pos) { if (_Size <= _Pos) { _Xran(); } @@ -546,7 +546,7 @@ public: return _Elems[_Pos]; } - _NODISCARD constexpr const_reference at(size_type _Pos) const { + _NODISCARD_PURE_METHOD constexpr const_reference at(size_type _Pos) const { if (_Size <= _Pos) { _Xran(); } @@ -554,7 +554,8 @@ public: return _Elems[_Pos]; } - _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept + /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -562,7 +563,8 @@ public: return _Elems[_Pos]; } - _NODISCARD constexpr const_reference operator[](_In_range_(0, _Size - 1) size_type _Pos) const noexcept + _NODISCARD_PURE_OPERATOR constexpr const_reference operator[]( + _In_range_(0, _Size - 1) size_type _Pos) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); @@ -571,27 +573,27 @@ public: return _Elems[_Pos]; } - _NODISCARD _CONSTEXPR17 reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference front() noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD constexpr const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD constexpr const_reference front() const noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD _CONSTEXPR17 reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference back() noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD constexpr const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD constexpr const_reference back() const noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 _Ty* data() noexcept { return _Elems; } - _NODISCARD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const _Ty* data() const noexcept { return _Elems; } @@ -639,51 +641,51 @@ public: _CONSTEXPR20 void swap(array&) noexcept {} - _NODISCARD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator begin() noexcept { return iterator{}; } - _NODISCARD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator{}; } - _NODISCARD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator end() noexcept { return iterator{}; } - _NODISCARD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator{}; } - _NODISCARD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -703,15 +705,15 @@ public: return nullptr; } - _NODISCARD constexpr size_type size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type size() const noexcept { return 0; } - _NODISCARD constexpr size_type max_size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type max_size() const noexcept { return 0; } - _NODISCARD constexpr bool empty() const noexcept { + _NODISCARD_PURE_METHOD constexpr bool empty() const noexcept { return true; } @@ -723,7 +725,7 @@ public: _Xran(); } - _NODISCARD reference operator[](size_type) noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_OPERATOR reference operator[](size_type) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -731,7 +733,7 @@ public: return _Elems[0]; } - _NODISCARD const_reference operator[](size_type) const noexcept /* strengthened */ { + _NODISCARD_PURE_OPERATOR const_reference operator[](size_type) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -739,7 +741,7 @@ public: return _Elems[0]; } - _NODISCARD reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -747,7 +749,7 @@ public: return _Elems[0]; } - _NODISCARD const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -755,7 +757,7 @@ public: return _Elems[0]; } - _NODISCARD reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -763,7 +765,7 @@ public: return _Elems[0]; } - _NODISCARD const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -771,11 +773,11 @@ public: return _Elems[0]; } - _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 _Ty* data() noexcept { return nullptr; } - _NODISCARD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const _Ty* data() const noexcept { return nullptr; } @@ -792,7 +794,7 @@ _CONSTEXPR20 void swap(array<_Ty, _Size>& _Left, array<_Ty, _Size>& _Right) noex } template -_NODISCARD _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD equal(_Left.begin(), _Left.end(), _Right.begin()); #else // ^^^ workaround / no workaround vvv @@ -802,14 +804,14 @@ _NODISCARD _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const ar #if !_HAS_CXX20 template -_NODISCARD bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 #ifdef __cpp_lib_concepts template -_NODISCARD constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD_PURE_OPERATOR constexpr _Synth_three_way_result<_Ty> operator<=>( const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD lexicographical_compare_three_way( @@ -831,17 +833,17 @@ _NODISCARD _CONSTEXPR20 bool operator<(const array<_Ty, _Size>& _Left, const arr } template -_NODISCARD _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return _Right < _Left; } template -_NODISCARD _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Right < _Left); } template -_NODISCARD _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ @@ -860,7 +862,7 @@ _NODISCARD constexpr array, _Size> _To_array_rvalue_impl( } template -_NODISCARD constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { +_NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/1: " "to_array does not accept multidimensional arrays."); static_assert(is_constructible_v<_Ty, _Ty&>, "N4830 [array.creation]/1: " @@ -869,7 +871,7 @@ _NODISCARD constexpr array, _Size> to_array(_Ty (&_Array)[_Size } template -_NODISCARD constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { +_NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/4: " "to_array does not accept multidimensional arrays."); static_assert(is_move_constructible_v<_Ty>, "N4830 [array.creation]/4: " @@ -879,25 +881,25 @@ _NODISCARD constexpr array, _Size> to_array(_Ty(&&_Array)[_Size #endif // _HAS_CXX20 template -_NODISCARD constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD_ACCESSOR_FUNCTION constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD_PURE_FUNCTION constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD_ACCESSOR_FUNCTION constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } template -_NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD_PURE_FUNCTION constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } diff --git a/stl/inc/atomic b/stl/inc/atomic index 3f15cb007c5..f98eb9356ca 100644 --- a/stl/inc/atomic +++ b/stl/inc/atomic @@ -500,7 +500,7 @@ struct _Atomic_storage { _Storage = _Value; } - _NODISCARD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { // load with sequential consistency _Check_load_memory_order(_Order); _Guard _Lock{_Spinlock}; @@ -661,14 +661,14 @@ struct _Atomic_storage<_Ty, 1> { // lock-free using 1-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Load_barrier(_Order); @@ -782,14 +782,14 @@ struct _Atomic_storage<_Ty, 2> { // lock-free using 2-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Load_barrier(_Order); @@ -900,14 +900,14 @@ struct _Atomic_storage<_Ty, 4> { // lock-free using 4-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Load_barrier(_Order); @@ -1024,7 +1024,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); long long _As_bytes; #ifdef _M_ARM @@ -1037,7 +1037,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); #ifdef _M_ARM long long _As_bytes = __ldrexd(_Mem); @@ -1140,14 +1140,14 @@ struct _Atomic_storage<_Ty&, 16> { // lock-free using 16-byte intrinsics (void) exchange(_Value, _Order); } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 (void) _STD_COMPARE_EXCHANGE_128(_Storage_ptr, 0, 0, &_Result._Low); return reinterpret_cast<_TVal&>(_Result); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order #if defined(_M_ARM64) || defined(_M_ARM64EC) long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 @@ -2168,14 +2168,14 @@ public: #endif // _HAS_CXX17 #if 1 // TRANSITION, ABI - _NODISCARD bool is_lock_free() const volatile noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const volatile noexcept { constexpr bool _Result = sizeof(_Ty) <= 8 && (sizeof(_Ty) & sizeof(_Ty) - 1) == 0; return _Result; } #else // ^^^ don't break ABI / break ABI vvv - _NODISCARD bool is_lock_free() const volatile noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const volatile noexcept { #if _ATOMIC_HAS_DCAS return sizeof(_Ty) <= 2 * sizeof(void*); #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2184,7 +2184,7 @@ public: } #endif // TRANSITION, ABI - _NODISCARD bool is_lock_free() const noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const noexcept { return static_cast(this)->is_lock_free(); } @@ -2216,12 +2216,12 @@ public: } using _Base::load; - _NODISCARD _Ty load() const volatile noexcept { + _NODISCARD_PURE_METHOD _Ty load() const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(); } - _NODISCARD _Ty load(const memory_order _Order) const volatile noexcept { + _NODISCARD_PURE_METHOD _Ty load(const memory_order _Order) const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(_Order); } @@ -2351,7 +2351,7 @@ public: static constexpr size_t required_alignment = _Is_potentially_lock_free ? sizeof(_Ty) : alignof(_Ty); - _NODISCARD bool is_lock_free() const noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const noexcept { #if _ATOMIC_HAS_DCAS return is_always_lock_free; #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2432,12 +2432,12 @@ private: #endif // _HAS_CXX20 template -_NODISCARD bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { +_NODISCARD_PURE_FUNCTION bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } template -_NODISCARD bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { +_NODISCARD_PURE_FUNCTION bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } @@ -2478,24 +2478,25 @@ _CXX20_DEPRECATE_ATOMIC_INIT void atomic_init( } template -_NODISCARD _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(); } template -_NODISCARD _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { return _Mem->load(); } template -_NODISCARD _Ty atomic_load_explicit(const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load_explicit( + const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(_Order); } template -_NODISCARD _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { return _Mem->load(_Order); } @@ -2807,11 +2808,11 @@ using atomic_unsigned_lock_free = atomic_uintptr_t; {} struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 - _NODISCARD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_METHOD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { return _Storage.load(_Order) != 0; } - _NODISCARD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { + _NODISCARD_PURE_METHOD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { return _Storage.load(_Order) != 0; } #endif // _HAS_CXX20 @@ -2869,20 +2870,21 @@ struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 -_NODISCARD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { +_NODISCARD_PURE_METHOD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { +_NODISCARD_PURE_METHOD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD inline bool atomic_flag_test_explicit( +_NODISCARD_PURE_METHOD inline bool atomic_flag_test_explicit( const volatile atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } -_NODISCARD inline bool atomic_flag_test_explicit(const atomic_flag* const _Flag, const memory_order _Order) noexcept { +_NODISCARD_PURE_METHOD inline bool atomic_flag_test_explicit( + const atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } #endif // _HAS_CXX20 diff --git a/stl/inc/barrier b/stl/inc/barrier index fc0eb1df2cd..2e987e6b001 100644 --- a/stl/inc/barrier +++ b/stl/inc/barrier @@ -88,11 +88,11 @@ public: barrier(const barrier&) = delete; barrier& operator=(const barrier&) = delete; - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return _Barrier_max; } - _NODISCARD arrival_token arrive(ptrdiff_t _Update = 1) noexcept /* strengthened */ { + _NODISCARD_BARRIER_TOKEN arrival_token arrive(ptrdiff_t _Update = 1) noexcept /* strengthened */ { // Shifting before precondition check, so that exceeding max() will trigger precondition check too _Update <<= _Barrier_value_shift; _STL_VERIFY(_Update > 0, "Precondition: update > 0 (N4861 [thread.barrier.class]/12)"); diff --git a/stl/inc/bit b/stl/inc/bit index 85040110d33..5e759d808ce 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -30,22 +30,22 @@ template , is_trivially_copyable<_To>, is_trivially_copyable<_From>>, int> = 0> -_NODISCARD constexpr _To bit_cast(const _From& _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _To bit_cast(const _From& _Val) noexcept { return __builtin_bit_cast(_To, _Val); } template , int> = 0> -_NODISCARD constexpr int countl_zero(_Ty _Val) noexcept; +_NODISCARD_PURE_FUNCTION constexpr int countl_zero(_Ty _Val) noexcept; template , int> = 0> -_NODISCARD constexpr bool has_single_bit(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr bool has_single_bit(const _Ty _Val) noexcept { return _Val != 0 && (_Val & (_Val - 1)) == 0; } inline void _Precondition_violation_in_bit_ceil() noexcept {} template , int> = 0> -_NODISCARD constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { +_NODISCARD_PURE_FUNCTION constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { if (_Val <= 1u) { return _Ty{1}; } @@ -73,7 +73,7 @@ _NODISCARD constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { } template , int> = 0> -_NODISCARD constexpr _Ty bit_floor(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty bit_floor(const _Ty _Val) noexcept { if (_Val == 0) { return 0; } @@ -82,15 +82,15 @@ _NODISCARD constexpr _Ty bit_floor(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD constexpr _Ty bit_width(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty bit_width(const _Ty _Val) noexcept { return static_cast<_Ty>(numeric_limits<_Ty>::digits - _STD countl_zero(_Val)); } template , int> = 0> -_NODISCARD constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; +_NODISCARD_PURE_FUNCTION constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; template , int> = 0> -_NODISCARD constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; const auto _Remainder = _Rotation % _Digits; if (_Remainder > 0) { @@ -104,7 +104,7 @@ _NODISCARD constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { } template , int> _Enabled> -_NODISCARD constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; const auto _Remainder = _Rotation % _Digits; if (_Remainder > 0) { @@ -234,7 +234,7 @@ _NODISCARD int _Checked_arm_arm64_countl_zero(const _Ty _Val) noexcept { #endif // defined(_M_ARM) || defined(_M_ARM64) template , int> _Enabled> -_NODISCARD constexpr int countl_zero(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countl_zero(const _Ty _Val) noexcept { #if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) if (!_STD is_constant_evaluated()) { return _Checked_x86_x64_countl_zero(_Val); @@ -249,22 +249,22 @@ _NODISCARD constexpr int countl_zero(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD constexpr int countl_one(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countl_one(const _Ty _Val) noexcept { return _STD countl_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD constexpr int countr_zero(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countr_zero(const _Ty _Val) noexcept { return _Countr_zero(_Val); } template , int> _Enabled = 0> -_NODISCARD constexpr int countr_one(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countr_one(const _Ty _Val) noexcept { return _Countr_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD constexpr int popcount(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int popcount(const _Ty _Val) noexcept { return _Popcount(_Val); } diff --git a/stl/inc/latch b/stl/inc/latch index 16eea8b0fed..f764cda0aa4 100644 --- a/stl/inc/latch +++ b/stl/inc/latch @@ -31,7 +31,7 @@ _STD_BEGIN class latch { public: - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return (1ULL << (sizeof(ptrdiff_t) * CHAR_BIT - 1)) - 1; } @@ -53,7 +53,7 @@ public: } } - _NODISCARD bool try_wait() const noexcept { + _NODISCARD_TRY_WAIT bool try_wait() const noexcept { // TRANSITION, GH-1133: should be memory_order_acquire return _Counter.load() == 0; } diff --git a/stl/inc/mutex b/stl/inc/mutex index eea7d5426a6..0163edbe9fb 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -50,7 +50,7 @@ public: _Check_C_return(_Mtx_lock(_Mymtx())); } - _NODISCARD bool try_lock() { + _NODISCARD_MODIFY_STATE bool try_lock() { const auto _Res = _Mtx_trylock(_Mymtx()); switch (_Res) { case _Thrd_success: @@ -68,7 +68,7 @@ public: using native_handle_type = void*; - _NODISCARD native_handle_type native_handle() { + _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() { return _Mtx_getconcrtcs(_Mymtx()); } @@ -96,7 +96,7 @@ class recursive_mutex : public _Mutex_base { // class for recursive mutual exclu public: recursive_mutex() : _Mutex_base(_Mtx_recursive) {} - _NODISCARD bool try_lock() noexcept { + _NODISCARD_MODIFY_STATE bool try_lock() noexcept { return _Mutex_base::try_lock(); } @@ -128,27 +128,27 @@ public: unique_lock() noexcept : _Pmtx(nullptr), _Owns(false) {} - _NODISCARD_CTOR explicit unique_lock(_Mutex& _Mtx) + _NODISCARD_CTOR_LOCK explicit unique_lock(_Mutex& _Mtx) : _Pmtx(_STD addressof(_Mtx)), _Owns(false) { // construct and lock _Pmtx->lock(); _Owns = true; } - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, adopt_lock_t) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, adopt_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(true) {} // construct and assume already locked unique_lock(_Mutex& _Mtx, defer_lock_t) noexcept : _Pmtx(_STD addressof(_Mtx)), _Owns(false) {} // construct but don't lock - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, try_to_lock_t) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, try_to_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock()) {} // construct and try to lock template - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock_for(_Rel_time)) {} // construct and lock with timeout template - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock_until(_Abs_time)) { // construct and lock with timeout #if _HAS_CXX20 @@ -156,12 +156,12 @@ public: #endif // _HAS_CXX20 } - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, const xtime* _Abs_time) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, const xtime* _Abs_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(false) { // try to lock until _Abs_time _Owns = _Pmtx->try_lock_until(_Abs_time); } - _NODISCARD_CTOR unique_lock(unique_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { + _NODISCARD_CTOR_LOCK unique_lock(unique_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { _Other._Pmtx = nullptr; _Other._Owns = false; } @@ -195,21 +195,21 @@ public: _Owns = true; } - _NODISCARD bool try_lock() { + _NODISCARD_MODIFY_STATE bool try_lock() { _Validate(); _Owns = _Pmtx->try_lock(); return _Owns; } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { _Validate(); _Owns = _Pmtx->try_lock_for(_Rel_time); return _Owns; } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); #endif // _HAS_CXX20 @@ -218,7 +218,7 @@ public: return _Owns; } - _NODISCARD bool try_lock_until(const xtime* _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { _Validate(); _Owns = _Pmtx->try_lock_until(_Abs_time); return _Owns; @@ -245,7 +245,7 @@ public: return _Res; } - _NODISCARD bool owns_lock() const noexcept { + _NODISCARD_PURE_METHOD bool owns_lock() const noexcept { return _Owns; } @@ -253,7 +253,7 @@ public: return _Owns; } - _NODISCARD _Mutex* mutex() const noexcept { + _NODISCARD_PURE_METHOD _Mutex* mutex() const noexcept { return _Pmtx; } @@ -347,7 +347,8 @@ int _Try_lock1(_Lock0& _Lk0, _Lock1& _Lk1) { } template -_NODISCARD int try_lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks +_NODISCARD_MODIFY_STATE_FUNCTION int try_lock( + _Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks return _Try_lock1(_Lk0, _Lk1, _LkN...); } @@ -419,7 +420,7 @@ void lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // lock multiple locks, } template -class _NODISCARD lock_guard { // class with destructor that unlocks a mutex +class _NODISCARD_LOCK lock_guard { // class with destructor that unlocks a mutex public: using mutex_type = _Mutex; @@ -442,7 +443,7 @@ private: #if _HAS_CXX17 template -class _NODISCARD scoped_lock { // class with destructor that unlocks mutexes +class _NODISCARD_LOCK scoped_lock { // class with destructor that unlocks mutexes public: explicit scoped_lock(_Mutexes&... _Mtxes) : _MyMutexes(_Mtxes...) { // construct and lock _STD lock(_Mtxes...); @@ -462,7 +463,7 @@ private: }; template -class _NODISCARD scoped_lock<_Mutex> { +class _NODISCARD_LOCK scoped_lock<_Mutex> { public: using mutex_type = _Mutex; @@ -682,7 +683,7 @@ public: return _Wait_until1(_Lck, _Abs_time, _Pred); } - _NODISCARD native_handle_type native_handle() { + _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() { return _Mycnd(); } @@ -757,7 +758,7 @@ public: _My_locked = UINT_MAX; } - _NODISCARD bool try_lock() noexcept { // try to lock the mutex + _NODISCARD_MODIFY_STATE bool try_lock() noexcept { // try to lock the mutex lock_guard _Lock(_My_mutex); if (_My_locked != 0) { return false; @@ -777,7 +778,8 @@ public: } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for( + const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } @@ -793,7 +795,7 @@ public: } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex with timeout #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -801,7 +803,7 @@ public: return _Try_lock_until(_Abs_time); } - _NODISCARD bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout + _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout return _Try_lock_until(_Abs_time); } @@ -839,7 +841,7 @@ public: } } - _NODISCARD bool try_lock() noexcept { // try to lock the mutex + _NODISCARD_MODIFY_STATE bool try_lock() noexcept { // try to lock the mutex const thread::id _Tid = this_thread::get_id(); lock_guard _Lock(_My_mutex); @@ -879,7 +881,8 @@ public: } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for( + const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } @@ -907,7 +910,7 @@ public: } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex with timeout #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -915,7 +918,7 @@ public: return _Try_lock_until(_Abs_time); } - _NODISCARD bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout + _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout return _Try_lock_until(_Abs_time); } diff --git a/stl/inc/semaphore b/stl/inc/semaphore index 903c4800bdd..5779b644e87 100644 --- a/stl/inc/semaphore +++ b/stl/inc/semaphore @@ -58,7 +58,7 @@ inline constexpr ptrdiff_t _Semaphore_max = (1ULL << (sizeof(ptrdiff_t) * CHAR_B template class counting_semaphore { public: - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return _Least_max_value; } @@ -139,7 +139,7 @@ public: } } - _NODISCARD bool try_acquire() noexcept { + _NODISCARD_MODIFY_STATE bool try_acquire() noexcept { ptrdiff_t _Current = _Counter.load(); if (_Current == 0) { return false; @@ -152,7 +152,7 @@ public: } template - _NODISCARD bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { auto _Deadline = _Semaphore_deadline(_Rel_time); ptrdiff_t _Current = _Counter.load(memory_order_relaxed); for (;;) { @@ -176,7 +176,7 @@ public: } template - _NODISCARD bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); ptrdiff_t _Current = _Counter.load(memory_order_relaxed); for (;;) { @@ -207,7 +207,7 @@ private: template <> class counting_semaphore<1> { public: - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return 1; } @@ -245,7 +245,7 @@ public: } } - _NODISCARD bool try_acquire() noexcept { + _NODISCARD_MODIFY_STATE bool try_acquire() noexcept { // TRANSITION, GH-1133: should be memory_order_acquire unsigned char _Prev = _Counter.exchange(0); _STL_VERIFY((_Prev & ~1) == 0, "Invariant: semaphore counter is non-negative and doesn't exceed max(), " @@ -254,7 +254,7 @@ public: } template - _NODISCARD bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { auto _Deadline = _Semaphore_deadline(_Rel_time); for (;;) { // "happens after release" ordering is provided by this exchange, so loads and waits can be relaxed @@ -274,7 +274,7 @@ public: } template - _NODISCARD bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); for (;;) { // "happens after release" ordering is provided by this exchange, so loads and waits can be relaxed diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index 87b629d7389..6b9c7f985ca 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -40,7 +40,7 @@ public: _Smtx_lock_exclusive(&_Myhandle); } - _NODISCARD bool try_lock() noexcept /* strengthened */ { // try to lock exclusive + _NODISCARD_MODIFY_STATE bool try_lock() noexcept /* strengthened */ { // try to lock exclusive return _Smtx_try_lock_exclusive(&_Myhandle) != 0; } @@ -52,7 +52,7 @@ public: _Smtx_lock_shared(&_Myhandle); } - _NODISCARD bool try_lock_shared() noexcept /* strengthened */ { // try to lock non-exclusive + _NODISCARD_MODIFY_STATE bool try_lock_shared() noexcept /* strengthened */ { // try to lock non-exclusive return _Smtx_try_lock_shared(&_Myhandle) != 0; } @@ -60,7 +60,7 @@ public: _Smtx_unlock_shared(&_Myhandle); } - _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle + _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle return &_Myhandle; } @@ -96,7 +96,7 @@ public: } } - _NODISCARD bool try_lock() { // try to lock exclusive + _NODISCARD_MODIFY_STATE bool try_lock() { // try to lock exclusive lock_guard _Lock(_Mymtx); if (_Writing || 0 < _Readers) { return false; @@ -107,12 +107,12 @@ public: } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock until time point #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -156,7 +156,7 @@ public: ++_Readers; } - _NODISCARD bool try_lock_shared() { // try to lock non-exclusive + _NODISCARD_MODIFY_STATE bool try_lock_shared() { // try to lock non-exclusive lock_guard _Lock(_Mymtx); if (_Writing || _Readers == _Max_readers) { return false; @@ -167,7 +167,7 @@ public: } template - _NODISCARD bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock non-exclusive for relative time return try_lock_shared_until(_To_absolute_time(_Rel_time)); } @@ -187,7 +187,7 @@ public: } template - _NODISCARD bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock non-exclusive until absolute time #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -195,7 +195,8 @@ public: return _Try_lock_shared_until(_Abs_time); } - _NODISCARD bool try_lock_shared_until(const xtime* _Abs_time) { // try to lock non-exclusive until absolute time + _NODISCARD_MODIFY_STATE bool try_lock_shared_until( + const xtime* _Abs_time) { // try to lock non-exclusive until absolute time return _Try_lock_shared_until(_Abs_time); } @@ -236,7 +237,7 @@ public: shared_lock() noexcept : _Pmtx(nullptr), _Owns(false) {} - _NODISCARD_CTOR explicit shared_lock(mutex_type& _Mtx) + _NODISCARD_CTOR_LOCK explicit shared_lock(mutex_type& _Mtx) : _Pmtx(_STD addressof(_Mtx)), _Owns(true) { // construct with mutex and lock shared _Mtx.lock_shared(); } @@ -244,20 +245,20 @@ public: shared_lock(mutex_type& _Mtx, defer_lock_t) noexcept : _Pmtx(_STD addressof(_Mtx)), _Owns(false) {} // construct with unlocked mutex - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, try_to_lock_t) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, try_to_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared()) {} // construct with mutex and try to lock shared - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, adopt_lock_t) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, adopt_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(true) {} // construct with mutex and adopt ownership template - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared_for(_Rel_time)) { // construct with mutex and try to lock for relative time } template - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared_until(_Abs_time)) { // construct with mutex and try to lock until absolute time #if _HAS_CXX20 @@ -271,7 +272,7 @@ public: } } - _NODISCARD_CTOR shared_lock(shared_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { + _NODISCARD_CTOR_LOCK shared_lock(shared_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { _Other._Pmtx = nullptr; _Other._Owns = false; } @@ -297,14 +298,14 @@ public: _Owns = true; } - _NODISCARD bool try_lock() { // try to lock the mutex + _NODISCARD_MODIFY_STATE bool try_lock() { // try to lock the mutex _Validate(); _Owns = _Pmtx->try_lock_shared(); return _Owns; } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock the mutex for _Rel_time _Validate(); _Owns = _Pmtx->try_lock_shared_for(_Rel_time); @@ -312,7 +313,7 @@ public: } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex until _Abs_time #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -343,7 +344,7 @@ public: return _Res; } - _NODISCARD bool owns_lock() const noexcept { + _NODISCARD_PURE_METHOD bool owns_lock() const noexcept { return _Owns; } @@ -351,7 +352,7 @@ public: return _Owns; } - _NODISCARD mutex_type* mutex() const noexcept { + _NODISCARD_PURE_METHOD mutex_type* mutex() const noexcept { return _Pmtx; } diff --git a/stl/inc/source_location b/stl/inc/source_location index a9e6154c44f..316db1ebfa8 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -23,7 +23,7 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN struct source_location { - _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), + _NODISCARD_PURE_METHOD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), const char* const _Function_ = __builtin_FUNCTION()) noexcept { source_location _Result; @@ -34,18 +34,18 @@ struct source_location { return _Result; } - _NODISCARD_CTOR constexpr source_location() noexcept = default; + _NODISCARD_CTOR_PURE constexpr source_location() noexcept = default; - _NODISCARD constexpr uint_least32_t line() const noexcept { + _NODISCARD_PURE_METHOD constexpr uint_least32_t line() const noexcept { return _Line; } - _NODISCARD constexpr uint_least32_t column() const noexcept { + _NODISCARD_PURE_METHOD constexpr uint_least32_t column() const noexcept { return _Column; } - _NODISCARD constexpr const char* file_name() const noexcept { + _NODISCARD_PURE_METHOD constexpr const char* file_name() const noexcept { return _File; } - _NODISCARD constexpr const char* function_name() const noexcept { + _NODISCARD_PURE_METHOD constexpr const char* function_name() const noexcept { return _Function; } diff --git a/stl/inc/thread b/stl/inc/thread index ef864b20b5f..92eda6eea2a 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -86,7 +86,7 @@ private: public: template , thread>, int> = 0> - _NODISCARD_CTOR explicit thread(_Fn&& _Fx, _Args&&... _Ax) { + _NODISCARD_CTOR_THREAD explicit thread(_Fn&& _Fx, _Args&&... _Ax) { _Start(_STD forward<_Fn>(_Fx), _STD forward<_Args>(_Ax)...); } @@ -114,7 +114,7 @@ public: _STD swap(_Thr, _Other._Thr); } - _NODISCARD bool joinable() const noexcept { + _NODISCARD_PURE_METHOD bool joinable() const noexcept { return _Thr._Id != 0; } @@ -143,13 +143,14 @@ public: _Thr = {}; } - _NODISCARD id get_id() const noexcept; + _NODISCARD_PURE_METHOD id get_id() const noexcept; - _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // return Win32 HANDLE as void * + _NODISCARD_PURE_METHOD native_handle_type native_handle() noexcept + /* strengthened */ { // return Win32 HANDLE as void * return _Thr._Hnd; } - _NODISCARD static unsigned int hardware_concurrency() noexcept { + _NODISCARD_PURE_METHOD static unsigned int hardware_concurrency() noexcept { return _Thrd_hardware_concurrency(); } @@ -174,7 +175,7 @@ _NODISCARD auto _To_absolute_time(const chrono::duration<_Rep, _Period>& _Rel_ti } namespace this_thread { - _NODISCARD thread::id get_id() noexcept; + _NODISCARD_PURE_FUNCTION thread::id get_id() noexcept; inline void yield() noexcept { _Thrd_yield(); @@ -229,11 +230,11 @@ private: friend hash; }; -_NODISCARD inline thread::id thread::get_id() const noexcept { +_NODISCARD_PURE_METHOD inline thread::id thread::get_id() const noexcept { return _Thr._Id; } -_NODISCARD inline thread::id this_thread::get_id() noexcept { +_NODISCARD_PURE_FUNCTION inline thread::id this_thread::get_id() noexcept { return _Thrd_id(); } @@ -241,32 +242,32 @@ inline void swap(thread& _Left, thread& _Right) noexcept { _Left.swap(_Right); } -_NODISCARD inline bool operator==(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator==(thread::id _Left, thread::id _Right) noexcept { return _Left._Id == _Right._Id; } #if _HAS_CXX20 -_NODISCARD inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { return _Left._Id <=> _Right._Id; } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -_NODISCARD inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { return !(_Left == _Right); } -_NODISCARD inline bool operator<(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator<(thread::id _Left, thread::id _Right) noexcept { return _Left._Id < _Right._Id; } -_NODISCARD inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { return !(_Right < _Left); } -_NODISCARD inline bool operator>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator>(thread::id _Left, thread::id _Right) noexcept { return _Right < _Left; } -_NODISCARD inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { return !(_Left < _Right); } #endif // !_HAS_CXX20 @@ -281,7 +282,7 @@ struct hash { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef thread::id _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD size_t operator()(const thread::id _Keyval) const noexcept { + _NODISCARD_PURE_METHOD size_t operator()(const thread::id _Keyval) const noexcept { return _Hash_representation(_Keyval._Id); } }; @@ -295,7 +296,7 @@ public: jthread() noexcept : _Impl{}, _Ssource{nostopstate} {} template , jthread>, int> = 0> - _NODISCARD_CTOR explicit jthread(_Fn&& _Fx, _Args&&... _Ax) { + _NODISCARD_CTOR_JTHREAD explicit jthread(_Fn&& _Fx, _Args&&... _Ax) { if constexpr (is_invocable_v, stop_token, decay_t<_Args>...>) { _Impl._Start(_STD forward<_Fn>(_Fx), _Ssource.get_token(), _STD forward<_Args>(_Ax)...); } else { @@ -327,7 +328,7 @@ public: _Ssource.swap(_Other._Ssource); } - _NODISCARD bool joinable() const noexcept { + _NODISCARD_PURE_METHOD bool joinable() const noexcept { return _Impl.joinable(); } @@ -339,19 +340,19 @@ public: _Impl.detach(); } - _NODISCARD id get_id() const noexcept { + _NODISCARD_PURE_METHOD id get_id() const noexcept { return _Impl.get_id(); } - _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD native_handle_type native_handle() noexcept /* strengthened */ { return _Impl.native_handle(); } - _NODISCARD stop_source get_stop_source() noexcept { + _NODISCARD_ACCESSOR_METHOD stop_source get_stop_source() noexcept { return _Ssource; } - _NODISCARD stop_token get_stop_token() const noexcept { + _NODISCARD_PURE_METHOD stop_token get_stop_token() const noexcept { return _Ssource.get_token(); } @@ -363,7 +364,7 @@ public: _Lhs.swap(_Rhs); } - _NODISCARD static unsigned int hardware_concurrency() noexcept { + _NODISCARD_PURE_METHOD static unsigned int hardware_concurrency() noexcept { return thread::hardware_concurrency(); } diff --git a/stl/inc/vector b/stl/inc/vector index d300d12e32f..30ab693cfe1 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -45,7 +45,7 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vector_const_iterator& operator=(const _Vector_const_iterator&) noexcept = default; - _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -56,7 +56,7 @@ public: return *_Ptr; } - _NODISCARD _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -123,7 +123,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -133,50 +133,52 @@ public: return *this += -_Off; } - _NODISCARD _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR20 difference_type operator-(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 difference_type operator-( + const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr - _Right._Ptr; } - _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>( + const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Unfancy(_Ptr) <=> _Unfancy(_Right._Ptr); } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD bool operator!=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator!=(const _Vector_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD bool operator<(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator<(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr < _Right._Ptr; } - _NODISCARD bool operator>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator>(const _Vector_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD bool operator<=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator<=(const _Vector_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD bool operator>=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator>=(const _Vector_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -212,7 +214,7 @@ public: }; template -_NODISCARD _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( typename _Vector_const_iterator<_Myvec>::difference_type _Off, _Vector_const_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -225,7 +227,7 @@ struct pointer_traits<_Vector_const_iterator<_Myvec>> { using element_type = const typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_METHOD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -264,11 +266,11 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vector_iterator& operator=(const _Vector_iterator&) noexcept = default; - _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(this->_Ptr, "can't dereference value-initialized vector iterator"); @@ -306,7 +308,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -319,13 +321,13 @@ public: using _Mybase::operator-; - _NODISCARD _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -337,7 +339,7 @@ public: }; template -_NODISCARD _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( typename _Vector_iterator<_Myvec>::difference_type _Off, _Vector_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -350,7 +352,7 @@ struct pointer_traits<_Vector_iterator<_Myvec>> { using element_type = typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_METHOD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -1373,7 +1375,7 @@ public: return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD _CONSTEXPR20 const _Ty* data() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty* data() const noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 4d245fd85a6..c949ac89f51 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -414,14 +414,102 @@ // _HAS_NODISCARD (in vcruntime.h) controls: // [[nodiscard]] attributes on STL functions +// TRANSITION, This should go to vcruntime.h +#if _HAS_NODISCARD +#define _NODISCARD_MSG(_Msg) [[nodiscard(_Msg)]] +#else // ^^^ CAN HAZ [[nodiscard]] / NO CAN HAZ [[nodiscard]] vvv +#define _NODISCARD_MSG(_Msg) +#endif // _HAS_NODISCARD + #ifndef __has_cpp_attribute #define _NODISCARD_CTOR +#define _NODISCARD_CTOR_MSG(_Msg) #elif __has_cpp_attribute(nodiscard) >= 201907L #define _NODISCARD_CTOR _NODISCARD +#define _NODISCARD_CTOR_MSG(_Msg) _NODISCARD_MSG(_Msg) #else #define _NODISCARD_CTOR +#define _NODISCARD_CTOR_MSG(_Msg) #endif +#define _NODISCARD_PURE_ALGORITHM \ + _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ + "and discard the return value") + +#define _NODISCARD_PURE_FUNCTION \ + _NODISCARD_MSG("This function is pure, i.e. has no side effects; it is not useful to call this function and " \ + "discard the return value") + +#define _NODISCARD_PURE_METHOD \ + _NODISCARD_MSG("This method is pure obeserver, i.e. has no side effects; it is not useful to call this method " \ + "and discard the return value") + +#define _NODISCARD_PURE_OPERATOR \ + _NODISCARD_MSG("This operator is pure obeserver, i.e. has no side effects; it is not useful to call this " \ + "operator and discard the return value") + +#define _NODISCARD_ACCESSOR_FUNCTION \ + _NODISCARD_MSG("This function returns a value that provides access to the passed object and has no side effects " \ + "otherwise; it is not useful to call this function and discard the return value") + +#define _NODISCARD_ACCESSOR_METHOD \ + _NODISCARD_MSG("This method returns an object that can access the state of the current object and has no other " \ + "side effects; it is not useful to call this method and discard the return value") + +#define _NODISCARD_ACCESSOR_OPERATOR \ + _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ + "no other side effects; it is not useful to call this operator and discard the return value") + +#define _NODISCARD_REMOVE_ALGORITHM \ + _NODISCARD_MSG("The remove, remove_if, and unique algorithms returns the iterator past the last removed element. " \ + "Normally you need to use the result to call container's erase method afterwards to erase " \ + "elements. In C++20 you can also use erase and erase_if functions to replace these two steps.") + +#define _NODISCARD_EMPTY_METHOD \ + _NODISCARD_MSG("This method checks whether the container is empty. Use 'clear()' method if you intend to clear " \ + "the container.") + +#define _NODISCARD_EMPTY_METHOD_ARRAY \ + _NODISCARD_MSG( \ + "This method checks whether the array is empty. There's no way to clear an array, as its size is fixed.") + +#define _NODISCARD_BARRIER_TOKEN \ + _NODISCARD_MSG("The token from 'arrive' should not be discarded; it should be passed to 'wait'") + +#define _NODISCARD_TRY_WAIT \ + _NODISCARD_MSG("This method returns the state of the synchronization object and does not do anything else; it is " \ + "not useful to call this method and discard the return value") + + +#define _NODISCARD_MODIFY_STATE \ + _NODISCARD_MSG("This method returns whether the operation succeeds in modifying the state of the object or not. " \ + "It is dangerous to ignore the return value") + +#define _NODISCARD_MODIFY_STATE_FUNCTION \ + _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ + "objects or not. It is dangerous to ignore the return value") + +#define _NODISCARD_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ + "current statement, using comma operator, please use cast to void to suppress this warning).") + +#define _NODISCARD_CTOR_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ + "current statement, using comma operator, please use cast to void to suppress this warning).") + +#define _NODISCARD_CTOR_THREAD \ + _NODISCARD_CTOR_MSG("Thread is not joined or detached, terminate will be called at the end of the statement") + +#define _NODISCARD_CTOR_JTHREAD \ + _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention?") + +#define _NODISCARD_CTOR_PURE \ + _NODISCARD_CTOR_MSG( \ + "Construction of the object hass no side effects; it is not useful to construct an object just to discard it") + + // Determine if we should use [[msvc::known_semantics]] to communicate to the compiler // that certain type trait specializations have the standard-mandated semantics #ifndef __has_cpp_attribute From de17454eaf5f152cf310752a008b739cd3dab901 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 18:51:05 +0300 Subject: [PATCH 02/73] [[nodiscard]] messages Partly addresses #271 --- stl/inc/algorithm | 397 +++++++++++++++++++++++----------------- stl/inc/any | 21 ++- stl/inc/array | 192 +++++++++---------- stl/inc/atomic | 60 +++--- stl/inc/barrier | 4 +- stl/inc/bit | 28 +-- stl/inc/latch | 4 +- stl/inc/mutex | 61 +++--- stl/inc/semaphore | 16 +- stl/inc/shared_mutex | 43 ++--- stl/inc/source_location | 12 +- stl/inc/thread | 47 ++--- stl/inc/vector | 208 +++++++++++---------- stl/inc/yvals_core.h | 88 +++++++++ 14 files changed, 671 insertions(+), 510 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 7c7b95bb9ae..e835990302f 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -373,11 +373,12 @@ namespace ranges { #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt find_if( + _ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { // find first element that satisfies !_Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -394,11 +395,12 @@ _NODISCARD _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _ #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt find_if_not( + _ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find first satisfying _Pred with successor _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -417,16 +419,19 @@ _NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, } template -_NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, const _FwdIt _Last) { // find first matching successor +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find( + const _FwdIt _First, const _FwdIt _Last) { // find first matching successor return _STD adjacent_find(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt adjacent_find( + _ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept +/* terminates */ { // find first matching successor return _STD adjacent_find(_STD forward<_ExPo>(_Exec), _First, _Last, equal_to{}); } @@ -440,7 +445,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_binary_predicate, projected<_It, _Pj>> _Pr = ranges::equal_to> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Adjacent_find_unchecked( @@ -453,7 +459,8 @@ namespace ranges { template , _Pj>, projected, _Pj>> _Pr = ranges::equal_to> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Adjacent_find_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_iterator(_Range, _STD move(_UResult)); @@ -492,7 +499,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD constexpr iter_difference_t<_It> operator()( + _NODISCARD_PURE_ALGORITHM constexpr iter_difference_t<_It> operator()( _It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_unchecked( @@ -501,7 +508,7 @@ namespace ranges { template requires indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { return _Count_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); } // clang-format on @@ -529,7 +536,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { // count elements satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -546,7 +553,7 @@ _NODISCARD _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, #if _HAS_CXX17 template = 0> -_NODISCARD _Iter_diff_t<_FwdIt> count_if( +_NODISCARD_PURE_ALGORITHM _Iter_diff_t<_FwdIt> count_if( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 @@ -558,7 +565,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr iter_difference_t<_It> operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr iter_difference_t<_It> operator()( + _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_if_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -566,7 +574,8 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Count_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -594,7 +603,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( + _InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, ...) mismatch _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -612,19 +622,20 @@ _NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, const _InI #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( + const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { // return [_First1, _Last1)/[_First2, ...) mismatch return _STD mismatch(_First1, _Last1, _First2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, ...) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -634,7 +645,7 @@ _NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, _Last2) mismatch _Adl_verify_range(_First1, _Last1); @@ -667,19 +678,20 @@ _NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( + _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // return [_First1, _Last1)/[_First2, _Last2) mismatch return _STD mismatch(_First1, _Last1, _First2, _Last2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, _Last2) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -737,7 +749,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -763,7 +775,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { using _Size1 = _Make_unsigned_like_t>; @@ -787,7 +799,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( + _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, ...) _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -811,7 +824,7 @@ _NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _Fw } template -_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { // test if [_First1, _Last1) == permuted [_First2, ...) return _STD is_permutation(_First1, _Last1, _First2, equal_to<>{}); } @@ -870,7 +883,7 @@ _CONSTEXPR20 bool _Is_permutation_unchecked(_FwdIt1 _First1, _FwdIt1 _Last1, _Fw } template -_NODISCARD _CONSTEXPR20 bool is_permutation( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, _Last2) _Adl_verify_range(_First1, _Last1); @@ -880,7 +893,8 @@ _NODISCARD _CONSTEXPR20 bool is_permutation( } template -_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( + _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { // test if [_First1, _Last1) == permuted [_First2, _Last2) return _STD is_permutation(_First1, _Last1, _First2, _Last2, equal_to<>{}); } @@ -899,8 +913,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_equivalence_relation, projected<_It2, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_STD move(_First1)); @@ -925,7 +939,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { const auto _Count = _RANGES distance(_Range1); @@ -1117,7 +1131,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool all_of(_InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool all_of( + _InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); @@ -1132,7 +1147,7 @@ _NODISCARD _CONSTEXPR20 bool all_of(_InIt _First, _InIt _Last, _Pr _Pred) { // t #if _HAS_CXX17 template = 0> -_NODISCARD bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1143,7 +1158,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _All_of_unchecked( @@ -1152,7 +1167,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _All_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1178,7 +1193,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if any element satisfies _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1194,7 +1209,8 @@ _NODISCARD _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _ #if _HAS_CXX17 template = 0> -_NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool any_of( + _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1205,7 +1221,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Any_of_unchecked( @@ -1214,7 +1230,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Any_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1240,7 +1256,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if no elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1256,7 +1272,8 @@ _NODISCARD _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr #if _HAS_CXX17 template = 0> -_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool none_of( + _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1267,7 +1284,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _None_of_unchecked( @@ -1276,7 +1293,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _None_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1665,7 +1682,7 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if [_First, _Last) partitioned by _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1692,7 +1709,8 @@ _NODISCARD _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Las #if _HAS_CXX17 template = 0> -_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM bool is_partitioned( + _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1703,7 +1721,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Is_partitioned_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1711,7 +1729,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Is_partitioned_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1748,7 +1766,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find beginning of false partition in [_First, _Last) _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1779,7 +1797,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); if constexpr (sized_sentinel_for<_Se, _It>) { @@ -1796,7 +1814,8 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { if constexpr (sized_range<_Rng>) { const auto _Length = _RANGES distance(_Range); auto _UFirst = _Partition_point_n_unchecked(_Ubegin(_Range), _Length, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1891,8 +1910,8 @@ _NODISCARD _CONSTEXPR20 bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _F } template -_NODISCARD _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, - const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, + const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_First1); @@ -1935,12 +1954,12 @@ _NODISCARD _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHays #if _HAS_CXX17 template = 0> -_NODISCARD _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, +_NODISCARD_PURE_ALGORITHM _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First1, const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) { // find first [_First2, _Last2) match return _STD search(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -1948,22 +1967,22 @@ _NODISCARD _CONSTEXPR20 _FwdItHaystack search( #if _HAS_CXX17 template = 0> -_NODISCARD _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, const _FwdItHaystack _Last1, - const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, + const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { // find first [_First2, _Last2) match return _STD search(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First, const _FwdItHaystack _Last, const _Searcher& _Search) { // find _Search's pattern in [_First, _Last) return _Search(_First, _Last).first; } template -_NODISCARD _CONSTEXPR20 _FwdIt search_n( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) { // find first _Count * _Val satisfying _Pred const _Algorithm_int_t<_Diff> _Count = _Count_raw; @@ -2036,19 +2055,21 @@ _NODISCARD _CONSTEXPR20 _FwdIt search_n( #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, +_NODISCARD_PURE_ALGORITHM _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, + const _Ty& _Val, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 _FwdIt search_n(const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( + const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { // find first _Count * _Val match return _STD search_n(_First, _Last, _Count, _Val, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, +_NODISCARD_PURE_ALGORITHM _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) noexcept /* terminates */ { // find first _Count * _Val match return _STD search_n(_STD forward<_ExPo>(_Exec), _First, _Last, _Count, _Val, equal_to{}); } @@ -2064,7 +2085,7 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); @@ -2089,7 +2110,7 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, + _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); @@ -2218,7 +2239,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // find last [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); @@ -2299,7 +2320,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt1 find_end( } template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 const _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) { // find last [_First2, _Last2) match return _STD find_end(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -2307,11 +2328,12 @@ _NODISCARD _CONSTEXPR20 _FwdIt1 find_end( #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt1 find_end( +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_end( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt1 find_end(_ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_end( + _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // find last [_First2, _Last2) match return _STD find_end(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } @@ -2428,7 +2450,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2458,7 +2480,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr borrowed_subrange_t<_Rng1> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (random_access_range<_Rng1> && sized_range<_Rng1> && random_access_range<_Rng2> && sized_range<_Rng2>) { @@ -2483,7 +2505,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of( +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // look for one of [_First2, _Last2) satisfying _Pred with element _Adl_verify_range(_First1, _Last1); @@ -2506,18 +2528,21 @@ _NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of( } template -_NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, + const _FwdIt2 _First2, const _FwdIt2 _Last2) { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_First1, _Last1, _First2, _Last2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, + const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of( + _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } @@ -2533,7 +2558,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2549,7 +2574,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr borrowed_iterator_t<_Rng1> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); @@ -3412,11 +3437,11 @@ _FwdIt2 remove_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _P #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt remove( +_NODISCARD_REMOVE_ALGORITHM _FwdIt remove( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept; // terminates template = 0> -_NODISCARD _FwdIt remove_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_REMOVE_ALGORITHM _FwdIt remove_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -3428,7 +3453,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Val, _Pass_fn(_Proj)); @@ -3439,7 +3464,7 @@ namespace ranges { template requires permutable> && indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()( + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { auto _UResult = _Remove_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); @@ -3480,7 +3505,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_if_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -3492,7 +3518,7 @@ namespace ranges { template , _Pj>> _Pr> requires permutable> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { auto _UResult = _Remove_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_subrange>(_Range, _STD move(_UResult)); @@ -3650,7 +3676,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // remove each satisfying _Pred with previous _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -3675,20 +3701,20 @@ _NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { } template -_NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous +_NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous return _STD unique(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALGORITHM _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // remove each satisfying _Pred with previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALGORITHM _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // remove each matching previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last); @@ -3703,7 +3729,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_equivalence_relation> _Pr = ranges::equal_to> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Unique_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -3715,7 +3742,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::equal_to> requires permutable> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Unique_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_subrange>(_Range, _STD move(_UResult)); @@ -5694,7 +5721,7 @@ _CONSTEXPR20 _RanIt _Is_heap_until_unchecked(_RanIt _First, _RanIt _Last, _Pr _P } template -_NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { // find extent of range that is a heap _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Is_heap_until_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); @@ -5702,7 +5729,7 @@ _NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _P } template -_NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // test if range is a heap _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -5711,34 +5738,37 @@ _NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { } template -_NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_First, _Last, less<>{}); } template -_NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap( + _RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< return _STD is_heap(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _RanIt is_heap_until( + _ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept +/* terminates */ { // test if range is a heap return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // test if range is a heap ordered by operator< return _STD is_heap(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -5775,7 +5805,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _ULast = _Get_unwrapped(_STD move(_Last)); @@ -5787,7 +5818,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); const auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -5803,7 +5834,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _Size = _RANGES distance(_UFirst, _Get_unwrapped(_STD move(_Last))); @@ -5815,7 +5847,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_iterator(_Range, _STD move(_UResult)); @@ -5931,7 +5964,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()( + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -5944,7 +5977,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = @@ -5960,7 +5993,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find first element that _Val is before _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -5982,7 +6015,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _T } template -_NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find first element that _Val is before return _STD upper_bound(_First, _Last, _Val, less<>{}); } @@ -6018,7 +6051,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()( + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6030,7 +6063,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = _Upper_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -6045,7 +6078,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( + _FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find range equivalent to _Val _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6082,7 +6116,7 @@ _NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _ } template -_NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find range equivalent to _Val return _STD equal_range(_First, _Last, _Val, less<>{}); } @@ -6151,7 +6185,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // test if _Val equivalent to some element _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6161,7 +6195,7 @@ _NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _T } template -_NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // test if _Val equivalent to some element return _STD binary_search(_First, _Last, _Val, less<>{}); } @@ -6174,7 +6208,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6187,7 +6221,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); const auto _UFirst = _RANGES _Lower_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -8229,7 +8264,8 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes( + _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -8253,14 +8289,15 @@ _NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _Fir } template -_NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) return _STD includes(_First1, _Last1, _First2, _Last2, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept +_NODISCARD_PURE_ALGORITHM bool includes( + _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8270,7 +8307,8 @@ _NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _Firs } template = 0> -_NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD_PURE_ALGORITHM bool includes( + _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8288,7 +8326,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -8300,7 +8339,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Includes_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); @@ -8916,27 +8955,28 @@ constexpr _FwdIt _Max_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Max_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element return _STD max_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last); @@ -8970,7 +9010,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -8979,7 +9020,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9007,27 +9049,29 @@ constexpr _FwdIt _Min_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt min_element( + _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Min_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element +_NODISCARD_PURE_ALGORITHM constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element return _STD min_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last); @@ -9061,7 +9105,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9070,7 +9115,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9122,7 +9168,7 @@ constexpr pair<_FwdIt, _FwdIt> _Minmax_element_unchecked(_FwdIt _First, _FwdIt _ } template -_NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest and largest elements _Adl_verify_range(_First, _Last); const auto _Result = _Minmax_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred)); @@ -9132,14 +9178,14 @@ _NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _ } template -_NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { // find smallest and largest elements return _STD minmax_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release @@ -9147,7 +9193,8 @@ _NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _L } template = 0> -_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept +/* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release return _STD minmax_element(_First, _Last); @@ -9212,7 +9259,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr minmax_element_result<_It> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_element_result<_It> operator()( _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9225,7 +9272,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr minmax_element_result> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_element_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9243,14 +9290,14 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/largest const _Ty* _Res = _Max_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { // return leftmost/largest return (_STD max) (_Ilist, less<>{}); } @@ -9269,7 +9316,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr const _Ty& operator()( + _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Left), _STD invoke(_Proj, _Right))) { return _Right; @@ -9280,7 +9327,8 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr _Ty operator()(initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _Ty operator()( + initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, @@ -9292,7 +9340,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( @@ -9319,14 +9367,14 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/smallest const _Ty* _Res = _Min_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALGORITHM constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { // return leftmost/smallest return (_STD min) (_Ilist, less<>{}); } @@ -9339,7 +9387,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr const _Ty& operator()( + _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return _Right; @@ -9350,7 +9398,8 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr _Ty operator()(initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _Ty operator()( + initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, @@ -9362,7 +9411,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( @@ -9389,7 +9438,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept( +_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept( noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) { @@ -9400,14 +9449,14 @@ _NODISCARD constexpr pair minmax(const _Ty& _Left, const } template -_NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return {leftmost/smallest, rightmost/largest} pair _Res = _Minmax_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return pair<_Ty, _Ty>(*_Res.first, *_Res.second); } template -_NODISCARD constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( +_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( noexcept(_Right < _Left)) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_Right < _Left) { @@ -9419,7 +9468,7 @@ _NODISCARD constexpr pair minmax(const _Ty& _Left, const } template -_NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALGORITHM constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { // return {leftmost/smallest, rightmost/largest} return _STD minmax(_Ilist, less<>{}); } @@ -9435,7 +9484,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr minmax_result operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_result operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return {_Right, _Left}; @@ -9446,7 +9495,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr minmax_result<_Ty> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_result<_Ty> operator()( initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); @@ -9460,7 +9509,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr minmax_result> operator()( + _NODISCARD_PURE_ALGORITHM constexpr minmax_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { // clang-format on auto _UFirst = _Ubegin(_Range); @@ -9737,7 +9786,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find extent of range that is ordered by predicate _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -9756,7 +9805,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last } template -_NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // test if range is ordered by predicate _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -9765,34 +9814,37 @@ _NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { } template -_NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { // find extent of range that is ordered by operator< return _STD is_sorted_until(_First, _Last, less<>{}); } template -_NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< +_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted( + _FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< return _STD is_sorted(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALGORITHM _FwdIt is_sorted_until( + _ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // test if range is ordered by predicate return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find extent of range that is ordered by operator< return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALGORITHM bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // test if range is ordered by operator< return _STD is_sorted(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -9805,7 +9857,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); const auto _ULast = _Get_unwrapped(_STD move(_Last)); const auto _UFirst = @@ -9815,7 +9868,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _ULast = _Uend(_Range); const auto _UFirst = _Is_sorted_until_unchecked(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _UFirst == _ULast; @@ -9830,7 +9883,8 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Is_sorted_until_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -9840,7 +9894,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UFirst = _Is_sorted_until_unchecked(_Get_unwrapped(_First), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -9854,7 +9909,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { +_NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp( + const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { // returns _Val constrained to [_Min_val, _Max_val] #if _ITERATOR_DEBUG_LEVEL == 2 if (_DEBUG_LT_PRED(_Pred, _Max_val, _Min_val)) { @@ -9875,7 +9931,7 @@ _NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, cons } template -_NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { +_NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { // returns _Val constrained to [_Min_val, _Max_val] return _STD clamp(_Val, _Min_val, _Max_val, less{}); } @@ -9888,7 +9944,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD constexpr const _Ty& operator()( + _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( const _Ty& _Val, const _Ty& _Lo, const _Ty& _Hi, _Pr _Pred = {}, _Pj _Proj = {}) const { _STL_ASSERT(!_STD invoke(_Pred, _STD invoke(_Proj, _Hi), _STD invoke(_Proj, _Lo)), "The lower bound cannot be greater than the upper bound in a call to std::ranges::clamp " @@ -9915,7 +9971,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -9928,7 +9985,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALGORITHM constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Lexicographical_compare_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); diff --git a/stl/inc/any b/stl/inc/any index 8f4ba7cc292..17f3f2d2e33 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -33,7 +33,7 @@ _STD_BEGIN class bad_any_cast : public bad_cast { // thrown by failed any_cast public: - _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD_PURE_METHOD const char* __CLR_OR_THIS_CALL what() const noexcept override { return "Bad any_cast"; } }; @@ -225,11 +225,11 @@ public: } // Observers [any.observers] - _NODISCARD bool has_value() const noexcept { + _NODISCARD_PURE_METHOD bool has_value() const noexcept { return _Storage._TypeData != 0; } - _NODISCARD const type_info& type() const noexcept { + _NODISCARD_PURE_METHOD const type_info& type() const noexcept { // if *this contains a value of type T, return typeid(T); otherwise typeid(void) const type_info* const _Info = _TypeInfo(); if (_Info) { @@ -358,17 +358,18 @@ inline void swap(any& _Left, any& _Right) noexcept { } template -_NODISCARD any make_any(_Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... +_NODISCARD_PURE_FUNCTION any make_any( + _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... return any{in_place_type<_ValueType>, _STD forward<_Types>(_Args)...}; } template -_NODISCARD any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { +_NODISCARD_PURE_FUNCTION any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Ilist and _Args... return any{in_place_type<_ValueType>, _Ilist, _STD forward<_Types>(_Args)...}; } template -_NODISCARD const _ValueType* any_cast(const any* const _Any) noexcept { +_NODISCARD_PURE_FUNCTION const _ValueType* any_cast(const any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -383,7 +384,7 @@ _NODISCARD const _ValueType* any_cast(const any* const _Any) noexcept { } } template -_NODISCARD _ValueType* any_cast(any* const _Any) noexcept { +_NODISCARD_PURE_FUNCTION _ValueType* any_cast(any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -399,7 +400,7 @@ _NODISCARD _ValueType* any_cast(any* const _Any) noexcept { } template -_NODISCARD remove_cv_t<_Ty> any_cast(const any& _Any) { +_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(const any& _Any) { static_assert(is_constructible_v, const _Remove_cvref_t<_Ty>&>, "any_cast(const any&) requires remove_cv_t to be constructible from " "const remove_cv_t>&"); @@ -412,7 +413,7 @@ _NODISCARD remove_cv_t<_Ty> any_cast(const any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD remove_cv_t<_Ty> any_cast(any& _Any) { +_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>&>, "any_cast(any&) requires remove_cv_t to be constructible from remove_cv_t>&"); @@ -424,7 +425,7 @@ _NODISCARD remove_cv_t<_Ty> any_cast(any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD remove_cv_t<_Ty> any_cast(any&& _Any) { +_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any&& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>>, "any_cast(any&&) requires remove_cv_t to be constructible from remove_cv_t>"); diff --git a/stl/inc/array b/stl/inc/array index c417a1826b4..128e0242abf 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -48,11 +48,11 @@ public: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg + _Off) {} - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { return *_Ptr; } - _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { return _Ptr; } @@ -83,7 +83,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -94,46 +94,46 @@ public: return *this; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { return _Ptr - _Right._Ptr; } - _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return _Ptr[_Off]; } - _NODISCARD _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { return _Ptr <=> _Right._Ptr; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { return _Ptr < _Right._Ptr; } - _NODISCARD _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -158,11 +158,11 @@ private: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg), _Idx(_Off) {} - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { return *operator->(); } - _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { _STL_VERIFY(_Ptr, "cannot dereference value-initialized array iterator"); _STL_VERIFY(_Idx < _Size, "cannot dereference out of range array iterator"); return _Ptr + _Idx; @@ -214,7 +214,7 @@ private: return *this; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -224,50 +224,50 @@ private: return *this += -_Off; } - _NODISCARD _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_Idx - _Right._Idx); } - _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return *(*this + _Off); } - _NODISCARD _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx == _Right._Idx; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx <=> _Right._Idx; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx < _Right._Idx; } - _NODISCARD _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -307,7 +307,7 @@ constexpr void _Verify_range( #endif // _ITERATOR_DEBUG_LEVEL != 0 template -_NODISCARD _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_const_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -320,7 +320,7 @@ struct pointer_traits<_Array_const_iterator<_Ty, _Size>> { using element_type = const _Ty; using difference_type = ptrdiff_t; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_FUNCTION static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -346,11 +346,11 @@ public: _CONSTEXPR17 explicit _Array_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Mybase(_Parg, _Off) {} - _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { return const_cast(_Mybase::operator->()); } @@ -381,7 +381,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -394,13 +394,13 @@ public: using _Mybase::operator-; - _NODISCARD _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -412,7 +412,7 @@ public: }; template -_NODISCARD _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -425,7 +425,7 @@ struct pointer_traits<_Array_iterator<_Ty, _Size>> { using element_type = _Ty; using difference_type = ptrdiff_t; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_FUNCTION static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -462,51 +462,51 @@ public: _Swap_ranges_unchecked(_Elems, _Elems + _Size, _Other._Elems); } - _NODISCARD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator begin() noexcept { return iterator(_Elems, 0); } - _NODISCARD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator(_Elems, 0); } - _NODISCARD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator end() noexcept { return iterator(_Elems, _Size); } - _NODISCARD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator(_Elems, _Size); } - _NODISCARD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -526,19 +526,19 @@ public: return _Elems + _Size; } - _NODISCARD constexpr size_type size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type size() const noexcept { return _Size; } - _NODISCARD constexpr size_type max_size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type max_size() const noexcept { return _Size; } - _NODISCARD constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_METHOD_ARRAY constexpr bool empty() const noexcept { return false; } - _NODISCARD _CONSTEXPR17 reference at(size_type _Pos) { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference at(size_type _Pos) { if (_Size <= _Pos) { _Xran(); } @@ -546,7 +546,7 @@ public: return _Elems[_Pos]; } - _NODISCARD constexpr const_reference at(size_type _Pos) const { + _NODISCARD_PURE_METHOD constexpr const_reference at(size_type _Pos) const { if (_Size <= _Pos) { _Xran(); } @@ -554,7 +554,8 @@ public: return _Elems[_Pos]; } - _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept + /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -562,7 +563,8 @@ public: return _Elems[_Pos]; } - _NODISCARD constexpr const_reference operator[](_In_range_(0, _Size - 1) size_type _Pos) const noexcept + _NODISCARD_PURE_OPERATOR constexpr const_reference operator[]( + _In_range_(0, _Size - 1) size_type _Pos) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); @@ -571,27 +573,27 @@ public: return _Elems[_Pos]; } - _NODISCARD _CONSTEXPR17 reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference front() noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD constexpr const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD constexpr const_reference front() const noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD _CONSTEXPR17 reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference back() noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD constexpr const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD constexpr const_reference back() const noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 _Ty* data() noexcept { return _Elems; } - _NODISCARD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const _Ty* data() const noexcept { return _Elems; } @@ -639,51 +641,51 @@ public: _CONSTEXPR20 void swap(array&) noexcept {} - _NODISCARD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator begin() noexcept { return iterator{}; } - _NODISCARD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator{}; } - _NODISCARD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator end() noexcept { return iterator{}; } - _NODISCARD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator{}; } - _NODISCARD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -703,15 +705,15 @@ public: return nullptr; } - _NODISCARD constexpr size_type size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type size() const noexcept { return 0; } - _NODISCARD constexpr size_type max_size() const noexcept { + _NODISCARD_PURE_METHOD constexpr size_type max_size() const noexcept { return 0; } - _NODISCARD constexpr bool empty() const noexcept { + _NODISCARD_PURE_METHOD constexpr bool empty() const noexcept { return true; } @@ -723,7 +725,7 @@ public: _Xran(); } - _NODISCARD reference operator[](size_type) noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_OPERATOR reference operator[](size_type) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -731,7 +733,7 @@ public: return _Elems[0]; } - _NODISCARD const_reference operator[](size_type) const noexcept /* strengthened */ { + _NODISCARD_PURE_OPERATOR const_reference operator[](size_type) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -739,7 +741,7 @@ public: return _Elems[0]; } - _NODISCARD reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -747,7 +749,7 @@ public: return _Elems[0]; } - _NODISCARD const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -755,7 +757,7 @@ public: return _Elems[0]; } - _NODISCARD reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -763,7 +765,7 @@ public: return _Elems[0]; } - _NODISCARD const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -771,11 +773,11 @@ public: return _Elems[0]; } - _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 _Ty* data() noexcept { return nullptr; } - _NODISCARD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR17 const _Ty* data() const noexcept { return nullptr; } @@ -792,7 +794,7 @@ _CONSTEXPR20 void swap(array<_Ty, _Size>& _Left, array<_Ty, _Size>& _Right) noex } template -_NODISCARD _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD equal(_Left.begin(), _Left.end(), _Right.begin()); #else // ^^^ workaround / no workaround vvv @@ -802,14 +804,14 @@ _NODISCARD _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const ar #if !_HAS_CXX20 template -_NODISCARD bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 #ifdef __cpp_lib_concepts template -_NODISCARD constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD_PURE_OPERATOR constexpr _Synth_three_way_result<_Ty> operator<=>( const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD lexicographical_compare_three_way( @@ -831,17 +833,17 @@ _NODISCARD _CONSTEXPR20 bool operator<(const array<_Ty, _Size>& _Left, const arr } template -_NODISCARD _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return _Right < _Left; } template -_NODISCARD _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Right < _Left); } template -_NODISCARD _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ @@ -860,7 +862,7 @@ _NODISCARD constexpr array, _Size> _To_array_rvalue_impl( } template -_NODISCARD constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { +_NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/1: " "to_array does not accept multidimensional arrays."); static_assert(is_constructible_v<_Ty, _Ty&>, "N4830 [array.creation]/1: " @@ -869,7 +871,7 @@ _NODISCARD constexpr array, _Size> to_array(_Ty (&_Array)[_Size } template -_NODISCARD constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { +_NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/4: " "to_array does not accept multidimensional arrays."); static_assert(is_move_constructible_v<_Ty>, "N4830 [array.creation]/4: " @@ -879,25 +881,25 @@ _NODISCARD constexpr array, _Size> to_array(_Ty(&&_Array)[_Size #endif // _HAS_CXX20 template -_NODISCARD constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD_ACCESSOR_FUNCTION constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD_PURE_FUNCTION constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD_ACCESSOR_FUNCTION constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } template -_NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD_PURE_FUNCTION constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } diff --git a/stl/inc/atomic b/stl/inc/atomic index 3f15cb007c5..f98eb9356ca 100644 --- a/stl/inc/atomic +++ b/stl/inc/atomic @@ -500,7 +500,7 @@ struct _Atomic_storage { _Storage = _Value; } - _NODISCARD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { // load with sequential consistency _Check_load_memory_order(_Order); _Guard _Lock{_Spinlock}; @@ -661,14 +661,14 @@ struct _Atomic_storage<_Ty, 1> { // lock-free using 1-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Load_barrier(_Order); @@ -782,14 +782,14 @@ struct _Atomic_storage<_Ty, 2> { // lock-free using 2-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Load_barrier(_Order); @@ -900,14 +900,14 @@ struct _Atomic_storage<_Ty, 4> { // lock-free using 4-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Load_barrier(_Order); @@ -1024,7 +1024,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics } } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); long long _As_bytes; #ifdef _M_ARM @@ -1037,7 +1037,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); #ifdef _M_ARM long long _As_bytes = __ldrexd(_Mem); @@ -1140,14 +1140,14 @@ struct _Atomic_storage<_Ty&, 16> { // lock-free using 16-byte intrinsics (void) exchange(_Value, _Order); } - _NODISCARD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 (void) _STD_COMPARE_EXCHANGE_128(_Storage_ptr, 0, 0, &_Result._Low); return reinterpret_cast<_TVal&>(_Result); } - _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order #if defined(_M_ARM64) || defined(_M_ARM64EC) long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 @@ -2168,14 +2168,14 @@ public: #endif // _HAS_CXX17 #if 1 // TRANSITION, ABI - _NODISCARD bool is_lock_free() const volatile noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const volatile noexcept { constexpr bool _Result = sizeof(_Ty) <= 8 && (sizeof(_Ty) & sizeof(_Ty) - 1) == 0; return _Result; } #else // ^^^ don't break ABI / break ABI vvv - _NODISCARD bool is_lock_free() const volatile noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const volatile noexcept { #if _ATOMIC_HAS_DCAS return sizeof(_Ty) <= 2 * sizeof(void*); #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2184,7 +2184,7 @@ public: } #endif // TRANSITION, ABI - _NODISCARD bool is_lock_free() const noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const noexcept { return static_cast(this)->is_lock_free(); } @@ -2216,12 +2216,12 @@ public: } using _Base::load; - _NODISCARD _Ty load() const volatile noexcept { + _NODISCARD_PURE_METHOD _Ty load() const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(); } - _NODISCARD _Ty load(const memory_order _Order) const volatile noexcept { + _NODISCARD_PURE_METHOD _Ty load(const memory_order _Order) const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(_Order); } @@ -2351,7 +2351,7 @@ public: static constexpr size_t required_alignment = _Is_potentially_lock_free ? sizeof(_Ty) : alignof(_Ty); - _NODISCARD bool is_lock_free() const noexcept { + _NODISCARD_PURE_METHOD bool is_lock_free() const noexcept { #if _ATOMIC_HAS_DCAS return is_always_lock_free; #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2432,12 +2432,12 @@ private: #endif // _HAS_CXX20 template -_NODISCARD bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { +_NODISCARD_PURE_FUNCTION bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } template -_NODISCARD bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { +_NODISCARD_PURE_FUNCTION bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } @@ -2478,24 +2478,25 @@ _CXX20_DEPRECATE_ATOMIC_INIT void atomic_init( } template -_NODISCARD _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(); } template -_NODISCARD _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { return _Mem->load(); } template -_NODISCARD _Ty atomic_load_explicit(const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load_explicit( + const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(_Order); } template -_NODISCARD _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD_PURE_FUNCTION _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { return _Mem->load(_Order); } @@ -2807,11 +2808,11 @@ using atomic_unsigned_lock_free = atomic_uintptr_t; {} struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 - _NODISCARD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_METHOD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { return _Storage.load(_Order) != 0; } - _NODISCARD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { + _NODISCARD_PURE_METHOD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { return _Storage.load(_Order) != 0; } #endif // _HAS_CXX20 @@ -2869,20 +2870,21 @@ struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 -_NODISCARD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { +_NODISCARD_PURE_METHOD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { +_NODISCARD_PURE_METHOD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD inline bool atomic_flag_test_explicit( +_NODISCARD_PURE_METHOD inline bool atomic_flag_test_explicit( const volatile atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } -_NODISCARD inline bool atomic_flag_test_explicit(const atomic_flag* const _Flag, const memory_order _Order) noexcept { +_NODISCARD_PURE_METHOD inline bool atomic_flag_test_explicit( + const atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } #endif // _HAS_CXX20 diff --git a/stl/inc/barrier b/stl/inc/barrier index fc0eb1df2cd..2e987e6b001 100644 --- a/stl/inc/barrier +++ b/stl/inc/barrier @@ -88,11 +88,11 @@ public: barrier(const barrier&) = delete; barrier& operator=(const barrier&) = delete; - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return _Barrier_max; } - _NODISCARD arrival_token arrive(ptrdiff_t _Update = 1) noexcept /* strengthened */ { + _NODISCARD_BARRIER_TOKEN arrival_token arrive(ptrdiff_t _Update = 1) noexcept /* strengthened */ { // Shifting before precondition check, so that exceeding max() will trigger precondition check too _Update <<= _Barrier_value_shift; _STL_VERIFY(_Update > 0, "Precondition: update > 0 (N4861 [thread.barrier.class]/12)"); diff --git a/stl/inc/bit b/stl/inc/bit index 85040110d33..5e759d808ce 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -30,22 +30,22 @@ template , is_trivially_copyable<_To>, is_trivially_copyable<_From>>, int> = 0> -_NODISCARD constexpr _To bit_cast(const _From& _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _To bit_cast(const _From& _Val) noexcept { return __builtin_bit_cast(_To, _Val); } template , int> = 0> -_NODISCARD constexpr int countl_zero(_Ty _Val) noexcept; +_NODISCARD_PURE_FUNCTION constexpr int countl_zero(_Ty _Val) noexcept; template , int> = 0> -_NODISCARD constexpr bool has_single_bit(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr bool has_single_bit(const _Ty _Val) noexcept { return _Val != 0 && (_Val & (_Val - 1)) == 0; } inline void _Precondition_violation_in_bit_ceil() noexcept {} template , int> = 0> -_NODISCARD constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { +_NODISCARD_PURE_FUNCTION constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { if (_Val <= 1u) { return _Ty{1}; } @@ -73,7 +73,7 @@ _NODISCARD constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { } template , int> = 0> -_NODISCARD constexpr _Ty bit_floor(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty bit_floor(const _Ty _Val) noexcept { if (_Val == 0) { return 0; } @@ -82,15 +82,15 @@ _NODISCARD constexpr _Ty bit_floor(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD constexpr _Ty bit_width(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty bit_width(const _Ty _Val) noexcept { return static_cast<_Ty>(numeric_limits<_Ty>::digits - _STD countl_zero(_Val)); } template , int> = 0> -_NODISCARD constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; +_NODISCARD_PURE_FUNCTION constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; template , int> = 0> -_NODISCARD constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; const auto _Remainder = _Rotation % _Digits; if (_Remainder > 0) { @@ -104,7 +104,7 @@ _NODISCARD constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { } template , int> _Enabled> -_NODISCARD constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD_PURE_FUNCTION constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; const auto _Remainder = _Rotation % _Digits; if (_Remainder > 0) { @@ -234,7 +234,7 @@ _NODISCARD int _Checked_arm_arm64_countl_zero(const _Ty _Val) noexcept { #endif // defined(_M_ARM) || defined(_M_ARM64) template , int> _Enabled> -_NODISCARD constexpr int countl_zero(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countl_zero(const _Ty _Val) noexcept { #if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) if (!_STD is_constant_evaluated()) { return _Checked_x86_x64_countl_zero(_Val); @@ -249,22 +249,22 @@ _NODISCARD constexpr int countl_zero(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD constexpr int countl_one(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countl_one(const _Ty _Val) noexcept { return _STD countl_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD constexpr int countr_zero(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countr_zero(const _Ty _Val) noexcept { return _Countr_zero(_Val); } template , int> _Enabled = 0> -_NODISCARD constexpr int countr_one(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int countr_one(const _Ty _Val) noexcept { return _Countr_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD constexpr int popcount(const _Ty _Val) noexcept { +_NODISCARD_PURE_FUNCTION constexpr int popcount(const _Ty _Val) noexcept { return _Popcount(_Val); } diff --git a/stl/inc/latch b/stl/inc/latch index 16eea8b0fed..f764cda0aa4 100644 --- a/stl/inc/latch +++ b/stl/inc/latch @@ -31,7 +31,7 @@ _STD_BEGIN class latch { public: - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return (1ULL << (sizeof(ptrdiff_t) * CHAR_BIT - 1)) - 1; } @@ -53,7 +53,7 @@ public: } } - _NODISCARD bool try_wait() const noexcept { + _NODISCARD_TRY_WAIT bool try_wait() const noexcept { // TRANSITION, GH-1133: should be memory_order_acquire return _Counter.load() == 0; } diff --git a/stl/inc/mutex b/stl/inc/mutex index eea7d5426a6..0163edbe9fb 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -50,7 +50,7 @@ public: _Check_C_return(_Mtx_lock(_Mymtx())); } - _NODISCARD bool try_lock() { + _NODISCARD_MODIFY_STATE bool try_lock() { const auto _Res = _Mtx_trylock(_Mymtx()); switch (_Res) { case _Thrd_success: @@ -68,7 +68,7 @@ public: using native_handle_type = void*; - _NODISCARD native_handle_type native_handle() { + _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() { return _Mtx_getconcrtcs(_Mymtx()); } @@ -96,7 +96,7 @@ class recursive_mutex : public _Mutex_base { // class for recursive mutual exclu public: recursive_mutex() : _Mutex_base(_Mtx_recursive) {} - _NODISCARD bool try_lock() noexcept { + _NODISCARD_MODIFY_STATE bool try_lock() noexcept { return _Mutex_base::try_lock(); } @@ -128,27 +128,27 @@ public: unique_lock() noexcept : _Pmtx(nullptr), _Owns(false) {} - _NODISCARD_CTOR explicit unique_lock(_Mutex& _Mtx) + _NODISCARD_CTOR_LOCK explicit unique_lock(_Mutex& _Mtx) : _Pmtx(_STD addressof(_Mtx)), _Owns(false) { // construct and lock _Pmtx->lock(); _Owns = true; } - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, adopt_lock_t) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, adopt_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(true) {} // construct and assume already locked unique_lock(_Mutex& _Mtx, defer_lock_t) noexcept : _Pmtx(_STD addressof(_Mtx)), _Owns(false) {} // construct but don't lock - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, try_to_lock_t) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, try_to_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock()) {} // construct and try to lock template - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock_for(_Rel_time)) {} // construct and lock with timeout template - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Pmtx->try_lock_until(_Abs_time)) { // construct and lock with timeout #if _HAS_CXX20 @@ -156,12 +156,12 @@ public: #endif // _HAS_CXX20 } - _NODISCARD_CTOR unique_lock(_Mutex& _Mtx, const xtime* _Abs_time) + _NODISCARD_CTOR_LOCK unique_lock(_Mutex& _Mtx, const xtime* _Abs_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(false) { // try to lock until _Abs_time _Owns = _Pmtx->try_lock_until(_Abs_time); } - _NODISCARD_CTOR unique_lock(unique_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { + _NODISCARD_CTOR_LOCK unique_lock(unique_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { _Other._Pmtx = nullptr; _Other._Owns = false; } @@ -195,21 +195,21 @@ public: _Owns = true; } - _NODISCARD bool try_lock() { + _NODISCARD_MODIFY_STATE bool try_lock() { _Validate(); _Owns = _Pmtx->try_lock(); return _Owns; } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { _Validate(); _Owns = _Pmtx->try_lock_for(_Rel_time); return _Owns; } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); #endif // _HAS_CXX20 @@ -218,7 +218,7 @@ public: return _Owns; } - _NODISCARD bool try_lock_until(const xtime* _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { _Validate(); _Owns = _Pmtx->try_lock_until(_Abs_time); return _Owns; @@ -245,7 +245,7 @@ public: return _Res; } - _NODISCARD bool owns_lock() const noexcept { + _NODISCARD_PURE_METHOD bool owns_lock() const noexcept { return _Owns; } @@ -253,7 +253,7 @@ public: return _Owns; } - _NODISCARD _Mutex* mutex() const noexcept { + _NODISCARD_PURE_METHOD _Mutex* mutex() const noexcept { return _Pmtx; } @@ -347,7 +347,8 @@ int _Try_lock1(_Lock0& _Lk0, _Lock1& _Lk1) { } template -_NODISCARD int try_lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks +_NODISCARD_MODIFY_STATE_FUNCTION int try_lock( + _Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks return _Try_lock1(_Lk0, _Lk1, _LkN...); } @@ -419,7 +420,7 @@ void lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // lock multiple locks, } template -class _NODISCARD lock_guard { // class with destructor that unlocks a mutex +class _NODISCARD_LOCK lock_guard { // class with destructor that unlocks a mutex public: using mutex_type = _Mutex; @@ -442,7 +443,7 @@ private: #if _HAS_CXX17 template -class _NODISCARD scoped_lock { // class with destructor that unlocks mutexes +class _NODISCARD_LOCK scoped_lock { // class with destructor that unlocks mutexes public: explicit scoped_lock(_Mutexes&... _Mtxes) : _MyMutexes(_Mtxes...) { // construct and lock _STD lock(_Mtxes...); @@ -462,7 +463,7 @@ private: }; template -class _NODISCARD scoped_lock<_Mutex> { +class _NODISCARD_LOCK scoped_lock<_Mutex> { public: using mutex_type = _Mutex; @@ -682,7 +683,7 @@ public: return _Wait_until1(_Lck, _Abs_time, _Pred); } - _NODISCARD native_handle_type native_handle() { + _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() { return _Mycnd(); } @@ -757,7 +758,7 @@ public: _My_locked = UINT_MAX; } - _NODISCARD bool try_lock() noexcept { // try to lock the mutex + _NODISCARD_MODIFY_STATE bool try_lock() noexcept { // try to lock the mutex lock_guard _Lock(_My_mutex); if (_My_locked != 0) { return false; @@ -777,7 +778,8 @@ public: } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for( + const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } @@ -793,7 +795,7 @@ public: } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex with timeout #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -801,7 +803,7 @@ public: return _Try_lock_until(_Abs_time); } - _NODISCARD bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout + _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout return _Try_lock_until(_Abs_time); } @@ -839,7 +841,7 @@ public: } } - _NODISCARD bool try_lock() noexcept { // try to lock the mutex + _NODISCARD_MODIFY_STATE bool try_lock() noexcept { // try to lock the mutex const thread::id _Tid = this_thread::get_id(); lock_guard _Lock(_My_mutex); @@ -879,7 +881,8 @@ public: } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for( + const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } @@ -907,7 +910,7 @@ public: } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex with timeout #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -915,7 +918,7 @@ public: return _Try_lock_until(_Abs_time); } - _NODISCARD bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout + _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout return _Try_lock_until(_Abs_time); } diff --git a/stl/inc/semaphore b/stl/inc/semaphore index 903c4800bdd..5779b644e87 100644 --- a/stl/inc/semaphore +++ b/stl/inc/semaphore @@ -58,7 +58,7 @@ inline constexpr ptrdiff_t _Semaphore_max = (1ULL << (sizeof(ptrdiff_t) * CHAR_B template class counting_semaphore { public: - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return _Least_max_value; } @@ -139,7 +139,7 @@ public: } } - _NODISCARD bool try_acquire() noexcept { + _NODISCARD_MODIFY_STATE bool try_acquire() noexcept { ptrdiff_t _Current = _Counter.load(); if (_Current == 0) { return false; @@ -152,7 +152,7 @@ public: } template - _NODISCARD bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { auto _Deadline = _Semaphore_deadline(_Rel_time); ptrdiff_t _Current = _Counter.load(memory_order_relaxed); for (;;) { @@ -176,7 +176,7 @@ public: } template - _NODISCARD bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); ptrdiff_t _Current = _Counter.load(memory_order_relaxed); for (;;) { @@ -207,7 +207,7 @@ private: template <> class counting_semaphore<1> { public: - _NODISCARD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { return 1; } @@ -245,7 +245,7 @@ public: } } - _NODISCARD bool try_acquire() noexcept { + _NODISCARD_MODIFY_STATE bool try_acquire() noexcept { // TRANSITION, GH-1133: should be memory_order_acquire unsigned char _Prev = _Counter.exchange(0); _STL_VERIFY((_Prev & ~1) == 0, "Invariant: semaphore counter is non-negative and doesn't exceed max(), " @@ -254,7 +254,7 @@ public: } template - _NODISCARD bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { auto _Deadline = _Semaphore_deadline(_Rel_time); for (;;) { // "happens after release" ordering is provided by this exchange, so loads and waits can be relaxed @@ -274,7 +274,7 @@ public: } template - _NODISCARD bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); for (;;) { // "happens after release" ordering is provided by this exchange, so loads and waits can be relaxed diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index 87b629d7389..6b9c7f985ca 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -40,7 +40,7 @@ public: _Smtx_lock_exclusive(&_Myhandle); } - _NODISCARD bool try_lock() noexcept /* strengthened */ { // try to lock exclusive + _NODISCARD_MODIFY_STATE bool try_lock() noexcept /* strengthened */ { // try to lock exclusive return _Smtx_try_lock_exclusive(&_Myhandle) != 0; } @@ -52,7 +52,7 @@ public: _Smtx_lock_shared(&_Myhandle); } - _NODISCARD bool try_lock_shared() noexcept /* strengthened */ { // try to lock non-exclusive + _NODISCARD_MODIFY_STATE bool try_lock_shared() noexcept /* strengthened */ { // try to lock non-exclusive return _Smtx_try_lock_shared(&_Myhandle) != 0; } @@ -60,7 +60,7 @@ public: _Smtx_unlock_shared(&_Myhandle); } - _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle + _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle return &_Myhandle; } @@ -96,7 +96,7 @@ public: } } - _NODISCARD bool try_lock() { // try to lock exclusive + _NODISCARD_MODIFY_STATE bool try_lock() { // try to lock exclusive lock_guard _Lock(_Mymtx); if (_Writing || 0 < _Readers) { return false; @@ -107,12 +107,12 @@ public: } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock until time point #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -156,7 +156,7 @@ public: ++_Readers; } - _NODISCARD bool try_lock_shared() { // try to lock non-exclusive + _NODISCARD_MODIFY_STATE bool try_lock_shared() { // try to lock non-exclusive lock_guard _Lock(_Mymtx); if (_Writing || _Readers == _Max_readers) { return false; @@ -167,7 +167,7 @@ public: } template - _NODISCARD bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock non-exclusive for relative time return try_lock_shared_until(_To_absolute_time(_Rel_time)); } @@ -187,7 +187,7 @@ public: } template - _NODISCARD bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock non-exclusive until absolute time #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -195,7 +195,8 @@ public: return _Try_lock_shared_until(_Abs_time); } - _NODISCARD bool try_lock_shared_until(const xtime* _Abs_time) { // try to lock non-exclusive until absolute time + _NODISCARD_MODIFY_STATE bool try_lock_shared_until( + const xtime* _Abs_time) { // try to lock non-exclusive until absolute time return _Try_lock_shared_until(_Abs_time); } @@ -236,7 +237,7 @@ public: shared_lock() noexcept : _Pmtx(nullptr), _Owns(false) {} - _NODISCARD_CTOR explicit shared_lock(mutex_type& _Mtx) + _NODISCARD_CTOR_LOCK explicit shared_lock(mutex_type& _Mtx) : _Pmtx(_STD addressof(_Mtx)), _Owns(true) { // construct with mutex and lock shared _Mtx.lock_shared(); } @@ -244,20 +245,20 @@ public: shared_lock(mutex_type& _Mtx, defer_lock_t) noexcept : _Pmtx(_STD addressof(_Mtx)), _Owns(false) {} // construct with unlocked mutex - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, try_to_lock_t) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, try_to_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared()) {} // construct with mutex and try to lock shared - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, adopt_lock_t) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, adopt_lock_t) : _Pmtx(_STD addressof(_Mtx)), _Owns(true) {} // construct with mutex and adopt ownership template - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, const chrono::duration<_Rep, _Period>& _Rel_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared_for(_Rel_time)) { // construct with mutex and try to lock for relative time } template - _NODISCARD_CTOR shared_lock(mutex_type& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) + _NODISCARD_CTOR_LOCK shared_lock(mutex_type& _Mtx, const chrono::time_point<_Clock, _Duration>& _Abs_time) : _Pmtx(_STD addressof(_Mtx)), _Owns(_Mtx.try_lock_shared_until(_Abs_time)) { // construct with mutex and try to lock until absolute time #if _HAS_CXX20 @@ -271,7 +272,7 @@ public: } } - _NODISCARD_CTOR shared_lock(shared_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { + _NODISCARD_CTOR_LOCK shared_lock(shared_lock&& _Other) noexcept : _Pmtx(_Other._Pmtx), _Owns(_Other._Owns) { _Other._Pmtx = nullptr; _Other._Owns = false; } @@ -297,14 +298,14 @@ public: _Owns = true; } - _NODISCARD bool try_lock() { // try to lock the mutex + _NODISCARD_MODIFY_STATE bool try_lock() { // try to lock the mutex _Validate(); _Owns = _Pmtx->try_lock_shared(); return _Owns; } template - _NODISCARD bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock the mutex for _Rel_time _Validate(); _Owns = _Pmtx->try_lock_shared_for(_Rel_time); @@ -312,7 +313,7 @@ public: } template - _NODISCARD bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex until _Abs_time #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -343,7 +344,7 @@ public: return _Res; } - _NODISCARD bool owns_lock() const noexcept { + _NODISCARD_PURE_METHOD bool owns_lock() const noexcept { return _Owns; } @@ -351,7 +352,7 @@ public: return _Owns; } - _NODISCARD mutex_type* mutex() const noexcept { + _NODISCARD_PURE_METHOD mutex_type* mutex() const noexcept { return _Pmtx; } diff --git a/stl/inc/source_location b/stl/inc/source_location index a9e6154c44f..316db1ebfa8 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -23,7 +23,7 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN struct source_location { - _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), + _NODISCARD_PURE_METHOD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), const char* const _Function_ = __builtin_FUNCTION()) noexcept { source_location _Result; @@ -34,18 +34,18 @@ struct source_location { return _Result; } - _NODISCARD_CTOR constexpr source_location() noexcept = default; + _NODISCARD_CTOR_PURE constexpr source_location() noexcept = default; - _NODISCARD constexpr uint_least32_t line() const noexcept { + _NODISCARD_PURE_METHOD constexpr uint_least32_t line() const noexcept { return _Line; } - _NODISCARD constexpr uint_least32_t column() const noexcept { + _NODISCARD_PURE_METHOD constexpr uint_least32_t column() const noexcept { return _Column; } - _NODISCARD constexpr const char* file_name() const noexcept { + _NODISCARD_PURE_METHOD constexpr const char* file_name() const noexcept { return _File; } - _NODISCARD constexpr const char* function_name() const noexcept { + _NODISCARD_PURE_METHOD constexpr const char* function_name() const noexcept { return _Function; } diff --git a/stl/inc/thread b/stl/inc/thread index ef864b20b5f..92eda6eea2a 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -86,7 +86,7 @@ private: public: template , thread>, int> = 0> - _NODISCARD_CTOR explicit thread(_Fn&& _Fx, _Args&&... _Ax) { + _NODISCARD_CTOR_THREAD explicit thread(_Fn&& _Fx, _Args&&... _Ax) { _Start(_STD forward<_Fn>(_Fx), _STD forward<_Args>(_Ax)...); } @@ -114,7 +114,7 @@ public: _STD swap(_Thr, _Other._Thr); } - _NODISCARD bool joinable() const noexcept { + _NODISCARD_PURE_METHOD bool joinable() const noexcept { return _Thr._Id != 0; } @@ -143,13 +143,14 @@ public: _Thr = {}; } - _NODISCARD id get_id() const noexcept; + _NODISCARD_PURE_METHOD id get_id() const noexcept; - _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // return Win32 HANDLE as void * + _NODISCARD_PURE_METHOD native_handle_type native_handle() noexcept + /* strengthened */ { // return Win32 HANDLE as void * return _Thr._Hnd; } - _NODISCARD static unsigned int hardware_concurrency() noexcept { + _NODISCARD_PURE_METHOD static unsigned int hardware_concurrency() noexcept { return _Thrd_hardware_concurrency(); } @@ -174,7 +175,7 @@ _NODISCARD auto _To_absolute_time(const chrono::duration<_Rep, _Period>& _Rel_ti } namespace this_thread { - _NODISCARD thread::id get_id() noexcept; + _NODISCARD_PURE_FUNCTION thread::id get_id() noexcept; inline void yield() noexcept { _Thrd_yield(); @@ -229,11 +230,11 @@ private: friend hash; }; -_NODISCARD inline thread::id thread::get_id() const noexcept { +_NODISCARD_PURE_METHOD inline thread::id thread::get_id() const noexcept { return _Thr._Id; } -_NODISCARD inline thread::id this_thread::get_id() noexcept { +_NODISCARD_PURE_FUNCTION inline thread::id this_thread::get_id() noexcept { return _Thrd_id(); } @@ -241,32 +242,32 @@ inline void swap(thread& _Left, thread& _Right) noexcept { _Left.swap(_Right); } -_NODISCARD inline bool operator==(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator==(thread::id _Left, thread::id _Right) noexcept { return _Left._Id == _Right._Id; } #if _HAS_CXX20 -_NODISCARD inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { return _Left._Id <=> _Right._Id; } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -_NODISCARD inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { return !(_Left == _Right); } -_NODISCARD inline bool operator<(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator<(thread::id _Left, thread::id _Right) noexcept { return _Left._Id < _Right._Id; } -_NODISCARD inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { return !(_Right < _Left); } -_NODISCARD inline bool operator>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator>(thread::id _Left, thread::id _Right) noexcept { return _Right < _Left; } -_NODISCARD inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OPERATOR inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { return !(_Left < _Right); } #endif // !_HAS_CXX20 @@ -281,7 +282,7 @@ struct hash { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef thread::id _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD size_t operator()(const thread::id _Keyval) const noexcept { + _NODISCARD_PURE_METHOD size_t operator()(const thread::id _Keyval) const noexcept { return _Hash_representation(_Keyval._Id); } }; @@ -295,7 +296,7 @@ public: jthread() noexcept : _Impl{}, _Ssource{nostopstate} {} template , jthread>, int> = 0> - _NODISCARD_CTOR explicit jthread(_Fn&& _Fx, _Args&&... _Ax) { + _NODISCARD_CTOR_JTHREAD explicit jthread(_Fn&& _Fx, _Args&&... _Ax) { if constexpr (is_invocable_v, stop_token, decay_t<_Args>...>) { _Impl._Start(_STD forward<_Fn>(_Fx), _Ssource.get_token(), _STD forward<_Args>(_Ax)...); } else { @@ -327,7 +328,7 @@ public: _Ssource.swap(_Other._Ssource); } - _NODISCARD bool joinable() const noexcept { + _NODISCARD_PURE_METHOD bool joinable() const noexcept { return _Impl.joinable(); } @@ -339,19 +340,19 @@ public: _Impl.detach(); } - _NODISCARD id get_id() const noexcept { + _NODISCARD_PURE_METHOD id get_id() const noexcept { return _Impl.get_id(); } - _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD native_handle_type native_handle() noexcept /* strengthened */ { return _Impl.native_handle(); } - _NODISCARD stop_source get_stop_source() noexcept { + _NODISCARD_ACCESSOR_METHOD stop_source get_stop_source() noexcept { return _Ssource; } - _NODISCARD stop_token get_stop_token() const noexcept { + _NODISCARD_PURE_METHOD stop_token get_stop_token() const noexcept { return _Ssource.get_token(); } @@ -363,7 +364,7 @@ public: _Lhs.swap(_Rhs); } - _NODISCARD static unsigned int hardware_concurrency() noexcept { + _NODISCARD_PURE_METHOD static unsigned int hardware_concurrency() noexcept { return thread::hardware_concurrency(); } diff --git a/stl/inc/vector b/stl/inc/vector index d300d12e32f..eb2f7e027af 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -45,7 +45,7 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vector_const_iterator& operator=(const _Vector_const_iterator&) noexcept = default; - _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -56,7 +56,7 @@ public: return *_Ptr; } - _NODISCARD _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -123,7 +123,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -133,50 +133,52 @@ public: return *this += -_Off; } - _NODISCARD _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR20 difference_type operator-(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 difference_type operator-( + const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr - _Right._Ptr; } - _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>( + const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Unfancy(_Ptr) <=> _Unfancy(_Right._Ptr); } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD bool operator!=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator!=(const _Vector_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD bool operator<(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator<(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr < _Right._Ptr; } - _NODISCARD bool operator>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator>(const _Vector_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD bool operator<=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator<=(const _Vector_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD bool operator>=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator>=(const _Vector_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -212,7 +214,7 @@ public: }; template -_NODISCARD _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( typename _Vector_const_iterator<_Myvec>::difference_type _Off, _Vector_const_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -225,7 +227,7 @@ struct pointer_traits<_Vector_const_iterator<_Myvec>> { using element_type = const typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_METHOD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -264,11 +266,11 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vector_iterator& operator=(const _Vector_iterator&) noexcept = default; - _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(this->_Ptr, "can't dereference value-initialized vector iterator"); @@ -306,7 +308,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -319,13 +321,13 @@ public: using _Mybase::operator-; - _NODISCARD _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -337,7 +339,7 @@ public: }; template -_NODISCARD _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( typename _Vector_iterator<_Myvec>::difference_type _Off, _Vector_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -350,7 +352,7 @@ struct pointer_traits<_Vector_iterator<_Myvec>> { using element_type = typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_METHOD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -1369,63 +1371,63 @@ public: } } - _NODISCARD _CONSTEXPR20 _Ty* data() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty* data() noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD _CONSTEXPR20 const _Ty* data() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty* data() const noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD _CONSTEXPR20 iterator begin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator begin() noexcept { auto& _My_data = _Mypair._Myval2; return iterator(_My_data._Myfirst, _STD addressof(_My_data)); } - _NODISCARD _CONSTEXPR20 const_iterator begin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator begin() const noexcept { auto& _My_data = _Mypair._Myval2; return const_iterator(_My_data._Myfirst, _STD addressof(_My_data)); } - _NODISCARD _CONSTEXPR20 iterator end() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator end() noexcept { auto& _My_data = _Mypair._Myval2; return iterator(_My_data._Mylast, _STD addressof(_My_data)); } - _NODISCARD _CONSTEXPR20 const_iterator end() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator end() const noexcept { auto& _My_data = _Mypair._Myval2; return const_iterator(_My_data._Mylast, _STD addressof(_My_data)); } - _NODISCARD _CONSTEXPR20 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR20 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD _CONSTEXPR20 const_iterator cend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cend() const noexcept { return end(); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { return rend(); } @@ -1445,27 +1447,27 @@ public: return _Mypair._Myval2._Mylast; } - _NODISCARD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_METHOD _CONSTEXPR20 bool empty() const noexcept { auto& _My_data = _Mypair._Myval2; return _My_data._Myfirst == _My_data._Mylast; } - _NODISCARD _CONSTEXPR20 size_type size() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type size() const noexcept { auto& _My_data = _Mypair._Myval2; return static_cast(_My_data._Mylast - _My_data._Myfirst); } - _NODISCARD _CONSTEXPR20 size_type max_size() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type max_size() const noexcept { return (_STD min) (static_cast((numeric_limits::max) ()), _Alty_traits::max_size(_Getal())); } - _NODISCARD _CONSTEXPR20 size_type capacity() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type capacity() const noexcept { auto& _My_data = _Mypair._Myval2; return static_cast(_My_data._Myend - _My_data._Myfirst); } - _NODISCARD _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY( @@ -1475,7 +1477,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept /* strengthened */ { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY( @@ -1485,7 +1487,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD _CONSTEXPR20 _Ty& at(const size_type _Pos) { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty& at(const size_type _Pos) { auto& _My_data = _Mypair._Myval2; if (static_cast(_My_data._Mylast - _My_data._Myfirst) <= _Pos) { _Xrange(); @@ -1494,7 +1496,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD _CONSTEXPR20 const _Ty& at(const size_type _Pos) const { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty& at(const size_type _Pos) const { auto& _My_data = _Mypair._Myval2; if (static_cast(_My_data._Mylast - _My_data._Myfirst) <= _Pos) { _Xrange(); @@ -1503,7 +1505,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD _CONSTEXPR20 _Ty& front() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty& front() noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "front() called on empty vector"); @@ -1512,7 +1514,7 @@ public: return *_My_data._Myfirst; } - _NODISCARD _CONSTEXPR20 const _Ty& front() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty& front() const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "front() called on empty vector"); @@ -1521,7 +1523,7 @@ public: return *_My_data._Myfirst; } - _NODISCARD _CONSTEXPR20 _Ty& back() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty& back() noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "back() called on empty vector"); @@ -1530,7 +1532,7 @@ public: return _My_data._Mylast[-1]; } - _NODISCARD _CONSTEXPR20 const _Ty& back() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty& back() const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "back() called on empty vector"); @@ -1539,7 +1541,7 @@ public: return _My_data._Mylast[-1]; } - _NODISCARD _CONSTEXPR20 allocator_type get_allocator() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 allocator_type get_allocator() const noexcept { return static_cast(_Getal()); } @@ -1775,7 +1777,7 @@ using _Vbase = unsigned int; // word type for vector representatio constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word template -_NODISCARD _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if (_Left.size() != _Right.size()) { return false; } @@ -1790,7 +1792,7 @@ _NODISCARD _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const #if !_HAS_CXX20 template -_NODISCARD bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 @@ -1812,7 +1814,7 @@ _NODISCARD bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _ template struct _Vbase_compare_three_way { - _NODISCARD constexpr _Ret operator()(const _Vbase _Left, const _Vbase _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr _Ret operator()(const _Vbase _Left, const _Vbase _Right) const noexcept { const _Vbase _Differing_bits = _Left ^ _Right; if (_Differing_bits == 0) { // improves _Countr_zero codegen below @@ -1839,7 +1841,7 @@ struct _Vbase_compare_three_way { #ifdef __cpp_lib_concepts template -_NODISCARD constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD_PURE_OPERATOR constexpr _Synth_three_way_result<_Ty> operator<=>( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. @@ -1864,7 +1866,8 @@ _NODISCARD constexpr _Synth_three_way_result<_Ty> operator<=>( } #else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv template -_NODISCARD _CONSTEXPR20 bool operator<(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<( + const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. auto _First = _Left._Myvec._Unchecked_begin(); @@ -1891,17 +1894,20 @@ _NODISCARD _CONSTEXPR20 bool operator<(const vector<_Ty, _Alloc>& _Left, const v } template -_NODISCARD _CONSTEXPR20 bool operator>(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>( + const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return _Right < _Left; } template -_NODISCARD _CONSTEXPR20 bool operator<=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<=( + const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Right < _Left); } template -_NODISCARD _CONSTEXPR20 bool operator>=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>=( + const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ @@ -2050,7 +2056,7 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vb_const_iterator& operator=(const _Vb_const_iterator&) noexcept = default; - _NODISCARD _CONSTEXPR20 const_reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const_reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Cont = static_cast(this->_Getcont()); _STL_VERIFY(_Cont, "cannot dereference value-initialized vector iterator"); @@ -2110,7 +2116,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR20 _Vb_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_const_iterator operator+(const difference_type _Off) const noexcept { _Vb_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -2120,29 +2126,29 @@ public: return *this += -_Off; } - _NODISCARD _CONSTEXPR20 _Vb_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_const_iterator operator-(const difference_type _Off) const noexcept { _Vb_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR20 difference_type operator-(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 difference_type operator-(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_VBITS * (this->_Myptr - _Right._Myptr)) + static_cast(this->_Myoff) - static_cast(_Right._Myoff); } - _NODISCARD _CONSTEXPR20 const_reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const_reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD _CONSTEXPR20 bool operator==(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return this->_Myptr == _Right._Myptr && this->_Myoff == _Right._Myoff; } #if _HAS_CXX20 - _NODISCARD constexpr strong_ordering operator<=>(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); if (const auto _CmpResult = this->_Myptr <=> _Right._Myptr; _CmpResult != 0) { return _CmpResult; @@ -2150,24 +2156,24 @@ public: return this->_Myoff <=> _Right._Myoff; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD bool operator!=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator!=(const _Vb_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD bool operator<(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator<(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return this->_Myptr < _Right._Myptr || (this->_Myptr == _Right._Myptr && this->_Myoff < _Right._Myoff); } - _NODISCARD bool operator>(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator>(const _Vb_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD bool operator<=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator<=(const _Vb_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD bool operator>=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OPERATOR bool operator>=(const _Vb_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -2223,7 +2229,7 @@ public: }; template -_NODISCARD _CONSTEXPR20 _Vb_const_iterator<_Alvbase_wrapped> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_const_iterator<_Alvbase_wrapped> operator+( typename _Vb_const_iterator<_Alvbase_wrapped>::difference_type _Off, _Vb_const_iterator<_Alvbase_wrapped> _Right) noexcept { _Right += _Off; @@ -2248,7 +2254,7 @@ public: using _Mybase::_Mybase; - _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Cont = static_cast(this->_Getcont()); _STL_VERIFY(_Cont, "cannot dereference value-initialized vector iterator"); @@ -2289,7 +2295,7 @@ public: return *this; } - _NODISCARD _CONSTEXPR20 _Vb_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_iterator operator+(const difference_type _Off) const noexcept { _Vb_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -2302,13 +2308,13 @@ public: using _Mybase::operator-; - _NODISCARD _CONSTEXPR20 _Vb_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_iterator operator-(const difference_type _Off) const noexcept { _Vb_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } @@ -2316,7 +2322,7 @@ public: }; template -_NODISCARD _CONSTEXPR20 _Vb_iterator<_Alvbase_wrapped> operator+( +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_iterator<_Alvbase_wrapped> operator+( typename _Vb_iterator<_Alvbase_wrapped>::difference_type _Off, _Vb_iterator<_Alvbase_wrapped> _Right) noexcept { _Right += _Off; return _Right; @@ -2610,39 +2616,39 @@ public: this->_Myvec.reserve(this->_Nw(_Count)); } - _NODISCARD _CONSTEXPR20 size_type capacity() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type capacity() const noexcept { return this->_Myvec.capacity() * _VBITS; } - _NODISCARD _CONSTEXPR20 iterator begin() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator begin() noexcept { return iterator(this->_Myvec.data(), this); } - _NODISCARD _CONSTEXPR20 const_iterator begin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator begin() const noexcept { return const_iterator(this->_Myvec.data(), this); } - _NODISCARD _CONSTEXPR20 iterator end() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator end() noexcept { return begin() + static_cast(this->_Mysize); } - _NODISCARD _CONSTEXPR20 const_iterator end() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator end() const noexcept { return begin() + static_cast(this->_Mysize); } - _NODISCARD _CONSTEXPR20 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD _CONSTEXPR20 const_iterator cend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cend() const noexcept { return end(); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { return rend(); } @@ -2678,19 +2684,19 @@ public: return _Tmp; } - _NODISCARD _CONSTEXPR20 reverse_iterator rbegin() noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } @@ -2702,11 +2708,11 @@ public: } } - _NODISCARD _CONSTEXPR20 size_type size() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type size() const noexcept { return this->_Mysize; } - _NODISCARD _CONSTEXPR20 size_type max_size() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type max_size() const noexcept { constexpr auto _Diff_max = static_cast((numeric_limits::max) ()); const size_type _Ints_max = this->_Myvec.max_size(); if (_Ints_max > _Diff_max / _VBITS) { // max_size bound by difference_type limits @@ -2717,15 +2723,15 @@ public: return _Ints_max * _VBITS; } - _NODISCARD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_METHOD _CONSTEXPR20 bool empty() const noexcept { return this->_Mysize == 0; } - _NODISCARD _CONSTEXPR20 allocator_type get_allocator() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 allocator_type get_allocator() const noexcept { return static_cast(this->_Myvec.get_allocator()); } - _NODISCARD _CONSTEXPR20 const_reference at(size_type _Off) const { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reference at(size_type _Off) const { if (size() <= _Off) { _Xran(); } @@ -2733,7 +2739,7 @@ public: return (*this)[_Off]; } - _NODISCARD _CONSTEXPR20 reference at(size_type _Off) { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reference at(size_type _Off) { if (size() <= _Off) { _Xran(); } @@ -2741,7 +2747,7 @@ public: return (*this)[_Off]; } - _NODISCARD _CONSTEXPR20 const_reference operator[](size_type _Off) const noexcept /* strengthened */ { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const_reference operator[](size_type _Off) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < this->_Mysize, "vector subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2751,7 +2757,7 @@ public: return *_It; } - _NODISCARD _CONSTEXPR20 reference operator[](size_type _Off) noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR20 reference operator[](size_type _Off) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < this->_Mysize, "vector subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2761,7 +2767,7 @@ public: return *_It; } - _NODISCARD _CONSTEXPR20 reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "front() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2769,7 +2775,7 @@ public: return *begin(); } - _NODISCARD _CONSTEXPR20 const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "front() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2777,7 +2783,7 @@ public: return *begin(); } - _NODISCARD _CONSTEXPR20 reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "back() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2785,7 +2791,7 @@ public: return *(end() - 1); } - _NODISCARD _CONSTEXPR20 const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "back() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3022,7 +3028,7 @@ struct hash> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef vector _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD size_t operator()(const vector& _Keyval) const noexcept { + _NODISCARD_PURE_OPERATOR size_t operator()(const vector& _Keyval) const noexcept { return _Hash_array_representation(_Keyval._Myvec.data(), _Keyval._Myvec.size()); } }; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 4d245fd85a6..c949ac89f51 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -414,14 +414,102 @@ // _HAS_NODISCARD (in vcruntime.h) controls: // [[nodiscard]] attributes on STL functions +// TRANSITION, This should go to vcruntime.h +#if _HAS_NODISCARD +#define _NODISCARD_MSG(_Msg) [[nodiscard(_Msg)]] +#else // ^^^ CAN HAZ [[nodiscard]] / NO CAN HAZ [[nodiscard]] vvv +#define _NODISCARD_MSG(_Msg) +#endif // _HAS_NODISCARD + #ifndef __has_cpp_attribute #define _NODISCARD_CTOR +#define _NODISCARD_CTOR_MSG(_Msg) #elif __has_cpp_attribute(nodiscard) >= 201907L #define _NODISCARD_CTOR _NODISCARD +#define _NODISCARD_CTOR_MSG(_Msg) _NODISCARD_MSG(_Msg) #else #define _NODISCARD_CTOR +#define _NODISCARD_CTOR_MSG(_Msg) #endif +#define _NODISCARD_PURE_ALGORITHM \ + _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ + "and discard the return value") + +#define _NODISCARD_PURE_FUNCTION \ + _NODISCARD_MSG("This function is pure, i.e. has no side effects; it is not useful to call this function and " \ + "discard the return value") + +#define _NODISCARD_PURE_METHOD \ + _NODISCARD_MSG("This method is pure obeserver, i.e. has no side effects; it is not useful to call this method " \ + "and discard the return value") + +#define _NODISCARD_PURE_OPERATOR \ + _NODISCARD_MSG("This operator is pure obeserver, i.e. has no side effects; it is not useful to call this " \ + "operator and discard the return value") + +#define _NODISCARD_ACCESSOR_FUNCTION \ + _NODISCARD_MSG("This function returns a value that provides access to the passed object and has no side effects " \ + "otherwise; it is not useful to call this function and discard the return value") + +#define _NODISCARD_ACCESSOR_METHOD \ + _NODISCARD_MSG("This method returns an object that can access the state of the current object and has no other " \ + "side effects; it is not useful to call this method and discard the return value") + +#define _NODISCARD_ACCESSOR_OPERATOR \ + _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ + "no other side effects; it is not useful to call this operator and discard the return value") + +#define _NODISCARD_REMOVE_ALGORITHM \ + _NODISCARD_MSG("The remove, remove_if, and unique algorithms returns the iterator past the last removed element. " \ + "Normally you need to use the result to call container's erase method afterwards to erase " \ + "elements. In C++20 you can also use erase and erase_if functions to replace these two steps.") + +#define _NODISCARD_EMPTY_METHOD \ + _NODISCARD_MSG("This method checks whether the container is empty. Use 'clear()' method if you intend to clear " \ + "the container.") + +#define _NODISCARD_EMPTY_METHOD_ARRAY \ + _NODISCARD_MSG( \ + "This method checks whether the array is empty. There's no way to clear an array, as its size is fixed.") + +#define _NODISCARD_BARRIER_TOKEN \ + _NODISCARD_MSG("The token from 'arrive' should not be discarded; it should be passed to 'wait'") + +#define _NODISCARD_TRY_WAIT \ + _NODISCARD_MSG("This method returns the state of the synchronization object and does not do anything else; it is " \ + "not useful to call this method and discard the return value") + + +#define _NODISCARD_MODIFY_STATE \ + _NODISCARD_MSG("This method returns whether the operation succeeds in modifying the state of the object or not. " \ + "It is dangerous to ignore the return value") + +#define _NODISCARD_MODIFY_STATE_FUNCTION \ + _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ + "objects or not. It is dangerous to ignore the return value") + +#define _NODISCARD_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ + "current statement, using comma operator, please use cast to void to suppress this warning).") + +#define _NODISCARD_CTOR_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ + "current statement, using comma operator, please use cast to void to suppress this warning).") + +#define _NODISCARD_CTOR_THREAD \ + _NODISCARD_CTOR_MSG("Thread is not joined or detached, terminate will be called at the end of the statement") + +#define _NODISCARD_CTOR_JTHREAD \ + _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention?") + +#define _NODISCARD_CTOR_PURE \ + _NODISCARD_CTOR_MSG( \ + "Construction of the object hass no side effects; it is not useful to construct an object just to discard it") + + // Determine if we should use [[msvc::known_semantics]] to communicate to the compiler // that certain type trait specializations have the standard-mandated semantics #ifndef __has_cpp_attribute From e36a54565694db2d41121561c2f1e45b90e1d3ed Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 19:12:29 +0300 Subject: [PATCH 03/73] clang format --- stl/inc/vector | 10 ++++++---- stl/inc/yvals_core.h | 10 ++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stl/inc/vector b/stl/inc/vector index eb2f7e027af..f21247a5dc9 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -1407,11 +1407,11 @@ public: return const_reverse_iterator(end()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } @@ -1477,7 +1477,8 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept /* strengthened */ { + _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept + /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY( @@ -1777,7 +1778,8 @@ using _Vbase = unsigned int; // word type for vector representatio constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==( + const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if (_Left.size() != _Right.size()) { return false; } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index c949ac89f51..959faa0af85 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -425,7 +425,7 @@ #define _NODISCARD_CTOR #define _NODISCARD_CTOR_MSG(_Msg) #elif __has_cpp_attribute(nodiscard) >= 201907L -#define _NODISCARD_CTOR _NODISCARD +#define _NODISCARD_CTOR _NODISCARD #define _NODISCARD_CTOR_MSG(_Msg) _NODISCARD_MSG(_Msg) #else #define _NODISCARD_CTOR @@ -448,7 +448,7 @@ _NODISCARD_MSG("This operator is pure obeserver, i.e. has no side effects; it is not useful to call this " \ "operator and discard the return value") -#define _NODISCARD_ACCESSOR_FUNCTION \ +#define _NODISCARD_ACCESSOR_FUNCTION \ _NODISCARD_MSG("This function returns a value that provides access to the passed object and has no side effects " \ "otherwise; it is not useful to call this function and discard the return value") @@ -476,16 +476,15 @@ #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive' should not be discarded; it should be passed to 'wait'") -#define _NODISCARD_TRY_WAIT \ +#define _NODISCARD_TRY_WAIT \ _NODISCARD_MSG("This method returns the state of the synchronization object and does not do anything else; it is " \ "not useful to call this method and discard the return value") - #define _NODISCARD_MODIFY_STATE \ _NODISCARD_MSG("This method returns whether the operation succeeds in modifying the state of the object or not. " \ "It is dangerous to ignore the return value") -#define _NODISCARD_MODIFY_STATE_FUNCTION \ +#define _NODISCARD_MODIFY_STATE_FUNCTION \ _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ "objects or not. It is dangerous to ignore the return value") @@ -509,7 +508,6 @@ _NODISCARD_CTOR_MSG( \ "Construction of the object hass no side effects; it is not useful to construct an object just to discard it") - // Determine if we should use [[msvc::known_semantics]] to communicate to the compiler // that certain type trait specializations have the standard-mandated semantics #ifndef __has_cpp_attribute From 0fbb82d8bb2cda90c302825ec5941cac067d7131 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 19:27:27 +0300 Subject: [PATCH 04/73] clang format --- stl/inc/algorithm | 17 +++++++---------- stl/inc/shared_mutex | 3 ++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index e835990302f..c42a2cf6d7b 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2537,13 +2537,12 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _Firs #if _HAS_CXX17 template = 0> _NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, - const _FwdIt2 _First2, - const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates + const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> _NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of( - _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, - const _FwdIt2 _Last2) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element + _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) noexcept +/* terminates */ { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } #endif // _HAS_CXX17 @@ -8327,8 +8326,7 @@ namespace ranges { class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); return _Includes_unchecked(_Get_unwrapped(_STD move(_First1)), _Get_unwrapped(_STD move(_Last1)), @@ -9438,8 +9436,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept( - noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { +_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, + _Pr _Pred) noexcept(noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) { return {_Right, _Left}; @@ -9972,8 +9970,7 @@ namespace ranges { class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index 6b9c7f985ca..3c8afb3eaeb 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -107,7 +107,8 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration + _NODISCARD_MODIFY_STATE bool try_lock_for( + const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } From 2c6d357380196fbcf1fca34140099512049eb439 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 19:55:03 +0300 Subject: [PATCH 05/73] line len --- stl/inc/algorithm | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index c42a2cf6d7b..eebf8858ecf 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -508,7 +508,8 @@ namespace ranges { template requires indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()( + _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { return _Count_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); } // clang-format on @@ -749,8 +750,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {},_Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_STD move(_First1)); @@ -2085,8 +2086,8 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, - const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, + const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); if (_Count <= 0) { @@ -2110,8 +2111,8 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, - const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, + const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); if (_Count <= 0) { @@ -2450,8 +2451,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, + _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_First1); @@ -2557,8 +2558,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -3440,7 +3441,8 @@ _NODISCARD_REMOVE_ALGORITHM _FwdIt remove( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept; // terminates template = 0> -_NODISCARD_REMOVE_ALGORITHM _FwdIt remove_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_REMOVE_ALGORITHM _FwdIt remove_if( + _ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -3452,7 +3454,8 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Val, _Pass_fn(_Proj)); @@ -3517,7 +3520,8 @@ namespace ranges { template , _Pj>> _Pr> requires permutable> - _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { auto _UResult = _Remove_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_subrange>(_Range, _STD move(_UResult)); @@ -3741,7 +3745,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::equal_to> requires permutable> - _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Unique_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_subrange>(_Range, _STD move(_UResult)); @@ -9409,7 +9414,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( From 06f082ede2820ab0ac9f820593ddea9351b3b792 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 19:57:04 +0300 Subject: [PATCH 06/73] non-ctor lock --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 959faa0af85..250debe520c 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -489,7 +489,7 @@ "objects or not. It is dangerous to ignore the return value") #define _NODISCARD_LOCK \ - _NODISCARD_CTOR_MSG( \ + _NODISCARD_MSG( \ "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ "current statement, using comma operator, please use cast to void to suppress this warning).") From bcd7b1e8a09fcd54a8f596a2a865b95168a0e453 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 20:05:13 +0300 Subject: [PATCH 07/73] clang format --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 250debe520c..6b6326fea13 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -489,7 +489,7 @@ "objects or not. It is dangerous to ignore the return value") #define _NODISCARD_LOCK \ - _NODISCARD_MSG( \ + _NODISCARD_MSG( \ "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ "current statement, using comma operator, please use cast to void to suppress this warning).") From b7a1e0f639e1699154a22b95e8f44d6c3933c808 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 20:09:27 +0300 Subject: [PATCH 08/73] more formatting --- stl/inc/algorithm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index eebf8858ecf..98d7388348c 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2086,7 +2086,7 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, + _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); @@ -2111,7 +2111,7 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, + _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); @@ -9343,7 +9343,8 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()( + _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( From baf36de5be326b800b6eef2e90e79bda993ccffe Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 20:10:26 +0300 Subject: [PATCH 09/73] variable --- stl/inc/yvals_core.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 6b6326fea13..bd0b45e0f4b 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -488,14 +488,14 @@ _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ "objects or not. It is dangerous to ignore the return value") -#define _NODISCARD_LOCK \ - _NODISCARD_MSG( \ - "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ +#define _NODISCARD_LOCK \ + _NODISCARD_MSG( \ + "A lock should be saved in a variable to protect the scope. (If the intetion is to protect the rest of the " \ "current statement, using comma operator, please use cast to void to suppress this warning).") -#define _NODISCARD_CTOR_LOCK \ - _NODISCARD_CTOR_MSG( \ - "A lock should be saved in a varible to protect the scope. (If the intetion is to protect the rest of the " \ +#define _NODISCARD_CTOR_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be saved in a variable to protect the scope. (If the intetion is to protect the rest of the " \ "current statement, using comma operator, please use cast to void to suppress this warning).") #define _NODISCARD_CTOR_THREAD \ From 49d82597666c7780c2326fa66b4dd64948a732b4 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 21:49:46 +0300 Subject: [PATCH 10/73] better spelling --- stl/inc/yvals_core.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index bd0b45e0f4b..7b0684a3d4b 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -433,7 +433,7 @@ #endif #define _NODISCARD_PURE_ALGORITHM \ - _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ + _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ "and discard the return value") #define _NODISCARD_PURE_FUNCTION \ @@ -460,10 +460,11 @@ _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ "no other side effects; it is not useful to call this operator and discard the return value") -#define _NODISCARD_REMOVE_ALGORITHM \ - _NODISCARD_MSG("The remove, remove_if, and unique algorithms returns the iterator past the last removed element. " \ - "Normally you need to use the result to call container's erase method afterwards to erase " \ - "elements. In C++20 you can also use erase and erase_if functions to replace these two steps.") +#define _NODISCARD_REMOVE_ALGORITHM \ + _NODISCARD_MSG( \ + "The 'remove', 'remove_if', and 'unique' algorithms return the iterator past the last removed element. " \ + "Normally you need to use the result to call container's erase method afterwards to erase elements. " \ + "In C++ 20 you can also use erase and erase_if functions to replace these two steps.") #define _NODISCARD_EMPTY_METHOD \ _NODISCARD_MSG("This method checks whether the container is empty. Use 'clear()' method if you intend to clear " \ @@ -474,7 +475,7 @@ "This method checks whether the array is empty. There's no way to clear an array, as its size is fixed.") #define _NODISCARD_BARRIER_TOKEN \ - _NODISCARD_MSG("The token from 'arrive' should not be discarded; it should be passed to 'wait'") + _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") #define _NODISCARD_TRY_WAIT \ _NODISCARD_MSG("This method returns the state of the synchronization object and does not do anything else; it is " \ @@ -506,7 +507,7 @@ #define _NODISCARD_CTOR_PURE \ _NODISCARD_CTOR_MSG( \ - "Construction of the object hass no side effects; it is not useful to construct an object just to discard it") + "Construction of the object has no side effects; it is not useful to construct an object just to discard it") // Determine if we should use [[msvc::known_semantics]] to communicate to the compiler // that certain type trait specializations have the standard-mandated semantics From feec5c903011542c3f5960a17984da19aac07d3f Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 21:58:55 +0300 Subject: [PATCH 11/73] Skip for CUDA --- stl/inc/yvals_core.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 7b0684a3d4b..3fcd46f5bfe 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -416,8 +416,12 @@ // TRANSITION, This should go to vcruntime.h #if _HAS_NODISCARD +#ifdef __CUDACC__ // TRANSITION, CUDA 10.1 version does not support [[nodiscard("message")]] +#define _NODISCARD_MSG(_Msg) [[nodiscard]] +#else // ^^^ TRANSITION, __CUDACC__ ^^^ / vvv !__CUDACC__ vvv #define _NODISCARD_MSG(_Msg) [[nodiscard(_Msg)]] -#else // ^^^ CAN HAZ [[nodiscard]] / NO CAN HAZ [[nodiscard]] vvv +#endif // ^^^!__CUDACC__ ^^^ +#else // ^^^ CAN HAZ [[nodiscard("message")]] / NO CAN HAZ [[nodiscard("message")]] vvv #define _NODISCARD_MSG(_Msg) #endif // _HAS_NODISCARD From 50d5404eaa123ccfa3fee2ce5a187f10a869e799 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 22:09:24 +0300 Subject: [PATCH 12/73] Improve detection --- stl/inc/yvals_core.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 3fcd46f5bfe..22e1d787898 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -415,13 +415,14 @@ // [[nodiscard]] attributes on STL functions // TRANSITION, This should go to vcruntime.h -#if _HAS_NODISCARD -#ifdef __CUDACC__ // TRANSITION, CUDA 10.1 version does not support [[nodiscard("message")]] -#define _NODISCARD_MSG(_Msg) [[nodiscard]] -#else // ^^^ TRANSITION, __CUDACC__ ^^^ / vvv !__CUDACC__ vvv +#ifndef __has_cpp_attribute +#define _NODISCARD_MSG(_Msg) +#elif __has_cpp_attribute(nodiscard) >= 201907L \ + && !defined(__CUDACC__) // TRANSITION, CUDA 10.1 version does not support [[nodiscard("message")]] #define _NODISCARD_MSG(_Msg) [[nodiscard(_Msg)]] -#endif // ^^^!__CUDACC__ ^^^ -#else // ^^^ CAN HAZ [[nodiscard("message")]] / NO CAN HAZ [[nodiscard("message")]] vvv +#elif __has_cpp_attribute(nodiscard) >= 201603L +#define _NODISCARD_MSG(_Msg) [[nodiscard]] +#else #define _NODISCARD_MSG(_Msg) #endif // _HAS_NODISCARD From 70469ec8375ab4bbefbfbbe86a129d495761f6b9 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 22:09:52 +0300 Subject: [PATCH 13/73] -misleading comment --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 22e1d787898..870d111c8a6 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -424,7 +424,7 @@ #define _NODISCARD_MSG(_Msg) [[nodiscard]] #else #define _NODISCARD_MSG(_Msg) -#endif // _HAS_NODISCARD +#endif #ifndef __has_cpp_attribute #define _NODISCARD_CTOR From 8471d484dc2fe02555801182d9ad02e1b0e4f598 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 22:14:31 +0300 Subject: [PATCH 14/73] more formatting --- stl/inc/yvals_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 870d111c8a6..359d444d4a0 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -437,8 +437,8 @@ #define _NODISCARD_CTOR_MSG(_Msg) #endif -#define _NODISCARD_PURE_ALGORITHM \ - _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ +#define _NODISCARD_PURE_ALGORITHM \ + _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ "and discard the return value") #define _NODISCARD_PURE_FUNCTION \ From b313c673b35914a25fa8bc89f383ac436fac4a4a Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 18 Sep 2021 22:16:52 +0300 Subject: [PATCH 15/73] non --- stl/inc/yvals_core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 359d444d4a0..aaaa93c14fe 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -465,10 +465,10 @@ _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ "no other side effects; it is not useful to call this operator and discard the return value") -#define _NODISCARD_REMOVE_ALGORITHM \ - _NODISCARD_MSG( \ - "The 'remove', 'remove_if', and 'unique' algorithms return the iterator past the last removed element. " \ - "Normally you need to use the result to call container's erase method afterwards to erase elements. " \ +#define _NODISCARD_REMOVE_ALGORITHM \ + _NODISCARD_MSG( \ + "The 'remove', 'remove_if', and 'unique' algorithms return the iterator past the last non-removed element. " \ + "Normally you need to use the result to call container's erase method afterwards to erase elements. " \ "In C++ 20 you can also use erase and erase_if functions to replace these two steps.") #define _NODISCARD_EMPTY_METHOD \ From d72d9b2f8ee2992a262cd9d2403b3cc7a6c47a2d Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 10:54:02 +0300 Subject: [PATCH 16/73] Abbreviated --- stl/inc/algorithm | 358 +++++++++++++++++++--------------------- stl/inc/any | 20 +-- stl/inc/array | 190 ++++++++++----------- stl/inc/atomic | 58 +++---- stl/inc/barrier | 2 +- stl/inc/bit | 28 ++-- stl/inc/latch | 2 +- stl/inc/mutex | 38 ++--- stl/inc/semaphore | 16 +- stl/inc/shared_mutex | 30 ++-- stl/inc/source_location | 10 +- stl/inc/thread | 42 ++--- stl/inc/vector | 202 +++++++++++------------ stl/inc/yvals_core.h | 53 +++--- 14 files changed, 521 insertions(+), 528 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 98d7388348c..2f43b6d256d 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -373,12 +373,11 @@ namespace ranges { #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt find_if( - _ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { // find first element that satisfies !_Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -395,12 +394,11 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _In #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt find_if_not( - _ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find first satisfying _Pred with successor _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -419,18 +417,17 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt adjacent_find( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt adjacent_find( const _FwdIt _First, const _FwdIt _Last) { // find first matching successor return _STD adjacent_find(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt adjacent_find( - _ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG _FwdIt adjacent_find(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept +_NODISCARD_PURE_ALG _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept /* terminates */ { // find first matching successor return _STD adjacent_find(_STD forward<_ExPo>(_Exec), _First, _Last, equal_to{}); @@ -445,8 +442,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_binary_predicate, projected<_It, _Pj>> _Pr = ranges::equal_to> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Adjacent_find_unchecked( @@ -459,7 +455,7 @@ namespace ranges { template , _Pj>, projected, _Pj>> _Pr = ranges::equal_to> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Adjacent_find_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -499,7 +495,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD_PURE_ALGORITHM constexpr iter_difference_t<_It> operator()( + _NODISCARD_PURE_ALG constexpr iter_difference_t<_It> operator()( _It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_unchecked( @@ -508,7 +504,7 @@ namespace ranges { template requires indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr range_difference_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { return _Count_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); } @@ -537,7 +533,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { // count elements satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -554,7 +550,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _Iter_diff_t<_FwdIt> count_if( +_NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count_if( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 @@ -566,7 +562,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr iter_difference_t<_It> operator()( + _NODISCARD_PURE_ALG constexpr iter_difference_t<_It> operator()( _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_if_unchecked( @@ -575,7 +571,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr range_difference_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr range_difference_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Count_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -604,7 +600,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( _InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, ...) mismatch _Adl_verify_range(_First1, _Last1); @@ -623,12 +619,12 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { // return [_First1, _Last1)/[_First2, ...) mismatch return _STD mismatch(_First1, _Last1, _First2, equal_to<>{}); @@ -636,7 +632,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, ...) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -646,7 +642,7 @@ _NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, _Last2) mismatch _Adl_verify_range(_First1, _Last1); @@ -679,12 +675,12 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // return [_First1, _Last1)/[_First2, _Last2) mismatch return _STD mismatch(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -692,7 +688,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, _Last2) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -750,7 +746,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {},_Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -776,7 +772,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { using _Size1 = _Make_unsigned_like_t>; @@ -800,8 +796,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( - _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, ...) _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -825,7 +820,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { // test if [_First1, _Last1) == permuted [_First2, ...) return _STD is_permutation(_First1, _Last1, _First2, equal_to<>{}); } @@ -884,7 +879,7 @@ _CONSTEXPR20 bool _Is_permutation_unchecked(_FwdIt1 _First1, _FwdIt1 _Last1, _Fw } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation( _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, _Last2) _Adl_verify_range(_First1, _Last1); @@ -894,8 +889,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_permutation( - _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { // test if [_First1, _Last1) == permuted [_First2, _Last2) return _STD is_permutation(_First1, _Last1, _First2, _Last2, equal_to<>{}); } @@ -914,7 +908,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_equivalence_relation, projected<_It2, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -940,7 +934,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { const auto _Count = _RANGES distance(_Range1); @@ -1132,7 +1126,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool all_of( +_NODISCARD_PURE_ALG _CONSTEXPR20 bool all_of( _InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1148,7 +1142,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool all_of( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1159,7 +1153,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _All_of_unchecked( @@ -1168,7 +1162,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _All_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1194,7 +1188,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if any element satisfies _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1210,8 +1204,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool any_of(const _InIt _First, const _In #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM bool any_of( - _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1222,7 +1215,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Any_of_unchecked( @@ -1231,7 +1224,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Any_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1257,7 +1250,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if no elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1273,8 +1266,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool none_of(const _InIt _First, const _I #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM bool none_of( - _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1285,7 +1277,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _None_of_unchecked( @@ -1294,7 +1286,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _None_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1683,7 +1675,7 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if [_First, _Last) partitioned by _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1710,7 +1702,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_partitioned(const _InIt _First, c #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM bool is_partitioned( +_NODISCARD_PURE_ALG bool is_partitioned( _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 @@ -1722,7 +1714,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Is_partitioned_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1730,7 +1722,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Is_partitioned_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1767,7 +1759,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find beginning of false partition in [_First, _Last) _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1798,7 +1790,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); if constexpr (sized_sentinel_for<_Se, _It>) { @@ -1815,7 +1807,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { if constexpr (sized_range<_Rng>) { const auto _Length = _RANGES distance(_Range); @@ -1911,7 +1903,7 @@ _NODISCARD _CONSTEXPR20 bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _F } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -1955,12 +1947,12 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _Fir #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, +_NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First1, const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) { // find first [_First2, _Last2) match return _STD search(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -1968,22 +1960,22 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, - const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, const _FwdItHaystack _Last1, + const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { // find first [_First2, _Last2) match return _STD search(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First, const _FwdItHaystack _Last, const _Searcher& _Search) { // find _Search's pattern in [_First, _Last) return _Search(_First, _Last).first; } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt search_n( const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) { // find first _Count * _Val satisfying _Pred const _Algorithm_int_t<_Diff> _Count = _Count_raw; @@ -2056,13 +2048,13 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, +_NODISCARD_PURE_ALG _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt search_n( const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { // find first _Count * _Val match return _STD search_n(_First, _Last, _Count, _Val, equal_to<>{}); @@ -2070,7 +2062,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt search_n( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, +_NODISCARD_PURE_ALG _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) noexcept /* terminates */ { // find first _Count * _Val match return _STD search_n(_STD forward<_ExPo>(_Exec), _First, _Last, _Count, _Val, equal_to{}); } @@ -2086,7 +2078,7 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALGORITHM constexpr subrange<_It> operator()(_It _First, _Se _Last, + _NODISCARD_PURE_ALG constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); @@ -2111,7 +2103,7 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, + _NODISCARD_PURE_ALG constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); @@ -2240,7 +2232,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // find last [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); @@ -2321,7 +2313,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 const _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) { // find last [_First2, _Last2) match return _STD find_end(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -2329,11 +2321,11 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_end( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt1 find_end( +_NODISCARD_PURE_ALG _FwdIt1 find_end( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt1 find_end( +_NODISCARD_PURE_ALG _FwdIt1 find_end( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // find last [_First2, _Last2) match return _STD find_end(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); @@ -2451,7 +2443,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, + _NODISCARD_PURE_ALG constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2481,7 +2473,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_subrange_t<_Rng1> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_subrange_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (random_access_range<_Rng1> && sized_range<_Rng1> && random_access_range<_Rng2> && sized_range<_Rng2>) { @@ -2506,7 +2498,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of( +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_first_of( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // look for one of [_First2, _Last2) satisfying _Pred with element _Adl_verify_range(_First1, _Last1); @@ -2529,7 +2521,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of( } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -2537,11 +2529,11 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _Firs #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, - const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, + const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt1 find_first_of( +_NODISCARD_PURE_ALG _FwdIt1 find_first_of( _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); @@ -2558,7 +2550,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALG constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2574,7 +2566,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng1> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); @@ -3437,11 +3429,11 @@ _FwdIt2 remove_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _P #if _HAS_CXX17 template = 0> -_NODISCARD_REMOVE_ALGORITHM _FwdIt remove( +_NODISCARD_REMOVE_ALG _FwdIt remove( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept; // terminates template = 0> -_NODISCARD_REMOVE_ALGORITHM _FwdIt remove_if( +_NODISCARD_REMOVE_ALG _FwdIt remove_if( _ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 @@ -3454,7 +3446,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _NODISCARD_REMOVE_ALG constexpr subrange<_It> operator()( _It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_unchecked( @@ -3466,7 +3458,7 @@ namespace ranges { template requires permutable> && indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( + _NODISCARD_REMOVE_ALG constexpr borrowed_subrange_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { auto _UResult = _Remove_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); @@ -3507,7 +3499,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _NODISCARD_REMOVE_ALG constexpr subrange<_It> operator()( _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Remove_if_unchecked( @@ -3520,7 +3512,7 @@ namespace ranges { template , _Pj>> _Pr> requires permutable> - _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( + _NODISCARD_REMOVE_ALG constexpr borrowed_subrange_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { auto _UResult = _Remove_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -3679,7 +3671,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // remove each satisfying _Pred with previous _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -3704,20 +3696,20 @@ _NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _La } template -_NODISCARD_REMOVE_ALGORITHM _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous +_NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous return _STD unique(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_REMOVE_ALGORITHM _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALG _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // remove each satisfying _Pred with previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD_REMOVE_ALGORITHM _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALG _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // remove each matching previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last); @@ -3732,7 +3724,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_equivalence_relation> _Pr = ranges::equal_to> - _NODISCARD_REMOVE_ALGORITHM constexpr subrange<_It> operator()( + _NODISCARD_REMOVE_ALG constexpr subrange<_It> operator()( _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Unique_unchecked( @@ -3745,7 +3737,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::equal_to> requires permutable> - _NODISCARD_REMOVE_ALGORITHM constexpr borrowed_subrange_t<_Rng> operator()( + _NODISCARD_REMOVE_ALG constexpr borrowed_subrange_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Unique_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -5725,7 +5717,7 @@ _CONSTEXPR20 _RanIt _Is_heap_until_unchecked(_RanIt _First, _RanIt _Last, _Pr _P } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { // find extent of range that is a heap _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Is_heap_until_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); @@ -5733,7 +5725,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanI } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // test if range is a heap _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -5742,37 +5734,36 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_First, _Last, less<>{}); } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_heap( +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_heap( _RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< return _STD is_heap(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _RanIt is_heap_until( - _ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALGORITHM bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is a heap return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD_PURE_ALGORITHM _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD_PURE_ALGORITHM bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // test if range is a heap ordered by operator< return _STD is_heap(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -5809,8 +5800,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _ULast = _Get_unwrapped(_STD move(_Last)); @@ -5822,7 +5812,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); const auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -5838,8 +5828,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _Size = _RANGES distance(_UFirst, _Get_unwrapped(_STD move(_Last))); @@ -5851,7 +5840,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -5968,7 +5957,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _NODISCARD_PURE_ALG constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -5981,7 +5970,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = @@ -5997,7 +5986,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find first element that _Val is before _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6019,7 +6008,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find first element that _Val is before return _STD upper_bound(_First, _Last, _Val, less<>{}); } @@ -6055,7 +6044,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( + _NODISCARD_PURE_ALG constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6067,7 +6056,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = _Upper_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -6082,7 +6071,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( +_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( _FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find range equivalent to _Val _Adl_verify_range(_First, _Last); @@ -6120,7 +6109,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find range equivalent to _Val return _STD equal_range(_First, _Last, _Val, less<>{}); } @@ -6189,7 +6178,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // test if _Val equivalent to some element _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6199,7 +6188,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // test if _Val equivalent to some element return _STD binary_search(_First, _Last, _Val, less<>{}); } @@ -6212,7 +6201,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6225,7 +6214,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); const auto _UFirst = @@ -8268,7 +8257,7 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes( +_NODISCARD_PURE_ALG _CONSTEXPR20 bool includes( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) _Adl_verify_range(_First1, _Last1); @@ -8293,14 +8282,14 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes( } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) return _STD includes(_First1, _Last1, _First2, _Last2, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM bool includes( +_NODISCARD_PURE_ALG bool includes( _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) @@ -8311,8 +8300,7 @@ _NODISCARD_PURE_ALGORITHM bool includes( } template = 0> -_NODISCARD_PURE_ALGORITHM bool includes( - _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD_PURE_ALG bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8330,7 +8318,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -8342,7 +8330,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Includes_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); @@ -8958,20 +8946,20 @@ constexpr _FwdIt _Max_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD_PURE_ALGORITHM constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element +_NODISCARD_PURE_ALG constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Max_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD_PURE_ALGORITHM constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element +_NODISCARD_PURE_ALG constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element return _STD max_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release @@ -8979,7 +8967,7 @@ _NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Las } template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last); @@ -9013,8 +9001,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9023,7 +9010,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), @@ -9052,21 +9039,20 @@ constexpr _FwdIt _Min_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD_PURE_ALGORITHM constexpr _FwdIt min_element( - _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element +_NODISCARD_PURE_ALG constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Min_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD_PURE_ALGORITHM constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element +_NODISCARD_PURE_ALG constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element return _STD min_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release @@ -9074,7 +9060,7 @@ _NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Las } template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last); @@ -9108,8 +9094,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9118,7 +9103,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), @@ -9171,7 +9156,7 @@ constexpr pair<_FwdIt, _FwdIt> _Minmax_element_unchecked(_FwdIt _First, _FwdIt _ } template -_NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest and largest elements _Adl_verify_range(_First, _Last); const auto _Result = _Minmax_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred)); @@ -9181,14 +9166,14 @@ _NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _ } template -_NODISCARD_PURE_ALGORITHM constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { +_NODISCARD_PURE_ALG constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { // find smallest and largest elements return _STD minmax_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release @@ -9196,7 +9181,7 @@ _NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _F } template = 0> -_NODISCARD_PURE_ALGORITHM pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept +_NODISCARD_PURE_ALG pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release @@ -9262,7 +9247,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr minmax_element_result<_It> operator()( + _NODISCARD_PURE_ALG constexpr minmax_element_result<_It> operator()( _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9275,7 +9260,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr minmax_element_result> operator()( + _NODISCARD_PURE_ALG constexpr minmax_element_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9293,14 +9278,14 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALGORITHM constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALG constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/largest const _Ty* _Res = _Max_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD_PURE_ALGORITHM constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALG constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { // return leftmost/largest return (_STD max) (_Ilist, less<>{}); } @@ -9319,7 +9304,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( + _NODISCARD_PURE_ALG constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Left), _STD invoke(_Proj, _Right))) { return _Right; @@ -9330,7 +9315,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _Ty operator()( + _NODISCARD_PURE_ALG constexpr _Ty operator()( initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); @@ -9343,7 +9328,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr range_value_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); @@ -9371,14 +9356,14 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALG constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/smallest const _Ty* _Res = _Min_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD_PURE_ALGORITHM constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALG constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { // return leftmost/smallest return (_STD min) (_Ilist, less<>{}); } @@ -9391,7 +9376,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( + _NODISCARD_PURE_ALG constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return _Right; @@ -9402,7 +9387,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _Ty operator()( + _NODISCARD_PURE_ALG constexpr _Ty operator()( initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); @@ -9415,7 +9400,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALGORITHM constexpr range_value_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr range_value_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); @@ -9443,7 +9428,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, +_NODISCARD_PURE_ALG constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept(noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) { @@ -9454,14 +9439,14 @@ _NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _T } template -_NODISCARD_PURE_ALGORITHM constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD_PURE_ALG constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return {leftmost/smallest, rightmost/largest} pair _Res = _Minmax_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return pair<_Ty, _Ty>(*_Res.first, *_Res.second); } template -_NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( +_NODISCARD_PURE_ALG constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( noexcept(_Right < _Left)) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_Right < _Left) { @@ -9473,7 +9458,7 @@ _NODISCARD_PURE_ALGORITHM constexpr pair minmax(const _T } template -_NODISCARD_PURE_ALGORITHM constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { +_NODISCARD_PURE_ALG constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { // return {leftmost/smallest, rightmost/largest} return _STD minmax(_Ilist, less<>{}); } @@ -9489,7 +9474,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr minmax_result operator()( + _NODISCARD_PURE_ALG constexpr minmax_result operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return {_Right, _Left}; @@ -9500,7 +9485,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr minmax_result<_Ty> operator()( + _NODISCARD_PURE_ALG constexpr minmax_result<_Ty> operator()( initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); @@ -9514,7 +9499,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALGORITHM constexpr minmax_result> operator()( + _NODISCARD_PURE_ALG constexpr minmax_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { // clang-format on auto _UFirst = _Ubegin(_Range); @@ -9791,7 +9776,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find extent of range that is ordered by predicate _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -9810,7 +9795,7 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _Firs } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // test if range is ordered by predicate _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -9819,37 +9804,35 @@ _NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Las } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { +_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { // find extent of range that is ordered by operator< return _STD is_sorted_until(_First, _Last, less<>{}); } template -_NODISCARD_PURE_ALGORITHM _CONSTEXPR20 bool is_sorted( - _FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< +_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< return _STD is_sorted(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt is_sorted_until( - _ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD_PURE_ALG _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALGORITHM bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is ordered by predicate return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD_PURE_ALGORITHM _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find extent of range that is ordered by operator< return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD_PURE_ALGORITHM bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // test if range is ordered by operator< return _STD is_sorted(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -9862,8 +9845,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); const auto _ULast = _Get_unwrapped(_STD move(_Last)); const auto _UFirst = @@ -9873,7 +9855,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _ULast = _Uend(_Range); const auto _UFirst = _Is_sorted_until_unchecked(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _UFirst == _ULast; @@ -9888,8 +9870,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr _It operator()( - _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Is_sorted_until_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -9899,7 +9880,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UFirst = @@ -9914,8 +9895,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp( - const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { +_NODISCARD_PURE_ALG constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { // returns _Val constrained to [_Min_val, _Max_val] #if _ITERATOR_DEBUG_LEVEL == 2 if (_DEBUG_LT_PRED(_Pred, _Max_val, _Min_val)) { @@ -9936,7 +9916,7 @@ _NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp( } template -_NODISCARD_PURE_ALGORITHM constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { +_NODISCARD_PURE_ALG constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { // returns _Val constrained to [_Min_val, _Max_val] return _STD clamp(_Val, _Min_val, _Max_val, less{}); } @@ -9949,7 +9929,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr const _Ty& operator()( + _NODISCARD_PURE_ALG constexpr const _Ty& operator()( const _Ty& _Val, const _Ty& _Lo, const _Ty& _Hi, _Pr _Pred = {}, _Pj _Proj = {}) const { _STL_ASSERT(!_STD invoke(_Pred, _STD invoke(_Proj, _Hi), _STD invoke(_Proj, _Lo)), "The lower bound cannot be greater than the upper bound in a call to std::ranges::clamp " @@ -9976,7 +9956,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -9989,7 +9969,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALGORITHM constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Lexicographical_compare_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); diff --git a/stl/inc/any b/stl/inc/any index 17f3f2d2e33..fef3c7d5934 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -33,7 +33,7 @@ _STD_BEGIN class bad_any_cast : public bad_cast { // thrown by failed any_cast public: - _NODISCARD_PURE_METHOD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD_PURE_MTHD const char* __CLR_OR_THIS_CALL what() const noexcept override { return "Bad any_cast"; } }; @@ -225,11 +225,11 @@ public: } // Observers [any.observers] - _NODISCARD_PURE_METHOD bool has_value() const noexcept { + _NODISCARD_PURE_MTHD bool has_value() const noexcept { return _Storage._TypeData != 0; } - _NODISCARD_PURE_METHOD const type_info& type() const noexcept { + _NODISCARD_PURE_MTHD const type_info& type() const noexcept { // if *this contains a value of type T, return typeid(T); otherwise typeid(void) const type_info* const _Info = _TypeInfo(); if (_Info) { @@ -358,18 +358,18 @@ inline void swap(any& _Left, any& _Right) noexcept { } template -_NODISCARD_PURE_FUNCTION any make_any( +_NODISCARD_PURE_FN any make_any( _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... return any{in_place_type<_ValueType>, _STD forward<_Types>(_Args)...}; } template -_NODISCARD_PURE_FUNCTION any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { +_NODISCARD_PURE_FN any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Ilist and _Args... return any{in_place_type<_ValueType>, _Ilist, _STD forward<_Types>(_Args)...}; } template -_NODISCARD_PURE_FUNCTION const _ValueType* any_cast(const any* const _Any) noexcept { +_NODISCARD_PURE_FN const _ValueType* any_cast(const any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -384,7 +384,7 @@ _NODISCARD_PURE_FUNCTION const _ValueType* any_cast(const any* const _Any) noexc } } template -_NODISCARD_PURE_FUNCTION _ValueType* any_cast(any* const _Any) noexcept { +_NODISCARD_PURE_FN _ValueType* any_cast(any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -400,7 +400,7 @@ _NODISCARD_PURE_FUNCTION _ValueType* any_cast(any* const _Any) noexcept { } template -_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(const any& _Any) { +_NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(const any& _Any) { static_assert(is_constructible_v, const _Remove_cvref_t<_Ty>&>, "any_cast(const any&) requires remove_cv_t to be constructible from " "const remove_cv_t>&"); @@ -413,7 +413,7 @@ _NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(const any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any& _Any) { +_NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(any& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>&>, "any_cast(any&) requires remove_cv_t to be constructible from remove_cv_t>&"); @@ -425,7 +425,7 @@ _NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_PURE_FUNCTION remove_cv_t<_Ty> any_cast(any&& _Any) { +_NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(any&& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>>, "any_cast(any&&) requires remove_cv_t to be constructible from remove_cv_t>"); diff --git a/stl/inc/array b/stl/inc/array index 128e0242abf..02e9ab168f3 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -48,11 +48,11 @@ public: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg + _Off) {} - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 reference operator*() const noexcept { return *_Ptr; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 pointer operator->() const noexcept { return _Ptr; } @@ -83,7 +83,7 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -94,46 +94,46 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { return _Ptr - _Right._Ptr; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return _Ptr[_Off]; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { return _Ptr <=> _Right._Ptr; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { return _Ptr < _Right._Ptr; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -158,11 +158,11 @@ private: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg), _Idx(_Off) {} - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 reference operator*() const noexcept { return *operator->(); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 pointer operator->() const noexcept { _STL_VERIFY(_Ptr, "cannot dereference value-initialized array iterator"); _STL_VERIFY(_Idx < _Size, "cannot dereference out of range array iterator"); return _Ptr + _Idx; @@ -214,7 +214,7 @@ private: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -224,50 +224,50 @@ private: return *this += -_Off; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_Idx - _Right._Idx); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return *(*this + _Off); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx == _Right._Idx; } #if _HAS_CXX20 - _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx <=> _Right._Idx; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx < _Right._Idx; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -307,7 +307,7 @@ constexpr void _Verify_range( #endif // _ITERATOR_DEBUG_LEVEL != 0 template -_NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( +_NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_const_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -320,7 +320,7 @@ struct pointer_traits<_Array_const_iterator<_Ty, _Size>> { using element_type = const _Ty; using difference_type = ptrdiff_t; - _NODISCARD_PURE_FUNCTION static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_FN static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -346,11 +346,11 @@ public: _CONSTEXPR17 explicit _Array_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Mybase(_Parg, _Off) {} - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 pointer operator->() const noexcept { return const_cast(_Mybase::operator->()); } @@ -381,7 +381,7 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -394,13 +394,13 @@ public: using _Mybase::operator-; - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -412,7 +412,7 @@ public: }; template -_NODISCARD_PURE_OPERATOR _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( +_NODISCARD_PURE_OP _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -425,7 +425,7 @@ struct pointer_traits<_Array_iterator<_Ty, _Size>> { using element_type = _Ty; using difference_type = ptrdiff_t; - _NODISCARD_PURE_FUNCTION static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_FN static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -462,51 +462,51 @@ public: _Swap_ranges_unchecked(_Elems, _Elems + _Size, _Other._Elems); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator begin() noexcept { return iterator(_Elems, 0); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator(_Elems, 0); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator end() noexcept { return iterator(_Elems, _Size); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator(_Elems, _Size); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -526,19 +526,19 @@ public: return _Elems + _Size; } - _NODISCARD_PURE_METHOD constexpr size_type size() const noexcept { + _NODISCARD_PURE_MTHD constexpr size_type size() const noexcept { return _Size; } - _NODISCARD_PURE_METHOD constexpr size_type max_size() const noexcept { + _NODISCARD_PURE_MTHD constexpr size_type max_size() const noexcept { return _Size; } - _NODISCARD_EMPTY_METHOD_ARRAY constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD_ARRAY constexpr bool empty() const noexcept { return false; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference at(size_type _Pos) { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reference at(size_type _Pos) { if (_Size <= _Pos) { _Xran(); } @@ -546,7 +546,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_PURE_METHOD constexpr const_reference at(size_type _Pos) const { + _NODISCARD_PURE_MTHD constexpr const_reference at(size_type _Pos) const { if (_Size <= _Pos) { _Xran(); } @@ -554,7 +554,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept + _NODISCARD_ACCESS_OP _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); @@ -563,7 +563,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_PURE_OPERATOR constexpr const_reference operator[]( + _NODISCARD_PURE_OP constexpr const_reference operator[]( _In_range_(0, _Size - 1) size_type _Pos) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 @@ -573,27 +573,27 @@ public: return _Elems[_Pos]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reference front() noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD_PURE_METHOD constexpr const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD constexpr const_reference front() const noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reference back() noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD_PURE_METHOD constexpr const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD constexpr const_reference back() const noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 _Ty* data() noexcept { return _Elems; } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const _Ty* data() const noexcept { return _Elems; } @@ -641,51 +641,51 @@ public: _CONSTEXPR20 void swap(array&) noexcept {} - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator begin() noexcept { return iterator{}; } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator{}; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator end() noexcept { return iterator{}; } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator{}; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -705,15 +705,15 @@ public: return nullptr; } - _NODISCARD_PURE_METHOD constexpr size_type size() const noexcept { + _NODISCARD_PURE_MTHD constexpr size_type size() const noexcept { return 0; } - _NODISCARD_PURE_METHOD constexpr size_type max_size() const noexcept { + _NODISCARD_PURE_MTHD constexpr size_type max_size() const noexcept { return 0; } - _NODISCARD_PURE_METHOD constexpr bool empty() const noexcept { + _NODISCARD_PURE_MTHD constexpr bool empty() const noexcept { return true; } @@ -725,7 +725,7 @@ public: _Xran(); } - _NODISCARD_ACCESSOR_OPERATOR reference operator[](size_type) noexcept /* strengthened */ { + _NODISCARD_ACCESS_OP reference operator[](size_type) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -733,7 +733,7 @@ public: return _Elems[0]; } - _NODISCARD_PURE_OPERATOR const_reference operator[](size_type) const noexcept /* strengthened */ { + _NODISCARD_PURE_OP const_reference operator[](size_type) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -741,7 +741,7 @@ public: return _Elems[0]; } - _NODISCARD_ACCESSOR_METHOD reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -749,7 +749,7 @@ public: return _Elems[0]; } - _NODISCARD_PURE_METHOD const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -757,7 +757,7 @@ public: return _Elems[0]; } - _NODISCARD_ACCESSOR_METHOD reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -765,7 +765,7 @@ public: return _Elems[0]; } - _NODISCARD_PURE_METHOD const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -773,11 +773,11 @@ public: return _Elems[0]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR17 _Ty* data() noexcept { return nullptr; } - _NODISCARD_PURE_METHOD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR17 const _Ty* data() const noexcept { return nullptr; } @@ -794,7 +794,7 @@ _CONSTEXPR20 void swap(array<_Ty, _Size>& _Left, array<_Ty, _Size>& _Right) noex } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD equal(_Left.begin(), _Left.end(), _Right.begin()); #else // ^^^ workaround / no workaround vvv @@ -804,14 +804,14 @@ _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _ #if !_HAS_CXX20 template -_NODISCARD_PURE_OPERATOR bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OP bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 #ifdef __cpp_lib_concepts template -_NODISCARD_PURE_OPERATOR constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD_PURE_OP constexpr _Synth_three_way_result<_Ty> operator<=>( const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD lexicographical_compare_three_way( @@ -833,17 +833,17 @@ _NODISCARD _CONSTEXPR20 bool operator<(const array<_Ty, _Size>& _Left, const arr } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Right < _Left); } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ @@ -862,7 +862,7 @@ _NODISCARD constexpr array, _Size> _To_array_rvalue_impl( } template -_NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { +_NODISCARD_PURE_FN constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/1: " "to_array does not accept multidimensional arrays."); static_assert(is_constructible_v<_Ty, _Ty&>, "N4830 [array.creation]/1: " @@ -871,7 +871,7 @@ _NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty ( } template -_NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { +_NODISCARD_PURE_FN constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/4: " "to_array does not accept multidimensional arrays."); static_assert(is_move_constructible_v<_Ty>, "N4830 [array.creation]/4: " @@ -881,25 +881,25 @@ _NODISCARD_PURE_FUNCTION constexpr array, _Size> to_array(_Ty(& #endif // _HAS_CXX20 template -_NODISCARD_ACCESSOR_FUNCTION constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD_ACCESS_FN constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD_PURE_FUNCTION constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD_PURE_FN constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD_ACCESSOR_FUNCTION constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD_ACCESS_FN constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } template -_NODISCARD_PURE_FUNCTION constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD_PURE_FN constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } diff --git a/stl/inc/atomic b/stl/inc/atomic index f98eb9356ca..a5736388f21 100644 --- a/stl/inc/atomic +++ b/stl/inc/atomic @@ -500,7 +500,7 @@ struct _Atomic_storage { _Storage = _Value; } - _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { // load with sequential consistency _Check_load_memory_order(_Order); _Guard _Lock{_Spinlock}; @@ -661,14 +661,14 @@ struct _Atomic_storage<_Ty, 1> { // lock-free using 1-byte intrinsics } } - _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Load_barrier(_Order); @@ -782,14 +782,14 @@ struct _Atomic_storage<_Ty, 2> { // lock-free using 2-byte intrinsics } } - _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Load_barrier(_Order); @@ -900,14 +900,14 @@ struct _Atomic_storage<_Ty, 4> { // lock-free using 4-byte intrinsics } } - _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Load_barrier(_Order); @@ -1024,7 +1024,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics } } - _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); long long _As_bytes; #ifdef _M_ARM @@ -1037,7 +1037,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); #ifdef _M_ARM long long _As_bytes = __ldrexd(_Mem); @@ -1140,14 +1140,14 @@ struct _Atomic_storage<_Ty&, 16> { // lock-free using 16-byte intrinsics (void) exchange(_Value, _Order); } - _NODISCARD_PURE_METHOD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 (void) _STD_COMPARE_EXCHANGE_128(_Storage_ptr, 0, 0, &_Result._Low); return reinterpret_cast<_TVal&>(_Result); } - _NODISCARD_PURE_METHOD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order #if defined(_M_ARM64) || defined(_M_ARM64EC) long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 @@ -2168,14 +2168,14 @@ public: #endif // _HAS_CXX17 #if 1 // TRANSITION, ABI - _NODISCARD_PURE_METHOD bool is_lock_free() const volatile noexcept { + _NODISCARD_PURE_MTHD bool is_lock_free() const volatile noexcept { constexpr bool _Result = sizeof(_Ty) <= 8 && (sizeof(_Ty) & sizeof(_Ty) - 1) == 0; return _Result; } #else // ^^^ don't break ABI / break ABI vvv - _NODISCARD_PURE_METHOD bool is_lock_free() const volatile noexcept { + _NODISCARD_PURE_MTHD bool is_lock_free() const volatile noexcept { #if _ATOMIC_HAS_DCAS return sizeof(_Ty) <= 2 * sizeof(void*); #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2184,7 +2184,7 @@ public: } #endif // TRANSITION, ABI - _NODISCARD_PURE_METHOD bool is_lock_free() const noexcept { + _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { return static_cast(this)->is_lock_free(); } @@ -2216,12 +2216,12 @@ public: } using _Base::load; - _NODISCARD_PURE_METHOD _Ty load() const volatile noexcept { + _NODISCARD_PURE_MTHD _Ty load() const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(); } - _NODISCARD_PURE_METHOD _Ty load(const memory_order _Order) const volatile noexcept { + _NODISCARD_PURE_MTHD _Ty load(const memory_order _Order) const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(_Order); } @@ -2351,7 +2351,7 @@ public: static constexpr size_t required_alignment = _Is_potentially_lock_free ? sizeof(_Ty) : alignof(_Ty); - _NODISCARD_PURE_METHOD bool is_lock_free() const noexcept { + _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { #if _ATOMIC_HAS_DCAS return is_always_lock_free; #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2432,12 +2432,12 @@ private: #endif // _HAS_CXX20 template -_NODISCARD_PURE_FUNCTION bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { +_NODISCARD_PURE_FN bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } template -_NODISCARD_PURE_FUNCTION bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { +_NODISCARD_PURE_FN bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } @@ -2478,25 +2478,25 @@ _CXX20_DEPRECATE_ATOMIC_INIT void atomic_init( } template -_NODISCARD_PURE_FUNCTION _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { +_NODISCARD_PURE_FN _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(); } template -_NODISCARD_PURE_FUNCTION _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { +_NODISCARD_PURE_FN _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { return _Mem->load(); } template -_NODISCARD_PURE_FUNCTION _Ty atomic_load_explicit( +_NODISCARD_PURE_FN _Ty atomic_load_explicit( const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(_Order); } template -_NODISCARD_PURE_FUNCTION _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD_PURE_FN _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { return _Mem->load(_Order); } @@ -2808,11 +2808,11 @@ using atomic_unsigned_lock_free = atomic_uintptr_t; {} struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 - _NODISCARD_PURE_METHOD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_MTHD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { return _Storage.load(_Order) != 0; } - _NODISCARD_PURE_METHOD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { + _NODISCARD_PURE_MTHD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { return _Storage.load(_Order) != 0; } #endif // _HAS_CXX20 @@ -2870,20 +2870,20 @@ struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 -_NODISCARD_PURE_METHOD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { +_NODISCARD_PURE_MTHD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD_PURE_METHOD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { +_NODISCARD_PURE_MTHD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD_PURE_METHOD inline bool atomic_flag_test_explicit( +_NODISCARD_PURE_MTHD inline bool atomic_flag_test_explicit( const volatile atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } -_NODISCARD_PURE_METHOD inline bool atomic_flag_test_explicit( +_NODISCARD_PURE_MTHD inline bool atomic_flag_test_explicit( const atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } diff --git a/stl/inc/barrier b/stl/inc/barrier index 2e987e6b001..3331a2f8e3c 100644 --- a/stl/inc/barrier +++ b/stl/inc/barrier @@ -88,7 +88,7 @@ public: barrier(const barrier&) = delete; barrier& operator=(const barrier&) = delete; - _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { return _Barrier_max; } diff --git a/stl/inc/bit b/stl/inc/bit index 5e759d808ce..00226825e6b 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -30,22 +30,22 @@ template , is_trivially_copyable<_To>, is_trivially_copyable<_From>>, int> = 0> -_NODISCARD_PURE_FUNCTION constexpr _To bit_cast(const _From& _Val) noexcept { +_NODISCARD_PURE_FN constexpr _To bit_cast(const _From& _Val) noexcept { return __builtin_bit_cast(_To, _Val); } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr int countl_zero(_Ty _Val) noexcept; +_NODISCARD_PURE_FN constexpr int countl_zero(_Ty _Val) noexcept; template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr bool has_single_bit(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr bool has_single_bit(const _Ty _Val) noexcept { return _Val != 0 && (_Val & (_Val - 1)) == 0; } inline void _Precondition_violation_in_bit_ceil() noexcept {} template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { +_NODISCARD_PURE_FN constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { if (_Val <= 1u) { return _Ty{1}; } @@ -73,7 +73,7 @@ _NODISCARD_PURE_FUNCTION constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* stre } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr _Ty bit_floor(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr _Ty bit_floor(const _Ty _Val) noexcept { if (_Val == 0) { return 0; } @@ -82,15 +82,15 @@ _NODISCARD_PURE_FUNCTION constexpr _Ty bit_floor(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr _Ty bit_width(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr _Ty bit_width(const _Ty _Val) noexcept { return static_cast<_Ty>(numeric_limits<_Ty>::digits - _STD countl_zero(_Val)); } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; +_NODISCARD_PURE_FN constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD_PURE_FN constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; const auto _Remainder = _Rotation % _Digits; if (_Remainder > 0) { @@ -104,7 +104,7 @@ _NODISCARD_PURE_FUNCTION constexpr _Ty rotl(const _Ty _Val, const int _Rotation) } template , int> _Enabled> -_NODISCARD_PURE_FUNCTION constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD_PURE_FN constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; const auto _Remainder = _Rotation % _Digits; if (_Remainder > 0) { @@ -234,7 +234,7 @@ _NODISCARD int _Checked_arm_arm64_countl_zero(const _Ty _Val) noexcept { #endif // defined(_M_ARM) || defined(_M_ARM64) template , int> _Enabled> -_NODISCARD_PURE_FUNCTION constexpr int countl_zero(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr int countl_zero(const _Ty _Val) noexcept { #if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) if (!_STD is_constant_evaluated()) { return _Checked_x86_x64_countl_zero(_Val); @@ -249,22 +249,22 @@ _NODISCARD_PURE_FUNCTION constexpr int countl_zero(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr int countl_one(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr int countl_one(const _Ty _Val) noexcept { return _STD countl_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr int countr_zero(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr int countr_zero(const _Ty _Val) noexcept { return _Countr_zero(_Val); } template , int> _Enabled = 0> -_NODISCARD_PURE_FUNCTION constexpr int countr_one(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr int countr_one(const _Ty _Val) noexcept { return _Countr_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD_PURE_FUNCTION constexpr int popcount(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr int popcount(const _Ty _Val) noexcept { return _Popcount(_Val); } diff --git a/stl/inc/latch b/stl/inc/latch index f764cda0aa4..e2dd618ab7a 100644 --- a/stl/inc/latch +++ b/stl/inc/latch @@ -31,7 +31,7 @@ _STD_BEGIN class latch { public: - _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { return (1ULL << (sizeof(ptrdiff_t) * CHAR_BIT - 1)) - 1; } diff --git a/stl/inc/mutex b/stl/inc/mutex index 0163edbe9fb..bb33024e743 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -50,7 +50,7 @@ public: _Check_C_return(_Mtx_lock(_Mymtx())); } - _NODISCARD_MODIFY_STATE bool try_lock() { + _NODISCARD_TRY_CHANGE_STATE bool try_lock() { const auto _Res = _Mtx_trylock(_Mymtx()); switch (_Res) { case _Thrd_success: @@ -68,7 +68,7 @@ public: using native_handle_type = void*; - _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() { + _NODISCARD_ACCESS_MTHD native_handle_type native_handle() { return _Mtx_getconcrtcs(_Mymtx()); } @@ -96,7 +96,7 @@ class recursive_mutex : public _Mutex_base { // class for recursive mutual exclu public: recursive_mutex() : _Mutex_base(_Mtx_recursive) {} - _NODISCARD_MODIFY_STATE bool try_lock() noexcept { + _NODISCARD_TRY_CHANGE_STATE bool try_lock() noexcept { return _Mutex_base::try_lock(); } @@ -195,21 +195,21 @@ public: _Owns = true; } - _NODISCARD_MODIFY_STATE bool try_lock() { + _NODISCARD_TRY_CHANGE_STATE bool try_lock() { _Validate(); _Owns = _Pmtx->try_lock(); return _Owns; } template - _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { _Validate(); _Owns = _Pmtx->try_lock_for(_Rel_time); return _Owns; } template - _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); #endif // _HAS_CXX20 @@ -218,7 +218,7 @@ public: return _Owns; } - _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const xtime* _Abs_time) { _Validate(); _Owns = _Pmtx->try_lock_until(_Abs_time); return _Owns; @@ -245,7 +245,7 @@ public: return _Res; } - _NODISCARD_PURE_METHOD bool owns_lock() const noexcept { + _NODISCARD_PURE_MTHD bool owns_lock() const noexcept { return _Owns; } @@ -253,7 +253,7 @@ public: return _Owns; } - _NODISCARD_PURE_METHOD _Mutex* mutex() const noexcept { + _NODISCARD_PURE_MTHD _Mutex* mutex() const noexcept { return _Pmtx; } @@ -347,7 +347,7 @@ int _Try_lock1(_Lock0& _Lk0, _Lock1& _Lk1) { } template -_NODISCARD_MODIFY_STATE_FUNCTION int try_lock( +_NODISCARD_TRY_CHANGE_STATE_FN int try_lock( _Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks return _Try_lock1(_Lk0, _Lk1, _LkN...); } @@ -683,7 +683,7 @@ public: return _Wait_until1(_Lck, _Abs_time, _Pred); } - _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() { + _NODISCARD_ACCESS_MTHD native_handle_type native_handle() { return _Mycnd(); } @@ -758,7 +758,7 @@ public: _My_locked = UINT_MAX; } - _NODISCARD_MODIFY_STATE bool try_lock() noexcept { // try to lock the mutex + _NODISCARD_TRY_CHANGE_STATE bool try_lock() noexcept { // try to lock the mutex lock_guard _Lock(_My_mutex); if (_My_locked != 0) { return false; @@ -778,7 +778,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_for( + _NODISCARD_TRY_CHANGE_STATE bool try_lock_for( const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } @@ -795,7 +795,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex with timeout #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -803,7 +803,7 @@ public: return _Try_lock_until(_Abs_time); } - _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout return _Try_lock_until(_Abs_time); } @@ -841,7 +841,7 @@ public: } } - _NODISCARD_MODIFY_STATE bool try_lock() noexcept { // try to lock the mutex + _NODISCARD_TRY_CHANGE_STATE bool try_lock() noexcept { // try to lock the mutex const thread::id _Tid = this_thread::get_id(); lock_guard _Lock(_My_mutex); @@ -881,7 +881,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_for( + _NODISCARD_TRY_CHANGE_STATE bool try_lock_for( const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } @@ -910,7 +910,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex with timeout #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -918,7 +918,7 @@ public: return _Try_lock_until(_Abs_time); } - _NODISCARD_MODIFY_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const xtime* _Abs_time) { // try to lock the mutex with timeout return _Try_lock_until(_Abs_time); } diff --git a/stl/inc/semaphore b/stl/inc/semaphore index 5779b644e87..8956452e32c 100644 --- a/stl/inc/semaphore +++ b/stl/inc/semaphore @@ -58,7 +58,7 @@ inline constexpr ptrdiff_t _Semaphore_max = (1ULL << (sizeof(ptrdiff_t) * CHAR_B template class counting_semaphore { public: - _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { return _Least_max_value; } @@ -139,7 +139,7 @@ public: } } - _NODISCARD_MODIFY_STATE bool try_acquire() noexcept { + _NODISCARD_TRY_CHANGE_STATE bool try_acquire() noexcept { ptrdiff_t _Current = _Counter.load(); if (_Current == 0) { return false; @@ -152,7 +152,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { auto _Deadline = _Semaphore_deadline(_Rel_time); ptrdiff_t _Current = _Counter.load(memory_order_relaxed); for (;;) { @@ -176,7 +176,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); ptrdiff_t _Current = _Counter.load(memory_order_relaxed); for (;;) { @@ -207,7 +207,7 @@ private: template <> class counting_semaphore<1> { public: - _NODISCARD_PURE_METHOD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { return 1; } @@ -245,7 +245,7 @@ public: } } - _NODISCARD_MODIFY_STATE bool try_acquire() noexcept { + _NODISCARD_TRY_CHANGE_STATE bool try_acquire() noexcept { // TRANSITION, GH-1133: should be memory_order_acquire unsigned char _Prev = _Counter.exchange(0); _STL_VERIFY((_Prev & ~1) == 0, "Invariant: semaphore counter is non-negative and doesn't exceed max(), " @@ -254,7 +254,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_acquire_for(const chrono::duration<_Rep, _Period>& _Rel_time) { auto _Deadline = _Semaphore_deadline(_Rel_time); for (;;) { // "happens after release" ordering is provided by this exchange, so loads and waits can be relaxed @@ -274,7 +274,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_acquire_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); for (;;) { // "happens after release" ordering is provided by this exchange, so loads and waits can be relaxed diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index 3c8afb3eaeb..70f29345268 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -40,7 +40,7 @@ public: _Smtx_lock_exclusive(&_Myhandle); } - _NODISCARD_MODIFY_STATE bool try_lock() noexcept /* strengthened */ { // try to lock exclusive + _NODISCARD_TRY_CHANGE_STATE bool try_lock() noexcept /* strengthened */ { // try to lock exclusive return _Smtx_try_lock_exclusive(&_Myhandle) != 0; } @@ -52,7 +52,7 @@ public: _Smtx_lock_shared(&_Myhandle); } - _NODISCARD_MODIFY_STATE bool try_lock_shared() noexcept /* strengthened */ { // try to lock non-exclusive + _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared() noexcept /* strengthened */ { // try to lock non-exclusive return _Smtx_try_lock_shared(&_Myhandle) != 0; } @@ -60,7 +60,7 @@ public: _Smtx_unlock_shared(&_Myhandle); } - _NODISCARD_ACCESSOR_METHOD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle + _NODISCARD_ACCESS_MTHD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle return &_Myhandle; } @@ -96,7 +96,7 @@ public: } } - _NODISCARD_MODIFY_STATE bool try_lock() { // try to lock exclusive + _NODISCARD_TRY_CHANGE_STATE bool try_lock() { // try to lock exclusive lock_guard _Lock(_Mymtx); if (_Writing || 0 < _Readers) { return false; @@ -107,13 +107,13 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_for( + _NODISCARD_TRY_CHANGE_STATE bool try_lock_for( const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock for duration return try_lock_until(_To_absolute_time(_Rel_time)); } template - _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock until time point #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -157,7 +157,7 @@ public: ++_Readers; } - _NODISCARD_MODIFY_STATE bool try_lock_shared() { // try to lock non-exclusive + _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared() { // try to lock non-exclusive lock_guard _Lock(_Mymtx); if (_Writing || _Readers == _Max_readers) { return false; @@ -168,7 +168,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock non-exclusive for relative time return try_lock_shared_until(_To_absolute_time(_Rel_time)); } @@ -188,7 +188,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock non-exclusive until absolute time #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -196,7 +196,7 @@ public: return _Try_lock_shared_until(_Abs_time); } - _NODISCARD_MODIFY_STATE bool try_lock_shared_until( + _NODISCARD_TRY_CHANGE_STATE bool try_lock_shared_until( const xtime* _Abs_time) { // try to lock non-exclusive until absolute time return _Try_lock_shared_until(_Abs_time); } @@ -299,14 +299,14 @@ public: _Owns = true; } - _NODISCARD_MODIFY_STATE bool try_lock() { // try to lock the mutex + _NODISCARD_TRY_CHANGE_STATE bool try_lock() { // try to lock the mutex _Validate(); _Owns = _Pmtx->try_lock_shared(); return _Owns; } template - _NODISCARD_MODIFY_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_for(const chrono::duration<_Rep, _Period>& _Rel_time) { // try to lock the mutex for _Rel_time _Validate(); _Owns = _Pmtx->try_lock_shared_for(_Rel_time); @@ -314,7 +314,7 @@ public: } template - _NODISCARD_MODIFY_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { + _NODISCARD_TRY_CHANGE_STATE bool try_lock_until(const chrono::time_point<_Clock, _Duration>& _Abs_time) { // try to lock the mutex until _Abs_time #if _HAS_CXX20 static_assert(chrono::is_clock_v<_Clock>, "Clock type required"); @@ -345,7 +345,7 @@ public: return _Res; } - _NODISCARD_PURE_METHOD bool owns_lock() const noexcept { + _NODISCARD_PURE_MTHD bool owns_lock() const noexcept { return _Owns; } @@ -353,7 +353,7 @@ public: return _Owns; } - _NODISCARD_PURE_METHOD mutex_type* mutex() const noexcept { + _NODISCARD_PURE_MTHD mutex_type* mutex() const noexcept { return _Pmtx; } diff --git a/stl/inc/source_location b/stl/inc/source_location index 316db1ebfa8..c2c63a9bea9 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -23,7 +23,7 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN struct source_location { - _NODISCARD_PURE_METHOD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), + _NODISCARD_PURE_MTHD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), const char* const _Function_ = __builtin_FUNCTION()) noexcept { source_location _Result; @@ -36,16 +36,16 @@ struct source_location { _NODISCARD_CTOR_PURE constexpr source_location() noexcept = default; - _NODISCARD_PURE_METHOD constexpr uint_least32_t line() const noexcept { + _NODISCARD_PURE_MTHD constexpr uint_least32_t line() const noexcept { return _Line; } - _NODISCARD_PURE_METHOD constexpr uint_least32_t column() const noexcept { + _NODISCARD_PURE_MTHD constexpr uint_least32_t column() const noexcept { return _Column; } - _NODISCARD_PURE_METHOD constexpr const char* file_name() const noexcept { + _NODISCARD_PURE_MTHD constexpr const char* file_name() const noexcept { return _File; } - _NODISCARD_PURE_METHOD constexpr const char* function_name() const noexcept { + _NODISCARD_PURE_MTHD constexpr const char* function_name() const noexcept { return _Function; } diff --git a/stl/inc/thread b/stl/inc/thread index 92eda6eea2a..b83789a215c 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -114,7 +114,7 @@ public: _STD swap(_Thr, _Other._Thr); } - _NODISCARD_PURE_METHOD bool joinable() const noexcept { + _NODISCARD_PURE_MTHD bool joinable() const noexcept { return _Thr._Id != 0; } @@ -143,14 +143,14 @@ public: _Thr = {}; } - _NODISCARD_PURE_METHOD id get_id() const noexcept; + _NODISCARD_PURE_MTHD id get_id() const noexcept; - _NODISCARD_PURE_METHOD native_handle_type native_handle() noexcept + _NODISCARD_PURE_MTHD native_handle_type native_handle() noexcept /* strengthened */ { // return Win32 HANDLE as void * return _Thr._Hnd; } - _NODISCARD_PURE_METHOD static unsigned int hardware_concurrency() noexcept { + _NODISCARD_PURE_MTHD static unsigned int hardware_concurrency() noexcept { return _Thrd_hardware_concurrency(); } @@ -175,7 +175,7 @@ _NODISCARD auto _To_absolute_time(const chrono::duration<_Rep, _Period>& _Rel_ti } namespace this_thread { - _NODISCARD_PURE_FUNCTION thread::id get_id() noexcept; + _NODISCARD_PURE_FN thread::id get_id() noexcept; inline void yield() noexcept { _Thrd_yield(); @@ -230,11 +230,11 @@ private: friend hash; }; -_NODISCARD_PURE_METHOD inline thread::id thread::get_id() const noexcept { +_NODISCARD_PURE_MTHD inline thread::id thread::get_id() const noexcept { return _Thr._Id; } -_NODISCARD_PURE_FUNCTION inline thread::id this_thread::get_id() noexcept { +_NODISCARD_PURE_FN inline thread::id this_thread::get_id() noexcept { return _Thrd_id(); } @@ -242,32 +242,32 @@ inline void swap(thread& _Left, thread& _Right) noexcept { _Left.swap(_Right); } -_NODISCARD_PURE_OPERATOR inline bool operator==(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline bool operator==(thread::id _Left, thread::id _Right) noexcept { return _Left._Id == _Right._Id; } #if _HAS_CXX20 -_NODISCARD_PURE_OPERATOR inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { return _Left._Id <=> _Right._Id; } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -_NODISCARD_PURE_OPERATOR inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { return !(_Left == _Right); } -_NODISCARD_PURE_OPERATOR inline bool operator<(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline bool operator<(thread::id _Left, thread::id _Right) noexcept { return _Left._Id < _Right._Id; } -_NODISCARD_PURE_OPERATOR inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { return !(_Right < _Left); } -_NODISCARD_PURE_OPERATOR inline bool operator>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline bool operator>(thread::id _Left, thread::id _Right) noexcept { return _Right < _Left; } -_NODISCARD_PURE_OPERATOR inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD_PURE_OP inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { return !(_Left < _Right); } #endif // !_HAS_CXX20 @@ -282,7 +282,7 @@ struct hash { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef thread::id _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD_PURE_METHOD size_t operator()(const thread::id _Keyval) const noexcept { + _NODISCARD_PURE_MTHD size_t operator()(const thread::id _Keyval) const noexcept { return _Hash_representation(_Keyval._Id); } }; @@ -328,7 +328,7 @@ public: _Ssource.swap(_Other._Ssource); } - _NODISCARD_PURE_METHOD bool joinable() const noexcept { + _NODISCARD_PURE_MTHD bool joinable() const noexcept { return _Impl.joinable(); } @@ -340,19 +340,19 @@ public: _Impl.detach(); } - _NODISCARD_PURE_METHOD id get_id() const noexcept { + _NODISCARD_PURE_MTHD id get_id() const noexcept { return _Impl.get_id(); } - _NODISCARD_PURE_METHOD native_handle_type native_handle() noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD native_handle_type native_handle() noexcept /* strengthened */ { return _Impl.native_handle(); } - _NODISCARD_ACCESSOR_METHOD stop_source get_stop_source() noexcept { + _NODISCARD_ACCESS_MTHD stop_source get_stop_source() noexcept { return _Ssource; } - _NODISCARD_PURE_METHOD stop_token get_stop_token() const noexcept { + _NODISCARD_PURE_MTHD stop_token get_stop_token() const noexcept { return _Ssource.get_token(); } @@ -364,7 +364,7 @@ public: _Lhs.swap(_Rhs); } - _NODISCARD_PURE_METHOD static unsigned int hardware_concurrency() noexcept { + _NODISCARD_PURE_MTHD static unsigned int hardware_concurrency() noexcept { return thread::hardware_concurrency(); } diff --git a/stl/inc/vector b/stl/inc/vector index f21247a5dc9..e88d16d3e8d 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -45,7 +45,7 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vector_const_iterator& operator=(const _Vector_const_iterator&) noexcept = default; - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -56,7 +56,7 @@ public: return *_Ptr; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -123,7 +123,7 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -133,52 +133,52 @@ public: return *this += -_Off; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 difference_type operator-( + _NODISCARD_PURE_OP _CONSTEXPR20 difference_type operator-( const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr - _Right._Ptr; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>( + _NODISCARD_PURE_OP constexpr strong_ordering operator<=>( const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Unfancy(_Ptr) <=> _Unfancy(_Right._Ptr); } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OPERATOR bool operator!=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator!=(const _Vector_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OPERATOR bool operator<(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator<(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr < _Right._Ptr; } - _NODISCARD_PURE_OPERATOR bool operator>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator>(const _Vector_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OPERATOR bool operator<=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator<=(const _Vector_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OPERATOR bool operator>=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator>=(const _Vector_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -214,7 +214,7 @@ public: }; template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( +_NODISCARD_PURE_OP _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( typename _Vector_const_iterator<_Myvec>::difference_type _Off, _Vector_const_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -227,7 +227,7 @@ struct pointer_traits<_Vector_const_iterator<_Myvec>> { using element_type = const typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD_PURE_METHOD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_MTHD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -266,11 +266,11 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vector_iterator& operator=(const _Vector_iterator&) noexcept = default; - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(this->_Ptr, "can't dereference value-initialized vector iterator"); @@ -308,7 +308,7 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -321,13 +321,13 @@ public: using _Mybase::operator-; - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -339,7 +339,7 @@ public: }; template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( +_NODISCARD_PURE_OP _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( typename _Vector_iterator<_Myvec>::difference_type _Off, _Vector_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -352,7 +352,7 @@ struct pointer_traits<_Vector_iterator<_Myvec>> { using element_type = typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD_PURE_METHOD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD_PURE_MTHD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -1371,63 +1371,63 @@ public: } } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty* data() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty* data() noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty* data() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty* data() const noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator begin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator begin() noexcept { auto& _My_data = _Mypair._Myval2; return iterator(_My_data._Myfirst, _STD addressof(_My_data)); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator begin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator begin() const noexcept { auto& _My_data = _Mypair._Myval2; return const_iterator(_My_data._Myfirst, _STD addressof(_My_data)); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator end() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator end() noexcept { auto& _My_data = _Mypair._Myval2; return iterator(_My_data._Mylast, _STD addressof(_My_data)); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator end() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator end() const noexcept { auto& _My_data = _Mypair._Myval2; return const_iterator(_My_data._Mylast, _STD addressof(_My_data)); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reverse_iterator rbegin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { return rend(); } @@ -1447,27 +1447,27 @@ public: return _Mypair._Myval2._Mylast; } - _NODISCARD_EMPTY_METHOD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD _CONSTEXPR20 bool empty() const noexcept { auto& _My_data = _Mypair._Myval2; return _My_data._Myfirst == _My_data._Mylast; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type size() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type size() const noexcept { auto& _My_data = _Mypair._Myval2; return static_cast(_My_data._Mylast - _My_data._Myfirst); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type max_size() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type max_size() const noexcept { return (_STD min) (static_cast((numeric_limits::max) ()), _Alty_traits::max_size(_Getal())); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type capacity() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type capacity() const noexcept { auto& _My_data = _Mypair._Myval2; return static_cast(_My_data._Myend - _My_data._Myfirst); } - _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ { + _NODISCARD_ACCESS_OP _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY( @@ -1477,7 +1477,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept + _NODISCARD_PURE_OP _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 @@ -1488,7 +1488,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty& at(const size_type _Pos) { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty& at(const size_type _Pos) { auto& _My_data = _Mypair._Myval2; if (static_cast(_My_data._Mylast - _My_data._Myfirst) <= _Pos) { _Xrange(); @@ -1497,7 +1497,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty& at(const size_type _Pos) const { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty& at(const size_type _Pos) const { auto& _My_data = _Mypair._Myval2; if (static_cast(_My_data._Mylast - _My_data._Myfirst) <= _Pos) { _Xrange(); @@ -1506,7 +1506,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty& front() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty& front() noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "front() called on empty vector"); @@ -1515,7 +1515,7 @@ public: return *_My_data._Myfirst; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty& front() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty& front() const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "front() called on empty vector"); @@ -1524,7 +1524,7 @@ public: return *_My_data._Myfirst; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 _Ty& back() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty& back() noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "back() called on empty vector"); @@ -1533,7 +1533,7 @@ public: return _My_data._Mylast[-1]; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const _Ty& back() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty& back() const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "back() called on empty vector"); @@ -1542,7 +1542,7 @@ public: return _My_data._Mylast[-1]; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 allocator_type get_allocator() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 allocator_type get_allocator() const noexcept { return static_cast(_Getal()); } @@ -1778,7 +1778,7 @@ using _Vbase = unsigned int; // word type for vector representatio constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==( +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator==( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if (_Left.size() != _Right.size()) { return false; @@ -1794,7 +1794,7 @@ _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==( #if !_HAS_CXX20 template -_NODISCARD_PURE_OPERATOR bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OP bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 @@ -1816,7 +1816,7 @@ _NODISCARD_PURE_OPERATOR bool operator!=(const vector<_Ty, _Alloc>& _Left, const template struct _Vbase_compare_three_way { - _NODISCARD_PURE_OPERATOR constexpr _Ret operator()(const _Vbase _Left, const _Vbase _Right) const noexcept { + _NODISCARD_PURE_OP constexpr _Ret operator()(const _Vbase _Left, const _Vbase _Right) const noexcept { const _Vbase _Differing_bits = _Left ^ _Right; if (_Differing_bits == 0) { // improves _Countr_zero codegen below @@ -1843,7 +1843,7 @@ struct _Vbase_compare_three_way { #ifdef __cpp_lib_concepts template -_NODISCARD_PURE_OPERATOR constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD_PURE_OP constexpr _Synth_three_way_result<_Ty> operator<=>( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. @@ -1868,7 +1868,7 @@ _NODISCARD_PURE_OPERATOR constexpr _Synth_three_way_result<_Ty> operator<=>( } #else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<( +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. @@ -1896,19 +1896,19 @@ _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<( } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>( +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator<=( +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<=( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Right < _Left); } template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator>=( +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>=( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left < _Right); } @@ -2058,7 +2058,7 @@ public: // TRANSITION, DevCom-1331017 _CONSTEXPR20 _Vb_const_iterator& operator=(const _Vb_const_iterator&) noexcept = default; - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const_reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 const_reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Cont = static_cast(this->_Getcont()); _STL_VERIFY(_Cont, "cannot dereference value-initialized vector iterator"); @@ -2118,7 +2118,7 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_const_iterator operator+(const difference_type _Off) const noexcept { _Vb_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -2128,29 +2128,29 @@ public: return *this += -_Off; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_const_iterator operator-(const difference_type _Off) const noexcept { _Vb_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 difference_type operator-(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 difference_type operator-(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_VBITS * (this->_Myptr - _Right._Myptr)) + static_cast(this->_Myoff) - static_cast(_Right._Myoff); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const_reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 const_reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 bool operator==(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return this->_Myptr == _Right._Myptr && this->_Myoff == _Right._Myoff; } #if _HAS_CXX20 - _NODISCARD_PURE_OPERATOR constexpr strong_ordering operator<=>(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); if (const auto _CmpResult = this->_Myptr <=> _Right._Myptr; _CmpResult != 0) { return _CmpResult; @@ -2158,24 +2158,24 @@ public: return this->_Myoff <=> _Right._Myoff; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OPERATOR bool operator!=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator!=(const _Vb_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OPERATOR bool operator<(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator<(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return this->_Myptr < _Right._Myptr || (this->_Myptr == _Right._Myptr && this->_Myoff < _Right._Myoff); } - _NODISCARD_PURE_OPERATOR bool operator>(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator>(const _Vb_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OPERATOR bool operator<=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator<=(const _Vb_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OPERATOR bool operator>=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator>=(const _Vb_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -2231,7 +2231,7 @@ public: }; template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_const_iterator<_Alvbase_wrapped> operator+( +_NODISCARD_PURE_OP _CONSTEXPR20 _Vb_const_iterator<_Alvbase_wrapped> operator+( typename _Vb_const_iterator<_Alvbase_wrapped>::difference_type _Off, _Vb_const_iterator<_Alvbase_wrapped> _Right) noexcept { _Right += _Off; @@ -2256,7 +2256,7 @@ public: using _Mybase::_Mybase; - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Cont = static_cast(this->_Getcont()); _STL_VERIFY(_Cont, "cannot dereference value-initialized vector iterator"); @@ -2297,7 +2297,7 @@ public: return *this; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_iterator operator+(const difference_type _Off) const noexcept { _Vb_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -2310,13 +2310,13 @@ public: using _Mybase::operator-; - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_iterator operator-(const difference_type _Off) const noexcept { _Vb_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } @@ -2324,7 +2324,7 @@ public: }; template -_NODISCARD_PURE_OPERATOR _CONSTEXPR20 _Vb_iterator<_Alvbase_wrapped> operator+( +_NODISCARD_PURE_OP _CONSTEXPR20 _Vb_iterator<_Alvbase_wrapped> operator+( typename _Vb_iterator<_Alvbase_wrapped>::difference_type _Off, _Vb_iterator<_Alvbase_wrapped> _Right) noexcept { _Right += _Off; return _Right; @@ -2618,39 +2618,39 @@ public: this->_Myvec.reserve(this->_Nw(_Count)); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type capacity() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type capacity() const noexcept { return this->_Myvec.capacity() * _VBITS; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator begin() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator begin() noexcept { return iterator(this->_Myvec.data(), this); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator begin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator begin() const noexcept { return const_iterator(this->_Myvec.data(), this); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 iterator end() noexcept { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator end() noexcept { return begin() + static_cast(this->_Mysize); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator end() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator end() const noexcept { return begin() + static_cast(this->_Mysize); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_iterator cend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { return rend(); } @@ -2686,19 +2686,19 @@ public: return _Tmp; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 reverse_iterator rbegin() noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } @@ -2710,11 +2710,11 @@ public: } } - _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type size() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type size() const noexcept { return this->_Mysize; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 size_type max_size() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type max_size() const noexcept { constexpr auto _Diff_max = static_cast((numeric_limits::max) ()); const size_type _Ints_max = this->_Myvec.max_size(); if (_Ints_max > _Diff_max / _VBITS) { // max_size bound by difference_type limits @@ -2725,15 +2725,15 @@ public: return _Ints_max * _VBITS; } - _NODISCARD_EMPTY_METHOD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD _CONSTEXPR20 bool empty() const noexcept { return this->_Mysize == 0; } - _NODISCARD_PURE_METHOD _CONSTEXPR20 allocator_type get_allocator() const noexcept { + _NODISCARD_PURE_MTHD _CONSTEXPR20 allocator_type get_allocator() const noexcept { return static_cast(this->_Myvec.get_allocator()); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reference at(size_type _Off) const { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reference at(size_type _Off) const { if (size() <= _Off) { _Xran(); } @@ -2741,7 +2741,7 @@ public: return (*this)[_Off]; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reference at(size_type _Off) { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reference at(size_type _Off) { if (size() <= _Off) { _Xran(); } @@ -2749,7 +2749,7 @@ public: return (*this)[_Off]; } - _NODISCARD_PURE_OPERATOR _CONSTEXPR20 const_reference operator[](size_type _Off) const noexcept /* strengthened */ { + _NODISCARD_PURE_OP _CONSTEXPR20 const_reference operator[](size_type _Off) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < this->_Mysize, "vector subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2759,7 +2759,7 @@ public: return *_It; } - _NODISCARD_ACCESSOR_OPERATOR _CONSTEXPR20 reference operator[](size_type _Off) noexcept /* strengthened */ { + _NODISCARD_ACCESS_OP _CONSTEXPR20 reference operator[](size_type _Off) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < this->_Mysize, "vector subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2769,7 +2769,7 @@ public: return *_It; } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reference front() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "front() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2777,7 +2777,7 @@ public: return *begin(); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reference front() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "front() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2785,7 +2785,7 @@ public: return *begin(); } - _NODISCARD_ACCESSOR_METHOD _CONSTEXPR20 reference back() noexcept /* strengthened */ { + _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "back() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -2793,7 +2793,7 @@ public: return *(end() - 1); } - _NODISCARD_PURE_METHOD _CONSTEXPR20 const_reference back() const noexcept /* strengthened */ { + _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "back() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3030,7 +3030,7 @@ struct hash> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef vector _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD_PURE_OPERATOR size_t operator()(const vector& _Keyval) const noexcept { + _NODISCARD_PURE_OP size_t operator()(const vector& _Keyval) const noexcept { return _Hash_array_representation(_Keyval._Myvec.data(), _Keyval._Myvec.size()); } }; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index aaaa93c14fe..ddce90754c9 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -437,47 +437,49 @@ #define _NODISCARD_CTOR_MSG(_Msg) #endif -#define _NODISCARD_PURE_ALGORITHM \ +#define _NODISCARD_PURE_ALG \ _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ "and discard the return value") -#define _NODISCARD_PURE_FUNCTION \ +#define _NODISCARD_PURE_FN \ _NODISCARD_MSG("This function is pure, i.e. has no side effects; it is not useful to call this function and " \ "discard the return value") -#define _NODISCARD_PURE_METHOD \ +#define _NODISCARD_PURE_MTHD \ _NODISCARD_MSG("This method is pure obeserver, i.e. has no side effects; it is not useful to call this method " \ "and discard the return value") -#define _NODISCARD_PURE_OPERATOR \ +#define _NODISCARD_PURE_OP \ _NODISCARD_MSG("This operator is pure obeserver, i.e. has no side effects; it is not useful to call this " \ "operator and discard the return value") -#define _NODISCARD_ACCESSOR_FUNCTION \ +#define _NODISCARD_ACCESS_FN \ _NODISCARD_MSG("This function returns a value that provides access to the passed object and has no side effects " \ "otherwise; it is not useful to call this function and discard the return value") -#define _NODISCARD_ACCESSOR_METHOD \ +#define _NODISCARD_ACCESS_MTHD \ _NODISCARD_MSG("This method returns an object that can access the state of the current object and has no other " \ "side effects; it is not useful to call this method and discard the return value") -#define _NODISCARD_ACCESSOR_OPERATOR \ +#define _NODISCARD_ACCESS_OP \ _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ "no other side effects; it is not useful to call this operator and discard the return value") -#define _NODISCARD_REMOVE_ALGORITHM \ +#define _NODISCARD_REMOVE_ALG \ _NODISCARD_MSG( \ "The 'remove', 'remove_if', and 'unique' algorithms return the iterator past the last non-removed element. " \ - "Normally you need to use the result to call container's erase method afterwards to erase elements. " \ - "In C++ 20 you can also use erase and erase_if functions to replace these two steps.") + "Normally you need to use the result to call container's 'erase' method afterwards to erase elements. " \ + "In C++ 20 you can also use 'erase' and 'erase_if' functions to replace the two steps") -#define _NODISCARD_EMPTY_METHOD \ - _NODISCARD_MSG("This method checks whether the container is empty. Use 'clear()' method if you intend to clear " \ - "the container.") +#define _NODISCARD_EMPTY_MTHD \ + _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "Use 'clear()' method if you intend to clear the container instead") -#define _NODISCARD_EMPTY_METHOD_ARRAY \ - _NODISCARD_MSG( \ - "This method checks whether the array is empty. There's no way to clear an array, as its size is fixed.") +#define _NODISCARD_EMPTY_MTHD_ARRAY \ + _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "There's no way to clear an array as its size is fixed") #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") @@ -486,23 +488,34 @@ _NODISCARD_MSG("This method returns the state of the synchronization object and does not do anything else; it is " \ "not useful to call this method and discard the return value") -#define _NODISCARD_MODIFY_STATE \ +#define _NODISCARD_TRY_CHANGE_STATE \ _NODISCARD_MSG("This method returns whether the operation succeeds in modifying the state of the object or not. " \ "It is dangerous to ignore the return value") -#define _NODISCARD_MODIFY_STATE_FUNCTION \ +#define _NODISCARD_TRY_CHANGE_STATE_FN \ _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ "objects or not. It is dangerous to ignore the return value") +#ifdef _NODISCARD_LOCK_SUPPRESS + +#define _NODISCARD_LOCK +#define _NODISCARD_CTOR_LOCK + +#else // ^^^ defined(_NODISCARD_LOCK_SUPPRESS) ^^^ / vvv !defined(_NODISCARD_LOCK_SUPPRESS) vvv + #define _NODISCARD_LOCK \ _NODISCARD_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intetion is to protect the rest of the " \ - "current statement, using comma operator, please use cast to void to suppress this warning).") + "current statement, using comma operator, please use cast to void to suppress this warning. " \ + "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") #define _NODISCARD_CTOR_LOCK \ _NODISCARD_CTOR_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intetion is to protect the rest of the " \ - "current statement, using comma operator, please use cast to void to suppress this warning).") + "current statement, using comma operator, please use cast to void to suppress this warning)" \ + "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") + +#endif // ^^^ !defined(_NODISCARD_LOCK_SUPPRESS) ^^^ #define _NODISCARD_CTOR_THREAD \ _NODISCARD_CTOR_MSG("Thread is not joined or detached, terminate will be called at the end of the statement") From 8005b8f12a1146f898078726400d8fb7dc421a3a Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 11:03:23 +0300 Subject: [PATCH 17/73] clang-format --- stl/inc/array | 3 +-- stl/inc/mutex | 3 +-- stl/inc/vector | 21 +++++++-------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/stl/inc/array b/stl/inc/array index 02e9ab168f3..a65aa6ea3da 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -563,8 +563,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_PURE_OP constexpr const_reference operator[]( - _In_range_(0, _Size - 1) size_type _Pos) const noexcept + _NODISCARD_PURE_OP constexpr const_reference operator[](_In_range_(0, _Size - 1) size_type _Pos) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); diff --git a/stl/inc/mutex b/stl/inc/mutex index bb33024e743..fc2c920dd7d 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -347,8 +347,7 @@ int _Try_lock1(_Lock0& _Lk0, _Lock1& _Lk1) { } template -_NODISCARD_TRY_CHANGE_STATE_FN int try_lock( - _Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks +_NODISCARD_TRY_CHANGE_STATE_FN int try_lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks return _Try_lock1(_Lk0, _Lk1, _LkN...); } diff --git a/stl/inc/vector b/stl/inc/vector index e88d16d3e8d..d108bac8311 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -139,8 +139,7 @@ public: return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR20 difference_type operator-( - const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP _CONSTEXPR20 difference_type operator-(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr - _Right._Ptr; } @@ -155,8 +154,7 @@ public: } #if _HAS_CXX20 - _NODISCARD_PURE_OP constexpr strong_ordering operator<=>( - const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Unfancy(_Ptr) <=> _Unfancy(_Right._Ptr); } @@ -1778,8 +1776,7 @@ using _Vbase = unsigned int; // word type for vector representatio constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator==( - const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if (_Left.size() != _Right.size()) { return false; } @@ -1868,8 +1865,7 @@ _NODISCARD_PURE_OP constexpr _Synth_three_way_result<_Ty> operator<=>( } #else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<( - const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. auto _First = _Left._Myvec._Unchecked_begin(); @@ -1896,20 +1892,17 @@ _NODISCARD_PURE_OP _CONSTEXPR20 bool operator<( } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>( - const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<=( - const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Right < _Left); } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>=( - const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ From 6b81546d484503bf305dbc4a4865080213dc4e62 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 13:12:58 +0300 Subject: [PATCH 18/73] any accessor --- stl/inc/any | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/any b/stl/inc/any index fef3c7d5934..8e88605b092 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -384,7 +384,7 @@ _NODISCARD_PURE_FN const _ValueType* any_cast(const any* const _Any) noexcept { } } template -_NODISCARD_PURE_FN _ValueType* any_cast(any* const _Any) noexcept { +_NODISCARD_ACESS_FN _ValueType* any_cast(any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -413,7 +413,7 @@ _NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(const any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(any& _Any) { +_NODISCARD_ACESS_FN remove_cv_t<_Ty> any_cast(any& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>&>, "any_cast(any&) requires remove_cv_t to be constructible from remove_cv_t>&"); @@ -425,7 +425,7 @@ _NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(any&& _Any) { +_NODISCARD_ACESS_FN remove_cv_t<_Ty> any_cast(any&& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>>, "any_cast(any&&) requires remove_cv_t to be constructible from remove_cv_t>"); From 8469c10060ab0b550d7373faf9ff22ad49d82e0c Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 13:13:14 +0300 Subject: [PATCH 19/73] spelling --- stl/inc/yvals_core.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index ddce90754c9..365cb27c4ce 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -445,8 +445,8 @@ _NODISCARD_MSG("This function is pure, i.e. has no side effects; it is not useful to call this function and " \ "discard the return value") -#define _NODISCARD_PURE_MTHD \ - _NODISCARD_MSG("This method is pure obeserver, i.e. has no side effects; it is not useful to call this method " \ +#define _NODISCARD_PURE_MTHD \ + _NODISCARD_MSG("This method is pure observer, i.e. has no side effects; it is not useful to call this method " \ "and discard the return value") #define _NODISCARD_PURE_OP \ @@ -503,22 +503,22 @@ #else // ^^^ defined(_NODISCARD_LOCK_SUPPRESS) ^^^ / vvv !defined(_NODISCARD_LOCK_SUPPRESS) vvv -#define _NODISCARD_LOCK \ - _NODISCARD_MSG( \ - "A lock should be saved in a variable to protect the scope. (If the intetion is to protect the rest of the " \ - "current statement, using comma operator, please use cast to void to suppress this warning. " \ +#define _NODISCARD_LOCK \ + _NODISCARD_MSG( \ + "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ + "current statement, using comma operator, please use cast to void to suppress this warning. " \ "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") -#define _NODISCARD_CTOR_LOCK \ - _NODISCARD_CTOR_MSG( \ - "A lock should be saved in a variable to protect the scope. (If the intetion is to protect the rest of the " \ - "current statement, using comma operator, please use cast to void to suppress this warning)" \ +#define _NODISCARD_CTOR_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ + "current statement, using comma operator, please use cast to void to suppress this warning)" \ "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") #endif // ^^^ !defined(_NODISCARD_LOCK_SUPPRESS) ^^^ #define _NODISCARD_CTOR_THREAD \ - _NODISCARD_CTOR_MSG("Thread is not joined or detached, terminate will be called at the end of the statement") + _NODISCARD_CTOR_MSG("Thread is not joined or detached, 'terminate' will be called at the end of the statement") #define _NODISCARD_CTOR_JTHREAD \ _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention?") From 7f41c9a474765e039f0c90998a515317e5ac5964 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 13:44:39 +0300 Subject: [PATCH 20/73] typo --- stl/inc/any | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/any b/stl/inc/any index 8e88605b092..71113451108 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -413,7 +413,7 @@ _NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(const any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_ACESS_FN remove_cv_t<_Ty> any_cast(any& _Any) { +_NODISCARD_ACCESS_FN remove_cv_t<_Ty> any_cast(any& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>&>, "any_cast(any&) requires remove_cv_t to be constructible from remove_cv_t>&"); @@ -425,7 +425,7 @@ _NODISCARD_ACESS_FN remove_cv_t<_Ty> any_cast(any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_ACESS_FN remove_cv_t<_Ty> any_cast(any&& _Any) { +_NODISCARD_ACCESS_FN remove_cv_t<_Ty> any_cast(any&& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>>, "any_cast(any&&) requires remove_cv_t to be constructible from remove_cv_t>"); From 31f506c966125ea216756dd300e2d2600fe00068 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 14:13:54 +0300 Subject: [PATCH 21/73] unique --- stl/inc/algorithm | 12 ++++++------ stl/inc/yvals_core.h | 17 +++++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 2f43b6d256d..4670d692587 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -3671,7 +3671,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD_UNIQUE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // remove each satisfying _Pred with previous _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -3696,20 +3696,20 @@ _NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _P } template -_NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous +_NODISCARD_UNIQUE_ALG _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last) { // remove each matching previous return _STD unique(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_REMOVE_ALG _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_UNIQUE_ALG _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // remove each satisfying _Pred with previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last, _Pass_fn(_Pred)); } template = 0> -_NODISCARD_REMOVE_ALG _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD_UNIQUE_ALG _FwdIt unique(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // remove each matching previous // not parallelized at present, parallelism expected to be feasible in a future release return _STD unique(_First, _Last); @@ -3724,7 +3724,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_equivalence_relation> _Pr = ranges::equal_to> - _NODISCARD_REMOVE_ALG constexpr subrange<_It> operator()( + _NODISCARD_UNIQUE_ALG constexpr subrange<_It> operator()( _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _Unique_unchecked( @@ -3737,7 +3737,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::equal_to> requires permutable> - _NODISCARD_REMOVE_ALG constexpr borrowed_subrange_t<_Rng> operator()( + _NODISCARD_UNIQUE_ALG constexpr borrowed_subrange_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UResult = _Unique_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 365cb27c4ce..ec8cc2ce683 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -465,12 +465,17 @@ _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ "no other side effects; it is not useful to call this operator and discard the return value") -#define _NODISCARD_REMOVE_ALG \ - _NODISCARD_MSG( \ - "The 'remove', 'remove_if', and 'unique' algorithms return the iterator past the last non-removed element. " \ - "Normally you need to use the result to call container's 'erase' method afterwards to erase elements. " \ +#define _NODISCARD_REMOVE_ALG \ + _NODISCARD_MSG( \ + "The 'remove' and 'remove_if' algorithms return the iterator past the last non-removed element. " \ + "Normally you need to use the result to call container's 'erase' method afterwards to erase elements. " \ "In C++ 20 you can also use 'erase' and 'erase_if' functions to replace the two steps") +#define _NODISCARD_UNIQUE_ALG \ + _NODISCARD_MSG( \ + "The 'unique' algorithms return the iterator past the last non-removed element. " \ + "Normally you need to use the result to call container's 'erase' method afterwards to erase elements" + #define _NODISCARD_EMPTY_MTHD \ _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ @@ -506,13 +511,13 @@ #define _NODISCARD_LOCK \ _NODISCARD_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ - "current statement, using comma operator, please use cast to void to suppress this warning. " \ + "current expression, using comma operator, please use cast to void to suppress this warning. " \ "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") #define _NODISCARD_CTOR_LOCK \ _NODISCARD_CTOR_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ - "current statement, using comma operator, please use cast to void to suppress this warning)" \ + "current expression, using comma operator, please use cast to void to suppress this warning)" \ "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") #endif // ^^^ !defined(_NODISCARD_LOCK_SUPPRESS) ^^^ From 9c1db4a963a1f53bad55b8d8d1fc9bb7b09c1d3d Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 15:42:09 +0300 Subject: [PATCH 22/73] ) --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index ec8cc2ce683..4f157e6f5c4 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -474,7 +474,7 @@ #define _NODISCARD_UNIQUE_ALG \ _NODISCARD_MSG( \ "The 'unique' algorithms return the iterator past the last non-removed element. " \ - "Normally you need to use the result to call container's 'erase' method afterwards to erase elements" + "Normally you need to use the result to call container's 'erase' method afterwards to erase elements") #define _NODISCARD_EMPTY_MTHD \ _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ From 2fdb8abb6d4af39213ae83969bf2a916c0bcddd1 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 16:37:51 +0300 Subject: [PATCH 23/73] fix build --- stl/inc/any | 2 +- stl/inc/yvals_core.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/any b/stl/inc/any index 71113451108..d07c6005498 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -384,7 +384,7 @@ _NODISCARD_PURE_FN const _ValueType* any_cast(const any* const _Any) noexcept { } } template -_NODISCARD_ACESS_FN _ValueType* any_cast(any* const _Any) noexcept { +_NODISCARD_ACCESS_FN _ValueType* any_cast(any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 4f157e6f5c4..9165da4095a 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -512,13 +512,13 @@ _NODISCARD_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ "current expression, using comma operator, please use cast to void to suppress this warning. " \ - "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") + "Alternatively, define _NODISCARD_LOCK_SUPPRESS)") #define _NODISCARD_CTOR_LOCK \ _NODISCARD_CTOR_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ - "current expression, using comma operator, please use cast to void to suppress this warning)" \ - "Alternatively, define _NODISCARD_LOCK_SUPPRESS.)") + "current expression, using comma operator, please use cast to void to suppress this warning. " \ + "Alternatively, define _NODISCARD_LOCK_SUPPRESS)") #endif // ^^^ !defined(_NODISCARD_LOCK_SUPPRESS) ^^^ From 26cb8f7cfee148915ffcb4baed6b7b74335ab543 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 17:42:24 +0300 Subject: [PATCH 24/73] memory --- stl/inc/memory | 234 ++++++++++++++++++++++--------------------- stl/inc/yvals_core.h | 8 ++ 2 files changed, 127 insertions(+), 115 deletions(-) diff --git a/stl/inc/memory b/stl/inc/memory index 7f2ca6eb710..8b944177b51 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -883,7 +883,7 @@ public: explicit raw_storage_iterator(_OutIt _First) : _Next(_First) {} - _NODISCARD raw_storage_iterator& operator*() { // pretend to return designated value + _NODISCARD_ACCESS_OP raw_storage_iterator& operator*() { // pretend to return designated value return *this; } @@ -908,7 +908,7 @@ public: return _Ans; } - _NODISCARD _OutIt base() const { + _NODISCARD_PURE_MTHD _OutIt base() const { return _Next; } @@ -982,7 +982,7 @@ public: delete _Myptr; } - _NODISCARD _Ty& operator*() const noexcept { + _NODISCARD_PURE_OP _Ty& operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL == 2 _STL_VERIFY(_Myptr, "auto_ptr not dereferenceable"); #endif // _ITERATOR_DEBUG_LEVEL == 2 @@ -990,7 +990,7 @@ public: return *get(); } - _NODISCARD _Ty* operator->() const noexcept { + _NODISCARD_PURE_OP _Ty* operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL == 2 _STL_VERIFY(_Myptr, "auto_ptr not dereferenceable"); #endif // _ITERATOR_DEBUG_LEVEL == 2 @@ -998,7 +998,7 @@ public: return get(); } - _NODISCARD _Ty* get() const noexcept { + _NODISCARD_PURE_MTHD _Ty* get() const noexcept { return _Myptr; } @@ -1032,7 +1032,7 @@ class bad_weak_ptr : public exception { // exception type for invalid use of exp public: bad_weak_ptr() noexcept {} - _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD_PURE_MTHD const char* __CLR_OR_THIS_CALL what() const noexcept override { // return pointer to message string return "bad_weak_ptr"; } @@ -1242,12 +1242,13 @@ class _Ptr_base { // base class for shared_ptr and weak_ptr public: using element_type = remove_extent_t<_Ty>; - _NODISCARD long use_count() const noexcept { + _NODISCARD_PURE_MTHD long use_count() const noexcept { return _Rep ? _Rep->_Use_count() : 0; } template - _NODISCARD bool owner_before(const _Ptr_base<_Ty2>& _Right) const noexcept { // compare addresses of manager objects + _NODISCARD_PURE_MTHD bool owner_before( + const _Ptr_base<_Ty2>& _Right) const noexcept { // compare addresses of manager objects return _Rep < _Right._Rep; } @@ -1255,7 +1256,7 @@ public: _Ptr_base& operator=(const _Ptr_base&) = delete; protected: - _NODISCARD element_type* get() const noexcept { + _NODISCARD_PURE_MTHD element_type* get() const noexcept { return _Ptr; } @@ -1673,22 +1674,22 @@ public: using _Mybase::get; template , is_void<_Ty2>>, int> = 0> - _NODISCARD _Ty2& operator*() const noexcept { + _NODISCARD_PURE_OP _Ty2& operator*() const noexcept { return *get(); } template , int> = 0> - _NODISCARD _Ty2* operator->() const noexcept { + _NODISCARD_PURE_OP _Ty2* operator->() const noexcept { return get(); } template , int> = 0> - _NODISCARD _Elem& operator[](ptrdiff_t _Idx) const noexcept /* strengthened */ { + _NODISCARD_PURE_OP _Elem& operator[](ptrdiff_t _Idx) const noexcept /* strengthened */ { return get()[_Idx]; } #if _HAS_DEPRECATED_SHARED_PTR_UNIQUE - _CXX17_DEPRECATE_SHARED_PTR_UNIQUE _NODISCARD bool unique() const noexcept { + _CXX17_DEPRECATE_SHARED_PTR_UNIQUE _NODISCARD_PURE_MTHD bool unique() const noexcept { // return true if no other shared_ptr object owns this resource return this->use_count() == 1; } @@ -1788,105 +1789,105 @@ shared_ptr(unique_ptr<_Ty, _Dx>) -> shared_ptr<_Ty>; #endif // _HAS_CXX17 template -_NODISCARD bool operator==(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator==(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() == _Right.get(); } #if _HAS_CXX20 template -_NODISCARD strong_ordering operator<=>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP strong_ordering operator<=>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() <=> _Right.get(); } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template -_NODISCARD bool operator!=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator!=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() != _Right.get(); } template -_NODISCARD bool operator<(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator<(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() < _Right.get(); } template -_NODISCARD bool operator>=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator>=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() >= _Right.get(); } template -_NODISCARD bool operator>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() > _Right.get(); } template -_NODISCARD bool operator<=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator<=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() <= _Right.get(); } #endif // ^^^ !_HAS_CXX20 ^^^ template -_NODISCARD bool operator==(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator==(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() == nullptr; } #if _HAS_CXX20 template -_NODISCARD strong_ordering operator<=>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP strong_ordering operator<=>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() <=> static_cast::element_type*>(nullptr); } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template -_NODISCARD bool operator==(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator==(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return nullptr == _Right.get(); } template -_NODISCARD bool operator!=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator!=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() != nullptr; } template -_NODISCARD bool operator!=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator!=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return nullptr != _Right.get(); } template -_NODISCARD bool operator<(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator<(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() < static_cast::element_type*>(nullptr); } template -_NODISCARD bool operator<(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator<(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) < _Right.get(); } template -_NODISCARD bool operator>=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator>=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() >= static_cast::element_type*>(nullptr); } template -_NODISCARD bool operator>=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator>=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) >= _Right.get(); } template -_NODISCARD bool operator>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() > static_cast::element_type*>(nullptr); } template -_NODISCARD bool operator>(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator>(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) > _Right.get(); } template -_NODISCARD bool operator<=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator<=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() <= static_cast::element_type*>(nullptr); } template -_NODISCARD bool operator<=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator<=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) <= _Right.get(); } #endif // ^^^ !_HAS_CXX20 ^^^ @@ -1903,42 +1904,42 @@ void swap(shared_ptr<_Ty>& _Left, shared_ptr<_Ty>& _Right) noexcept { } template -_NODISCARD shared_ptr<_Ty1> static_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD_PURE_FN shared_ptr<_Ty1> static_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // static_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = static_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_Other, _Ptr); } template -_NODISCARD shared_ptr<_Ty1> static_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD_ACCESS_FN shared_ptr<_Ty1> static_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // static_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = static_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_STD move(_Other), _Ptr); } template -_NODISCARD shared_ptr<_Ty1> const_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD_PURE_FN shared_ptr<_Ty1> const_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // const_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = const_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_Other, _Ptr); } template -_NODISCARD shared_ptr<_Ty1> const_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD_ACCESS_FN shared_ptr<_Ty1> const_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // const_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = const_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_STD move(_Other), _Ptr); } template -_NODISCARD shared_ptr<_Ty1> reinterpret_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD_PURE_FN shared_ptr<_Ty1> reinterpret_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // reinterpret_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = reinterpret_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_Other, _Ptr); } template -_NODISCARD shared_ptr<_Ty1> reinterpret_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD_ACCESS_FN shared_ptr<_Ty1> reinterpret_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // reinterpret_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = reinterpret_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_STD move(_Other), _Ptr); @@ -1946,7 +1947,7 @@ _NODISCARD shared_ptr<_Ty1> reinterpret_pointer_cast(shared_ptr<_Ty2>&& _Other) #ifdef _CPPRTTI template -_NODISCARD shared_ptr<_Ty1> dynamic_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD_PURE_FN shared_ptr<_Ty1> dynamic_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // dynamic_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = dynamic_cast::element_type*>(_Other.get()); @@ -1958,7 +1959,7 @@ _NODISCARD shared_ptr<_Ty1> dynamic_pointer_cast(const shared_ptr<_Ty2>& _Other) } template -_NODISCARD shared_ptr<_Ty1> dynamic_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD_ACCESS_FN shared_ptr<_Ty1> dynamic_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // dynamic_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = dynamic_cast::element_type*>(_Other.get()); @@ -1977,7 +1978,7 @@ shared_ptr<_Ty1> dynamic_pointer_cast(shared_ptr<_Ty2>&&) noexcept = delete; // #if _HAS_STATIC_RTTI template -_NODISCARD _Dx* get_deleter(const shared_ptr<_Ty>& _Sx) noexcept { +_NODISCARD_PURE_FN _Dx* get_deleter(const shared_ptr<_Ty>& _Sx) noexcept { // return pointer to shared_ptr's deleter object if its type is _Dx if (_Sx._Rep) { return static_cast<_Dx*>(_Sx._Rep->_Get_deleter(typeid(_Dx))); @@ -2756,18 +2757,18 @@ _NODISCARD shared_ptr<_Ty> _Make_shared_unbounded_array(const size_t _Count, con } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared(const size_t _Count) { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared(const size_t _Count) { return _Make_shared_unbounded_array<_Ty>(_Count); } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared( +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared( const size_t _Count, const remove_extent_t<_Ty>& _Val) { return _Make_shared_unbounded_array<_Ty>(_Count, _Val); } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared() { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared() { // make a shared_ptr to a bounded array const auto _Rx = new _Ref_count_bounded_array<_Ty>(); shared_ptr<_Ty> _Ret; @@ -2776,7 +2777,8 @@ _NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared() { } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared(const remove_extent_t<_Ty>& _Val) { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared( + const remove_extent_t<_Ty>& _Val) { // make a shared_ptr to a bounded array const auto _Rx = new _Ref_count_bounded_array<_Ty>(_Val); shared_ptr<_Ty> _Ret; @@ -2785,7 +2787,7 @@ _NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared(con } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite() { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite() { shared_ptr<_Ty> _Ret; if constexpr (is_array_v<_Ty>) { // make a shared_ptr to a bounded array @@ -2800,13 +2802,14 @@ _NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared_ } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite(const size_t _Count) { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite( + const size_t _Count) { return _Make_shared_unbounded_array<_Ty>(_Count, _For_overwrite_tag{}); } #endif // _HAS_CXX20 template -_NODISCARD +_NODISCARD_PTR_ALLOC_FN #if _HAS_CXX20 enable_if_t, shared_ptr<_Ty>> #else // _HAS_CXX20 @@ -2867,19 +2870,19 @@ _NODISCARD shared_ptr<_Ty> _Allocate_shared_unbounded_array( } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared( +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const size_t _Count) { return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count); } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared( +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const size_t _Count, const remove_extent_t<_Ty>& _Val) { return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count, _Val); } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared(const _Alloc& _Al) { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared(const _Alloc& _Al) { // make a shared_ptr to a bounded array using _Refc = _Ref_count_bounded_array_alloc, _Alloc>; using _Alblock = _Rebind_alloc_t<_Alloc, _Refc>; @@ -2894,7 +2897,7 @@ _NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared( +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const remove_extent_t<_Ty>& _Val) { // make a shared_ptr to a bounded array using _Refc = _Ref_count_bounded_array_alloc, _Alloc>; @@ -2910,7 +2913,8 @@ _NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite(const _Alloc& _Al) { +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( + const _Alloc& _Al) { shared_ptr<_Ty> _Ret; if constexpr (is_array_v<_Ty>) { // make a shared_ptr to a bounded array @@ -2938,7 +2942,7 @@ _NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_sha } template -_NODISCARD enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( +_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( const _Alloc& _Al, const size_t _Count) { return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count, _For_overwrite_tag{}); } @@ -3012,11 +3016,11 @@ public: this->_Swap(_Other); } - _NODISCARD bool expired() const noexcept { + _NODISCARD_PURE_MTHD bool expired() const noexcept { return this->use_count() == 0; } - _NODISCARD shared_ptr<_Ty> lock() const noexcept { // convert to shared_ptr + _NODISCARD_PURE_MTHD shared_ptr<_Ty> lock() const noexcept { // convert to shared_ptr shared_ptr<_Ty> _Ret; (void) _Ret._Construct_from_weak(*this); return _Ret; @@ -3038,19 +3042,19 @@ class enable_shared_from_this { // provide member functions that create shared_p public: using _Esft_type = enable_shared_from_this; - _NODISCARD shared_ptr<_Ty> shared_from_this() { + _NODISCARD_ACCESS_MTHD shared_ptr<_Ty> shared_from_this() { return shared_ptr<_Ty>(_Wptr); } - _NODISCARD shared_ptr shared_from_this() const { + _NODISCARD_PURE_MTHD shared_ptr shared_from_this() const { return shared_ptr(_Wptr); } - _NODISCARD weak_ptr<_Ty> weak_from_this() noexcept { + _NODISCARD_ACCESS_MTHD weak_ptr<_Ty> weak_from_this() noexcept { return _Wptr; } - _NODISCARD weak_ptr weak_from_this() const noexcept { + _NODISCARD_PURE_MTHD weak_ptr weak_from_this() const noexcept { return _Wptr; } @@ -3196,23 +3200,23 @@ public: } } - _NODISCARD _Dx& get_deleter() noexcept { + _NODISCARD_ACCESS_MTHD _Dx& get_deleter() noexcept { return _Mypair._Get_first(); } - _NODISCARD const _Dx& get_deleter() const noexcept { + _NODISCARD_PURE_MTHD const _Dx& get_deleter() const noexcept { return _Mypair._Get_first(); } - _NODISCARD add_lvalue_reference_t<_Ty> operator*() const noexcept /* strengthened */ { + _NODISCARD_PURE_OP add_lvalue_reference_t<_Ty> operator*() const noexcept /* strengthened */ { return *_Mypair._Myval2; } - _NODISCARD pointer operator->() const noexcept { + _NODISCARD_PURE_OP pointer operator->() const noexcept { return _Mypair._Myval2; } - _NODISCARD pointer get() const noexcept { + _NODISCARD_PURE_MTHD pointer get() const noexcept { return _Mypair._Myval2; } @@ -3331,19 +3335,19 @@ public: } } - _NODISCARD _Dx& get_deleter() noexcept { + _NODISCARD_ACCESS_MTHD _Dx& get_deleter() noexcept { return _Mypair._Get_first(); } - _NODISCARD const _Dx& get_deleter() const noexcept { + _NODISCARD_PURE_MTHD const _Dx& get_deleter() const noexcept { return _Mypair._Get_first(); } - _NODISCARD _Ty& operator[](size_t _Idx) const noexcept /* strengthened */ { + _NODISCARD_PURE_OP _Ty& operator[](size_t _Idx) const noexcept /* strengthened */ { return _Mypair._Myval2[_Idx]; } - _NODISCARD pointer get() const noexcept { + _NODISCARD_PURE_MTHD pointer get() const noexcept { return _Mypair._Myval2; } @@ -3375,12 +3379,12 @@ private: template , int> = 0> -_NODISCARD unique_ptr<_Ty> make_unique(_Types&&... _Args) { // make a unique_ptr +_NODISCARD_PTR_ALLOC_FN unique_ptr<_Ty> make_unique(_Types&&... _Args) { // make a unique_ptr return unique_ptr<_Ty>(new _Ty(_STD forward<_Types>(_Args)...)); } template && extent_v<_Ty> == 0, int> = 0> -_NODISCARD unique_ptr<_Ty> make_unique(const size_t _Size) { // make a unique_ptr +_NODISCARD_PTR_ALLOC_FN unique_ptr<_Ty> make_unique(const size_t _Size) { // make a unique_ptr using _Elem = remove_extent_t<_Ty>; return unique_ptr<_Ty>(new _Elem[_Size]()); } @@ -3390,12 +3394,12 @@ void make_unique(_Types&&...) = delete; #if _HAS_CXX20 template , int> = 0> -_NODISCARD unique_ptr<_Ty> make_unique_for_overwrite() { // make a unique_ptr with default initialization +_NODISCARD_PTR_ALLOC_FN unique_ptr<_Ty> make_unique_for_overwrite() { // make a unique_ptr with default initialization return unique_ptr<_Ty>(new _Ty); } template , int> = 0> -_NODISCARD unique_ptr<_Ty> make_unique_for_overwrite( +_NODISCARD_PTR_ALLOC_FN unique_ptr<_Ty> make_unique_for_overwrite( const size_t _Size) { // make a unique_ptr with default initialization using _Elem = remove_extent_t<_Ty>; return unique_ptr<_Ty>(new _Elem[_Size]); @@ -3411,19 +3415,19 @@ void swap(unique_ptr<_Ty, _Dx>& _Left, unique_ptr<_Ty, _Dx>& _Right) noexcept { } template -_NODISCARD bool operator==(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP bool operator==(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return _Left.get() == _Right.get(); } #if !_HAS_CXX20 template -_NODISCARD bool operator!=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP bool operator!=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 template -_NODISCARD bool operator<(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP bool operator<(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { using _Ptr1 = typename unique_ptr<_Ty1, _Dx1>::pointer; using _Ptr2 = typename unique_ptr<_Ty2, _Dx2>::pointer; using _Common = common_type_t<_Ptr1, _Ptr2>; @@ -3431,17 +3435,17 @@ _NODISCARD bool operator<(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr< } template -_NODISCARD bool operator>=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP bool operator>=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return !(_Left < _Right); } template -_NODISCARD bool operator>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP bool operator>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return _Right < _Left; } template -_NODISCARD bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return !(_Right < _Left); } @@ -3450,7 +3454,7 @@ _NODISCARD bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr template requires three_way_comparable_with::pointer, typename unique_ptr<_Ty2, _Dx2>::pointer> -_NODISCARD compare_three_way_result_t::pointer, +_NODISCARD_PURE_OP compare_three_way_result_t::pointer, typename unique_ptr<_Ty2, _Dx2>::pointer> operator<=>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { // clang-format on @@ -3459,66 +3463,66 @@ _NODISCARD compare_three_way_result_t::pointer, #endif // __cpp_lib_concepts template -_NODISCARD bool operator==(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t) noexcept { +_NODISCARD_PURE_OP bool operator==(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t) noexcept { return !_Left; } #if !_HAS_CXX20 template -_NODISCARD bool operator==(nullptr_t, const unique_ptr<_Ty, _Dx>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator==(nullptr_t, const unique_ptr<_Ty, _Dx>& _Right) noexcept { return !_Right; } template -_NODISCARD bool operator!=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) noexcept { +_NODISCARD_PURE_OP bool operator!=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) noexcept { return !(_Left == _Right); } template -_NODISCARD bool operator!=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) noexcept { +_NODISCARD_PURE_OP bool operator!=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) noexcept { return !(_Left == _Right); } #endif // !_HAS_CXX20 template -_NODISCARD bool operator<(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD_PURE_OP bool operator<(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { using _Ptr = typename unique_ptr<_Ty, _Dx>::pointer; return less<_Ptr>{}(_Left.get(), _Right); } template -_NODISCARD bool operator<(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD_PURE_OP bool operator<(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { using _Ptr = typename unique_ptr<_Ty, _Dx>::pointer; return less<_Ptr>{}(_Left, _Right.get()); } template -_NODISCARD bool operator>=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD_PURE_OP bool operator>=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { return !(_Left < _Right); } template -_NODISCARD bool operator>=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD_PURE_OP bool operator>=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { return !(_Left < _Right); } template -_NODISCARD bool operator>(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD_PURE_OP bool operator>(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { return _Right < _Left; } template -_NODISCARD bool operator>(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD_PURE_OP bool operator>(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { return _Right < _Left; } template -_NODISCARD bool operator<=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD_PURE_OP bool operator<=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { return !(_Right < _Left); } template -_NODISCARD bool operator<=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD_PURE_OP bool operator<=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { return !(_Right < _Left); } @@ -3526,7 +3530,7 @@ _NODISCARD bool operator<=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) // clang-format off template requires three_way_comparable::pointer> -_NODISCARD compare_three_way_result_t::pointer> operator<=>( +_NODISCARD_PURE_OP compare_three_way_result_t::pointer> operator<=>( const unique_ptr<_Ty, _Dx>& _Left, nullptr_t) { // clang-format on return _Left.get() <=> static_cast::pointer>(nullptr); @@ -3575,15 +3579,15 @@ struct owner_less> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef shared_ptr<_Ty> _SECOND_ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef bool _RESULT_TYPE_NAME; - _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } }; @@ -3594,15 +3598,15 @@ struct owner_less> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef weak_ptr<_Ty> _SECOND_ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef bool _RESULT_TYPE_NAME; - _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } }; @@ -3610,22 +3614,22 @@ struct owner_less> { template <> struct owner_less { template - _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } template - _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } template - _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } template - _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { + _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } @@ -3646,7 +3650,7 @@ struct hash> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef shared_ptr<_Ty> _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD size_t operator()(const shared_ptr<_Ty>& _Keyval) const noexcept { + _NODISCARD_PURE_OP size_t operator()(const shared_ptr<_Ty>& _Keyval) const noexcept { return hash::element_type*>()(_Keyval.get()); } }; @@ -3670,7 +3674,7 @@ inline void* align(size_t _Bound, size_t _Size, void*& _Ptr, size_t& _Space) noe #if _HAS_CXX20 template -_NODISCARD constexpr _Ty* assume_aligned(_Ty* const _Ptr) noexcept /* strengthened */ { +_NODISCARD_ASSUME_ALIGNED constexpr _Ty* assume_aligned(_Ty* const _Ptr) noexcept /* strengthened */ { if (_STD is_constant_evaluated()) { return _Ptr; } else { @@ -3696,13 +3700,13 @@ struct _Shared_ptr_spin_lock { // class to manage a spin lock for shared_ptr ato }; template -_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD bool atomic_is_lock_free(const shared_ptr<_Ty>*) { +_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN bool atomic_is_lock_free(const shared_ptr<_Ty>*) { // return true if atomic operations on shared_ptr<_Ty> are lock-free return false; } template -_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD shared_ptr<_Ty> atomic_load_explicit( +_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN shared_ptr<_Ty> atomic_load_explicit( const shared_ptr<_Ty>* _Ptr, memory_order) { // load *_Ptr atomically _Shared_ptr_spin_lock _Lock; @@ -3711,7 +3715,7 @@ _CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD shared_ptr<_Ty> atomic } template -_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD shared_ptr<_Ty> atomic_load( +_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN shared_ptr<_Ty> atomic_load( const shared_ptr<_Ty>* _Ptr) { // load *_Ptr atomically return _STD atomic_load_explicit(_Ptr, memory_order_seq_cst); } @@ -3827,7 +3831,7 @@ public: static constexpr bool is_always_lock_free = false; - _NODISCARD bool is_lock_free() const noexcept { + _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { return false; } @@ -3841,7 +3845,7 @@ public: _Value._Rep = _Rep; } - _NODISCARD shared_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_MTHD shared_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { _Check_load_memory_order(_Order); shared_ptr<_Ty> _Result; const auto _Rep = this->_Repptr._Lock_and_load(); @@ -3944,7 +3948,7 @@ public: static constexpr bool is_always_lock_free = false; - _NODISCARD bool is_lock_free() const noexcept { + _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { return false; } @@ -3958,7 +3962,7 @@ public: _Value._Rep = _Rep; } - _NODISCARD weak_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD_PURE_MTHD weak_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { _Check_load_memory_order(_Order); weak_ptr<_Ty> _Result; const auto _Rep = this->_Repptr._Lock_and_load(); @@ -4158,7 +4162,7 @@ private: }; template -_NODISCARD auto out_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { +_NODISCARD_ACCESS_FN auto out_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { if constexpr (is_void_v<_Pointer>) { return out_ptr_t<_SmartPtr, _Pointer_of<_SmartPtr>, _ArgsT&&...>(_Smart_ptr, _STD forward<_ArgsT>(_Args)...); } else { @@ -4238,7 +4242,7 @@ private: }; template -_NODISCARD auto inout_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { +_NODISCARD_ACCESS_FN auto inout_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { if constexpr (is_void_v<_Pointer>) { return inout_ptr_t<_SmartPtr, _Pointer_of<_SmartPtr>, _ArgsT&&...>(_Smart_ptr, _STD forward<_ArgsT>(_Args)...); } else { diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 9165da4095a..298dc0abfe7 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -501,6 +501,14 @@ _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ "objects or not. It is dangerous to ignore the return value") +#define _NODISCARD_PTR_ALLOC_FN \ + _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ + "not useful to call this function and discard the return value") + +#define _NODISCARD_ASSUME_ALIGNED \ + _NODISCARD_MSG("Implementation might take advantage of alignment assumption only if the object is accesssed via " \ + "the returned pointer") + #ifdef _NODISCARD_LOCK_SUPPRESS #define _NODISCARD_LOCK From 317df86d9ce5125ac288305a3093d198c96622fa Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 19:21:23 +0300 Subject: [PATCH 25/73] cstddef --- stl/inc/cstddef | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stl/inc/cstddef b/stl/inc/cstddef index 2e346ffc161..cd8f9280dc3 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -28,36 +28,36 @@ using max_align_t = double; // most aligned type enum class byte : unsigned char {}; template , int> = 0> -_NODISCARD constexpr byte operator<<( +_NODISCARD_PURE_OP constexpr byte operator<<( const byte _Arg, const _IntType _Shift) noexcept { // bitwise LEFT SHIFT, every static_cast is intentional return static_cast(static_cast(static_cast(_Arg) << _Shift)); } template , int> = 0> -_NODISCARD constexpr byte operator>>( +_NODISCARD_PURE_OP constexpr byte operator>>( const byte _Arg, const _IntType _Shift) noexcept { // bitwise RIGHT SHIFT, every static_cast is intentional return static_cast(static_cast(static_cast(_Arg) >> _Shift)); } -_NODISCARD constexpr byte operator|( +_NODISCARD_PURE_OP constexpr byte operator|( const byte _Left, const byte _Right) noexcept { // bitwise OR, every static_cast is intentional return static_cast( static_cast(static_cast(_Left) | static_cast(_Right))); } -_NODISCARD constexpr byte operator&( +_NODISCARD_PURE_OP constexpr byte operator&( const byte _Left, const byte _Right) noexcept { // bitwise AND, every static_cast is intentional return static_cast( static_cast(static_cast(_Left) & static_cast(_Right))); } -_NODISCARD constexpr byte operator^( +_NODISCARD_PURE_OP constexpr byte operator^( const byte _Left, const byte _Right) noexcept { // bitwise XOR, every static_cast is intentional return static_cast( static_cast(static_cast(_Left) ^ static_cast(_Right))); } -_NODISCARD constexpr byte operator~(const byte _Arg) noexcept { // bitwise NOT, every static_cast is intentional +_NODISCARD_PURE_OP constexpr byte operator~(const byte _Arg) noexcept { // bitwise NOT, every static_cast is intentional return static_cast(static_cast(~static_cast(_Arg))); } @@ -84,7 +84,7 @@ constexpr byte& operator^=(byte& _Left, const byte _Right) noexcept { // bitwise } template , int> = 0> -_NODISCARD constexpr _IntType to_integer(const byte _Arg) noexcept { // convert byte to integer +_NODISCARD_PURE_FN constexpr _IntType to_integer(const byte _Arg) noexcept { // convert byte to integer return static_cast<_IntType>(_Arg); } #endif // __cpp_lib_byte From 78038a3d902116728fe81b4022dec088ab4edcc5 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 19:29:35 +0300 Subject: [PATCH 26/73] cmath --- stl/inc/cmath | 361 ++++++++++++++++++++++++------------------------ stl/inc/cstdlib | 6 +- 2 files changed, 184 insertions(+), 183 deletions(-) diff --git a/stl/inc/cmath b/stl/inc/cmath index 67232bdbfa4..5f0fcea294e 100644 --- a/stl/inc/cmath +++ b/stl/inc/cmath @@ -33,39 +33,39 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -_NODISCARD _Check_return_ inline float acos(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float acos(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD acosf(_Xx); } -_NODISCARD _Check_return_ inline float acosh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float acosh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD acoshf(_Xx); } -_NODISCARD _Check_return_ inline float asin(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float asin(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD asinf(_Xx); } -_NODISCARD _Check_return_ inline float asinh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float asinh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD asinhf(_Xx); } -_NODISCARD _Check_return_ inline float atan(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float atan(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD atanf(_Xx); } -_NODISCARD _Check_return_ inline float atanh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float atanh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD atanhf(_Xx); } -_NODISCARD _Check_return_ inline float atan2(_In_ float _Yx, _In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float atan2(_In_ float _Yx, _In_ float _Xx) noexcept /* strengthened */ { return _CSTD atan2f(_Yx, _Xx); } -_NODISCARD _Check_return_ inline float cbrt(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float cbrt(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD cbrtf(_Xx); } -_NODISCARD _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __ceilf(_Xx); #elif defined(__clang__) @@ -75,7 +75,7 @@ _NODISCARD _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strength #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __copysignf(_Number, _Sign); #elif defined(__clang__) @@ -85,43 +85,43 @@ _NODISCARD _Check_return_ inline float copysign(_In_ float _Number, _In_ float _ #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline float cos(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float cos(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD cosf(_Xx); } -_NODISCARD _Check_return_ inline float cosh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float cosh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD coshf(_Xx); } -_NODISCARD _Check_return_ inline float erf(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float erf(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD erff(_Xx); } -_NODISCARD _Check_return_ inline float erfc(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float erfc(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD erfcf(_Xx); } -_NODISCARD _Check_return_ inline float exp(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float exp(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD expf(_Xx); } -_NODISCARD _Check_return_ inline float exp2(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float exp2(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD exp2f(_Xx); } -_NODISCARD _Check_return_ inline float expm1(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float expm1(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD expm1f(_Xx); } -_NODISCARD _Check_return_ inline float fabs(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fabs(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD fabsf(_Xx); } -_NODISCARD _Check_return_ inline float fdim(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fdim(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fdimf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float floor(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float floor(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __floorf(_Xx); #elif defined(__clang__) @@ -131,19 +131,19 @@ _NODISCARD _Check_return_ inline float floor(_In_ float _Xx) noexcept /* strengt #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept /* strengthened */ { return _CSTD fmaf(_Xx, _Yx, _Zx); } -_NODISCARD _Check_return_ inline float fmax(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fmax(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fmaxf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float fmin(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fmin(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fminf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float fmod(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fmod(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fmodf(_Xx, _Yx); } @@ -151,55 +151,55 @@ inline float frexp(_In_ float _Xx, _Out_ int* _Yx) noexcept /* strengthened */ { return _CSTD frexpf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float hypot(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float hypot(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD hypotf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline int ilogb(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline int ilogb(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD ilogbf(_Xx); } -_NODISCARD _Check_return_ inline float ldexp(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float ldexp(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD ldexpf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float lgamma(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float lgamma(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD lgammaf(_Xx); } -_NODISCARD _Check_return_ inline long long llrint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long long llrint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD llrintf(_Xx); } -_NODISCARD _Check_return_ inline long long llround(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long long llround(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD llroundf(_Xx); } -_NODISCARD _Check_return_ inline float log(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float log(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD logf(_Xx); } -_NODISCARD _Check_return_ inline float log10(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float log10(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD log10f(_Xx); } -_NODISCARD _Check_return_ inline float log1p(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float log1p(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD log1pf(_Xx); } -_NODISCARD _Check_return_ inline float log2(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float log2(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD log2f(_Xx); } -_NODISCARD _Check_return_ inline float logb(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float logb(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD logbf(_Xx); } -_NODISCARD _Check_return_ inline long lrint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long lrint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD lrintf(_Xx); } -_NODISCARD _Check_return_ inline long lround(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long lround(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD lroundf(_Xx); } @@ -207,23 +207,23 @@ inline float modf(_In_ float _Xx, _Out_ float* _Yx) noexcept /* strengthened */ return _CSTD modff(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float nearbyint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float nearbyint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD nearbyintf(_Xx); } -_NODISCARD _Check_return_ inline float nextafter(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float nextafter(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD nextafterf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nexttowardf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float pow(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float pow(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD powf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float remainder(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float remainder(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD remainderf(_Xx, _Yx); } @@ -231,11 +231,11 @@ inline float remquo(_In_ float _Xx, _In_ float _Yx, _Out_ int* _Zx) noexcept /* return _CSTD remquof(_Xx, _Yx, _Zx); } -_NODISCARD _Check_return_ inline float rint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float rint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD rintf(_Xx); } -_NODISCARD _Check_return_ inline float round(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float round(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __roundf(_Xx); #elif defined(__clang__) @@ -245,39 +245,39 @@ _NODISCARD _Check_return_ inline float round(_In_ float _Xx) noexcept /* strengt #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline float scalbln(_In_ float _Xx, _In_ long _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float scalbln(_In_ float _Xx, _In_ long _Yx) noexcept /* strengthened */ { return _CSTD scalblnf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float scalbn(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float scalbn(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD scalbnf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float sin(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float sin(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD sinf(_Xx); } -_NODISCARD _Check_return_ inline float sinh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float sinh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD sinhf(_Xx); } -_NODISCARD _Check_return_ inline float sqrt(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float sqrt(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD sqrtf(_Xx); } -_NODISCARD _Check_return_ inline float tan(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float tan(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD tanf(_Xx); } -_NODISCARD _Check_return_ inline float tanh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float tanh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD tanhf(_Xx); } -_NODISCARD _Check_return_ inline float tgamma(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float tgamma(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD tgammaf(_Xx); } -_NODISCARD _Check_return_ inline float trunc(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float trunc(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __truncf(_Xx); #elif defined(__clang__) @@ -287,40 +287,40 @@ _NODISCARD _Check_return_ inline float trunc(_In_ float _Xx) noexcept /* strengt #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline long double acos(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double acos(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD acosl(_Xx); } -_NODISCARD _Check_return_ inline long double acosh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double acosh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD acoshl(_Xx); } -_NODISCARD _Check_return_ inline long double asin(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double asin(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD asinl(_Xx); } -_NODISCARD _Check_return_ inline long double asinh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double asinh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD asinhl(_Xx); } -_NODISCARD _Check_return_ inline long double atan(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double atan(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD atanl(_Xx); } -_NODISCARD _Check_return_ inline long double atanh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double atanh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD atanhl(_Xx); } -_NODISCARD _Check_return_ inline long double atan2(_In_ long double _Yx, _In_ long double _Xx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double atan2(_In_ long double _Yx, _In_ long double _Xx) noexcept /* strengthened */ { return _CSTD atan2l(_Yx, _Xx); } -_NODISCARD _Check_return_ inline long double cbrt(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double cbrt(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD cbrtl(_Xx); } -_NODISCARD _Check_return_ inline long double ceil(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double ceil(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __ceil(static_cast(_Xx)); #elif defined(__clang__) @@ -330,7 +330,7 @@ _NODISCARD _Check_return_ inline long double ceil(_In_ long double _Xx) noexcept #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline long double copysign(_In_ long double _Number, _In_ long double _Sign) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double copysign(_In_ long double _Number, _In_ long double _Sign) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __copysign(static_cast(_Number), static_cast(_Sign)); @@ -341,44 +341,44 @@ _NODISCARD _Check_return_ inline long double copysign(_In_ long double _Number, #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline long double cos(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double cos(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD cosl(_Xx); } -_NODISCARD _Check_return_ inline long double cosh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double cosh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD coshl(_Xx); } -_NODISCARD _Check_return_ inline long double erf(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double erf(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD erfl(_Xx); } -_NODISCARD _Check_return_ inline long double erfc(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double erfc(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD erfcl(_Xx); } -_NODISCARD _Check_return_ inline long double exp(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double exp(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD expl(_Xx); } -_NODISCARD _Check_return_ inline long double exp2(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double exp2(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD exp2l(_Xx); } -_NODISCARD _Check_return_ inline long double expm1(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double expm1(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD expm1l(_Xx); } -_NODISCARD _Check_return_ inline long double fabs(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double fabs(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD fabsl(_Xx); } -_NODISCARD _Check_return_ inline long double fdim(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double fdim(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fdiml(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double floor(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double floor(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __floor(static_cast(_Xx)); #elif defined(__clang__) @@ -388,22 +388,22 @@ _NODISCARD _Check_return_ inline long double floor(_In_ long double _Xx) noexcep #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline long double fma( +_NODISCARD_PURE_FN _Check_return_ inline long double fma( _In_ long double _Xx, _In_ long double _Yx, _In_ long double _Zx) noexcept /* strengthened */ { return _CSTD fmal(_Xx, _Yx, _Zx); } -_NODISCARD _Check_return_ inline long double fmax(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double fmax(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fmaxl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double fmin(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double fmin(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fminl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double fmod(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double fmod(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fmodl(_Xx, _Yx); } @@ -412,56 +412,56 @@ inline long double frexp(_In_ long double _Xx, _Out_ int* _Yx) noexcept /* stren return _CSTD frexpl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double hypot(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double hypot(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD hypotl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline int ilogb(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline int ilogb(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD ilogbl(_Xx); } -_NODISCARD _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD ldexpl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double lgamma(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double lgamma(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD lgammal(_Xx); } -_NODISCARD _Check_return_ inline long long llrint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long long llrint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD llrintl(_Xx); } -_NODISCARD _Check_return_ inline long long llround(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long long llround(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD llroundl(_Xx); } -_NODISCARD _Check_return_ inline long double log(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double log(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD logl(_Xx); } -_NODISCARD _Check_return_ inline long double log10(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double log10(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD log10l(_Xx); } -_NODISCARD _Check_return_ inline long double log1p(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double log1p(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD log1pl(_Xx); } -_NODISCARD _Check_return_ inline long double log2(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double log2(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD log2l(_Xx); } -_NODISCARD _Check_return_ inline long double logb(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double logb(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD logbl(_Xx); } -_NODISCARD _Check_return_ inline long lrint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long lrint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD lrintl(_Xx); } -_NODISCARD _Check_return_ inline long lround(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long lround(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD lroundl(_Xx); } @@ -469,26 +469,26 @@ inline long double modf(_In_ long double _Xx, _Out_ long double* _Yx) noexcept / return _CSTD modfl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double nearbyint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double nearbyint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD nearbyintl(_Xx); } -_NODISCARD _Check_return_ inline long double nextafter(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double nextafter(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nextafterl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double nexttoward(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double nexttoward(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nexttowardl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double pow(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double pow(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD powl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double remainder(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD_PURE_FN _Check_return_ inline long double remainder(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD remainderl(_Xx, _Yx); } @@ -497,11 +497,11 @@ inline long double remquo(_In_ long double _Xx, _In_ long double _Yx, _Out_ int* return _CSTD remquol(_Xx, _Yx, _Zx); } -_NODISCARD _Check_return_ inline long double rint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double rint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD rintl(_Xx); } -_NODISCARD _Check_return_ inline long double round(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double round(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __round(static_cast(_Xx)); #elif defined(__clang__) @@ -511,39 +511,39 @@ _NODISCARD _Check_return_ inline long double round(_In_ long double _Xx) noexcep #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept /* strengthened */ { return _CSTD scalblnl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD scalbnl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double sin(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double sin(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD sinl(_Xx); } -_NODISCARD _Check_return_ inline long double sinh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double sinh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD sinhl(_Xx); } -_NODISCARD _Check_return_ inline long double sqrt(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double sqrt(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD sqrtl(_Xx); } -_NODISCARD _Check_return_ inline long double tan(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double tan(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD tanl(_Xx); } -_NODISCARD _Check_return_ inline long double tanh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double tanh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD tanhl(_Xx); } -_NODISCARD _Check_return_ inline long double tgamma(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double tgamma(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD tgammal(_Xx); } -_NODISCARD _Check_return_ inline long double trunc(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double trunc(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __trunc(static_cast(_Xx)); #elif defined(__clang__) @@ -568,7 +568,7 @@ double frexp(_Ty _Value, _Out_ int* const _Exp) noexcept /* strengthened */ { template && _STD is_arithmetic_v<_Ty2> && _STD is_arithmetic_v<_Ty3>, int> = 0> -_NODISCARD _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>> fma( +_NODISCARD_PURE_FN _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>> fma( _Ty1 _Left, _Ty2 _Middle, _Ty3 _Right) noexcept /* strengthened */ { using _Common = _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>>; if constexpr (_STD is_same_v<_Common, float>) { @@ -594,7 +594,7 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo #define _GENERIC_MATH1_BASE(NAME, RET, FUN) \ template , int> = 0> \ - _NODISCARD RET NAME(_Ty _Left) noexcept /* strengthened */ { \ + _NODISCARD_PURE_FN RET NAME(_Ty _Left) noexcept /* strengthened */ { \ return FUN(static_cast(_Left)); \ } @@ -611,14 +611,15 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo #define _GENERIC_MATH1X(FUN, ARG2) \ template , int> = 0> \ - _NODISCARD double FUN(_Ty _Left, ARG2 _Arg2) noexcept /* strengthened */ { \ + _NODISCARD_PURE_FN double FUN(_Ty _Left, ARG2 _Arg2) noexcept /* strengthened */ { \ return _CSTD FUN(static_cast(_Left), _Arg2); \ } #define _GENERIC_MATH2_BASE(NAME, FUN) \ template && _STD is_arithmetic_v<_Ty2>, int> = 0> \ - _NODISCARD _STD _Common_float_type_t<_Ty1, _Ty2> NAME(_Ty1 _Left, _Ty2 _Right) noexcept /* strengthened */ { \ + _NODISCARD_PURE_FN _STD _Common_float_type_t<_Ty1, _Ty2> NAME( \ + _Ty1 _Left, _Ty2 _Right) noexcept /* strengthened */ { \ using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>; \ return FUN(static_cast<_Common>(_Left), static_cast<_Common>(_Right)); \ } @@ -953,276 +954,276 @@ _NODISCARD _CRT_SATELLITE_2 float __stdcall __std_smf_hypot3f(float, float, floa _END_EXTERN_C _STD_BEGIN -_NODISCARD inline double assoc_laguerre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { +_NODISCARD_PURE_FN inline double assoc_laguerre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { return __std_smf_assoc_laguerre(_Degree, _Order, _Value); } -_NODISCARD inline float assoc_laguerref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { +_NODISCARD_PURE_FN inline float assoc_laguerref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { return __std_smf_assoc_laguerref(_Degree, _Order, _Value); } -_NODISCARD inline long double assoc_laguerrel( +_NODISCARD_PURE_FN inline long double assoc_laguerrel( const unsigned int _Degree, const unsigned int _Order, const long double _Value) { return __std_smf_assoc_laguerre(_Degree, _Order, static_cast(_Value)); } -_NODISCARD inline double assoc_legendre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { +_NODISCARD_PURE_FN inline double assoc_legendre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { return __std_smf_assoc_legendre(_Degree, _Order, _Value); } -_NODISCARD inline float assoc_legendref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { +_NODISCARD_PURE_FN inline float assoc_legendref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { return __std_smf_assoc_legendref(_Degree, _Order, _Value); } -_NODISCARD inline long double assoc_legendrel( +_NODISCARD_PURE_FN inline long double assoc_legendrel( const unsigned int _Degree, const unsigned int _Order, const long double _Value) { return __std_smf_assoc_legendre(_Degree, _Order, static_cast(_Value)); } -_NODISCARD inline double beta(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double beta(const double _Arg1, const double _Arg2) { return __std_smf_beta(_Arg1, _Arg2); } -_NODISCARD inline float betaf(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float betaf(const float _Arg1, const float _Arg2) { return __std_smf_betaf(_Arg1, _Arg2); } -_NODISCARD inline long double betal(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double betal(const long double _Arg1, const long double _Arg2) { return __std_smf_beta(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double comp_ellint_1(const double _Arg) { +_NODISCARD_PURE_FN inline double comp_ellint_1(const double _Arg) { return __std_smf_comp_ellint_1(_Arg); } -_NODISCARD inline float comp_ellint_1f(const float _Arg) { +_NODISCARD_PURE_FN inline float comp_ellint_1f(const float _Arg) { return __std_smf_comp_ellint_1f(_Arg); } -_NODISCARD inline long double comp_ellint_1l(const long double _Arg) { +_NODISCARD_PURE_FN inline long double comp_ellint_1l(const long double _Arg) { return __std_smf_comp_ellint_1(static_cast(_Arg)); } -_NODISCARD inline double comp_ellint_2(const double _Arg) { +_NODISCARD_PURE_FN inline double comp_ellint_2(const double _Arg) { return __std_smf_comp_ellint_2(_Arg); } -_NODISCARD inline float comp_ellint_2f(const float _Arg) { +_NODISCARD_PURE_FN inline float comp_ellint_2f(const float _Arg) { return __std_smf_comp_ellint_2f(_Arg); } -_NODISCARD inline long double comp_ellint_2l(const long double _Arg) { +_NODISCARD_PURE_FN inline long double comp_ellint_2l(const long double _Arg) { return __std_smf_comp_ellint_2(static_cast(_Arg)); } -_NODISCARD inline double comp_ellint_3(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double comp_ellint_3(const double _Arg1, const double _Arg2) { return __std_smf_comp_ellint_3(_Arg1, _Arg2); } -_NODISCARD inline float comp_ellint_3f(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float comp_ellint_3f(const float _Arg1, const float _Arg2) { return __std_smf_comp_ellint_3f(_Arg1, _Arg2); } -_NODISCARD inline long double comp_ellint_3l(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double comp_ellint_3l(const long double _Arg1, const long double _Arg2) { return __std_smf_comp_ellint_3(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double cyl_bessel_i(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double cyl_bessel_i(const double _Arg1, const double _Arg2) { return __std_smf_cyl_bessel_i(_Arg1, _Arg2); } -_NODISCARD inline float cyl_bessel_if(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float cyl_bessel_if(const float _Arg1, const float _Arg2) { return __std_smf_cyl_bessel_if(_Arg1, _Arg2); } -_NODISCARD inline long double cyl_bessel_il(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double cyl_bessel_il(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_bessel_i(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double cyl_bessel_j(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double cyl_bessel_j(const double _Arg1, const double _Arg2) { return __std_smf_cyl_bessel_j(_Arg1, _Arg2); } -_NODISCARD inline float cyl_bessel_jf(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float cyl_bessel_jf(const float _Arg1, const float _Arg2) { return __std_smf_cyl_bessel_jf(_Arg1, _Arg2); } -_NODISCARD inline long double cyl_bessel_jl(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double cyl_bessel_jl(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_bessel_j(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double cyl_bessel_k(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double cyl_bessel_k(const double _Arg1, const double _Arg2) { return __std_smf_cyl_bessel_k(_Arg1, _Arg2); } -_NODISCARD inline float cyl_bessel_kf(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float cyl_bessel_kf(const float _Arg1, const float _Arg2) { return __std_smf_cyl_bessel_kf(_Arg1, _Arg2); } -_NODISCARD inline long double cyl_bessel_kl(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double cyl_bessel_kl(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_bessel_k(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double cyl_neumann(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double cyl_neumann(const double _Arg1, const double _Arg2) { return __std_smf_cyl_neumann(_Arg1, _Arg2); } -_NODISCARD inline float cyl_neumannf(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float cyl_neumannf(const float _Arg1, const float _Arg2) { return __std_smf_cyl_neumannf(_Arg1, _Arg2); } -_NODISCARD inline long double cyl_neumannl(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double cyl_neumannl(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_neumann(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double ellint_1(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double ellint_1(const double _Arg1, const double _Arg2) { return __std_smf_ellint_1(_Arg1, _Arg2); } -_NODISCARD inline float ellint_1f(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float ellint_1f(const float _Arg1, const float _Arg2) { return __std_smf_ellint_1f(_Arg1, _Arg2); } -_NODISCARD inline long double ellint_1l(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double ellint_1l(const long double _Arg1, const long double _Arg2) { return __std_smf_ellint_1(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double ellint_2(const double _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double ellint_2(const double _Arg1, const double _Arg2) { return __std_smf_ellint_2(_Arg1, _Arg2); } -_NODISCARD inline float ellint_2f(const float _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float ellint_2f(const float _Arg1, const float _Arg2) { return __std_smf_ellint_2f(_Arg1, _Arg2); } -_NODISCARD inline long double ellint_2l(const long double _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double ellint_2l(const long double _Arg1, const long double _Arg2) { return __std_smf_ellint_2(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD inline double ellint_3(const double _Arg1, const double _Arg2, const double _Arg3) { +_NODISCARD_PURE_FN inline double ellint_3(const double _Arg1, const double _Arg2, const double _Arg3) { return __std_smf_ellint_3(_Arg1, _Arg2, _Arg3); } -_NODISCARD inline float ellint_3f(const float _Arg1, const float _Arg2, const float _Arg3) { +_NODISCARD_PURE_FN inline float ellint_3f(const float _Arg1, const float _Arg2, const float _Arg3) { return __std_smf_ellint_3f(_Arg1, _Arg2, _Arg3); } -_NODISCARD inline long double ellint_3l(const long double _Arg1, const long double _Arg2, const long double _Arg3) { +_NODISCARD_PURE_FN inline long double ellint_3l(const long double _Arg1, const long double _Arg2, const long double _Arg3) { return __std_smf_ellint_3(static_cast(_Arg1), static_cast(_Arg2), static_cast(_Arg3)); } -_NODISCARD inline double expint(const double _Arg) { +_NODISCARD_PURE_FN inline double expint(const double _Arg) { return __std_smf_expint(_Arg); } -_NODISCARD inline float expintf(const float _Arg) { +_NODISCARD_PURE_FN inline float expintf(const float _Arg) { return __std_smf_expintf(_Arg); } -_NODISCARD inline long double expintl(const long double _Arg) { +_NODISCARD_PURE_FN inline long double expintl(const long double _Arg) { return __std_smf_expint(static_cast(_Arg)); } -_NODISCARD inline double hermite(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double hermite(const unsigned int _Arg1, const double _Arg2) { return __std_smf_hermite(_Arg1, _Arg2); } -_NODISCARD inline float hermitef(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float hermitef(const unsigned int _Arg1, const float _Arg2) { return __std_smf_hermitef(_Arg1, _Arg2); } -_NODISCARD inline long double hermitel(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double hermitel(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_hermite(_Arg1, static_cast(_Arg2)); } -_NODISCARD inline double laguerre(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double laguerre(const unsigned int _Arg1, const double _Arg2) { return __std_smf_laguerre(_Arg1, _Arg2); } -_NODISCARD inline float laguerref(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float laguerref(const unsigned int _Arg1, const float _Arg2) { return __std_smf_laguerref(_Arg1, _Arg2); } -_NODISCARD inline long double laguerrel(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double laguerrel(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_laguerre(_Arg1, static_cast(_Arg2)); } -_NODISCARD inline double legendre(const unsigned int _Degree, const double _Value) { +_NODISCARD_PURE_FN inline double legendre(const unsigned int _Degree, const double _Value) { return __std_smf_legendre(_Degree, _Value); } -_NODISCARD inline float legendref(const unsigned int _Degree, const float _Value) { +_NODISCARD_PURE_FN inline float legendref(const unsigned int _Degree, const float _Value) { return __std_smf_legendref(_Degree, _Value); } -_NODISCARD inline long double legendrel(const unsigned int _Degree, const long double _Value) { +_NODISCARD_PURE_FN inline long double legendrel(const unsigned int _Degree, const long double _Value) { return __std_smf_legendre(_Degree, static_cast(_Value)); } -_NODISCARD inline double riemann_zeta(const double _Arg) { +_NODISCARD_PURE_FN inline double riemann_zeta(const double _Arg) { return __std_smf_riemann_zeta(_Arg); } -_NODISCARD inline float riemann_zetaf(const float _Arg) { +_NODISCARD_PURE_FN inline float riemann_zetaf(const float _Arg) { return __std_smf_riemann_zetaf(_Arg); } -_NODISCARD inline long double riemann_zetal(const long double _Arg) { +_NODISCARD_PURE_FN inline long double riemann_zetal(const long double _Arg) { return __std_smf_riemann_zeta(static_cast(_Arg)); } -_NODISCARD inline double sph_bessel(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double sph_bessel(const unsigned int _Arg1, const double _Arg2) { return __std_smf_sph_bessel(_Arg1, _Arg2); } -_NODISCARD inline float sph_besself(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float sph_besself(const unsigned int _Arg1, const float _Arg2) { return __std_smf_sph_besself(_Arg1, _Arg2); } -_NODISCARD inline long double sph_bessell(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double sph_bessell(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_sph_bessel(_Arg1, static_cast(_Arg2)); } -_NODISCARD inline double sph_legendre(const unsigned int _Arg1, const unsigned int _Arg2, const double _Theta) { +_NODISCARD_PURE_FN inline double sph_legendre(const unsigned int _Arg1, const unsigned int _Arg2, const double _Theta) { return __std_smf_sph_legendre(_Arg1, _Arg2, _Theta); } -_NODISCARD inline float sph_legendref(const unsigned int _Arg1, const unsigned int _Arg2, const float _Theta) { +_NODISCARD_PURE_FN inline float sph_legendref(const unsigned int _Arg1, const unsigned int _Arg2, const float _Theta) { return __std_smf_sph_legendref(_Arg1, _Arg2, _Theta); } -_NODISCARD inline long double sph_legendrel( +_NODISCARD_PURE_FN inline long double sph_legendrel( const unsigned int _Arg1, const unsigned int _Arg2, const long double _Theta) { return __std_smf_sph_legendre(_Arg1, _Arg2, static_cast(_Theta)); } -_NODISCARD inline double sph_neumann(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD_PURE_FN inline double sph_neumann(const unsigned int _Arg1, const double _Arg2) { return __std_smf_sph_neumann(_Arg1, _Arg2); } -_NODISCARD inline float sph_neumannf(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD_PURE_FN inline float sph_neumannf(const unsigned int _Arg1, const float _Arg2) { return __std_smf_sph_neumannf(_Arg1, _Arg2); } -_NODISCARD inline long double sph_neumannl(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD_PURE_FN inline long double sph_neumannl(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_sph_neumann(_Arg1, static_cast(_Arg2)); } -_NODISCARD inline double hypot(const double _Dx, const double _Dy, const double _Dz) { +_NODISCARD_PURE_FN inline double hypot(const double _Dx, const double _Dy, const double _Dz) { return __std_smf_hypot3(_Dx, _Dy, _Dz); } -_NODISCARD inline float hypot(const float _Dx, const float _Dy, const float _Dz) { +_NODISCARD_PURE_FN inline float hypot(const float _Dx, const float _Dy, const float _Dz) { return __std_smf_hypot3f(_Dx, _Dy, _Dz); } -_NODISCARD inline long double hypot(const long double _Dx, const long double _Dy, const long double _Dz) { +_NODISCARD_PURE_FN inline long double hypot(const long double _Dx, const long double _Dy, const long double _Dz) { return __std_smf_hypot3(static_cast(_Dx), static_cast(_Dy), static_cast(_Dz)); } template && is_arithmetic_v<_Ty2> && is_arithmetic_v<_Ty3>, int> = 0> -_NODISCARD auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) { +_NODISCARD_PURE_FN auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) { // N4727 [cmath.syn]/2 "Sufficient additional overloads" // Note that this template is selected by overload resolution only when at least one // argument is double/long double/integral but not all three are double or long double. @@ -1311,15 +1312,15 @@ _NODISCARD constexpr _Ty _Common_lerp(const _Ty _ArgA, const _Ty _ArgB, const _T // As of 2019-06-17 it is unclear whether the "sufficient additional overloads" clause is intended to target lerp; // LWG-3223 is pending. -_NODISCARD constexpr inline float lerp(const float _ArgA, const float _ArgB, const float _ArgT) noexcept { +_NODISCARD_PURE_FN constexpr inline float lerp(const float _ArgA, const float _ArgB, const float _ArgT) noexcept { return _Common_lerp(_ArgA, _ArgB, _ArgT); } -_NODISCARD constexpr inline double lerp(const double _ArgA, const double _ArgB, const double _ArgT) noexcept { +_NODISCARD_PURE_FN constexpr inline double lerp(const double _ArgA, const double _ArgB, const double _ArgT) noexcept { return _Common_lerp(_ArgA, _ArgB, _ArgT); } -_NODISCARD constexpr inline long double lerp( +_NODISCARD_PURE_FN constexpr inline long double lerp( const long double _ArgA, const long double _ArgB, const long double _ArgT) noexcept { return _Common_lerp(_ArgA, _ArgB, _ArgT); } diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index 7afdd58d8ba..046ef75769d 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -20,15 +20,15 @@ _STL_DISABLE_CLANG_WARNINGS #undef new // has abs(long) and abs(long long) -_NODISCARD _Check_return_ inline double abs(_In_ double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline double abs(_In_ double _Xx) noexcept /* strengthened */ { return _CSTD fabs(_Xx); } -_NODISCARD _Check_return_ inline float abs(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float abs(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD fabsf(_Xx); } -_NODISCARD _Check_return_ inline long double abs(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double abs(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD fabsl(_Xx); } From 1e258f5e66ab32cf1a408582dda3647aa446a311 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 19:36:30 +0300 Subject: [PATCH 27/73] exception --- stl/inc/exception | 28 ++++++++++---------- stl/inc/execution | 67 ++++++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/stl/inc/exception b/stl/inc/exception index 0643e0be91a..eb8be6c0df4 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -40,7 +40,7 @@ using ::terminate; using ::set_terminate; using ::terminate_handler; -_NODISCARD inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler +_NODISCARD_PURE_FN inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler return _get_terminate(); } #endif // _M_CEE_PURE @@ -52,7 +52,7 @@ using ::unexpected; using ::set_unexpected; using ::unexpected_handler; -_NODISCARD inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler +_NODISCARD_PURE_FN inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler return _get_unexpected(); } #endif // _M_CEE_PURE @@ -98,7 +98,7 @@ public: virtual __CLR_OR_THIS_CALL ~exception() noexcept {} - _NODISCARD virtual const char* __CLR_OR_THIS_CALL what() const noexcept { // return pointer to message string + _NODISCARD_PURE_MTHD virtual const char* __CLR_OR_THIS_CALL what() const noexcept { // return pointer to message string return _Ptr ? _Ptr : "unknown exception"; } @@ -167,7 +167,7 @@ inline terminate_handler __CRTDECL set_terminate(terminate_handler) noexcept { / _CSTD abort(); } -_NODISCARD inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler +_NODISCARD_PURE_FN inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler return nullptr; } @@ -180,7 +180,7 @@ inline unexpected_handler __CRTDECL set_unexpected(unexpected_handler) noexcept inline void __CRTDECL unexpected() {} // handle unexpected exception -_NODISCARD inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler +_NODISCARD_PURE_FN inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler return nullptr; } #endif // _HAS_UNEXPECTED @@ -260,28 +260,28 @@ public: __ExceptionPtrSwap(&_Lhs, &_Rhs); } - _NODISCARD friend bool operator==(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept { + _NODISCARD_PURE_OP friend bool operator==(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept { return __ExceptionPtrCompare(&_Lhs, &_Rhs); } - _NODISCARD friend bool operator==(const exception_ptr& _Lhs, nullptr_t) noexcept { + _NODISCARD_PURE_OP friend bool operator==(const exception_ptr& _Lhs, nullptr_t) noexcept { return !_Lhs; } #if !_HAS_CXX20 - _NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept { + _NODISCARD_PURE_OP friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept { return !_Rhs; } - _NODISCARD friend bool operator!=(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept { + _NODISCARD_PURE_OP friend bool operator!=(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept { return !(_Lhs == _Rhs); } - _NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept { + _NODISCARD_PURE_OP friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept { return !(_Lhs == _Rhs); } - _NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept { + _NODISCARD_PURE_OP friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept { return !(_Lhs == _Rhs); } #endif // !_HAS_CXX20 @@ -298,7 +298,7 @@ private: #endif // __clang__ }; -_NODISCARD inline exception_ptr current_exception() noexcept { +_NODISCARD_PURE_FN inline exception_ptr current_exception() noexcept { return exception_ptr::_Current_exception(); } @@ -310,7 +310,7 @@ template void* __GetExceptionInfo(_Ex); template -_NODISCARD exception_ptr make_exception_ptr(_Ex _Except) noexcept { +_NODISCARD_PTR_ALLOC_FN exception_ptr make_exception_ptr(_Ex _Except) noexcept { return exception_ptr::_Copy_exception(_STD addressof(_Except), __GetExceptionInfo(_Except)); } @@ -334,7 +334,7 @@ public: } } - _NODISCARD exception_ptr nested_ptr() const noexcept { // return wrapped exception_ptr + _NODISCARD_PURE_MTHD exception_ptr nested_ptr() const noexcept { // return wrapped exception_ptr return _Exc; } diff --git a/stl/inc/execution b/stl/inc/execution index 80502d8d3a1..ae203337bee 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -138,7 +138,7 @@ struct is_execution_policy : true_type {}; #endif // _HAS_CXX20 struct _Parallelism_resources_exhausted : exception { - _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD_PURE_MTHD const char* __CLR_OR_THIS_CALL what() const noexcept override { // return pointer to message string return "Insufficient resources were available to use additional parallelism."; } @@ -1110,7 +1110,7 @@ bool _All_of_family_parallel(_FwdIt _First, const _FwdIt _Last, _Pr _Pred) { } template /* = 0 */> -_NODISCARD bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if all elements in [_First, _Last) satisfy _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1124,7 +1124,7 @@ _NODISCARD bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept } template /* = 0 */> -_NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if any element in [_First, _Last) satisfies _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1138,7 +1138,8 @@ _NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pr } template /* = 0 */> -_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // test if no element in [_First, _Last) satisfies _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1335,7 +1336,8 @@ _FwdIt _Find_parallel_unchecked(_ExPo&&, const _FwdIt _First, const _FwdIt _Last } template /* = 0 */> -_NODISCARD _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +/* terminates */ { // find first matching _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); using _UFwdIt = _Unwrapped_t; @@ -1347,7 +1349,8 @@ _NODISCARD _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _ } template /* = 0 */> -_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // find first satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); using _UFwdIt = _Unwrapped_t; @@ -1360,7 +1363,8 @@ _NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr } template /* = 0 */> -_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // find first satisfying !_Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); using _UFwdIt = _Unwrapped_t; @@ -1517,8 +1521,8 @@ struct _Static_partitioned_find_end_backward2 { }; template /* = 0 */> -_NODISCARD _FwdIt1 find_end(_ExPo&&, _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, - _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt1 find_end(_ExPo&&, _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, + const _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // find last [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -1573,7 +1577,7 @@ _NODISCARD _FwdIt1 find_end(_ExPo&&, _FwdIt1 _First1, const _FwdIt1 _Last1, cons } template /* = 0 */> -_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD_PURE_ALG _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -1639,7 +1643,7 @@ struct _Static_partitioned_adjacent_find2 { }; template /* = 0 */> -_NODISCARD _FwdIt adjacent_find(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt adjacent_find(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find first satisfying _Pred with successor _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1697,7 +1701,7 @@ struct _Static_partitioned_count_if2 { }; template /* = 0 */> -_NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // count elements satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1732,7 +1736,8 @@ _NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _Fw } template /* = 0 */> -_NODISCARD _Iter_diff_t<_FwdIt> count(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +_NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count( + _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // count elements that match _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1859,7 +1864,7 @@ struct _Static_partitioned_mismatch2 { #pragma warning(disable : 4868) // compiler may not enforce left-to-right evaluation order // in braced initializer list (/Wall) template /* = 0 */> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, ...) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -1901,7 +1906,7 @@ _NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( #pragma warning(pop) template /* = 0 */> -_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, _Last2) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -1978,7 +1983,8 @@ struct _Static_partitioned_equal2 { }; template /* = 0 */> -_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept +_NODISCARD_PURE_ALG_NODISCARD bool equal( + _ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { // compare [_First1, _Last1) to [_First2, ...) _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -2011,8 +2017,8 @@ _NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, cons } template /* = 0 */> -_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, - _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, + const _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // compare [_First1, _Last1) to [_First2, _Last2) _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -2097,8 +2103,8 @@ struct _Static_partitioned_search2 { }; template /* = 0 */> -_NODISCARD _FwdItHaystack search(_ExPo&&, const _FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, - const _FwdItPat _Last2, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&&, const _FwdItHaystack _First1, _FwdItHaystack _Last1, + const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) noexcept /* terminates */ { // find first [_First2, _Last2) match _Adl_verify_range(_First2, _Last2); const auto _UFirst2 = _Get_unwrapped(_First2); @@ -2224,7 +2230,7 @@ struct _Static_partitioned_search_n2 { }; template /* = 0 */> -_NODISCARD _FwdIt search_n(_ExPo&&, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, +_NODISCARD_PURE_ALG _FwdIt search_n(_ExPo&&, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) noexcept /* terminates */ { // find first _Count * _Val satisfying _Pred const _Algorithm_int_t<_Diff> _Count = _Count_raw; @@ -2560,7 +2566,7 @@ struct _Static_partitioned_remove_if2 { }; template /* = 0 */> -_NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // remove each satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -2587,7 +2593,7 @@ _NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pre } template /* = 0 */> -_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +_NODISCARD_PURE_ALG _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // remove each matching _Val return _STD remove_if(_STD forward<_ExPo>(_Exec), _First, _Last, @@ -3042,7 +3048,7 @@ struct _Static_partitioned_is_sorted_until { }; template /* = 0 */> -_NODISCARD _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find extent of range that is ordered by predicate _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -3196,7 +3202,8 @@ struct _Static_partitioned_is_partitioned { }; template /* = 0 */> -_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // test if [_First, _Last) is partitioned by _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -3268,7 +3275,7 @@ struct _Static_partitioned_is_heap_until { }; template /* = 0 */> -_NODISCARD _RanIt is_heap_until(_ExPo&&, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _RanIt is_heap_until(_ExPo&&, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { // find extent of range that is a heap _REQUIRE_PARALLEL_ITERATOR(_RanIt); _Adl_verify_range(_First, _Last); @@ -4038,7 +4045,7 @@ struct _Static_partitioned_reduce2 { }; template /* = 0 */> -_NODISCARD _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept +_NODISCARD_PURE_ALG _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept /* terminates */ { // return commutative and associative reduction of _Val and [_First, _Last), using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -4138,8 +4145,8 @@ struct _Static_partitioned_transform_reduce_binary2 { // transform-reduction tas // in braced initializer list (/Wall) template /* = 0 */> -_NODISCARD _Ty transform_reduce(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Ty _Val, _BinOp1 _Reduce_op, - _BinOp2 _Transform_op) noexcept /* terminates */ { +_NODISCARD_PURE_ALG _Ty transform_reduce(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Ty _Val, + _BinOp1 _Reduce_op, _BinOp2 _Transform_op) noexcept /* terminates */ { // return commutative and associative transform-reduction of sequences, using _Reduce_op and _Transform_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -4234,7 +4241,7 @@ struct _Static_partitioned_transform_reduce2 { // transformed reduction task sch template /* = 0 */> -_NODISCARD _Ty transform_reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op, +_NODISCARD_PURE_ALG _Ty transform_reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op, _UnaryOp _Transform_op) noexcept /* terminates */ { // return commutative and associative reduction of transformed sequence, using _Reduce_op and _Transform_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt); From 350c13777cbfbe5748e181b3e184f63d7e071c70 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 19:46:58 +0300 Subject: [PATCH 28/73] clang-format --- stl/inc/cmath | 55 ++++++++++++++++++++++++++++------------------- stl/inc/exception | 3 ++- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/stl/inc/cmath b/stl/inc/cmath index 5f0fcea294e..daf47ce7d64 100644 --- a/stl/inc/cmath +++ b/stl/inc/cmath @@ -75,7 +75,8 @@ _NODISCARD_PURE_FN _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept +/* strengthened */ { #if _HAS_CMATH_INTRINSICS return __copysignf(_Number, _Sign); #elif defined(__clang__) @@ -131,7 +132,8 @@ _NODISCARD_PURE_FN _Check_return_ inline float floor(_In_ float _Xx) noexcept /* #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept +/* strengthened */ { return _CSTD fmaf(_Xx, _Yx, _Zx); } @@ -215,7 +217,8 @@ _NODISCARD_PURE_FN _Check_return_ inline float nextafter(_In_ float _Xx, _In_ fl return _CSTD nextafterf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept +/* strengthened */ { return _CSTD nexttowardf(_Xx, _Yx); } @@ -421,7 +424,8 @@ _NODISCARD_PURE_FN _Check_return_ inline int ilogb(_In_ long double _Xx) noexcep return _CSTD ilogbl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept +/* strengthened */ { return _CSTD ldexpl(_Xx, _Yx); } @@ -511,11 +515,13 @@ _NODISCARD_PURE_FN _Check_return_ inline long double round(_In_ long double _Xx) #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept +/* strengthened */ { return _CSTD scalblnl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD_PURE_FN _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept +/* strengthened */ { return _CSTD scalbnl(_Xx, _Yx); } @@ -594,7 +600,7 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo #define _GENERIC_MATH1_BASE(NAME, RET, FUN) \ template , int> = 0> \ - _NODISCARD_PURE_FN RET NAME(_Ty _Left) noexcept /* strengthened */ { \ + _NODISCARD_PURE_FN RET NAME(_Ty _Left) noexcept /* strengthened */ { \ return FUN(static_cast(_Left)); \ } @@ -609,19 +615,19 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo #define _GENERIC_MATH1I(FUN, CLANG_INTRIN, MSVC_INTRIN) _GENERIC_MATH1_BASE(FUN, double, _CSTD FUN) #endif // ^^^ intrinsics unavailable ^^^ -#define _GENERIC_MATH1X(FUN, ARG2) \ - template , int> = 0> \ +#define _GENERIC_MATH1X(FUN, ARG2) \ + template , int> = 0> \ _NODISCARD_PURE_FN double FUN(_Ty _Left, ARG2 _Arg2) noexcept /* strengthened */ { \ - return _CSTD FUN(static_cast(_Left), _Arg2); \ + return _CSTD FUN(static_cast(_Left), _Arg2); \ } -#define _GENERIC_MATH2_BASE(NAME, FUN) \ - template && _STD is_arithmetic_v<_Ty2>, int> = 0> \ - _NODISCARD_PURE_FN _STD _Common_float_type_t<_Ty1, _Ty2> NAME( \ - _Ty1 _Left, _Ty2 _Right) noexcept /* strengthened */ { \ - using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>; \ - return FUN(static_cast<_Common>(_Left), static_cast<_Common>(_Right)); \ +#define _GENERIC_MATH2_BASE(NAME, FUN) \ + template && _STD is_arithmetic_v<_Ty2>, int> = 0> \ + _NODISCARD_PURE_FN _STD _Common_float_type_t<_Ty1, _Ty2> NAME( \ + _Ty1 _Left, _Ty2 _Right) noexcept /* strengthened */ { \ + using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>; \ + return FUN(static_cast<_Common>(_Left), static_cast<_Common>(_Right)); \ } #define _GENERIC_MATH2(FUN) _GENERIC_MATH2_BASE(FUN, _CSTD FUN) @@ -954,11 +960,13 @@ _NODISCARD _CRT_SATELLITE_2 float __stdcall __std_smf_hypot3f(float, float, floa _END_EXTERN_C _STD_BEGIN -_NODISCARD_PURE_FN inline double assoc_laguerre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { +_NODISCARD_PURE_FN inline double assoc_laguerre( + const unsigned int _Degree, const unsigned int _Order, const double _Value) { return __std_smf_assoc_laguerre(_Degree, _Order, _Value); } -_NODISCARD_PURE_FN inline float assoc_laguerref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { +_NODISCARD_PURE_FN inline float assoc_laguerref( + const unsigned int _Degree, const unsigned int _Order, const float _Value) { return __std_smf_assoc_laguerref(_Degree, _Order, _Value); } @@ -967,11 +975,13 @@ _NODISCARD_PURE_FN inline long double assoc_laguerrel( return __std_smf_assoc_laguerre(_Degree, _Order, static_cast(_Value)); } -_NODISCARD_PURE_FN inline double assoc_legendre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { +_NODISCARD_PURE_FN inline double assoc_legendre( + const unsigned int _Degree, const unsigned int _Order, const double _Value) { return __std_smf_assoc_legendre(_Degree, _Order, _Value); } -_NODISCARD_PURE_FN inline float assoc_legendref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { +_NODISCARD_PURE_FN inline float assoc_legendref( + const unsigned int _Degree, const unsigned int _Order, const float _Value) { return __std_smf_assoc_legendref(_Degree, _Order, _Value); } @@ -1108,7 +1118,8 @@ _NODISCARD_PURE_FN inline float ellint_3f(const float _Arg1, const float _Arg2, return __std_smf_ellint_3f(_Arg1, _Arg2, _Arg3); } -_NODISCARD_PURE_FN inline long double ellint_3l(const long double _Arg1, const long double _Arg2, const long double _Arg3) { +_NODISCARD_PURE_FN inline long double ellint_3l( + const long double _Arg1, const long double _Arg2, const long double _Arg3) { return __std_smf_ellint_3(static_cast(_Arg1), static_cast(_Arg2), static_cast(_Arg3)); } diff --git a/stl/inc/exception b/stl/inc/exception index eb8be6c0df4..0a7ee160676 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -98,7 +98,8 @@ public: virtual __CLR_OR_THIS_CALL ~exception() noexcept {} - _NODISCARD_PURE_MTHD virtual const char* __CLR_OR_THIS_CALL what() const noexcept { // return pointer to message string + _NODISCARD_PURE_MTHD virtual const char* __CLR_OR_THIS_CALL + what() const noexcept { // return pointer to message string return _Ptr ? _Ptr : "unknown exception"; } From 147efb31c001b8765a6cd48e03665a2197adc026 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 19 Sep 2021 19:57:05 +0300 Subject: [PATCH 29/73] typo --- stl/inc/execution | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/execution b/stl/inc/execution index ae203337bee..4309dde5e18 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -1983,7 +1983,7 @@ struct _Static_partitioned_equal2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG_NODISCARD bool equal( +_NODISCARD_PURE_ALG bool equal( _ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { // compare [_First1, _Last1) to [_First2, ...) From 1bcaa04b3355ce42c9883580a1f0f53cae42e801 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Mon, 20 Sep 2021 15:04:28 +0300 Subject: [PATCH 30/73] Tell to .join() explicitly to skip warning --- stl/inc/yvals_core.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 298dc0abfe7..782c7527160 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -534,7 +534,8 @@ _NODISCARD_CTOR_MSG("Thread is not joined or detached, 'terminate' will be called at the end of the statement") #define _NODISCARD_CTOR_JTHREAD \ - _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention?") + _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention? " \ + "(You can add '.join()' to avoid this warning if so)") #define _NODISCARD_CTOR_PURE \ _NODISCARD_CTOR_MSG( \ From 7c535cc773475b03eaafc602dad5483e25ba6aa7 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Mon, 20 Sep 2021 15:14:21 +0300 Subject: [PATCH 31/73] clang-format --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 782c7527160..8e4278d41b9 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -533,7 +533,7 @@ #define _NODISCARD_CTOR_THREAD \ _NODISCARD_CTOR_MSG("Thread is not joined or detached, 'terminate' will be called at the end of the statement") -#define _NODISCARD_CTOR_JTHREAD \ +#define _NODISCARD_CTOR_JTHREAD \ _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention? " \ "(You can add '.join()' to avoid this warning if so)") From b5a2d0b5776bd0c2ca50b9fdf350821af17207eb Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 23 Sep 2021 19:28:55 +0300 Subject: [PATCH 32/73] unique is unique --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 8e4278d41b9..befd6b5ff84 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -473,7 +473,7 @@ #define _NODISCARD_UNIQUE_ALG \ _NODISCARD_MSG( \ - "The 'unique' algorithms return the iterator past the last non-removed element. " \ + "The 'unique' algorithm returns the iterator past the last non-removed element. " \ "Normally you need to use the result to call container's 'erase' method afterwards to erase elements") #define _NODISCARD_EMPTY_MTHD \ From b4d339180d87c10da5c308a85d0b0b484064fd8b Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 21 Nov 2021 11:38:31 +0200 Subject: [PATCH 33/73] C++23 --- stl/inc/algorithm | 8 ++++---- stl/inc/bit | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 1319bdf3301..33bde534882 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2265,7 +2265,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); @@ -2296,7 +2296,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on if constexpr (_Sized_or_infinite_range<_Rng1> && sized_range<_Rng2>) { @@ -2331,7 +2331,7 @@ namespace ranges { requires (forward_iterator<_It1> || sized_sentinel_for<_Se1, _It1>) && (forward_iterator<_It2> || sized_sentinel_for<_Se2, _It2>) && indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); @@ -2354,7 +2354,7 @@ namespace ranges { requires (forward_range<_Rng1> || sized_range<_Rng1>) && (forward_range<_Rng2> || sized_range<_Rng2>) && indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()( + _NODISCARD_PURE_ALG constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on const auto _Count1 = _Distance_helper(_Range1); diff --git a/stl/inc/bit b/stl/inc/bit index 155a55410e8..17f4c74ecbe 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -298,7 +298,7 @@ _NODISCARD_PURE_FN constexpr int popcount(const _Ty _Val) noexcept { #if _HAS_CXX23 template , int> = 0> -_NODISCARD constexpr _Ty byteswap(const _Ty _Val) noexcept { +_NODISCARD_PURE_FN constexpr _Ty byteswap(const _Ty _Val) noexcept { if constexpr (sizeof(_Ty) == 1) { return _Val; } else if constexpr (sizeof(_Ty) == 2) { From 1662adeb41e447a1cecb52263b264ee0a8149639 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 21 Nov 2021 12:20:37 +0200 Subject: [PATCH 34/73] overlong line --- stl/inc/algorithm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 33bde534882..e78e2458611 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2331,8 +2331,8 @@ namespace ranges { requires (forward_iterator<_It1> || sized_sentinel_for<_Se1, _It1>) && (forward_iterator<_It2> || sized_sentinel_for<_Se2, _It2>) && indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); From a299ec2f7e2c1c23e4bbdf35cc38888f04c81cd9 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 21 Nov 2021 12:40:15 +0200 Subject: [PATCH 35/73] overlong line --- stl/inc/algorithm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index e78e2458611..7944fe7f1e9 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2265,8 +2265,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, - _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2331,7 +2331,7 @@ namespace ranges { requires (forward_iterator<_It1> || sized_sentinel_for<_Se1, _It1>) && (forward_iterator<_It2> || sized_sentinel_for<_Se2, _It2>) && indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); From a4512c8c5b1e5202e4252b0727ee60cef7a7d82f Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 9 Apr 2022 12:12:58 +0300 Subject: [PATCH 36/73] clang format --- stl/inc/algorithm | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 6db9cc7ef0b..5fe93b37dbd 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -795,36 +795,36 @@ _NODISCARD _CONSTEXPR20 bool is_permutation( for (;; ++_UFirst1, (void) ++_UFirst2) { // trim matching prefix if (_UFirst1 == _ULast1) { return _UFirst2 == _ULast2; - } + } if (_UFirst2 == _ULast2) { - return false; - } + return false; + } if (!_Pred(*_UFirst1, *_UFirst2)) { // found first inequality, check match counts in suffix - break; + break; + } } - } auto _Next1 = _UFirst1; auto _Next2 = _UFirst2; - for (;; ++_Next1, (void) ++_Next2) { // check for same lengths + for (;; ++_Next1, (void) ++_Next2) { // check for same lengths if (_Next1 == _ULast1) { if (_Next2 == _ULast2) { return _Check_match_counts(_UFirst1, _ULast1, _UFirst2, _ULast2, _Pass_fn(_Pred)); - } + } - return false; // sequence 1 is shorter than sequence 2, not a permutation - } + return false; // sequence 1 is shorter than sequence 2, not a permutation + } if (_Next2 == _ULast2) { - return false; // sequence 1 is longer than sequence 2, not a permutation + return false; // sequence 1 is longer than sequence 2, not a permutation + } } - } } else { static_assert(_Always_false<_FwdIt1>, "Iterators must be at least forward iterators"); } - } +} template _NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { @@ -1309,7 +1309,7 @@ namespace ranges { if constexpr (_Iter_copy_cat::_Bitcopy_assignable) { if (!_STD is_constant_evaluated()) { auto _Final = _UFirst + _Count; - _Result = _Copy_memmove(_STD move(_UFirst), _Final, _STD move(_Result)); + _Result = _Copy_memmove(_STD move(_UFirst), _Final, _STD move(_Result)); _Seek_wrapped(_First, _STD move(_Final)); return {_STD move(_First), _STD move(_Result)}; } @@ -4681,12 +4681,12 @@ _SampleIt sample(_PopIt _First, _PopIt _Last, _SampleIt _Dest, _Diff _Count, _Ur using _PopDiff = _Iter_diff_t<_PopIt>; _Rng_from_urng<_PopDiff, remove_reference_t<_Urng>> _RngFunc(_Func); if constexpr (_Is_fwd_iter_v<_PopIt>) { - // source is forward: use selection sampling (stable) - using _CT = common_type_t<_Diff, _PopDiff>; + // source is forward: use selection sampling (stable) + using _CT = common_type_t<_Diff, _PopDiff>; const auto _Pop_size = _STD distance(_UFirst, _ULast); - if (static_cast<_CT>(_Count) > static_cast<_CT>(_Pop_size)) { - _Count = static_cast<_Diff>(_Pop_size); // narrowing OK because _Count is getting smaller - } + if (static_cast<_CT>(_Count) > static_cast<_CT>(_Pop_size)) { + _Count = static_cast<_Diff>(_Pop_size); // narrowing OK because _Count is getting smaller + } _Seek_wrapped(_Dest, _Sample_selection_unchecked(_UFirst, _Pop_size, _Get_unwrapped_n(_Dest, _Count), _Count, _RngFunc)); @@ -4696,7 +4696,7 @@ _SampleIt sample(_PopIt _First, _PopIt _Last, _SampleIt _Dest, _Diff _Count, _Ur _Sample_reservoir_unchecked(_UFirst, _ULast, _Get_unwrapped_unverified(_Dest), _Count, _RngFunc)); } else { static_assert(_Always_false<_PopIt>, "Source iterators must be at least input iterators"); -} + } } return _Dest; @@ -5643,7 +5643,7 @@ namespace ranges { constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); - auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); + auto _ULast = _Get_final_iterator_unwrapped<_It>(_UFirst, _STD move(_Last)); _Seek_wrapped(_First, _ULast); _Push_heap_unchecked(_STD move(_UFirst), _STD move(_ULast), _Pass_fn(_Pred), _Pass_fn(_Proj)); return _First; From f38a65ad880d252bacdd1191c802db0fb9a22683 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 9 Apr 2022 12:14:52 +0300 Subject: [PATCH 37/73] clang format --- stl/inc/memory | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/stl/inc/memory b/stl/inc/memory index ea617141f90..1783733a999 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -3265,7 +3265,8 @@ public: return _Mypair._Get_first(); } - _NODISCARD_PURE_OP _CONSTEXPR23 add_lvalue_reference_t<_Ty> operator*() const noexcept(noexcept(*_STD declval())) { + _NODISCARD_PURE_OP _CONSTEXPR23 add_lvalue_reference_t<_Ty> operator*() const + noexcept(noexcept(*_STD declval())) { return *_Mypair._Myval2; } @@ -3452,7 +3453,8 @@ void make_unique(_Types&&...) = delete; #if _HAS_CXX20 template , int> = 0> -_NODISCARD_PTR_ALLOC_FN _CONSTEXPR23 unique_ptr<_Ty> make_unique_for_overwrite() { // make a unique_ptr with default initialization +_NODISCARD_PTR_ALLOC_FN _CONSTEXPR23 unique_ptr<_Ty> + make_unique_for_overwrite() { // make a unique_ptr with default initialization return unique_ptr<_Ty>(new _Ty); } @@ -3473,7 +3475,8 @@ _CONSTEXPR23 void swap(unique_ptr<_Ty, _Dx>& _Left, unique_ptr<_Ty, _Dx>& _Right } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator==(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD_PURE_OP _CONSTEXPR23 bool operator==( + const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return _Left.get() == _Right.get(); } From 27c9c93a9e665f548fbc16b7ace4b818a92a3eb6 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 05:53:25 +0300 Subject: [PATCH 38/73] - pure / accessor --- stl/inc/algorithm | 346 +++++++++++++++++------------------- stl/inc/any | 21 ++- stl/inc/array | 188 ++++++++++---------- stl/inc/atomic | 60 +++---- stl/inc/barrier | 2 +- stl/inc/bit | 30 ++-- stl/inc/cmath | 382 ++++++++++++++++++++-------------------- stl/inc/cstddef | 14 +- stl/inc/cstdlib | 6 +- stl/inc/exception | 15 +- stl/inc/execution | 62 ++++--- stl/inc/latch | 2 +- stl/inc/memory | 197 ++++++++++----------- stl/inc/mutex | 8 +- stl/inc/semaphore | 4 +- stl/inc/shared_mutex | 6 +- stl/inc/source_location | 10 +- stl/inc/thread | 42 ++--- stl/inc/vector | 198 ++++++++++----------- stl/inc/yvals_core.h | 28 --- 20 files changed, 777 insertions(+), 844 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 5fe93b37dbd..3c10f25aa69 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -345,11 +345,11 @@ namespace ranges { #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _Last, _Pr _Pred) { // find first element that satisfies !_Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -366,11 +366,11 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _InIt find_if_not(_InIt _First, const _InIt _La #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find first satisfying _Pred with successor _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -389,17 +389,16 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, _FwdI } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt adjacent_find( - const _FwdIt _First, const _FwdIt _Last) { // find first matching successor +_NODISCARD _CONSTEXPR20 _FwdIt adjacent_find(const _FwdIt _First, const _FwdIt _Last) { // find first matching successor return _STD adjacent_find(_First, _Last, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt adjacent_find(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALG _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept +_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept /* terminates */ { // find first matching successor return _STD adjacent_find(_STD forward<_ExPo>(_Exec), _First, _Last, equal_to{}); @@ -415,7 +414,7 @@ namespace ranges { // clang-format off template _Se, class _Ty, class _Pj = identity> requires indirect_binary_predicate, const _Ty*> - _NODISCARD_PURE_ALG constexpr iter_difference_t<_It> operator()( + _NODISCARD constexpr iter_difference_t<_It> operator()( _It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_unchecked( @@ -424,7 +423,7 @@ namespace ranges { template requires indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD_PURE_ALG constexpr range_difference_t<_Rng> operator()( + _NODISCARD constexpr range_difference_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { return _Count_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); } @@ -469,7 +468,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InIt _Last, _Pr _Pred) { // count elements satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -486,7 +485,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _Iter_diff_t<_InIt> count_if(_InIt _First, _InI #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count_if( +_NODISCARD _Iter_diff_t<_FwdIt> count_if( _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 @@ -498,8 +497,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALG constexpr iter_difference_t<_It> operator()( - _It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr iter_difference_t<_It> operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Count_if_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -507,8 +505,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALG constexpr range_difference_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Count_if_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -536,8 +533,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( - _InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, const _InIt1 _Last1, _InIt2 _First2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, ...) mismatch _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -555,20 +551,19 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( - const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { +_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(const _InIt1 _First1, const _InIt1 _Last1, const _InIt2 _First2) { // return [_First1, _Last1)/[_First2, ...) mismatch return _STD mismatch(_First1, _Last1, _First2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, ...) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -578,7 +573,7 @@ _NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( +_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // return [_First1, _Last1)/[_First2, _Last2) mismatch _Adl_verify_range(_First1, _Last1); @@ -611,20 +606,19 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch( - _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD _CONSTEXPR20 pair<_InIt1, _InIt2> mismatch(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // return [_First1, _Last1)/[_First2, _Last2) mismatch return _STD mismatch(_First1, _Last1, _First2, _Last2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, _Last2) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -689,7 +683,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {},_Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -715,7 +709,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { using _Size1 = _Make_unsigned_like_t>; @@ -739,7 +733,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) { // test if [_First1, _Last1) == permuted [_First2, ...) _Adl_verify_range(_First1, _Last1); auto _UFirst1 = _Get_unwrapped(_First1); @@ -763,7 +757,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _L } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { +_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2) { // test if [_First1, _Last1) == permuted [_First2, ...) return _STD is_permutation(_First1, _Last1, _First2, equal_to<>{}); } @@ -827,7 +821,7 @@ _NODISCARD _CONSTEXPR20 bool is_permutation( } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { +_NODISCARD _CONSTEXPR20 bool is_permutation(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) { // test if [_First1, _Last1) == permuted [_First2, _Last2) return _STD is_permutation(_First1, _Last1, _First2, _Last2, equal_to<>{}); } @@ -846,8 +840,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_equivalence_relation, projected<_It2, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_STD move(_First1)); @@ -872,7 +866,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::equal_to> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (sized_range<_Rng1> && sized_range<_Rng2>) { const auto _Count = _RANGES distance(_Range1); @@ -1112,8 +1106,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool all_of( - _InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred +_NODISCARD _CONSTEXPR20 bool all_of(_InIt _First, _InIt _Last, _Pr _Pred) { // test if all elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); const auto _ULast = _Get_unwrapped(_Last); @@ -1128,7 +1121,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool all_of( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1139,7 +1132,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _All_of_unchecked( @@ -1148,7 +1141,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _All_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1174,7 +1167,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if any element satisfies _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1190,7 +1183,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool any_of(const _InIt _First, const _InIt _La #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1201,7 +1194,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Any_of_unchecked( @@ -1210,7 +1203,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Any_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1236,7 +1229,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if no elements satisfy _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1252,7 +1245,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool none_of(const _InIt _First, const _InIt _L #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1263,7 +1256,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _None_of_unchecked( @@ -1272,7 +1265,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _None_of_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1644,7 +1637,7 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _InIt _Last, _Pr _Pred) { // test if [_First, _Last) partitioned by _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1671,8 +1664,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool is_partitioned(const _InIt _First, const _ #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG bool is_partitioned( - _ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 #ifdef __cpp_lib_concepts @@ -1683,7 +1675,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); return _Is_partitioned_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1691,7 +1683,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { return _Is_partitioned_unchecked(_Ubegin(_Range), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); } @@ -1728,7 +1720,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _FwdIt partition_point(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find beginning of false partition in [_First, _Last) _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1759,7 +1751,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_unary_predicate> _Pr> - _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); if constexpr (sized_sentinel_for<_Se, _It>) { @@ -1776,8 +1768,7 @@ namespace ranges { template , _Pj>> _Pr> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const { if constexpr (sized_range<_Rng>) { const auto _Length = _RANGES distance(_Range); auto _UFirst = _Partition_point_n_unchecked(_Ubegin(_Range), _Length, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -1872,8 +1863,8 @@ _NODISCARD _CONSTEXPR20 bool _Equal_rev_pred_unchecked(_InIt1 _First1, _InIt2 _F } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, - const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred +_NODISCARD _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, + const _FwdItPat _Last2, _Pr _Pred) { // find first [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_First1); @@ -1916,12 +1907,12 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search(_FwdItHaystack _First1, _ #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, +_NODISCARD _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First1, const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) { // find first [_First2, _Last2) match return _STD search(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -1929,7 +1920,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, const _FwdItHaystack _Last1, +_NODISCARD _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _First1, const _FwdItHaystack _Last1, const _FwdItPat _First2, const _FwdItPat _Last2) noexcept /* terminates */ { // find first [_First2, _Last2) match return _STD search(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); @@ -1937,14 +1928,14 @@ _NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&& _Exec, const _FwdItHaystack _F #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdItHaystack search( +_NODISCARD _CONSTEXPR20 _FwdItHaystack search( const _FwdItHaystack _First, const _FwdItHaystack _Last, const _Searcher& _Search) { // find _Search's pattern in [_First, _Last) return _Search(_First, _Last).first; } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt search_n( +_NODISCARD _CONSTEXPR20 _FwdIt search_n( const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) { // find first _Count * _Val satisfying _Pred const _Algorithm_int_t<_Diff> _Count = _Count_raw; @@ -2017,21 +2008,19 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt search_n( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, - const _Ty& _Val, +_NODISCARD _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) noexcept; // terminates #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt search_n( - const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { +_NODISCARD _CONSTEXPR20 _FwdIt search_n(const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) { // find first _Count * _Val match return _STD search_n(_First, _Last, _Count, _Val, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, +_NODISCARD _FwdIt search_n(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Diff _Count, const _Ty& _Val) noexcept /* terminates */ { // find first _Count * _Val match return _STD search_n(_STD forward<_ExPo>(_Exec), _First, _Last, _Count, _Val, equal_to{}); } @@ -2047,7 +2036,7 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALG constexpr subrange<_It> operator()(_It _First, _Se _Last, + _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); @@ -2072,7 +2061,7 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD_PURE_ALG constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, + _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); @@ -2207,7 +2196,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); @@ -2238,7 +2227,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on if constexpr (_Sized_or_infinite_range<_Rng1> && sized_range<_Rng2>) { @@ -2273,7 +2262,7 @@ namespace ranges { requires (forward_iterator<_It1> || sized_sentinel_for<_Se1, _It1>) && (forward_iterator<_It2> || sized_sentinel_for<_Se2, _It2>) && indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); @@ -2296,7 +2285,7 @@ namespace ranges { requires (forward_range<_Rng1> || sized_range<_Rng1>) && (forward_range<_Rng2> || sized_range<_Rng2>) && indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on const auto _Count1 = _Distance_helper(_Range1); @@ -2495,7 +2484,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // find last [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); @@ -2576,7 +2565,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_end( } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_end( +_NODISCARD _CONSTEXPR20 _FwdIt1 find_end( _FwdIt1 const _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) { // find last [_First2, _Last2) match return _STD find_end(_First1, _Last1, _First2, _Last2, equal_to<>{}); @@ -2584,12 +2573,11 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_end( #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt1 find_end( +_NODISCARD _FwdIt1 find_end( _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALG _FwdIt1 find_end( - _ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD _FwdIt1 find_end(_ExPo&& _Exec, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // find last [_First2, _Last2) match return _STD find_end(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } @@ -2706,7 +2694,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, + _NODISCARD constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2736,7 +2724,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr borrowed_subrange_t<_Rng1> operator()( + _NODISCARD constexpr borrowed_subrange_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { if constexpr (random_access_range<_Rng1> && sized_range<_Rng1> && random_access_range<_Rng2> && sized_range<_Rng2>) { @@ -2761,7 +2749,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_first_of( +_NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of( _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) { // look for one of [_First2, _Last2) satisfying _Pred with element _Adl_verify_range(_First1, _Last1); @@ -2784,19 +2772,18 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_first_of( } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, - const _FwdIt2 _First2, +_NODISCARD _CONSTEXPR20 _FwdIt1 find_first_of(const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_First1, _Last1, _First2, _Last2, equal_to<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALG _FwdIt1 find_first_of( +_NODISCARD _FwdIt1 find_first_of( _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); @@ -2813,7 +2800,7 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _NODISCARD constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2829,7 +2816,7 @@ namespace ranges { template requires indirectly_comparable, iterator_t<_Rng2>, _Pr, _Pj1, _Pj2> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng1> operator()( + _NODISCARD constexpr borrowed_iterator_t<_Rng1> operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { auto _First1 = _RANGES begin(_Range1); @@ -5939,7 +5926,7 @@ _CONSTEXPR20 _RanIt _Is_heap_until_unchecked(_RanIt _First, _RanIt _Last, _Pr _P } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last, _Pr _Pred) { // find extent of range that is a heap _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Is_heap_until_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); @@ -5947,7 +5934,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Las } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _Pred) { // test if range is a heap _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -5956,36 +5943,35 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last, _Pr _ } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { +_NODISCARD _CONSTEXPR20 _RanIt is_heap_until(_RanIt _First, _RanIt _Last) { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_First, _Last, less<>{}); } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_heap( - _RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< +_NODISCARD _CONSTEXPR20 bool is_heap(_RanIt _First, _RanIt _Last) { // test if range is a heap ordered by operator< return _STD is_heap(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALG bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept +_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is a heap return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD_PURE_ALG _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD _RanIt is_heap_until(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // find extent of range that is a heap ordered by operator< return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD_PURE_ALG bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { +_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last) noexcept /* terminates */ { // test if range is a heap ordered by operator< return _STD is_heap(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -6022,7 +6008,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _ULast = _Get_unwrapped(_STD move(_Last)); @@ -6034,7 +6020,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); const auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -6050,7 +6036,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); const auto _Size = _RANGES distance(_UFirst, _Get_unwrapped(_STD move(_Last))); @@ -6062,8 +6048,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Size = _RANGES distance(_Range); auto _UResult = _RANGES _Is_heap_until_unchecked(_Ubegin(_Range), _Size, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _Rewrap_iterator(_Range, _STD move(_UResult)); @@ -6173,7 +6158,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _It operator()( + _NODISCARD constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6186,7 +6171,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = @@ -6202,7 +6187,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find first element that _Val is before _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6224,7 +6209,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD _CONSTEXPR20 _FwdIt upper_bound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find first element that _Val is before return _STD upper_bound(_First, _Last, _Val, less<>{}); } @@ -6260,7 +6245,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _It operator()( + _NODISCARD constexpr _It operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6272,7 +6257,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()( _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); auto _UResult = _Upper_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -6287,8 +6272,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( - _FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // find range equivalent to _Val _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6325,7 +6309,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range( } template -_NODISCARD_PURE_ALG _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD _CONSTEXPR20 pair<_FwdIt, _FwdIt> equal_range(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // find range equivalent to _Val return _STD equal_range(_First, _Last, _Val, less<>{}); } @@ -6394,7 +6378,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred) { // test if _Val equivalent to some element _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -6404,7 +6388,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { +_NODISCARD _CONSTEXPR20 bool binary_search(_FwdIt _First, _FwdIt _Last, const _Ty& _Val) { // test if _Val equivalent to some element return _STD binary_search(_First, _Last, _Val, less<>{}); } @@ -6417,7 +6401,7 @@ namespace ranges { template _Se, class _Ty, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _It _First, _Se _Last, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_STD move(_First)); @@ -6430,8 +6414,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()( - _Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _Count = _RANGES distance(_Range); const auto _UFirst = _RANGES _Lower_bound_unchecked(_Ubegin(_Range), _Count, _Val, _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -8448,8 +8431,7 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool includes( - _InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2, _Pr _Pred) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -8473,15 +8455,14 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool includes( } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { +_NODISCARD _CONSTEXPR20 bool includes(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2, _InIt2 _Last2) { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) return _STD includes(_First1, _Last1, _First2, _Last2, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG bool includes( - _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept +_NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8491,7 +8472,7 @@ _NODISCARD_PURE_ALG bool includes( } template = 0> -_NODISCARD_PURE_ALG bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept +_NODISCARD bool includes(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2) noexcept /* terminates */ { // test if every element in sorted [_First2, _Last2) is in sorted [_First1, _Last1) // not parallelized at present, parallelism expected to be feasible in a future release @@ -8509,8 +8490,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); return _Includes_unchecked(_Get_unwrapped(_STD move(_First1)), _Get_unwrapped(_STD move(_Last1)), @@ -8521,7 +8502,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Includes_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); @@ -9133,20 +9114,20 @@ constexpr _FwdIt _Max_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD_PURE_ALG constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element +_NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find largest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Max_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD_PURE_ALG constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element +_NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find largest element return _STD max_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release @@ -9154,7 +9135,7 @@ _NODISCARD_PURE_ALG _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr } template = 0> -_NODISCARD_PURE_ALG _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last); @@ -9188,7 +9169,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9197,8 +9178,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Max_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9226,20 +9206,20 @@ constexpr _FwdIt _Min_element_unchecked(_FwdIt _First, _FwdIt _Last, _Pr _Pred) } template -_NODISCARD_PURE_ALG constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element +_NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest element _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _Min_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred))); return _First; } template -_NODISCARD_PURE_ALG constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element +_NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find smallest element return _STD min_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release @@ -9247,7 +9227,7 @@ _NODISCARD_PURE_ALG _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr } template = 0> -_NODISCARD_PURE_ALG _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last); @@ -9281,7 +9261,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9290,8 +9270,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); _Seek_wrapped(_First, _RANGES _Min_element_unchecked(_Get_unwrapped(_STD move(_First)), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj))); @@ -9345,7 +9324,7 @@ constexpr pair<_FwdIt, _FwdIt> _Minmax_element_unchecked(_FwdIt _First, _FwdIt _ } template -_NODISCARD_PURE_ALG constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find smallest and largest elements _Adl_verify_range(_First, _Last); const auto _Result = _Minmax_element_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last), _Pass_fn(_Pred)); @@ -9355,14 +9334,14 @@ _NODISCARD_PURE_ALG constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, } template -_NODISCARD_PURE_ALG constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { +_NODISCARD constexpr pair<_FwdIt, _FwdIt> minmax_element(_FwdIt _First, _FwdIt _Last) { // find smallest and largest elements return _STD minmax_element(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release @@ -9370,7 +9349,7 @@ _NODISCARD_PURE_ALG pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, } template = 0> -_NODISCARD_PURE_ALG pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept +_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release @@ -9436,7 +9415,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr minmax_element_result<_It> operator()( + _NODISCARD constexpr minmax_element_result<_It> operator()( _It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9449,7 +9428,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr minmax_element_result> operator()( + _NODISCARD constexpr minmax_element_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UResult = _RANGES _Minmax_element_unchecked( @@ -9467,14 +9446,14 @@ namespace ranges { #endif // _HAS_CXX17 template -_NODISCARD_PURE_ALG constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/largest const _Ty* _Res = _Max_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD_PURE_ALG constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { +_NODISCARD constexpr _Ty(max)(initializer_list<_Ty> _Ilist) { // return leftmost/largest return (_STD max)(_Ilist, less<>{}); } @@ -9493,7 +9472,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr const _Ty& operator()( + _NODISCARD constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Left), _STD invoke(_Proj, _Right))) { return _Right; @@ -9504,8 +9483,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _Ty operator()( - initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr _Ty operator()(initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, @@ -9517,7 +9495,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALG constexpr range_value_t<_Rng> operator()( + _NODISCARD constexpr range_value_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); @@ -9545,14 +9523,14 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return leftmost/smallest const _Ty* _Res = _Min_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return *_Res; } template -_NODISCARD_PURE_ALG constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { +_NODISCARD constexpr _Ty(min)(initializer_list<_Ty> _Ilist) { // return leftmost/smallest return (_STD min)(_Ilist, less<>{}); } @@ -9565,7 +9543,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr const _Ty& operator()( + _NODISCARD constexpr const _Ty& operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return _Right; @@ -9576,8 +9554,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _Ty operator()( - initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr _Ty operator()(initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); _STL_ASSERT(_First != _Last, @@ -9589,7 +9566,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALG constexpr range_value_t<_Rng> operator()( + _NODISCARD constexpr range_value_t<_Rng> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); @@ -9617,8 +9594,8 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, - _Pr _Pred) noexcept(noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { +_NODISCARD constexpr pair minmax(const _Ty& _Left, const _Ty& _Right, _Pr _Pred) noexcept( + noexcept(_DEBUG_LT_PRED(_Pred, _Right, _Left))) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_DEBUG_LT_PRED(_Pred, _Right, _Left)) { return {_Right, _Left}; @@ -9628,14 +9605,14 @@ _NODISCARD_PURE_ALG constexpr pair minmax(const _Ty& _Le } template -_NODISCARD_PURE_ALG constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { +_NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist, _Pr _Pred) { // return {leftmost/smallest, rightmost/largest} pair _Res = _Minmax_element_unchecked(_Ilist.begin(), _Ilist.end(), _Pass_fn(_Pred)); return pair<_Ty, _Ty>(*_Res.first, *_Res.second); } template -_NODISCARD_PURE_ALG constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( +_NODISCARD constexpr pair minmax(const _Ty& _Left, const _Ty& _Right) noexcept( noexcept(_Right < _Left)) /* strengthened */ { // return pair(leftmost/smaller, rightmost/larger) of _Left and _Right if (_Right < _Left) { @@ -9647,7 +9624,7 @@ _NODISCARD_PURE_ALG constexpr pair minmax(const _Ty& _Le } template -_NODISCARD_PURE_ALG constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { +_NODISCARD constexpr pair<_Ty, _Ty> minmax(initializer_list<_Ty> _Ilist) { // return {leftmost/smallest, rightmost/largest} return _STD minmax(_Ilist, less<>{}); } @@ -9663,7 +9640,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr minmax_result operator()( + _NODISCARD constexpr minmax_result operator()( const _Ty& _Left, const _Ty& _Right, _Pr _Pred = {}, _Pj _Proj = {}) const { if (_STD invoke(_Pred, _STD invoke(_Proj, _Right), _STD invoke(_Proj, _Left))) { return {_Right, _Left}; @@ -9674,7 +9651,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr minmax_result<_Ty> operator()( + _NODISCARD constexpr minmax_result<_Ty> operator()( initializer_list<_Ty> _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _First = _Range.begin(); const auto _Last = _Range.end(); @@ -9688,7 +9665,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD_PURE_ALG constexpr minmax_result> operator()( + _NODISCARD constexpr minmax_result> operator()( _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { // clang-format on auto _UFirst = _Ubegin(_Range); @@ -9957,7 +9934,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _FwdIt _Last, _Pr _Pred) { // find extent of range that is ordered by predicate _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -9976,7 +9953,7 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt is_sorted_until(const _FwdIt _First, _Fw } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { +_NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr _Pred) { // test if range is ordered by predicate _Adl_verify_range(_First, _Last); const auto _UFirst = _Get_unwrapped(_First); @@ -9985,35 +9962,35 @@ _NODISCARD_PURE_ALG _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last, _Pr } template -_NODISCARD_PURE_ALG _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { +_NODISCARD _CONSTEXPR20 _FwdIt is_sorted_until(_FwdIt _First, _FwdIt _Last) { // find extent of range that is ordered by operator< return _STD is_sorted_until(_First, _Last, less<>{}); } template -_NODISCARD_PURE_ALG _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< +_NODISCARD _CONSTEXPR20 bool is_sorted(_FwdIt _First, _FwdIt _Last) { // test if range is ordered by operator< return _STD is_sorted(_First, _Last, less<>{}); } #if _HAS_CXX17 template = 0> -_NODISCARD_PURE_ALG _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates +_NODISCARD _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD_PURE_ALG bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is ordered by predicate return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } template = 0> -_NODISCARD_PURE_ALG _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD _FwdIt is_sorted_until(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find extent of range that is ordered by operator< return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } template = 0> -_NODISCARD_PURE_ALG bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { +_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // test if range is ordered by operator< return _STD is_sorted(_STD forward<_ExPo>(_Exec), _First, _Last, less{}); } @@ -10026,7 +10003,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); const auto _ULast = _Get_unwrapped(_STD move(_Last)); const auto _UFirst = @@ -10036,7 +10013,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr bool operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { const auto _ULast = _Uend(_Range); const auto _UFirst = _Is_sorted_until_unchecked(_Ubegin(_Range), _ULast, _Pass_fn(_Pred), _Pass_fn(_Proj)); return _UFirst == _ULast; @@ -10051,7 +10028,7 @@ namespace ranges { template _Se, class _Pj = identity, indirect_strict_weak_order> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr _It operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); auto _UFirst = _Is_sorted_until_unchecked( _Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -10061,8 +10038,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr borrowed_iterator_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); auto _UFirst = _Is_sorted_until_unchecked(_Get_unwrapped(_First), _Uend(_Range), _Pass_fn(_Pred), _Pass_fn(_Proj)); @@ -10076,7 +10052,7 @@ namespace ranges { #endif // __cpp_lib_concepts template -_NODISCARD_PURE_ALG constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { +_NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val, _Pr _Pred) { // returns _Val constrained to [_Min_val, _Max_val] #if _ITERATOR_DEBUG_LEVEL == 2 if (_DEBUG_LT_PRED(_Pred, _Max_val, _Min_val)) { @@ -10097,7 +10073,7 @@ _NODISCARD_PURE_ALG constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_ } template -_NODISCARD_PURE_ALG constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { +_NODISCARD constexpr const _Ty& clamp(const _Ty& _Val, const _Ty& _Min_val, const _Ty& _Max_val) { // returns _Val constrained to [_Min_val, _Max_val] return _STD clamp(_Val, _Min_val, _Max_val, less{}); } @@ -10110,7 +10086,7 @@ namespace ranges { template > _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr const _Ty& operator()( + _NODISCARD constexpr const _Ty& operator()( const _Ty& _Val, const _Ty& _Lo, const _Ty& _Hi, _Pr _Pred = {}, _Pj _Proj = {}) const { _STL_ASSERT(!_STD invoke(_Pred, _STD invoke(_Proj, _Hi), _STD invoke(_Proj, _Lo)), "The lower bound cannot be greater than the upper bound in a call to std::ranges::clamp " @@ -10139,8 +10115,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pj1 = identity, class _Pj2 = identity, indirect_strict_weak_order, projected<_It2, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -10152,7 +10128,7 @@ namespace ranges { template , _Pj1>, projected, _Pj2>> _Pr = ranges::less> - _NODISCARD_PURE_ALG constexpr bool operator()( + _NODISCARD constexpr bool operator()( _Rng1&& _Range1, _Rng2&& _Range2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { return _Lexicographical_compare_unchecked(_Ubegin(_Range1), _Uend(_Range1), _Ubegin(_Range2), _Uend(_Range2), _Pass_fn(_Pred), _Pass_fn(_Proj1), _Pass_fn(_Proj2)); diff --git a/stl/inc/any b/stl/inc/any index 987e4bbed4c..12451840096 100644 --- a/stl/inc/any +++ b/stl/inc/any @@ -33,7 +33,7 @@ _STD_BEGIN class bad_any_cast : public bad_cast { // thrown by failed any_cast public: - _NODISCARD_PURE_MTHD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { return "Bad any_cast"; } }; @@ -225,11 +225,11 @@ public: } // Observers [any.observers] - _NODISCARD_PURE_MTHD bool has_value() const noexcept { + _NODISCARD bool has_value() const noexcept { return _Storage._TypeData != 0; } - _NODISCARD_PURE_MTHD const type_info& type() const noexcept { + _NODISCARD const type_info& type() const noexcept { // if *this contains a value of type T, return typeid(T); otherwise typeid(void) const type_info* const _Info = _TypeInfo(); if (_Info) { @@ -359,19 +359,18 @@ inline void swap(any& _Left, any& _Right) noexcept { template , _Types...>, int> = 0> -_NODISCARD_PURE_FN any make_any( - _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... +_NODISCARD any make_any(_Types&&... _Args) { // construct an any containing a _ValueType initialized with _Args... return any{in_place_type<_ValueType>, _STD forward<_Types>(_Args)...}; } template , initializer_list<_Elem>&, _Types...>, int> = 0> -_NODISCARD_PURE_FN any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { +_NODISCARD any make_any(initializer_list<_Elem> _Ilist, _Types&&... _Args) { // construct an any containing a _ValueType initialized with _Ilist and _Args... return any{in_place_type<_ValueType>, _Ilist, _STD forward<_Types>(_Args)...}; } template -_NODISCARD_PURE_FN const _ValueType* any_cast(const any* const _Any) noexcept { +_NODISCARD const _ValueType* any_cast(const any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -386,7 +385,7 @@ _NODISCARD_PURE_FN const _ValueType* any_cast(const any* const _Any) noexcept { } } template -_NODISCARD_ACCESS_FN _ValueType* any_cast(any* const _Any) noexcept { +_NODISCARD _ValueType* any_cast(any* const _Any) noexcept { // retrieve a pointer to the _ValueType contained in _Any, or null static_assert(!is_void_v<_ValueType>, "std::any cannot contain void."); @@ -402,7 +401,7 @@ _NODISCARD_ACCESS_FN _ValueType* any_cast(any* const _Any) noexcept { } template -_NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(const any& _Any) { +_NODISCARD remove_cv_t<_Ty> any_cast(const any& _Any) { static_assert(is_constructible_v, const _Remove_cvref_t<_Ty>&>, "any_cast(const any&) requires remove_cv_t to be constructible from " "const remove_cv_t>&"); @@ -415,7 +414,7 @@ _NODISCARD_PURE_FN remove_cv_t<_Ty> any_cast(const any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_ACCESS_FN remove_cv_t<_Ty> any_cast(any& _Any) { +_NODISCARD remove_cv_t<_Ty> any_cast(any& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>&>, "any_cast(any&) requires remove_cv_t to be constructible from remove_cv_t>&"); @@ -427,7 +426,7 @@ _NODISCARD_ACCESS_FN remove_cv_t<_Ty> any_cast(any& _Any) { return static_cast>(*_Ptr); } template -_NODISCARD_ACCESS_FN remove_cv_t<_Ty> any_cast(any&& _Any) { +_NODISCARD remove_cv_t<_Ty> any_cast(any&& _Any) { static_assert(is_constructible_v, _Remove_cvref_t<_Ty>>, "any_cast(any&&) requires remove_cv_t to be constructible from remove_cv_t>"); diff --git a/stl/inc/array b/stl/inc/array index 4e6c8e90c3c..1fb4108bb51 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -48,11 +48,11 @@ public: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg + _Off) {} - _NODISCARD_PURE_OP _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { return *_Ptr; } - _NODISCARD_PURE_OP _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { return _Ptr; } @@ -83,7 +83,7 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -94,46 +94,46 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { return _Ptr - _Right._Ptr; } - _NODISCARD_PURE_OP _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return _Ptr[_Off]; } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { return _Ptr <=> _Right._Ptr; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { return _Ptr < _Right._Ptr; } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -158,11 +158,11 @@ private: _CONSTEXPR17 explicit _Array_const_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Ptr(_Parg), _Idx(_Off) {} - _NODISCARD_PURE_OP _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { return *operator->(); } - _NODISCARD_PURE_OP _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { _STL_VERIFY(_Ptr, "cannot dereference value-initialized array iterator"); _STL_VERIFY(_Idx < _Size, "cannot dereference out of range array iterator"); return _Ptr + _Idx; @@ -214,7 +214,7 @@ private: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 _Array_const_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -224,50 +224,50 @@ private: return *this += -_Off; } - _NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 _Array_const_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 ptrdiff_t operator-(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_Idx - _Right._Idx); } - _NODISCARD_PURE_OP _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return *(*this + _Off); } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator==(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx == _Right._Idx; } #if _HAS_CXX20 - _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD constexpr strong_ordering operator<=>(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx <=> _Right._Idx; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator!=(const _Array_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator<(const _Array_const_iterator& _Right) const noexcept { _Compat(_Right); return _Idx < _Right._Idx; } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator>(const _Array_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator<=(const _Array_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OP _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR17 bool operator>=(const _Array_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -307,7 +307,7 @@ constexpr void _Verify_range( #endif // _ITERATOR_DEBUG_LEVEL != 0 template -_NODISCARD_PURE_OP _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( +_NODISCARD _CONSTEXPR17 _Array_const_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_const_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -320,7 +320,7 @@ struct pointer_traits<_Array_const_iterator<_Ty, _Size>> { using element_type = const _Ty; using difference_type = ptrdiff_t; - _NODISCARD_PURE_FN static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -346,11 +346,11 @@ public: _CONSTEXPR17 explicit _Array_iterator(pointer _Parg, size_t _Off = 0) noexcept : _Mybase(_Parg, _Off) {} - _NODISCARD_PURE_OP _CONSTEXPR17 reference operator*() const noexcept { + _NODISCARD _CONSTEXPR17 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD_PURE_OP _CONSTEXPR17 pointer operator->() const noexcept { + _NODISCARD _CONSTEXPR17 pointer operator->() const noexcept { return const_cast(_Mybase::operator->()); } @@ -381,7 +381,7 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 _Array_iterator operator+(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -394,13 +394,13 @@ public: using _Mybase::operator-; - _NODISCARD_PURE_OP _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 _Array_iterator operator-(const ptrdiff_t _Off) const noexcept { _Array_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { + _NODISCARD _CONSTEXPR17 reference operator[](const ptrdiff_t _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -412,7 +412,7 @@ public: }; template -_NODISCARD_PURE_OP _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( +_NODISCARD _CONSTEXPR17 _Array_iterator<_Ty, _Size> operator+( const ptrdiff_t _Off, _Array_iterator<_Ty, _Size> _Next) noexcept { _Next += _Off; return _Next; @@ -425,7 +425,7 @@ struct pointer_traits<_Array_iterator<_Ty, _Size>> { using element_type = _Ty; using difference_type = ptrdiff_t; - _NODISCARD_PURE_FN static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { return _Iter._Unwrapped(); } }; @@ -462,51 +462,51 @@ public: _Swap_ranges_unchecked(_Elems, _Elems + _Size, _Other._Elems); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD _CONSTEXPR17 iterator begin() noexcept { return iterator(_Elems, 0); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator(_Elems, 0); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD _CONSTEXPR17 iterator end() noexcept { return iterator(_Elems, _Size); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator(_Elems, _Size); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -526,11 +526,11 @@ public: return _Elems + _Size; } - _NODISCARD_PURE_MTHD constexpr size_type size() const noexcept { + _NODISCARD constexpr size_type size() const noexcept { return _Size; } - _NODISCARD_PURE_MTHD constexpr size_type max_size() const noexcept { + _NODISCARD constexpr size_type max_size() const noexcept { return _Size; } @@ -538,7 +538,7 @@ public: return false; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reference at(size_type _Pos) { + _NODISCARD _CONSTEXPR17 reference at(size_type _Pos) { if (_Size <= _Pos) { _Xran(); } @@ -546,7 +546,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_PURE_MTHD constexpr const_reference at(size_type _Pos) const { + _NODISCARD constexpr const_reference at(size_type _Pos) const { if (_Size <= _Pos) { _Xran(); } @@ -554,7 +554,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_ACCESS_OP _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept + _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); @@ -563,7 +563,7 @@ public: return _Elems[_Pos]; } - _NODISCARD_PURE_OP constexpr const_reference operator[](_In_range_(0, _Size - 1) size_type _Pos) const noexcept + _NODISCARD constexpr const_reference operator[](_In_range_(0, _Size - 1) size_type _Pos) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); @@ -572,27 +572,27 @@ public: return _Elems[_Pos]; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reference front() noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR17 reference front() noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD_PURE_MTHD constexpr const_reference front() const noexcept /* strengthened */ { + _NODISCARD constexpr const_reference front() const noexcept /* strengthened */ { return _Elems[0]; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reference back() noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR17 reference back() noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD_PURE_MTHD constexpr const_reference back() const noexcept /* strengthened */ { + _NODISCARD constexpr const_reference back() const noexcept /* strengthened */ { return _Elems[_Size - 1]; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { return _Elems; } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD _CONSTEXPR17 const _Ty* data() const noexcept { return _Elems; } @@ -642,51 +642,51 @@ public: _CONSTEXPR20 void swap(array&) noexcept {} - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator begin() noexcept { + _NODISCARD _CONSTEXPR17 iterator begin() noexcept { return iterator{}; } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator begin() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator begin() const noexcept { return const_iterator{}; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 iterator end() noexcept { + _NODISCARD _CONSTEXPR17 iterator end() noexcept { return iterator{}; } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator end() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator end() const noexcept { return const_iterator{}; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rbegin() noexcept { + _NODISCARD _CONSTEXPR17 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 reverse_iterator rend() noexcept { + _NODISCARD _CONSTEXPR17 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cbegin() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_iterator cend() const noexcept { + _NODISCARD _CONSTEXPR17 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { + _NODISCARD _CONSTEXPR17 const_reverse_iterator crend() const noexcept { return rend(); } @@ -706,15 +706,15 @@ public: return nullptr; } - _NODISCARD_PURE_MTHD constexpr size_type size() const noexcept { + _NODISCARD constexpr size_type size() const noexcept { return 0; } - _NODISCARD_PURE_MTHD constexpr size_type max_size() const noexcept { + _NODISCARD constexpr size_type max_size() const noexcept { return 0; } - _NODISCARD_PURE_MTHD constexpr bool empty() const noexcept { + _NODISCARD constexpr bool empty() const noexcept { return true; } @@ -726,7 +726,7 @@ public: _Xran(); } - _NODISCARD_ACCESS_OP reference operator[](size_type) noexcept /* strengthened */ { + _NODISCARD reference operator[](size_type) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -734,7 +734,7 @@ public: return *data(); } - _NODISCARD_PURE_OP const_reference operator[](size_type) const noexcept /* strengthened */ { + _NODISCARD const_reference operator[](size_type) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -742,7 +742,7 @@ public: return *data(); } - _NODISCARD_ACCESS_MTHD reference front() noexcept /* strengthened */ { + _NODISCARD reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -750,7 +750,7 @@ public: return *data(); } - _NODISCARD_PURE_MTHD const_reference front() const noexcept /* strengthened */ { + _NODISCARD const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::front() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -758,7 +758,7 @@ public: return *data(); } - _NODISCARD_ACCESS_MTHD reference back() noexcept /* strengthened */ { + _NODISCARD reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -766,7 +766,7 @@ public: return *data(); } - _NODISCARD_PURE_MTHD const_reference back() const noexcept /* strengthened */ { + _NODISCARD const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_REPORT_ERROR("array::back() invalid"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -774,11 +774,11 @@ public: return *data(); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR17 _Ty* data() noexcept { + _NODISCARD _CONSTEXPR17 _Ty* data() noexcept { return nullptr; } - _NODISCARD_PURE_MTHD _CONSTEXPR17 const _Ty* data() const noexcept { + _NODISCARD _CONSTEXPR17 const _Ty* data() const noexcept { return nullptr; } @@ -797,7 +797,7 @@ _CONSTEXPR20 void swap(array<_Ty, _Size>& _Left, array<_Ty, _Size>& _Right) noex } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD equal(_Left.begin(), _Left.end(), _Right.begin()); #else // ^^^ workaround / no workaround vvv @@ -807,14 +807,14 @@ _NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const array<_Ty, _Size>& _Left, #if !_HAS_CXX20 template -_NODISCARD_PURE_OP bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD bool operator!=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 #ifdef __cpp_lib_concepts template -_NODISCARD_PURE_OP constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD constexpr _Synth_three_way_result<_Ty> operator<=>( const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { #ifdef __EDG__ // TRANSITION, VSO-1161663 return _STD lexicographical_compare_three_way( @@ -836,17 +836,17 @@ _NODISCARD _CONSTEXPR20 bool operator<(const array<_Ty, _Size>& _Left, const arr } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator>(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator<=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Right < _Left); } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator>=(const array<_Ty, _Size>& _Left, const array<_Ty, _Size>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ @@ -865,7 +865,7 @@ _NODISCARD constexpr array, _Size> _To_array_rvalue_impl( } template -_NODISCARD_PURE_FN constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { +_NODISCARD constexpr array, _Size> to_array(_Ty (&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/1: " "to_array does not accept multidimensional arrays."); static_assert(is_constructible_v<_Ty, _Ty&>, "N4830 [array.creation]/1: " @@ -874,7 +874,7 @@ _NODISCARD_PURE_FN constexpr array, _Size> to_array(_Ty (&_Arra } template -_NODISCARD_PURE_FN constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { +_NODISCARD constexpr array, _Size> to_array(_Ty(&&_Array)[_Size]) { static_assert(!is_array_v<_Ty>, "N4830 [array.creation]/4: " "to_array does not accept multidimensional arrays."); static_assert(is_move_constructible_v<_Ty>, "N4830 [array.creation]/4: " @@ -884,25 +884,25 @@ _NODISCARD_PURE_FN constexpr array, _Size> to_array(_Ty(&&_Arra #endif // _HAS_CXX20 template -_NODISCARD_ACCESS_FN constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD_PURE_FN constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { +_NODISCARD constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _Arr._Elems[_Idx]; } template -_NODISCARD_ACCESS_FN constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } template -_NODISCARD_PURE_FN constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { +_NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept { static_assert(_Idx < _Size, "array index out of bounds"); return _STD move(_Arr._Elems[_Idx]); } diff --git a/stl/inc/atomic b/stl/inc/atomic index 969448fe4ab..457f7c153af 100644 --- a/stl/inc/atomic +++ b/stl/inc/atomic @@ -500,7 +500,7 @@ struct _Atomic_storage { _Storage = _Value; } - _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD _TVal load(const memory_order _Order = memory_order_seq_cst) const noexcept { // load with sequential consistency _Check_load_memory_order(_Order); _Guard _Lock{_Spinlock}; @@ -661,14 +661,14 @@ struct _Atomic_storage<_Ty, 1> { // lock-free using 1-byte intrinsics } } - _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); char _As_bytes = __iso_volatile_load8(_Mem); _Load_barrier(_Order); @@ -782,14 +782,14 @@ struct _Atomic_storage<_Ty, 2> { // lock-free using 2-byte intrinsics } } - _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); short _As_bytes = __iso_volatile_load16(_Mem); _Load_barrier(_Order); @@ -900,14 +900,14 @@ struct _Atomic_storage<_Ty, 4> { // lock-free using 4-byte intrinsics } } - _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Compiler_or_memory_barrier(); return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); auto _As_bytes = __iso_volatile_load32(_Mem); _Load_barrier(_Order); @@ -1024,7 +1024,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics } } - _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD _TVal load() const noexcept { // load with sequential consistency const auto _Mem = _Atomic_address_as(_Storage); long long _As_bytes; #ifdef _M_ARM @@ -1037,7 +1037,7 @@ struct _Atomic_storage<_Ty, 8> { // lock-free using 8-byte intrinsics return reinterpret_cast<_TVal&>(_As_bytes); } - _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order const auto _Mem = _Atomic_address_as(_Storage); #ifdef _M_ARM long long _As_bytes = __ldrexd(_Mem); @@ -1140,14 +1140,14 @@ struct _Atomic_storage<_Ty&, 16> { // lock-free using 16-byte intrinsics (void) exchange(_Value, _Order); } - _NODISCARD_PURE_MTHD _TVal load() const noexcept { // load with sequential consistency + _NODISCARD _TVal load() const noexcept { // load with sequential consistency long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 (void) _STD_COMPARE_EXCHANGE_128(_Storage_ptr, 0, 0, &_Result._Low); return reinterpret_cast<_TVal&>(_Result); } - _NODISCARD_PURE_MTHD _TVal load(const memory_order _Order) const noexcept { // load with given memory order + _NODISCARD _TVal load(const memory_order _Order) const noexcept { // load with given memory order #if defined(_M_ARM64) || defined(_M_ARM64EC) long long* const _Storage_ptr = const_cast(_Atomic_address_as(_Storage)); _Int128 _Result{}; // atomic CAS 0 with 0 @@ -2110,14 +2110,14 @@ public: #endif // _HAS_CXX17 #if 1 // TRANSITION, ABI - _NODISCARD_PURE_MTHD bool is_lock_free() const volatile noexcept { + _NODISCARD bool is_lock_free() const volatile noexcept { constexpr bool _Result = sizeof(_Ty) <= 8 && (sizeof(_Ty) & sizeof(_Ty) - 1) == 0; return _Result; } #else // ^^^ don't break ABI / break ABI vvv - _NODISCARD_PURE_MTHD bool is_lock_free() const volatile noexcept { + _NODISCARD bool is_lock_free() const volatile noexcept { #if _ATOMIC_HAS_DCAS return sizeof(_Ty) <= 2 * sizeof(void*); #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2126,7 +2126,7 @@ public: } #endif // TRANSITION, ABI - _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { + _NODISCARD bool is_lock_free() const noexcept { return static_cast(this)->is_lock_free(); } @@ -2158,12 +2158,12 @@ public: } using _Base::load; - _NODISCARD_PURE_MTHD _Ty load() const volatile noexcept { + _NODISCARD _Ty load() const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(); } - _NODISCARD_PURE_MTHD _Ty load(const memory_order _Order) const volatile noexcept { + _NODISCARD _Ty load(const memory_order _Order) const volatile noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return const_cast(this)->_Base::load(_Order); } @@ -2293,7 +2293,7 @@ public: static constexpr size_t required_alignment = _Is_potentially_lock_free ? sizeof(_Ty) : alignof(_Ty); - _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { + _NODISCARD bool is_lock_free() const noexcept { #if _ATOMIC_HAS_DCAS return is_always_lock_free; #else // ^^^ _ATOMIC_HAS_DCAS / !_ATOMIC_HAS_DCAS vvv @@ -2374,12 +2374,12 @@ private: #endif // _HAS_CXX20 template -_NODISCARD_PURE_FN bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { +_NODISCARD bool atomic_is_lock_free(const volatile atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } template -_NODISCARD_PURE_FN bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { +_NODISCARD bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { return _Mem->is_lock_free(); } @@ -2420,25 +2420,24 @@ _CXX20_DEPRECATE_ATOMIC_INIT void atomic_init( } template -_NODISCARD_PURE_FN _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { +_NODISCARD _Ty atomic_load(const volatile atomic<_Ty>* const _Mem) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(); } template -_NODISCARD_PURE_FN _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { +_NODISCARD _Ty atomic_load(const atomic<_Ty>* const _Mem) noexcept { return _Mem->load(); } template -_NODISCARD_PURE_FN _Ty atomic_load_explicit( - const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD _Ty atomic_load_explicit(const volatile atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { static_assert(_Deprecate_non_lock_free_volatile<_Ty>, "Never fails"); return _Mem->load(_Order); } template -_NODISCARD_PURE_FN _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { +_NODISCARD _Ty atomic_load_explicit(const atomic<_Ty>* const _Mem, const memory_order _Order) noexcept { return _Mem->load(_Order); } @@ -2750,11 +2749,11 @@ using atomic_unsigned_lock_free = atomic_uintptr_t; {} struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 - _NODISCARD_PURE_MTHD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD bool test(const memory_order _Order = memory_order_seq_cst) const noexcept { return _Storage.load(_Order) != 0; } - _NODISCARD_PURE_MTHD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { + _NODISCARD bool test(const memory_order _Order = memory_order_seq_cst) const volatile noexcept { return _Storage.load(_Order) != 0; } #endif // _HAS_CXX20 @@ -2812,21 +2811,20 @@ struct atomic_flag { // flag with test-and-set semantics #if _HAS_CXX20 -_NODISCARD_PURE_MTHD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { +_NODISCARD inline bool atomic_flag_test(const volatile atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD_PURE_MTHD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { +_NODISCARD inline bool atomic_flag_test(const atomic_flag* const _Flag) noexcept { return _Flag->test(); } -_NODISCARD_PURE_MTHD inline bool atomic_flag_test_explicit( +_NODISCARD inline bool atomic_flag_test_explicit( const volatile atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } -_NODISCARD_PURE_MTHD inline bool atomic_flag_test_explicit( - const atomic_flag* const _Flag, const memory_order _Order) noexcept { +_NODISCARD inline bool atomic_flag_test_explicit(const atomic_flag* const _Flag, const memory_order _Order) noexcept { return _Flag->test(_Order); } #endif // _HAS_CXX20 diff --git a/stl/inc/barrier b/stl/inc/barrier index 3331a2f8e3c..71c653259e0 100644 --- a/stl/inc/barrier +++ b/stl/inc/barrier @@ -88,7 +88,7 @@ public: barrier(const barrier&) = delete; barrier& operator=(const barrier&) = delete; - _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD static constexpr ptrdiff_t(max)() noexcept { return _Barrier_max; } diff --git a/stl/inc/bit b/stl/inc/bit index 251f3e60b1c..fe1d267f7fd 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -30,22 +30,22 @@ template , is_trivially_copyable<_To>, is_trivially_copyable<_From>>, int> = 0> -_NODISCARD_PURE_FN constexpr _To bit_cast(const _From& _Val) noexcept { +_NODISCARD constexpr _To bit_cast(const _From& _Val) noexcept { return __builtin_bit_cast(_To, _Val); } template , int> = 0> -_NODISCARD_PURE_FN constexpr int countl_zero(_Ty _Val) noexcept; +_NODISCARD constexpr int countl_zero(_Ty _Val) noexcept; template , int> = 0> -_NODISCARD_PURE_FN constexpr bool has_single_bit(const _Ty _Val) noexcept { +_NODISCARD constexpr bool has_single_bit(const _Ty _Val) noexcept { return _Val != 0 && (_Val & (_Val - 1)) == 0; } inline void _Precondition_violation_in_bit_ceil() noexcept {} template , int> = 0> -_NODISCARD_PURE_FN constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { +_NODISCARD constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthened */ { if (_Val <= 1u) { return _Ty{1}; } @@ -73,7 +73,7 @@ _NODISCARD_PURE_FN constexpr _Ty bit_ceil(const _Ty _Val) noexcept /* strengthen } template , int> = 0> -_NODISCARD_PURE_FN constexpr _Ty bit_floor(const _Ty _Val) noexcept { +_NODISCARD constexpr _Ty bit_floor(const _Ty _Val) noexcept { if (_Val == 0) { return 0; } @@ -82,15 +82,15 @@ _NODISCARD_PURE_FN constexpr _Ty bit_floor(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD_PURE_FN constexpr _Ty bit_width(const _Ty _Val) noexcept { +_NODISCARD constexpr _Ty bit_width(const _Ty _Val) noexcept { return static_cast<_Ty>(numeric_limits<_Ty>::digits - _STD countl_zero(_Val)); } template , int> = 0> -_NODISCARD_PURE_FN constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; +_NODISCARD constexpr _Ty rotr(_Ty _Val, int _Rotation) noexcept; template , int> = 0> -_NODISCARD_PURE_FN constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; if (!_STD is_constant_evaluated()) { @@ -118,7 +118,7 @@ _NODISCARD_PURE_FN constexpr _Ty rotl(const _Ty _Val, const int _Rotation) noexc } template , int> _Enabled> -_NODISCARD_PURE_FN constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { +_NODISCARD constexpr _Ty rotr(const _Ty _Val, const int _Rotation) noexcept { constexpr auto _Digits = numeric_limits<_Ty>::digits; if (!_STD is_constant_evaluated()) { @@ -290,7 +290,7 @@ _NODISCARD constexpr unsigned long long _Byteswap_uint64(const unsigned long lon #endif // _HAS_CXX23 template , int> _Enabled> -_NODISCARD_PURE_FN constexpr int countl_zero(const _Ty _Val) noexcept { +_NODISCARD constexpr int countl_zero(const _Ty _Val) noexcept { #if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) if (!_STD is_constant_evaluated()) { return _Checked_x86_x64_countl_zero(_Val); @@ -305,28 +305,28 @@ _NODISCARD_PURE_FN constexpr int countl_zero(const _Ty _Val) noexcept { } template , int> = 0> -_NODISCARD_PURE_FN constexpr int countl_one(const _Ty _Val) noexcept { +_NODISCARD constexpr int countl_one(const _Ty _Val) noexcept { return _STD countl_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD_PURE_FN constexpr int countr_zero(const _Ty _Val) noexcept { +_NODISCARD constexpr int countr_zero(const _Ty _Val) noexcept { return _Countr_zero(_Val); } template , int> _Enabled = 0> -_NODISCARD_PURE_FN constexpr int countr_one(const _Ty _Val) noexcept { +_NODISCARD constexpr int countr_one(const _Ty _Val) noexcept { return _Countr_zero(static_cast<_Ty>(~_Val)); } template , int> = 0> -_NODISCARD_PURE_FN constexpr int popcount(const _Ty _Val) noexcept { +_NODISCARD constexpr int popcount(const _Ty _Val) noexcept { return _Popcount(_Val); } #if _HAS_CXX23 template , int> = 0> -_NODISCARD_PURE_FN constexpr _Ty byteswap(const _Ty _Val) noexcept { +_NODISCARD constexpr _Ty byteswap(const _Ty _Val) noexcept { if constexpr (sizeof(_Ty) == 1) { return _Val; } else if constexpr (sizeof(_Ty) == 2) { diff --git a/stl/inc/cmath b/stl/inc/cmath index daf47ce7d64..49276893cfa 100644 --- a/stl/inc/cmath +++ b/stl/inc/cmath @@ -33,39 +33,39 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -_NODISCARD_PURE_FN _Check_return_ inline float acos(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float acos(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD acosf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float acosh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float acosh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD acoshf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float asin(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float asin(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD asinf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float asinh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float asinh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD asinhf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float atan(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float atan(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD atanf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float atanh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float atanh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD atanhf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float atan2(_In_ float _Yx, _In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float atan2(_In_ float _Yx, _In_ float _Xx) noexcept /* strengthened */ { return _CSTD atan2f(_Yx, _Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float cbrt(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float cbrt(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD cbrtf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __ceilf(_Xx); #elif defined(__clang__) @@ -75,7 +75,7 @@ _NODISCARD_PURE_FN _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept +_NODISCARD _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __copysignf(_Number, _Sign); @@ -86,43 +86,43 @@ _NODISCARD_PURE_FN _Check_return_ inline float copysign(_In_ float _Number, _In_ #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline float cos(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float cos(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD cosf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float cosh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float cosh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD coshf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float erf(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float erf(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD erff(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float erfc(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float erfc(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD erfcf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float exp(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float exp(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD expf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float exp2(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float exp2(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD exp2f(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float expm1(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float expm1(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD expm1f(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float fabs(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float fabs(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD fabsf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float fdim(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float fdim(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fdimf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float floor(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float floor(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __floorf(_Xx); #elif defined(__clang__) @@ -132,20 +132,20 @@ _NODISCARD_PURE_FN _Check_return_ inline float floor(_In_ float _Xx) noexcept /* #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept +_NODISCARD _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept /* strengthened */ { return _CSTD fmaf(_Xx, _Yx, _Zx); } -_NODISCARD_PURE_FN _Check_return_ inline float fmax(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float fmax(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fmaxf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float fmin(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float fmin(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fminf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float fmod(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float fmod(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD fmodf(_Xx, _Yx); } @@ -153,55 +153,55 @@ inline float frexp(_In_ float _Xx, _Out_ int* _Yx) noexcept /* strengthened */ { return _CSTD frexpf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float hypot(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float hypot(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD hypotf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline int ilogb(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline int ilogb(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD ilogbf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float ldexp(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float ldexp(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD ldexpf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float lgamma(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float lgamma(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD lgammaf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long long llrint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long long llrint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD llrintf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long long llround(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long long llround(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD llroundf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float log(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float log(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD logf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float log10(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float log10(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD log10f(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float log1p(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float log1p(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD log1pf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float log2(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float log2(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD log2f(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float logb(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float logb(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD logbf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long lrint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long lrint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD lrintf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long lround(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long lround(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD lroundf(_Xx); } @@ -209,24 +209,24 @@ inline float modf(_In_ float _Xx, _Out_ float* _Yx) noexcept /* strengthened */ return _CSTD modff(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float nearbyint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float nearbyint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD nearbyintf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float nextafter(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float nextafter(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD nextafterf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nexttowardf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float pow(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float pow(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD powf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float remainder(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float remainder(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ { return _CSTD remainderf(_Xx, _Yx); } @@ -234,11 +234,11 @@ inline float remquo(_In_ float _Xx, _In_ float _Yx, _Out_ int* _Zx) noexcept /* return _CSTD remquof(_Xx, _Yx, _Zx); } -_NODISCARD_PURE_FN _Check_return_ inline float rint(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float rint(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD rintf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float round(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float round(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __roundf(_Xx); #elif defined(__clang__) @@ -248,39 +248,39 @@ _NODISCARD_PURE_FN _Check_return_ inline float round(_In_ float _Xx) noexcept /* #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline float scalbln(_In_ float _Xx, _In_ long _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float scalbln(_In_ float _Xx, _In_ long _Yx) noexcept /* strengthened */ { return _CSTD scalblnf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float scalbn(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float scalbn(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD scalbnf(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline float sin(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float sin(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD sinf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float sinh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float sinh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD sinhf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float sqrt(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float sqrt(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD sqrtf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float tan(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float tan(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD tanf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float tanh(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float tanh(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD tanhf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float tgamma(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float tgamma(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD tgammaf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float trunc(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float trunc(_In_ float _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __truncf(_Xx); #elif defined(__clang__) @@ -290,40 +290,40 @@ _NODISCARD_PURE_FN _Check_return_ inline float trunc(_In_ float _Xx) noexcept /* #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline long double acos(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double acos(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD acosl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double acosh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double acosh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD acoshl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double asin(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double asin(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD asinl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double asinh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double asinh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD asinhl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double atan(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double atan(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD atanl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double atanh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double atanh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD atanhl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double atan2(_In_ long double _Yx, _In_ long double _Xx) noexcept +_NODISCARD _Check_return_ inline long double atan2(_In_ long double _Yx, _In_ long double _Xx) noexcept /* strengthened */ { return _CSTD atan2l(_Yx, _Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double cbrt(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double cbrt(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD cbrtl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double ceil(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double ceil(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __ceil(static_cast(_Xx)); #elif defined(__clang__) @@ -333,7 +333,7 @@ _NODISCARD_PURE_FN _Check_return_ inline long double ceil(_In_ long double _Xx) #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline long double copysign(_In_ long double _Number, _In_ long double _Sign) noexcept +_NODISCARD _Check_return_ inline long double copysign(_In_ long double _Number, _In_ long double _Sign) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __copysign(static_cast(_Number), static_cast(_Sign)); @@ -344,44 +344,44 @@ _NODISCARD_PURE_FN _Check_return_ inline long double copysign(_In_ long double _ #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline long double cos(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double cos(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD cosl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double cosh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double cosh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD coshl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double erf(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double erf(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD erfl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double erfc(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double erfc(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD erfcl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double exp(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double exp(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD expl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double exp2(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double exp2(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD exp2l(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double expm1(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double expm1(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD expm1l(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double fabs(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double fabs(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD fabsl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double fdim(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double fdim(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fdiml(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double floor(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double floor(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __floor(static_cast(_Xx)); #elif defined(__clang__) @@ -391,22 +391,22 @@ _NODISCARD_PURE_FN _Check_return_ inline long double floor(_In_ long double _Xx) #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline long double fma( +_NODISCARD _Check_return_ inline long double fma( _In_ long double _Xx, _In_ long double _Yx, _In_ long double _Zx) noexcept /* strengthened */ { return _CSTD fmal(_Xx, _Yx, _Zx); } -_NODISCARD_PURE_FN _Check_return_ inline long double fmax(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double fmax(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fmaxl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double fmin(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double fmin(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fminl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double fmod(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double fmod(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD fmodl(_Xx, _Yx); } @@ -415,57 +415,57 @@ inline long double frexp(_In_ long double _Xx, _Out_ int* _Yx) noexcept /* stren return _CSTD frexpl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double hypot(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double hypot(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD hypotl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline int ilogb(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline int ilogb(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD ilogbl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept +_NODISCARD _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD ldexpl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double lgamma(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double lgamma(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD lgammal(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long long llrint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long long llrint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD llrintl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long long llround(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long long llround(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD llroundl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double log(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double log(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD logl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double log10(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double log10(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD log10l(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double log1p(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double log1p(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD log1pl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double log2(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double log2(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD log2l(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double logb(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double logb(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD logbl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long lrint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long lrint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD lrintl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long lround(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long lround(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD lroundl(_Xx); } @@ -473,26 +473,26 @@ inline long double modf(_In_ long double _Xx, _Out_ long double* _Yx) noexcept / return _CSTD modfl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double nearbyint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double nearbyint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD nearbyintl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double nextafter(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double nextafter(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nextafterl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double nexttoward(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double nexttoward(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nexttowardl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double pow(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double pow(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD powl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double remainder(_In_ long double _Xx, _In_ long double _Yx) noexcept +_NODISCARD _Check_return_ inline long double remainder(_In_ long double _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD remainderl(_Xx, _Yx); } @@ -501,11 +501,11 @@ inline long double remquo(_In_ long double _Xx, _In_ long double _Yx, _Out_ int* return _CSTD remquol(_Xx, _Yx, _Zx); } -_NODISCARD_PURE_FN _Check_return_ inline long double rint(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double rint(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD rintl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double round(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double round(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __round(static_cast(_Xx)); #elif defined(__clang__) @@ -515,41 +515,41 @@ _NODISCARD_PURE_FN _Check_return_ inline long double round(_In_ long double _Xx) #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD_PURE_FN _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept +_NODISCARD _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept /* strengthened */ { return _CSTD scalblnl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept +_NODISCARD _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD scalbnl(_Xx, _Yx); } -_NODISCARD_PURE_FN _Check_return_ inline long double sin(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double sin(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD sinl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double sinh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double sinh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD sinhl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double sqrt(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double sqrt(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD sqrtl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double tan(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double tan(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD tanl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double tanh(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double tanh(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD tanhl(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double tgamma(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double tgamma(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD tgammal(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double trunc(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double trunc(_In_ long double _Xx) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __trunc(static_cast(_Xx)); #elif defined(__clang__) @@ -574,7 +574,7 @@ double frexp(_Ty _Value, _Out_ int* const _Exp) noexcept /* strengthened */ { template && _STD is_arithmetic_v<_Ty2> && _STD is_arithmetic_v<_Ty3>, int> = 0> -_NODISCARD_PURE_FN _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>> fma( +_NODISCARD _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>> fma( _Ty1 _Left, _Ty2 _Middle, _Ty3 _Right) noexcept /* strengthened */ { using _Common = _STD _Common_float_type_t<_Ty1, _STD _Common_float_type_t<_Ty2, _Ty3>>; if constexpr (_STD is_same_v<_Common, float>) { @@ -600,7 +600,7 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo #define _GENERIC_MATH1_BASE(NAME, RET, FUN) \ template , int> = 0> \ - _NODISCARD_PURE_FN RET NAME(_Ty _Left) noexcept /* strengthened */ { \ + _NODISCARD RET NAME(_Ty _Left) noexcept /* strengthened */ { \ return FUN(static_cast(_Left)); \ } @@ -615,19 +615,18 @@ _STD _Common_float_type_t<_Ty1, _Ty2> remquo(_Ty1 _Left, _Ty2 _Right, int* _Pquo #define _GENERIC_MATH1I(FUN, CLANG_INTRIN, MSVC_INTRIN) _GENERIC_MATH1_BASE(FUN, double, _CSTD FUN) #endif // ^^^ intrinsics unavailable ^^^ -#define _GENERIC_MATH1X(FUN, ARG2) \ - template , int> = 0> \ - _NODISCARD_PURE_FN double FUN(_Ty _Left, ARG2 _Arg2) noexcept /* strengthened */ { \ - return _CSTD FUN(static_cast(_Left), _Arg2); \ +#define _GENERIC_MATH1X(FUN, ARG2) \ + template , int> = 0> \ + _NODISCARD double FUN(_Ty _Left, ARG2 _Arg2) noexcept /* strengthened */ { \ + return _CSTD FUN(static_cast(_Left), _Arg2); \ } -#define _GENERIC_MATH2_BASE(NAME, FUN) \ - template && _STD is_arithmetic_v<_Ty2>, int> = 0> \ - _NODISCARD_PURE_FN _STD _Common_float_type_t<_Ty1, _Ty2> NAME( \ - _Ty1 _Left, _Ty2 _Right) noexcept /* strengthened */ { \ - using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>; \ - return FUN(static_cast<_Common>(_Left), static_cast<_Common>(_Right)); \ +#define _GENERIC_MATH2_BASE(NAME, FUN) \ + template && _STD is_arithmetic_v<_Ty2>, int> = 0> \ + _NODISCARD _STD _Common_float_type_t<_Ty1, _Ty2> NAME(_Ty1 _Left, _Ty2 _Right) noexcept /* strengthened */ { \ + using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>; \ + return FUN(static_cast<_Common>(_Left), static_cast<_Common>(_Right)); \ } #define _GENERIC_MATH2(FUN) _GENERIC_MATH2_BASE(FUN, _CSTD FUN) @@ -960,281 +959,276 @@ _NODISCARD _CRT_SATELLITE_2 float __stdcall __std_smf_hypot3f(float, float, floa _END_EXTERN_C _STD_BEGIN -_NODISCARD_PURE_FN inline double assoc_laguerre( - const unsigned int _Degree, const unsigned int _Order, const double _Value) { +_NODISCARD inline double assoc_laguerre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { return __std_smf_assoc_laguerre(_Degree, _Order, _Value); } -_NODISCARD_PURE_FN inline float assoc_laguerref( - const unsigned int _Degree, const unsigned int _Order, const float _Value) { +_NODISCARD inline float assoc_laguerref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { return __std_smf_assoc_laguerref(_Degree, _Order, _Value); } -_NODISCARD_PURE_FN inline long double assoc_laguerrel( +_NODISCARD inline long double assoc_laguerrel( const unsigned int _Degree, const unsigned int _Order, const long double _Value) { return __std_smf_assoc_laguerre(_Degree, _Order, static_cast(_Value)); } -_NODISCARD_PURE_FN inline double assoc_legendre( - const unsigned int _Degree, const unsigned int _Order, const double _Value) { +_NODISCARD inline double assoc_legendre(const unsigned int _Degree, const unsigned int _Order, const double _Value) { return __std_smf_assoc_legendre(_Degree, _Order, _Value); } -_NODISCARD_PURE_FN inline float assoc_legendref( - const unsigned int _Degree, const unsigned int _Order, const float _Value) { +_NODISCARD inline float assoc_legendref(const unsigned int _Degree, const unsigned int _Order, const float _Value) { return __std_smf_assoc_legendref(_Degree, _Order, _Value); } -_NODISCARD_PURE_FN inline long double assoc_legendrel( +_NODISCARD inline long double assoc_legendrel( const unsigned int _Degree, const unsigned int _Order, const long double _Value) { return __std_smf_assoc_legendre(_Degree, _Order, static_cast(_Value)); } -_NODISCARD_PURE_FN inline double beta(const double _Arg1, const double _Arg2) { +_NODISCARD inline double beta(const double _Arg1, const double _Arg2) { return __std_smf_beta(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float betaf(const float _Arg1, const float _Arg2) { +_NODISCARD inline float betaf(const float _Arg1, const float _Arg2) { return __std_smf_betaf(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double betal(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double betal(const long double _Arg1, const long double _Arg2) { return __std_smf_beta(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double comp_ellint_1(const double _Arg) { +_NODISCARD inline double comp_ellint_1(const double _Arg) { return __std_smf_comp_ellint_1(_Arg); } -_NODISCARD_PURE_FN inline float comp_ellint_1f(const float _Arg) { +_NODISCARD inline float comp_ellint_1f(const float _Arg) { return __std_smf_comp_ellint_1f(_Arg); } -_NODISCARD_PURE_FN inline long double comp_ellint_1l(const long double _Arg) { +_NODISCARD inline long double comp_ellint_1l(const long double _Arg) { return __std_smf_comp_ellint_1(static_cast(_Arg)); } -_NODISCARD_PURE_FN inline double comp_ellint_2(const double _Arg) { +_NODISCARD inline double comp_ellint_2(const double _Arg) { return __std_smf_comp_ellint_2(_Arg); } -_NODISCARD_PURE_FN inline float comp_ellint_2f(const float _Arg) { +_NODISCARD inline float comp_ellint_2f(const float _Arg) { return __std_smf_comp_ellint_2f(_Arg); } -_NODISCARD_PURE_FN inline long double comp_ellint_2l(const long double _Arg) { +_NODISCARD inline long double comp_ellint_2l(const long double _Arg) { return __std_smf_comp_ellint_2(static_cast(_Arg)); } -_NODISCARD_PURE_FN inline double comp_ellint_3(const double _Arg1, const double _Arg2) { +_NODISCARD inline double comp_ellint_3(const double _Arg1, const double _Arg2) { return __std_smf_comp_ellint_3(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float comp_ellint_3f(const float _Arg1, const float _Arg2) { +_NODISCARD inline float comp_ellint_3f(const float _Arg1, const float _Arg2) { return __std_smf_comp_ellint_3f(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double comp_ellint_3l(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double comp_ellint_3l(const long double _Arg1, const long double _Arg2) { return __std_smf_comp_ellint_3(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double cyl_bessel_i(const double _Arg1, const double _Arg2) { +_NODISCARD inline double cyl_bessel_i(const double _Arg1, const double _Arg2) { return __std_smf_cyl_bessel_i(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float cyl_bessel_if(const float _Arg1, const float _Arg2) { +_NODISCARD inline float cyl_bessel_if(const float _Arg1, const float _Arg2) { return __std_smf_cyl_bessel_if(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double cyl_bessel_il(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double cyl_bessel_il(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_bessel_i(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double cyl_bessel_j(const double _Arg1, const double _Arg2) { +_NODISCARD inline double cyl_bessel_j(const double _Arg1, const double _Arg2) { return __std_smf_cyl_bessel_j(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float cyl_bessel_jf(const float _Arg1, const float _Arg2) { +_NODISCARD inline float cyl_bessel_jf(const float _Arg1, const float _Arg2) { return __std_smf_cyl_bessel_jf(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double cyl_bessel_jl(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double cyl_bessel_jl(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_bessel_j(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double cyl_bessel_k(const double _Arg1, const double _Arg2) { +_NODISCARD inline double cyl_bessel_k(const double _Arg1, const double _Arg2) { return __std_smf_cyl_bessel_k(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float cyl_bessel_kf(const float _Arg1, const float _Arg2) { +_NODISCARD inline float cyl_bessel_kf(const float _Arg1, const float _Arg2) { return __std_smf_cyl_bessel_kf(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double cyl_bessel_kl(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double cyl_bessel_kl(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_bessel_k(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double cyl_neumann(const double _Arg1, const double _Arg2) { +_NODISCARD inline double cyl_neumann(const double _Arg1, const double _Arg2) { return __std_smf_cyl_neumann(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float cyl_neumannf(const float _Arg1, const float _Arg2) { +_NODISCARD inline float cyl_neumannf(const float _Arg1, const float _Arg2) { return __std_smf_cyl_neumannf(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double cyl_neumannl(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double cyl_neumannl(const long double _Arg1, const long double _Arg2) { return __std_smf_cyl_neumann(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double ellint_1(const double _Arg1, const double _Arg2) { +_NODISCARD inline double ellint_1(const double _Arg1, const double _Arg2) { return __std_smf_ellint_1(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float ellint_1f(const float _Arg1, const float _Arg2) { +_NODISCARD inline float ellint_1f(const float _Arg1, const float _Arg2) { return __std_smf_ellint_1f(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double ellint_1l(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double ellint_1l(const long double _Arg1, const long double _Arg2) { return __std_smf_ellint_1(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double ellint_2(const double _Arg1, const double _Arg2) { +_NODISCARD inline double ellint_2(const double _Arg1, const double _Arg2) { return __std_smf_ellint_2(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float ellint_2f(const float _Arg1, const float _Arg2) { +_NODISCARD inline float ellint_2f(const float _Arg1, const float _Arg2) { return __std_smf_ellint_2f(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double ellint_2l(const long double _Arg1, const long double _Arg2) { +_NODISCARD inline long double ellint_2l(const long double _Arg1, const long double _Arg2) { return __std_smf_ellint_2(static_cast(_Arg1), static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double ellint_3(const double _Arg1, const double _Arg2, const double _Arg3) { +_NODISCARD inline double ellint_3(const double _Arg1, const double _Arg2, const double _Arg3) { return __std_smf_ellint_3(_Arg1, _Arg2, _Arg3); } -_NODISCARD_PURE_FN inline float ellint_3f(const float _Arg1, const float _Arg2, const float _Arg3) { +_NODISCARD inline float ellint_3f(const float _Arg1, const float _Arg2, const float _Arg3) { return __std_smf_ellint_3f(_Arg1, _Arg2, _Arg3); } -_NODISCARD_PURE_FN inline long double ellint_3l( - const long double _Arg1, const long double _Arg2, const long double _Arg3) { +_NODISCARD inline long double ellint_3l(const long double _Arg1, const long double _Arg2, const long double _Arg3) { return __std_smf_ellint_3(static_cast(_Arg1), static_cast(_Arg2), static_cast(_Arg3)); } -_NODISCARD_PURE_FN inline double expint(const double _Arg) { +_NODISCARD inline double expint(const double _Arg) { return __std_smf_expint(_Arg); } -_NODISCARD_PURE_FN inline float expintf(const float _Arg) { +_NODISCARD inline float expintf(const float _Arg) { return __std_smf_expintf(_Arg); } -_NODISCARD_PURE_FN inline long double expintl(const long double _Arg) { +_NODISCARD inline long double expintl(const long double _Arg) { return __std_smf_expint(static_cast(_Arg)); } -_NODISCARD_PURE_FN inline double hermite(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD inline double hermite(const unsigned int _Arg1, const double _Arg2) { return __std_smf_hermite(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float hermitef(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD inline float hermitef(const unsigned int _Arg1, const float _Arg2) { return __std_smf_hermitef(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double hermitel(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD inline long double hermitel(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_hermite(_Arg1, static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double laguerre(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD inline double laguerre(const unsigned int _Arg1, const double _Arg2) { return __std_smf_laguerre(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float laguerref(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD inline float laguerref(const unsigned int _Arg1, const float _Arg2) { return __std_smf_laguerref(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double laguerrel(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD inline long double laguerrel(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_laguerre(_Arg1, static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double legendre(const unsigned int _Degree, const double _Value) { +_NODISCARD inline double legendre(const unsigned int _Degree, const double _Value) { return __std_smf_legendre(_Degree, _Value); } -_NODISCARD_PURE_FN inline float legendref(const unsigned int _Degree, const float _Value) { +_NODISCARD inline float legendref(const unsigned int _Degree, const float _Value) { return __std_smf_legendref(_Degree, _Value); } -_NODISCARD_PURE_FN inline long double legendrel(const unsigned int _Degree, const long double _Value) { +_NODISCARD inline long double legendrel(const unsigned int _Degree, const long double _Value) { return __std_smf_legendre(_Degree, static_cast(_Value)); } -_NODISCARD_PURE_FN inline double riemann_zeta(const double _Arg) { +_NODISCARD inline double riemann_zeta(const double _Arg) { return __std_smf_riemann_zeta(_Arg); } -_NODISCARD_PURE_FN inline float riemann_zetaf(const float _Arg) { +_NODISCARD inline float riemann_zetaf(const float _Arg) { return __std_smf_riemann_zetaf(_Arg); } -_NODISCARD_PURE_FN inline long double riemann_zetal(const long double _Arg) { +_NODISCARD inline long double riemann_zetal(const long double _Arg) { return __std_smf_riemann_zeta(static_cast(_Arg)); } -_NODISCARD_PURE_FN inline double sph_bessel(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD inline double sph_bessel(const unsigned int _Arg1, const double _Arg2) { return __std_smf_sph_bessel(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float sph_besself(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD inline float sph_besself(const unsigned int _Arg1, const float _Arg2) { return __std_smf_sph_besself(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double sph_bessell(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD inline long double sph_bessell(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_sph_bessel(_Arg1, static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double sph_legendre(const unsigned int _Arg1, const unsigned int _Arg2, const double _Theta) { +_NODISCARD inline double sph_legendre(const unsigned int _Arg1, const unsigned int _Arg2, const double _Theta) { return __std_smf_sph_legendre(_Arg1, _Arg2, _Theta); } -_NODISCARD_PURE_FN inline float sph_legendref(const unsigned int _Arg1, const unsigned int _Arg2, const float _Theta) { +_NODISCARD inline float sph_legendref(const unsigned int _Arg1, const unsigned int _Arg2, const float _Theta) { return __std_smf_sph_legendref(_Arg1, _Arg2, _Theta); } -_NODISCARD_PURE_FN inline long double sph_legendrel( +_NODISCARD inline long double sph_legendrel( const unsigned int _Arg1, const unsigned int _Arg2, const long double _Theta) { return __std_smf_sph_legendre(_Arg1, _Arg2, static_cast(_Theta)); } -_NODISCARD_PURE_FN inline double sph_neumann(const unsigned int _Arg1, const double _Arg2) { +_NODISCARD inline double sph_neumann(const unsigned int _Arg1, const double _Arg2) { return __std_smf_sph_neumann(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline float sph_neumannf(const unsigned int _Arg1, const float _Arg2) { +_NODISCARD inline float sph_neumannf(const unsigned int _Arg1, const float _Arg2) { return __std_smf_sph_neumannf(_Arg1, _Arg2); } -_NODISCARD_PURE_FN inline long double sph_neumannl(const unsigned int _Arg1, const long double _Arg2) { +_NODISCARD inline long double sph_neumannl(const unsigned int _Arg1, const long double _Arg2) { return __std_smf_sph_neumann(_Arg1, static_cast(_Arg2)); } -_NODISCARD_PURE_FN inline double hypot(const double _Dx, const double _Dy, const double _Dz) { +_NODISCARD inline double hypot(const double _Dx, const double _Dy, const double _Dz) { return __std_smf_hypot3(_Dx, _Dy, _Dz); } -_NODISCARD_PURE_FN inline float hypot(const float _Dx, const float _Dy, const float _Dz) { +_NODISCARD inline float hypot(const float _Dx, const float _Dy, const float _Dz) { return __std_smf_hypot3f(_Dx, _Dy, _Dz); } -_NODISCARD_PURE_FN inline long double hypot(const long double _Dx, const long double _Dy, const long double _Dz) { +_NODISCARD inline long double hypot(const long double _Dx, const long double _Dy, const long double _Dz) { return __std_smf_hypot3(static_cast(_Dx), static_cast(_Dy), static_cast(_Dz)); } template && is_arithmetic_v<_Ty2> && is_arithmetic_v<_Ty3>, int> = 0> -_NODISCARD_PURE_FN auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) { +_NODISCARD auto hypot(const _Ty1 _Dx, const _Ty2 _Dy, const _Ty3 _Dz) { // N4727 [cmath.syn]/2 "Sufficient additional overloads" // Note that this template is selected by overload resolution only when at least one // argument is double/long double/integral but not all three are double or long double. @@ -1323,15 +1317,15 @@ _NODISCARD constexpr _Ty _Common_lerp(const _Ty _ArgA, const _Ty _ArgB, const _T // As of 2019-06-17 it is unclear whether the "sufficient additional overloads" clause is intended to target lerp; // LWG-3223 is pending. -_NODISCARD_PURE_FN constexpr inline float lerp(const float _ArgA, const float _ArgB, const float _ArgT) noexcept { +_NODISCARD constexpr inline float lerp(const float _ArgA, const float _ArgB, const float _ArgT) noexcept { return _Common_lerp(_ArgA, _ArgB, _ArgT); } -_NODISCARD_PURE_FN constexpr inline double lerp(const double _ArgA, const double _ArgB, const double _ArgT) noexcept { +_NODISCARD constexpr inline double lerp(const double _ArgA, const double _ArgB, const double _ArgT) noexcept { return _Common_lerp(_ArgA, _ArgB, _ArgT); } -_NODISCARD_PURE_FN constexpr inline long double lerp( +_NODISCARD constexpr inline long double lerp( const long double _ArgA, const long double _ArgB, const long double _ArgT) noexcept { return _Common_lerp(_ArgA, _ArgB, _ArgT); } diff --git a/stl/inc/cstddef b/stl/inc/cstddef index cd8f9280dc3..2e346ffc161 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -28,36 +28,36 @@ using max_align_t = double; // most aligned type enum class byte : unsigned char {}; template , int> = 0> -_NODISCARD_PURE_OP constexpr byte operator<<( +_NODISCARD constexpr byte operator<<( const byte _Arg, const _IntType _Shift) noexcept { // bitwise LEFT SHIFT, every static_cast is intentional return static_cast(static_cast(static_cast(_Arg) << _Shift)); } template , int> = 0> -_NODISCARD_PURE_OP constexpr byte operator>>( +_NODISCARD constexpr byte operator>>( const byte _Arg, const _IntType _Shift) noexcept { // bitwise RIGHT SHIFT, every static_cast is intentional return static_cast(static_cast(static_cast(_Arg) >> _Shift)); } -_NODISCARD_PURE_OP constexpr byte operator|( +_NODISCARD constexpr byte operator|( const byte _Left, const byte _Right) noexcept { // bitwise OR, every static_cast is intentional return static_cast( static_cast(static_cast(_Left) | static_cast(_Right))); } -_NODISCARD_PURE_OP constexpr byte operator&( +_NODISCARD constexpr byte operator&( const byte _Left, const byte _Right) noexcept { // bitwise AND, every static_cast is intentional return static_cast( static_cast(static_cast(_Left) & static_cast(_Right))); } -_NODISCARD_PURE_OP constexpr byte operator^( +_NODISCARD constexpr byte operator^( const byte _Left, const byte _Right) noexcept { // bitwise XOR, every static_cast is intentional return static_cast( static_cast(static_cast(_Left) ^ static_cast(_Right))); } -_NODISCARD_PURE_OP constexpr byte operator~(const byte _Arg) noexcept { // bitwise NOT, every static_cast is intentional +_NODISCARD constexpr byte operator~(const byte _Arg) noexcept { // bitwise NOT, every static_cast is intentional return static_cast(static_cast(~static_cast(_Arg))); } @@ -84,7 +84,7 @@ constexpr byte& operator^=(byte& _Left, const byte _Right) noexcept { // bitwise } template , int> = 0> -_NODISCARD_PURE_FN constexpr _IntType to_integer(const byte _Arg) noexcept { // convert byte to integer +_NODISCARD constexpr _IntType to_integer(const byte _Arg) noexcept { // convert byte to integer return static_cast<_IntType>(_Arg); } #endif // __cpp_lib_byte diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index 046ef75769d..7afdd58d8ba 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -20,15 +20,15 @@ _STL_DISABLE_CLANG_WARNINGS #undef new // has abs(long) and abs(long long) -_NODISCARD_PURE_FN _Check_return_ inline double abs(_In_ double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline double abs(_In_ double _Xx) noexcept /* strengthened */ { return _CSTD fabs(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline float abs(_In_ float _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline float abs(_In_ float _Xx) noexcept /* strengthened */ { return _CSTD fabsf(_Xx); } -_NODISCARD_PURE_FN _Check_return_ inline long double abs(_In_ long double _Xx) noexcept /* strengthened */ { +_NODISCARD _Check_return_ inline long double abs(_In_ long double _Xx) noexcept /* strengthened */ { return _CSTD fabsl(_Xx); } diff --git a/stl/inc/exception b/stl/inc/exception index d8ec95cbf02..f89eb8bda2e 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -40,7 +40,7 @@ using ::terminate; using ::set_terminate; using ::terminate_handler; -_NODISCARD_PURE_FN inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler +_NODISCARD inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler return _get_terminate(); } #endif // _M_CEE_PURE @@ -52,7 +52,7 @@ using ::unexpected; using ::set_unexpected; using ::unexpected_handler; -_NODISCARD_PURE_FN inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler +_NODISCARD inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler return _get_unexpected(); } #endif // _M_CEE_PURE @@ -98,8 +98,7 @@ public: virtual __CLR_OR_THIS_CALL ~exception() noexcept {} - _NODISCARD_PURE_MTHD virtual const char* __CLR_OR_THIS_CALL - what() const noexcept { // return pointer to message string + _NODISCARD virtual const char* __CLR_OR_THIS_CALL what() const noexcept { // return pointer to message string return _Ptr ? _Ptr : "unknown exception"; } @@ -168,7 +167,7 @@ inline terminate_handler __CRTDECL set_terminate(terminate_handler) noexcept { / _CSTD abort(); } -_NODISCARD_PURE_FN inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler +_NODISCARD inline terminate_handler __CRTDECL get_terminate() noexcept { // get current terminate handler return nullptr; } @@ -181,7 +180,7 @@ inline unexpected_handler __CRTDECL set_unexpected(unexpected_handler) noexcept inline void __CRTDECL unexpected() {} // handle unexpected exception -_NODISCARD_PURE_FN inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler +_NODISCARD inline unexpected_handler __CRTDECL get_unexpected() noexcept { // get current unexpected handler return nullptr; } #endif // _HAS_UNEXPECTED @@ -299,7 +298,7 @@ private: #endif // __clang__ }; -_NODISCARD_PURE_FN inline exception_ptr current_exception() noexcept { +_NODISCARD inline exception_ptr current_exception() noexcept { return exception_ptr::_Current_exception(); } @@ -335,7 +334,7 @@ public: } } - _NODISCARD_PURE_MTHD exception_ptr nested_ptr() const noexcept { // return wrapped exception_ptr + _NODISCARD exception_ptr nested_ptr() const noexcept { // return wrapped exception_ptr return _Exc; } diff --git a/stl/inc/execution b/stl/inc/execution index 337e696eea8..5eff0af946a 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -138,7 +138,7 @@ struct is_execution_policy : true_type {}; #endif // _HAS_CXX20 struct _Parallelism_resources_exhausted : exception { - _NODISCARD_PURE_MTHD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { // return pointer to message string return "Insufficient resources were available to use additional parallelism."; } @@ -1110,7 +1110,7 @@ bool _All_of_family_parallel(_FwdIt _First, const _FwdIt _Last, _Pr _Pred) { } template /* = 0 */> -_NODISCARD_PURE_ALG bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if all elements in [_First, _Last) satisfy _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1124,7 +1124,7 @@ _NODISCARD_PURE_ALG bool all_of(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) } template /* = 0 */> -_NODISCARD_PURE_ALG bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if any element in [_First, _Last) satisfies _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1138,7 +1138,7 @@ _NODISCARD_PURE_ALG bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last } template /* = 0 */> -_NODISCARD_PURE_ALG bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if no element in [_First, _Last) satisfies _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1336,7 +1336,7 @@ _FwdIt _Find_parallel_unchecked(_ExPo&&, const _FwdIt _First, const _FwdIt _Last } template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +_NODISCARD _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // find first matching _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1349,7 +1349,7 @@ _NODISCARD_PURE_ALG _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last } template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find first satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1363,7 +1363,7 @@ _NODISCARD_PURE_ALG _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _L } template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find first satisfying !_Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1521,8 +1521,8 @@ struct _Static_partitioned_find_end_backward2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt1 find_end(_ExPo&&, _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, - const _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _FwdIt1 find_end(_ExPo&&, _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, + _Pr _Pred) noexcept /* terminates */ { // find last [_First2, _Last2) satisfying _Pred _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -1577,7 +1577,7 @@ _NODISCARD_PURE_ALG _FwdIt1 find_end(_ExPo&&, _FwdIt1 _First1, const _FwdIt1 _La } template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, +_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -1643,7 +1643,7 @@ struct _Static_partitioned_adjacent_find2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt adjacent_find(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _FwdIt adjacent_find(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find first satisfying _Pred with successor _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -1701,7 +1701,7 @@ struct _Static_partitioned_count_if2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // count elements satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1736,8 +1736,7 @@ _NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, } template /* = 0 */> -_NODISCARD_PURE_ALG _Iter_diff_t<_FwdIt> count( - _ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +_NODISCARD _Iter_diff_t<_FwdIt> count(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // count elements that match _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -1864,7 +1863,7 @@ struct _Static_partitioned_mismatch2 { #pragma warning(disable : 4868) // compiler may not enforce left-to-right evaluation order // in braced initializer list (/Wall) template /* = 0 */> -_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, ...) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -1906,7 +1905,7 @@ _NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( #pragma warning(pop) template /* = 0 */> -_NODISCARD_PURE_ALG pair<_FwdIt1, _FwdIt2> mismatch( +_NODISCARD pair<_FwdIt1, _FwdIt2> mismatch( _ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { // return [_First1, _Last1)/[_First2, _Last2) mismatch _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -1983,8 +1982,7 @@ struct _Static_partitioned_equal2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG bool equal( - _ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept +_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { // compare [_First1, _Last1) to [_First2, ...) _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); @@ -2017,8 +2015,8 @@ _NODISCARD_PURE_ALG bool equal( } template /* = 0 */> -_NODISCARD_PURE_ALG bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, - const _FwdIt2 _Last2, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2, + _Pr _Pred) noexcept /* terminates */ { // compare [_First1, _Last1) to [_First2, _Last2) _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -2103,8 +2101,8 @@ struct _Static_partitioned_search2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _FwdItHaystack search(_ExPo&&, const _FwdItHaystack _First1, _FwdItHaystack _Last1, - const _FwdItPat _First2, const _FwdItPat _Last2, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _FwdItHaystack search(_ExPo&&, const _FwdItHaystack _First1, _FwdItHaystack _Last1, const _FwdItPat _First2, + const _FwdItPat _Last2, _Pr _Pred) noexcept /* terminates */ { // find first [_First2, _Last2) match _Adl_verify_range(_First2, _Last2); const auto _UFirst2 = _Get_unwrapped(_First2); @@ -2230,7 +2228,7 @@ struct _Static_partitioned_search_n2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt search_n(_ExPo&&, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, +_NODISCARD _FwdIt search_n(_ExPo&&, const _FwdIt _First, _FwdIt _Last, const _Diff _Count_raw, const _Ty& _Val, _Pr _Pred) noexcept /* terminates */ { // find first _Count * _Val satisfying _Pred const _Algorithm_int_t<_Diff> _Count = _Count_raw; @@ -2566,7 +2564,7 @@ struct _Static_partitioned_remove_if2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // remove each satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -2593,7 +2591,7 @@ _NODISCARD_PURE_ALG _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, } template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // remove each matching _Val return _STD remove_if(_STD forward<_ExPo>(_Exec), _First, _Last, @@ -3048,7 +3046,7 @@ struct _Static_partitioned_is_sorted_until { }; template /* = 0 */> -_NODISCARD_PURE_ALG _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _FwdIt is_sorted_until(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find extent of range that is ordered by predicate _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -3202,7 +3200,7 @@ struct _Static_partitioned_is_partitioned { }; template /* = 0 */> -_NODISCARD_PURE_ALG bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if [_First, _Last) is partitioned by _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -3275,7 +3273,7 @@ struct _Static_partitioned_is_heap_until { }; template /* = 0 */> -_NODISCARD_PURE_ALG _RanIt is_heap_until(_ExPo&&, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _RanIt is_heap_until(_ExPo&&, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { // find extent of range that is a heap _REQUIRE_PARALLEL_ITERATOR(_RanIt); _Adl_verify_range(_First, _Last); @@ -4046,7 +4044,7 @@ struct _Static_partitioned_reduce2 { }; template /* = 0 */> -_NODISCARD_PURE_ALG _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept +_NODISCARD _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept /* terminates */ { // return commutative and associative reduction of _Val and [_First, _Last), using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt); @@ -4146,8 +4144,8 @@ struct _Static_partitioned_transform_reduce_binary2 { // transform-reduction tas // in braced initializer list (/Wall) template /* = 0 */> -_NODISCARD_PURE_ALG _Ty transform_reduce(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Ty _Val, - _BinOp1 _Reduce_op, _BinOp2 _Transform_op) noexcept /* terminates */ { +_NODISCARD _Ty transform_reduce(_ExPo&&, _FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2, _Ty _Val, _BinOp1 _Reduce_op, + _BinOp2 _Transform_op) noexcept /* terminates */ { // return commutative and associative transform-reduction of sequences, using _Reduce_op and _Transform_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -4242,7 +4240,7 @@ struct _Static_partitioned_transform_reduce2 { // transformed reduction task sch template /* = 0 */> -_NODISCARD_PURE_ALG _Ty transform_reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op, +_NODISCARD _Ty transform_reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op, _UnaryOp _Transform_op) noexcept /* terminates */ { // return commutative and associative reduction of transformed sequence, using _Reduce_op and _Transform_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt); diff --git a/stl/inc/latch b/stl/inc/latch index e2dd618ab7a..20279650f03 100644 --- a/stl/inc/latch +++ b/stl/inc/latch @@ -31,7 +31,7 @@ _STD_BEGIN class latch { public: - _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD static constexpr ptrdiff_t(max)() noexcept { return (1ULL << (sizeof(ptrdiff_t) * CHAR_BIT - 1)) - 1; } diff --git a/stl/inc/memory b/stl/inc/memory index 1783733a999..58ae8bf9a2c 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -890,7 +890,7 @@ public: explicit raw_storage_iterator(_OutIt _First) : _Next(_First) {} - _NODISCARD_ACCESS_OP raw_storage_iterator& operator*() { // pretend to return designated value + _NODISCARD raw_storage_iterator& operator*() { // pretend to return designated value return *this; } @@ -915,7 +915,7 @@ public: return _Ans; } - _NODISCARD_PURE_MTHD _OutIt base() const { + _NODISCARD _OutIt base() const { return _Next; } @@ -989,7 +989,7 @@ public: delete _Myptr; } - _NODISCARD_PURE_OP _Ty& operator*() const noexcept { + _NODISCARD _Ty& operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL == 2 _STL_VERIFY(_Myptr, "auto_ptr not dereferenceable"); #endif // _ITERATOR_DEBUG_LEVEL == 2 @@ -997,7 +997,7 @@ public: return *get(); } - _NODISCARD_PURE_OP _Ty* operator->() const noexcept { + _NODISCARD _Ty* operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL == 2 _STL_VERIFY(_Myptr, "auto_ptr not dereferenceable"); #endif // _ITERATOR_DEBUG_LEVEL == 2 @@ -1005,7 +1005,7 @@ public: return get(); } - _NODISCARD_PURE_MTHD _Ty* get() const noexcept { + _NODISCARD _Ty* get() const noexcept { return _Myptr; } @@ -1039,7 +1039,7 @@ class bad_weak_ptr : public exception { // exception type for invalid use of exp public: bad_weak_ptr() noexcept {} - _NODISCARD_PURE_MTHD const char* __CLR_OR_THIS_CALL what() const noexcept override { + _NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override { // return pointer to message string return "bad_weak_ptr"; } @@ -1249,13 +1249,12 @@ class _Ptr_base { // base class for shared_ptr and weak_ptr public: using element_type = remove_extent_t<_Ty>; - _NODISCARD_PURE_MTHD long use_count() const noexcept { + _NODISCARD long use_count() const noexcept { return _Rep ? _Rep->_Use_count() : 0; } template - _NODISCARD_PURE_MTHD bool owner_before( - const _Ptr_base<_Ty2>& _Right) const noexcept { // compare addresses of manager objects + _NODISCARD bool owner_before(const _Ptr_base<_Ty2>& _Right) const noexcept { // compare addresses of manager objects return _Rep < _Right._Rep; } @@ -1263,7 +1262,7 @@ public: _Ptr_base& operator=(const _Ptr_base&) = delete; protected: - _NODISCARD_PURE_MTHD element_type* get() const noexcept { + _NODISCARD element_type* get() const noexcept { return _Ptr; } @@ -1693,22 +1692,22 @@ public: using _Mybase::get; template , is_void<_Ty2>>, int> = 0> - _NODISCARD_PURE_OP _Ty2& operator*() const noexcept { + _NODISCARD _Ty2& operator*() const noexcept { return *get(); } template , int> = 0> - _NODISCARD_PURE_OP _Ty2* operator->() const noexcept { + _NODISCARD _Ty2* operator->() const noexcept { return get(); } template , int> = 0> - _NODISCARD_PURE_OP _Elem& operator[](ptrdiff_t _Idx) const noexcept /* strengthened */ { + _NODISCARD _Elem& operator[](ptrdiff_t _Idx) const noexcept /* strengthened */ { return get()[_Idx]; } #if _HAS_DEPRECATED_SHARED_PTR_UNIQUE - _CXX17_DEPRECATE_SHARED_PTR_UNIQUE _NODISCARD_PURE_MTHD bool unique() const noexcept { + _CXX17_DEPRECATE_SHARED_PTR_UNIQUE _NODISCARD bool unique() const noexcept { // return true if no other shared_ptr object owns this resource return this->use_count() == 1; } @@ -1808,105 +1807,105 @@ shared_ptr(unique_ptr<_Ty, _Dx>) -> shared_ptr<_Ty>; #endif // _HAS_CXX17 template -_NODISCARD_PURE_OP bool operator==(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD bool operator==(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() == _Right.get(); } #if _HAS_CXX20 template -_NODISCARD_PURE_OP strong_ordering operator<=>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD strong_ordering operator<=>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() <=> _Right.get(); } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template -_NODISCARD_PURE_OP bool operator!=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD bool operator!=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() != _Right.get(); } template -_NODISCARD_PURE_OP bool operator<(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD bool operator<(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() < _Right.get(); } template -_NODISCARD_PURE_OP bool operator>=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD bool operator>=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() >= _Right.get(); } template -_NODISCARD_PURE_OP bool operator>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD bool operator>(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() > _Right.get(); } template -_NODISCARD_PURE_OP bool operator<=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { +_NODISCARD bool operator<=(const shared_ptr<_Ty1>& _Left, const shared_ptr<_Ty2>& _Right) noexcept { return _Left.get() <= _Right.get(); } #endif // ^^^ !_HAS_CXX20 ^^^ template -_NODISCARD_PURE_OP bool operator==(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD bool operator==(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() == nullptr; } #if _HAS_CXX20 template -_NODISCARD_PURE_OP strong_ordering operator<=>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD strong_ordering operator<=>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() <=> static_cast::element_type*>(nullptr); } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv template -_NODISCARD_PURE_OP bool operator==(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD bool operator==(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return nullptr == _Right.get(); } template -_NODISCARD_PURE_OP bool operator!=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD bool operator!=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() != nullptr; } template -_NODISCARD_PURE_OP bool operator!=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD bool operator!=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return nullptr != _Right.get(); } template -_NODISCARD_PURE_OP bool operator<(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD bool operator<(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() < static_cast::element_type*>(nullptr); } template -_NODISCARD_PURE_OP bool operator<(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD bool operator<(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) < _Right.get(); } template -_NODISCARD_PURE_OP bool operator>=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD bool operator>=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() >= static_cast::element_type*>(nullptr); } template -_NODISCARD_PURE_OP bool operator>=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD bool operator>=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) >= _Right.get(); } template -_NODISCARD_PURE_OP bool operator>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD bool operator>(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() > static_cast::element_type*>(nullptr); } template -_NODISCARD_PURE_OP bool operator>(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD bool operator>(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) > _Right.get(); } template -_NODISCARD_PURE_OP bool operator<=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { +_NODISCARD bool operator<=(const shared_ptr<_Ty>& _Left, nullptr_t) noexcept { return _Left.get() <= static_cast::element_type*>(nullptr); } template -_NODISCARD_PURE_OP bool operator<=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { +_NODISCARD bool operator<=(nullptr_t, const shared_ptr<_Ty>& _Right) noexcept { return static_cast::element_type*>(nullptr) <= _Right.get(); } #endif // ^^^ !_HAS_CXX20 ^^^ @@ -1923,42 +1922,42 @@ void swap(shared_ptr<_Ty>& _Left, shared_ptr<_Ty>& _Right) noexcept { } template -_NODISCARD_PURE_FN shared_ptr<_Ty1> static_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> static_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // static_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = static_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_Other, _Ptr); } template -_NODISCARD_ACCESS_FN shared_ptr<_Ty1> static_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> static_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // static_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = static_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_STD move(_Other), _Ptr); } template -_NODISCARD_PURE_FN shared_ptr<_Ty1> const_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> const_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // const_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = const_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_Other, _Ptr); } template -_NODISCARD_ACCESS_FN shared_ptr<_Ty1> const_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> const_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // const_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = const_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_STD move(_Other), _Ptr); } template -_NODISCARD_PURE_FN shared_ptr<_Ty1> reinterpret_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> reinterpret_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // reinterpret_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = reinterpret_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_Other, _Ptr); } template -_NODISCARD_ACCESS_FN shared_ptr<_Ty1> reinterpret_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> reinterpret_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // reinterpret_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = reinterpret_cast::element_type*>(_Other.get()); return shared_ptr<_Ty1>(_STD move(_Other), _Ptr); @@ -1966,7 +1965,7 @@ _NODISCARD_ACCESS_FN shared_ptr<_Ty1> reinterpret_pointer_cast(shared_ptr<_Ty2>& #ifdef _CPPRTTI template -_NODISCARD_PURE_FN shared_ptr<_Ty1> dynamic_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> dynamic_pointer_cast(const shared_ptr<_Ty2>& _Other) noexcept { // dynamic_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = dynamic_cast::element_type*>(_Other.get()); @@ -1978,7 +1977,7 @@ _NODISCARD_PURE_FN shared_ptr<_Ty1> dynamic_pointer_cast(const shared_ptr<_Ty2>& } template -_NODISCARD_ACCESS_FN shared_ptr<_Ty1> dynamic_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { +_NODISCARD shared_ptr<_Ty1> dynamic_pointer_cast(shared_ptr<_Ty2>&& _Other) noexcept { // dynamic_cast for shared_ptr that properly respects the reference count control block const auto _Ptr = dynamic_cast::element_type*>(_Other.get()); @@ -1997,7 +1996,7 @@ shared_ptr<_Ty1> dynamic_pointer_cast(shared_ptr<_Ty2>&&) noexcept = delete; // #if _HAS_STATIC_RTTI template -_NODISCARD_PURE_FN _Dx* get_deleter(const shared_ptr<_Ty>& _Sx) noexcept { +_NODISCARD _Dx* get_deleter(const shared_ptr<_Ty>& _Sx) noexcept { // return pointer to shared_ptr's deleter object if its type is _Dx if (_Sx._Rep) { return static_cast<_Dx*>(_Sx._Rep->_Get_deleter(typeid(_Dx))); @@ -3070,11 +3069,11 @@ public: this->_Swap(_Other); } - _NODISCARD_PURE_MTHD bool expired() const noexcept { + _NODISCARD bool expired() const noexcept { return this->use_count() == 0; } - _NODISCARD_PURE_MTHD shared_ptr<_Ty> lock() const noexcept { // convert to shared_ptr + _NODISCARD shared_ptr<_Ty> lock() const noexcept { // convert to shared_ptr shared_ptr<_Ty> _Ret; (void) _Ret._Construct_from_weak(*this); return _Ret; @@ -3096,19 +3095,19 @@ class enable_shared_from_this { // provide member functions that create shared_p public: using _Esft_type = enable_shared_from_this; - _NODISCARD_ACCESS_MTHD shared_ptr<_Ty> shared_from_this() { + _NODISCARD shared_ptr<_Ty> shared_from_this() { return shared_ptr<_Ty>(_Wptr); } - _NODISCARD_PURE_MTHD shared_ptr shared_from_this() const { + _NODISCARD shared_ptr shared_from_this() const { return shared_ptr(_Wptr); } - _NODISCARD_ACCESS_MTHD weak_ptr<_Ty> weak_from_this() noexcept { + _NODISCARD weak_ptr<_Ty> weak_from_this() noexcept { return _Wptr; } - _NODISCARD_PURE_MTHD weak_ptr weak_from_this() const noexcept { + _NODISCARD weak_ptr weak_from_this() const noexcept { return _Wptr; } @@ -3257,24 +3256,23 @@ public: } } - _NODISCARD_ACCESS_MTHD _CONSTEXPR23 _Dx& get_deleter() noexcept { + _NODISCARD _CONSTEXPR23 _Dx& get_deleter() noexcept { return _Mypair._Get_first(); } - _NODISCARD_PURE_MTHD _CONSTEXPR23 const _Dx& get_deleter() const noexcept { + _NODISCARD _CONSTEXPR23 const _Dx& get_deleter() const noexcept { return _Mypair._Get_first(); } - _NODISCARD_PURE_OP _CONSTEXPR23 add_lvalue_reference_t<_Ty> operator*() const - noexcept(noexcept(*_STD declval())) { + _NODISCARD _CONSTEXPR23 add_lvalue_reference_t<_Ty> operator*() const noexcept(noexcept(*_STD declval())) { return *_Mypair._Myval2; } - _NODISCARD_PURE_OP _CONSTEXPR23 pointer operator->() const noexcept { + _NODISCARD _CONSTEXPR23 pointer operator->() const noexcept { return _Mypair._Myval2; } - _NODISCARD_PURE_MTHD _CONSTEXPR23 pointer get() const noexcept { + _NODISCARD _CONSTEXPR23 pointer get() const noexcept { return _Mypair._Myval2; } @@ -3394,19 +3392,19 @@ public: } } - _NODISCARD_ACCESS_MTHD _CONSTEXPR23 _Dx& get_deleter() noexcept { + _NODISCARD _CONSTEXPR23 _Dx& get_deleter() noexcept { return _Mypair._Get_first(); } - _NODISCARD_PURE_MTHD _CONSTEXPR23 const _Dx& get_deleter() const noexcept { + _NODISCARD _CONSTEXPR23 const _Dx& get_deleter() const noexcept { return _Mypair._Get_first(); } - _NODISCARD_PURE_OP _CONSTEXPR23 _Ty& operator[](size_t _Idx) const noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR23 _Ty& operator[](size_t _Idx) const noexcept /* strengthened */ { return _Mypair._Myval2[_Idx]; } - _NODISCARD_PURE_MTHD _CONSTEXPR23 pointer get() const noexcept { + _NODISCARD _CONSTEXPR23 pointer get() const noexcept { return _Mypair._Myval2; } @@ -3475,20 +3473,19 @@ _CONSTEXPR23 void swap(unique_ptr<_Ty, _Dx>& _Left, unique_ptr<_Ty, _Dx>& _Right } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator==( - const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD _CONSTEXPR23 bool operator==(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return _Left.get() == _Right.get(); } #if !_HAS_CXX20 template -_NODISCARD_PURE_OP bool operator!=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD bool operator!=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 template -_NODISCARD_PURE_OP bool operator<(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD bool operator<(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { using _Ptr1 = typename unique_ptr<_Ty1, _Dx1>::pointer; using _Ptr2 = typename unique_ptr<_Ty2, _Dx2>::pointer; using _Common = common_type_t<_Ptr1, _Ptr2>; @@ -3496,17 +3493,17 @@ _NODISCARD_PURE_OP bool operator<(const unique_ptr<_Ty1, _Dx1>& _Left, const uni } template -_NODISCARD_PURE_OP bool operator>=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD bool operator>=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return !(_Left < _Right); } template -_NODISCARD_PURE_OP bool operator>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD bool operator>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OP bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { +_NODISCARD bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { return !(_Right < _Left); } @@ -3515,7 +3512,7 @@ _NODISCARD_PURE_OP bool operator<=(const unique_ptr<_Ty1, _Dx1>& _Left, const un template requires three_way_comparable_with::pointer, typename unique_ptr<_Ty2, _Dx2>::pointer> -_NODISCARD_PURE_OP compare_three_way_result_t::pointer, +_NODISCARD compare_three_way_result_t::pointer, typename unique_ptr<_Ty2, _Dx2>::pointer> operator<=>(const unique_ptr<_Ty1, _Dx1>& _Left, const unique_ptr<_Ty2, _Dx2>& _Right) { // clang-format on @@ -3524,66 +3521,66 @@ _NODISCARD_PURE_OP compare_three_way_result_t::p #endif // __cpp_lib_concepts template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator==(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t) noexcept { +_NODISCARD _CONSTEXPR23 bool operator==(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t) noexcept { return !_Left; } #if !_HAS_CXX20 template -_NODISCARD_PURE_OP bool operator==(nullptr_t, const unique_ptr<_Ty, _Dx>& _Right) noexcept { +_NODISCARD bool operator==(nullptr_t, const unique_ptr<_Ty, _Dx>& _Right) noexcept { return !_Right; } template -_NODISCARD_PURE_OP bool operator!=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) noexcept { +_NODISCARD bool operator!=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) noexcept { return !(_Left == _Right); } template -_NODISCARD_PURE_OP bool operator!=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) noexcept { +_NODISCARD bool operator!=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) noexcept { return !(_Left == _Right); } #endif // !_HAS_CXX20 template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator<(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD _CONSTEXPR23 bool operator<(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { using _Ptr = typename unique_ptr<_Ty, _Dx>::pointer; return less<_Ptr>{}(_Left.get(), _Right); } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator<(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD _CONSTEXPR23 bool operator<(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { using _Ptr = typename unique_ptr<_Ty, _Dx>::pointer; return less<_Ptr>{}(_Left, _Right.get()); } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator>=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD _CONSTEXPR23 bool operator>=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { return !(_Left < _Right); } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator>=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD _CONSTEXPR23 bool operator>=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { return !(_Left < _Right); } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator>(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD _CONSTEXPR23 bool operator>(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator>(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD _CONSTEXPR23 bool operator>(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator<=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { +_NODISCARD _CONSTEXPR23 bool operator<=(const unique_ptr<_Ty, _Dx>& _Left, nullptr_t _Right) { return !(_Right < _Left); } template -_NODISCARD_PURE_OP _CONSTEXPR23 bool operator<=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { +_NODISCARD _CONSTEXPR23 bool operator<=(nullptr_t _Left, const unique_ptr<_Ty, _Dx>& _Right) { return !(_Right < _Left); } @@ -3591,7 +3588,7 @@ _NODISCARD_PURE_OP _CONSTEXPR23 bool operator<=(nullptr_t _Left, const unique_pt // clang-format off template requires three_way_comparable::pointer> -_NODISCARD_PURE_OP _CONSTEXPR23 compare_three_way_result_t::pointer> operator<=>( +_NODISCARD _CONSTEXPR23 compare_three_way_result_t::pointer> operator<=>( const unique_ptr<_Ty, _Dx>& _Left, nullptr_t) { // clang-format on return _Left.get() <=> static_cast::pointer>(nullptr); @@ -3640,15 +3637,15 @@ struct owner_less> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef shared_ptr<_Ty> _SECOND_ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef bool _RESULT_TYPE_NAME; - _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { + _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { + _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { + _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } }; @@ -3659,15 +3656,15 @@ struct owner_less> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef weak_ptr<_Ty> _SECOND_ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef bool _RESULT_TYPE_NAME; - _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { + _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { + _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } - _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { + _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Ty>& _Right) const noexcept { return _Left.owner_before(_Right); } }; @@ -3675,22 +3672,22 @@ struct owner_less> { template <> struct owner_less { template - _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { + _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } template - _NODISCARD_PURE_OP bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { + _NODISCARD bool operator()(const shared_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } template - _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { + _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const shared_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } template - _NODISCARD_PURE_OP bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { + _NODISCARD bool operator()(const weak_ptr<_Ty>& _Left, const weak_ptr<_Uty>& _Right) const noexcept { return _Left.owner_before(_Right); } @@ -3711,7 +3708,7 @@ struct hash> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef shared_ptr<_Ty> _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD_PURE_OP size_t operator()(const shared_ptr<_Ty>& _Keyval) const noexcept { + _NODISCARD size_t operator()(const shared_ptr<_Ty>& _Keyval) const noexcept { return hash::element_type*>()(_Keyval.get()); } }; @@ -3761,13 +3758,13 @@ struct _Shared_ptr_spin_lock { // class to manage a spin lock for shared_ptr ato }; template -_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN bool atomic_is_lock_free(const shared_ptr<_Ty>*) { +_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD bool atomic_is_lock_free(const shared_ptr<_Ty>*) { // return true if atomic operations on shared_ptr<_Ty> are lock-free return false; } template -_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN shared_ptr<_Ty> atomic_load_explicit( +_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD shared_ptr<_Ty> atomic_load_explicit( const shared_ptr<_Ty>* _Ptr, memory_order) { // load *_Ptr atomically _Shared_ptr_spin_lock _Lock; @@ -3776,7 +3773,7 @@ _CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN shared_ptr<_Ty } template -_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD_PURE_FN shared_ptr<_Ty> atomic_load( +_CXX20_DEPRECATE_OLD_SHARED_PTR_ATOMIC_SUPPORT _NODISCARD shared_ptr<_Ty> atomic_load( const shared_ptr<_Ty>* _Ptr) { // load *_Ptr atomically return _STD atomic_load_explicit(_Ptr, memory_order_seq_cst); } @@ -3892,7 +3889,7 @@ public: static constexpr bool is_always_lock_free = false; - _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { + _NODISCARD bool is_lock_free() const noexcept { return false; } @@ -3906,7 +3903,7 @@ public: _Value._Rep = _Rep; } - _NODISCARD_PURE_MTHD shared_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD shared_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { _Check_load_memory_order(_Order); shared_ptr<_Ty> _Result; const auto _Rep = this->_Repptr._Lock_and_load(); @@ -4011,7 +4008,7 @@ public: static constexpr bool is_always_lock_free = false; - _NODISCARD_PURE_MTHD bool is_lock_free() const noexcept { + _NODISCARD bool is_lock_free() const noexcept { return false; } @@ -4025,7 +4022,7 @@ public: _Value._Rep = _Rep; } - _NODISCARD_PURE_MTHD weak_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { + _NODISCARD weak_ptr<_Ty> load(const memory_order _Order = memory_order_seq_cst) const noexcept { _Check_load_memory_order(_Order); weak_ptr<_Ty> _Result; const auto _Rep = this->_Repptr._Lock_and_load(); @@ -4225,7 +4222,7 @@ private: }; template -_NODISCARD_ACCESS_FN auto out_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { +_NODISCARD auto out_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { if constexpr (is_void_v<_Pointer>) { return out_ptr_t<_SmartPtr, _Pointer_of<_SmartPtr>, _ArgsT&&...>(_Smart_ptr, _STD forward<_ArgsT>(_Args)...); } else { @@ -4305,7 +4302,7 @@ private: }; template -_NODISCARD_ACCESS_FN auto inout_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { +_NODISCARD auto inout_ptr(_SmartPtr& _Smart_ptr, _ArgsT&&... _Args) { if constexpr (is_void_v<_Pointer>) { return inout_ptr_t<_SmartPtr, _Pointer_of<_SmartPtr>, _ArgsT&&...>(_Smart_ptr, _STD forward<_ArgsT>(_Args)...); } else { diff --git a/stl/inc/mutex b/stl/inc/mutex index a08fab64bb6..59c986bc94b 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -68,7 +68,7 @@ public: using native_handle_type = void*; - _NODISCARD_ACCESS_MTHD native_handle_type native_handle() { + _NODISCARD native_handle_type native_handle() { return _Mtx_getconcrtcs(_Mymtx()); } @@ -245,7 +245,7 @@ public: return _Res; } - _NODISCARD_PURE_MTHD bool owns_lock() const noexcept { + _NODISCARD bool owns_lock() const noexcept { return _Owns; } @@ -253,7 +253,7 @@ public: return _Owns; } - _NODISCARD_PURE_MTHD _Mutex* mutex() const noexcept { + _NODISCARD _Mutex* mutex() const noexcept { return _Pmtx; } @@ -685,7 +685,7 @@ public: return _Wait_until1(_Lck, _Abs_time, _Pred); } - _NODISCARD_ACCESS_MTHD native_handle_type native_handle() { + _NODISCARD native_handle_type native_handle() { return _Mycnd(); } diff --git a/stl/inc/semaphore b/stl/inc/semaphore index 3b8c3c9306f..5333a7a322e 100644 --- a/stl/inc/semaphore +++ b/stl/inc/semaphore @@ -58,7 +58,7 @@ inline constexpr ptrdiff_t _Semaphore_max = (1ULL << (sizeof(ptrdiff_t) * CHAR_B template class counting_semaphore { public: - _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD static constexpr ptrdiff_t(max)() noexcept { return _Least_max_value; } @@ -207,7 +207,7 @@ private: template <> class counting_semaphore<1> { public: - _NODISCARD_PURE_MTHD static constexpr ptrdiff_t(max)() noexcept { + _NODISCARD static constexpr ptrdiff_t(max)() noexcept { return 1; } diff --git a/stl/inc/shared_mutex b/stl/inc/shared_mutex index f542a63ccae..67ebf8232a1 100644 --- a/stl/inc/shared_mutex +++ b/stl/inc/shared_mutex @@ -60,7 +60,7 @@ public: _Smtx_unlock_shared(&_Myhandle); } - _NODISCARD_ACCESS_MTHD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle + _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // get native handle return &_Myhandle; } @@ -346,7 +346,7 @@ public: return _Res; } - _NODISCARD_PURE_MTHD bool owns_lock() const noexcept { + _NODISCARD bool owns_lock() const noexcept { return _Owns; } @@ -354,7 +354,7 @@ public: return _Owns; } - _NODISCARD_PURE_MTHD mutex_type* mutex() const noexcept { + _NODISCARD mutex_type* mutex() const noexcept { return _Pmtx; } diff --git a/stl/inc/source_location b/stl/inc/source_location index c2c63a9bea9..58aa73b84cb 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -23,7 +23,7 @@ _STL_DISABLE_CLANG_WARNINGS _STD_BEGIN struct source_location { - _NODISCARD_PURE_MTHD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), + _NODISCARD static consteval source_location current(const uint_least32_t _Line_ = __builtin_LINE(), const uint_least32_t _Column_ = __builtin_COLUMN(), const char* const _File_ = __builtin_FILE(), const char* const _Function_ = __builtin_FUNCTION()) noexcept { source_location _Result; @@ -36,16 +36,16 @@ struct source_location { _NODISCARD_CTOR_PURE constexpr source_location() noexcept = default; - _NODISCARD_PURE_MTHD constexpr uint_least32_t line() const noexcept { + _NODISCARD constexpr uint_least32_t line() const noexcept { return _Line; } - _NODISCARD_PURE_MTHD constexpr uint_least32_t column() const noexcept { + _NODISCARD constexpr uint_least32_t column() const noexcept { return _Column; } - _NODISCARD_PURE_MTHD constexpr const char* file_name() const noexcept { + _NODISCARD constexpr const char* file_name() const noexcept { return _File; } - _NODISCARD_PURE_MTHD constexpr const char* function_name() const noexcept { + _NODISCARD constexpr const char* function_name() const noexcept { return _Function; } diff --git a/stl/inc/thread b/stl/inc/thread index b989c28fe99..b79198581fb 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -114,7 +114,7 @@ public: _STD swap(_Thr, _Other._Thr); } - _NODISCARD_PURE_MTHD bool joinable() const noexcept { + _NODISCARD bool joinable() const noexcept { return _Thr._Id != 0; } @@ -143,14 +143,14 @@ public: _Thr = {}; } - _NODISCARD_PURE_MTHD id get_id() const noexcept; + _NODISCARD id get_id() const noexcept; - _NODISCARD_PURE_MTHD native_handle_type native_handle() noexcept + _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // return Win32 HANDLE as void * return _Thr._Hnd; } - _NODISCARD_PURE_MTHD static unsigned int hardware_concurrency() noexcept { + _NODISCARD static unsigned int hardware_concurrency() noexcept { return _Thrd_hardware_concurrency(); } @@ -175,7 +175,7 @@ _NODISCARD auto _To_absolute_time(const chrono::duration<_Rep, _Period>& _Rel_ti } namespace this_thread { - _NODISCARD_PURE_FN thread::id get_id() noexcept; + _NODISCARD thread::id get_id() noexcept; inline void yield() noexcept { _Thrd_yield(); @@ -230,11 +230,11 @@ private: friend hash; }; -_NODISCARD_PURE_MTHD inline thread::id thread::get_id() const noexcept { +_NODISCARD inline thread::id thread::get_id() const noexcept { return _Thr._Id; } -_NODISCARD_PURE_FN inline thread::id this_thread::get_id() noexcept { +_NODISCARD inline thread::id this_thread::get_id() noexcept { return _Thrd_id(); } @@ -242,32 +242,32 @@ inline void swap(thread& _Left, thread& _Right) noexcept { _Left.swap(_Right); } -_NODISCARD_PURE_OP inline bool operator==(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline bool operator==(thread::id _Left, thread::id _Right) noexcept { return _Left._Id == _Right._Id; } #if _HAS_CXX20 -_NODISCARD_PURE_OP inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept { return _Left._Id <=> _Right._Id; } #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv -_NODISCARD_PURE_OP inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline bool operator!=(thread::id _Left, thread::id _Right) noexcept { return !(_Left == _Right); } -_NODISCARD_PURE_OP inline bool operator<(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline bool operator<(thread::id _Left, thread::id _Right) noexcept { return _Left._Id < _Right._Id; } -_NODISCARD_PURE_OP inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline bool operator<=(thread::id _Left, thread::id _Right) noexcept { return !(_Right < _Left); } -_NODISCARD_PURE_OP inline bool operator>(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline bool operator>(thread::id _Left, thread::id _Right) noexcept { return _Right < _Left; } -_NODISCARD_PURE_OP inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { +_NODISCARD inline bool operator>=(thread::id _Left, thread::id _Right) noexcept { return !(_Left < _Right); } #endif // !_HAS_CXX20 @@ -282,7 +282,7 @@ struct hash { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef thread::id _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD_PURE_MTHD size_t operator()(const thread::id _Keyval) const noexcept { + _NODISCARD size_t operator()(const thread::id _Keyval) const noexcept { return _Hash_representation(_Keyval._Id); } }; @@ -328,7 +328,7 @@ public: _Ssource.swap(_Other._Ssource); } - _NODISCARD_PURE_MTHD bool joinable() const noexcept { + _NODISCARD bool joinable() const noexcept { return _Impl.joinable(); } @@ -340,19 +340,19 @@ public: _Impl.detach(); } - _NODISCARD_PURE_MTHD id get_id() const noexcept { + _NODISCARD id get_id() const noexcept { return _Impl.get_id(); } - _NODISCARD_PURE_MTHD native_handle_type native_handle() noexcept /* strengthened */ { + _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { return _Impl.native_handle(); } - _NODISCARD_ACCESS_MTHD stop_source get_stop_source() noexcept { + _NODISCARD stop_source get_stop_source() noexcept { return _Ssource; } - _NODISCARD_PURE_MTHD stop_token get_stop_token() const noexcept { + _NODISCARD stop_token get_stop_token() const noexcept { return _Ssource.get_token(); } @@ -364,7 +364,7 @@ public: _Lhs.swap(_Rhs); } - _NODISCARD_PURE_MTHD static unsigned int hardware_concurrency() noexcept { + _NODISCARD static unsigned int hardware_concurrency() noexcept { return thread::hardware_concurrency(); } diff --git a/stl/inc/vector b/stl/inc/vector index 434928fbbd2..dd6e8241e1b 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -42,7 +42,7 @@ public: this->_Adopt(_Pvector); } - _NODISCARD_PURE_OP _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -53,7 +53,7 @@ public: return *_Ptr; } - _NODISCARD_PURE_OP _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(_Ptr, "can't dereference value-initialized vector iterator"); @@ -120,7 +120,7 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vector_const_iterator operator+(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -130,50 +130,50 @@ public: return *this += -_Off; } - _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vector_const_iterator operator-(const difference_type _Off) const noexcept { _Vector_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR20 difference_type operator-(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR20 difference_type operator-(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr - _Right._Ptr; } - _NODISCARD_PURE_OP _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR20 bool operator==(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr == _Right._Ptr; } #if _HAS_CXX20 - _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD constexpr strong_ordering operator<=>(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Unfancy(_Ptr) <=> _Unfancy(_Right._Ptr); } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OP bool operator!=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD bool operator!=(const _Vector_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OP bool operator<(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD bool operator<(const _Vector_const_iterator& _Right) const noexcept { _Compat(_Right); return _Ptr < _Right._Ptr; } - _NODISCARD_PURE_OP bool operator>(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD bool operator>(const _Vector_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OP bool operator<=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD bool operator<=(const _Vector_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OP bool operator>=(const _Vector_const_iterator& _Right) const noexcept { + _NODISCARD bool operator>=(const _Vector_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -209,7 +209,7 @@ public: }; template -_NODISCARD_PURE_OP _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( +_NODISCARD _CONSTEXPR20 _Vector_const_iterator<_Myvec> operator+( typename _Vector_const_iterator<_Myvec>::difference_type _Off, _Vector_const_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -222,7 +222,7 @@ struct pointer_traits<_Vector_const_iterator<_Myvec>> { using element_type = const typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD_PURE_MTHD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -258,11 +258,11 @@ public: using _Mybase::_Mybase; - _NODISCARD_PURE_OP _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { return const_cast(_Mybase::operator*()); } - _NODISCARD_PURE_OP _CONSTEXPR20 pointer operator->() const noexcept { + _NODISCARD _CONSTEXPR20 pointer operator->() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Mycont = static_cast(this->_Getcont()); _STL_VERIFY(this->_Ptr, "can't dereference value-initialized vector iterator"); @@ -300,7 +300,7 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vector_iterator operator+(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -313,13 +313,13 @@ public: using _Mybase::operator-; - _NODISCARD_PURE_OP _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vector_iterator operator-(const difference_type _Off) const noexcept { _Vector_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return const_cast(_Mybase::operator[](_Off)); } @@ -331,7 +331,7 @@ public: }; template -_NODISCARD_PURE_OP _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( +_NODISCARD _CONSTEXPR20 _Vector_iterator<_Myvec> operator+( typename _Vector_iterator<_Myvec>::difference_type _Off, _Vector_iterator<_Myvec> _Next) noexcept { _Next += _Off; return _Next; @@ -344,7 +344,7 @@ struct pointer_traits<_Vector_iterator<_Myvec>> { using element_type = typename pointer::value_type; using difference_type = typename pointer::difference_type; - _NODISCARD_PURE_MTHD static constexpr element_type* to_address(const pointer _Iter) noexcept { + _NODISCARD static constexpr element_type* to_address(const pointer _Iter) noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 // A value-initialized iterator is in the domain of to_address. An invalidated end iterator for a vector with // capacity() of 0 is not. This function cannot distinguish those two cases, so it incorrectly does not diagnose @@ -1629,63 +1629,63 @@ public: } } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty* data() noexcept { + _NODISCARD _CONSTEXPR20 _Ty* data() noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty* data() const noexcept { + _NODISCARD _CONSTEXPR20 const _Ty* data() const noexcept { return _Unfancy_maybe_null(_Mypair._Myval2._Myfirst); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator begin() noexcept { + _NODISCARD _CONSTEXPR20 iterator begin() noexcept { auto& _My_data = _Mypair._Myval2; return iterator(_My_data._Myfirst, _STD addressof(_My_data)); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator begin() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator begin() const noexcept { auto& _My_data = _Mypair._Myval2; return const_iterator(_My_data._Myfirst, _STD addressof(_My_data)); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator end() noexcept { + _NODISCARD _CONSTEXPR20 iterator end() noexcept { auto& _My_data = _Mypair._Myval2; return iterator(_My_data._Mylast, _STD addressof(_My_data)); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator end() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator end() const noexcept { auto& _My_data = _Mypair._Myval2; return const_iterator(_My_data._Mylast, _STD addressof(_My_data)); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reverse_iterator rbegin() noexcept { + _NODISCARD _CONSTEXPR20 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cbegin() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cend() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { return rend(); } @@ -1710,22 +1710,22 @@ public: return _My_data._Myfirst == _My_data._Mylast; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type size() const noexcept { + _NODISCARD _CONSTEXPR20 size_type size() const noexcept { auto& _My_data = _Mypair._Myval2; return static_cast(_My_data._Mylast - _My_data._Myfirst); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type max_size() const noexcept { + _NODISCARD _CONSTEXPR20 size_type max_size() const noexcept { return (_STD min)( static_cast((numeric_limits::max)()), _Alty_traits::max_size(_Getal())); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type capacity() const noexcept { + _NODISCARD _CONSTEXPR20 size_type capacity() const noexcept { auto& _My_data = _Mypair._Myval2; return static_cast(_My_data._Myend - _My_data._Myfirst); } - _NODISCARD_ACCESS_OP _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY( @@ -1735,7 +1735,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_PURE_OP _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept + _NODISCARD _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 @@ -1746,7 +1746,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty& at(const size_type _Pos) { + _NODISCARD _CONSTEXPR20 _Ty& at(const size_type _Pos) { auto& _My_data = _Mypair._Myval2; if (static_cast(_My_data._Mylast - _My_data._Myfirst) <= _Pos) { _Xrange(); @@ -1755,7 +1755,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty& at(const size_type _Pos) const { + _NODISCARD _CONSTEXPR20 const _Ty& at(const size_type _Pos) const { auto& _My_data = _Mypair._Myval2; if (static_cast(_My_data._Mylast - _My_data._Myfirst) <= _Pos) { _Xrange(); @@ -1764,7 +1764,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty& front() noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 _Ty& front() noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "front() called on empty vector"); @@ -1773,7 +1773,7 @@ public: return *_My_data._Myfirst; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty& front() const noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 const _Ty& front() const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "front() called on empty vector"); @@ -1782,7 +1782,7 @@ public: return *_My_data._Myfirst; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 _Ty& back() noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 _Ty& back() noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "back() called on empty vector"); @@ -1791,7 +1791,7 @@ public: return _My_data._Mylast[-1]; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const _Ty& back() const noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 const _Ty& back() const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_My_data._Myfirst != _My_data._Mylast, "back() called on empty vector"); @@ -1800,7 +1800,7 @@ public: return _My_data._Mylast[-1]; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 allocator_type get_allocator() const noexcept { + _NODISCARD _CONSTEXPR20 allocator_type get_allocator() const noexcept { return static_cast(_Getal()); } @@ -2059,7 +2059,7 @@ using _Vbase = unsigned int; // word type for vector representatio constexpr int _VBITS = 8 * sizeof(_Vbase); // at least CHAR_BITS bits per word template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if (_Left.size() != _Right.size()) { return false; } @@ -2074,7 +2074,7 @@ _NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const vector<_Ty, _Alloc>& _Left #if !_HAS_CXX20 template -_NODISCARD_PURE_OP bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD bool operator!=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left == _Right); } #endif // !_HAS_CXX20 @@ -2096,7 +2096,7 @@ _NODISCARD_PURE_OP bool operator!=(const vector<_Ty, _Alloc>& _Left, const vecto template struct _Vbase_compare_three_way { - _NODISCARD_PURE_OP constexpr _Ret operator()(const _Vbase _Left, const _Vbase _Right) const noexcept { + _NODISCARD constexpr _Ret operator()(const _Vbase _Left, const _Vbase _Right) const noexcept { const _Vbase _Differing_bits = _Left ^ _Right; if (_Differing_bits == 0) { // improves _Countr_zero codegen below @@ -2123,7 +2123,7 @@ struct _Vbase_compare_three_way { #ifdef __cpp_lib_concepts template -_NODISCARD_PURE_OP constexpr _Synth_three_way_result<_Ty> operator<=>( +_NODISCARD constexpr _Synth_three_way_result<_Ty> operator<=>( const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. @@ -2148,7 +2148,7 @@ _NODISCARD_PURE_OP constexpr _Synth_three_way_result<_Ty> operator<=>( } #else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator<(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { if constexpr (is_same_v<_Ty, bool>) { // This optimization works because vector "trims" its underlying storage by zeroing out unused bits. auto _First = _Left._Myvec._Unchecked_begin(); @@ -2175,17 +2175,17 @@ _NODISCARD_PURE_OP _CONSTEXPR20 bool operator<(const vector<_Ty, _Alloc>& _Left, } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator>(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return _Right < _Left; } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator<=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator<=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Right < _Left); } template -_NODISCARD_PURE_OP _CONSTEXPR20 bool operator>=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { +_NODISCARD _CONSTEXPR20 bool operator>=(const vector<_Ty, _Alloc>& _Left, const vector<_Ty, _Alloc>& _Right) { return !(_Left < _Right); } #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ @@ -2329,7 +2329,7 @@ public: _CONSTEXPR20 _Vb_const_iterator(const _Vbase* _Ptr, const _Container_base* _Mypvbool) noexcept : _Mybase(_Ptr, 0, _Mypvbool) {} - _NODISCARD_PURE_OP _CONSTEXPR20 const_reference operator*() const noexcept { + _NODISCARD _CONSTEXPR20 const_reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Cont = static_cast(this->_Getcont()); _STL_VERIFY(_Cont, "cannot dereference value-initialized vector iterator"); @@ -2389,7 +2389,7 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_const_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vb_const_iterator operator+(const difference_type _Off) const noexcept { _Vb_const_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -2399,29 +2399,29 @@ public: return *this += -_Off; } - _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_const_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vb_const_iterator operator-(const difference_type _Off) const noexcept { _Vb_const_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR20 difference_type operator-(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR20 difference_type operator-(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return static_cast(_VBITS * (this->_Myptr - _Right._Myptr)) + static_cast(this->_Myoff) - static_cast(_Right._Myoff); } - _NODISCARD_PURE_OP _CONSTEXPR20 const_reference operator[](const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 const_reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } - _NODISCARD_PURE_OP _CONSTEXPR20 bool operator==(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD _CONSTEXPR20 bool operator==(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return this->_Myptr == _Right._Myptr && this->_Myoff == _Right._Myoff; } #if _HAS_CXX20 - _NODISCARD_PURE_OP constexpr strong_ordering operator<=>(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD constexpr strong_ordering operator<=>(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); if (const auto _CmpResult = this->_Myptr <=> _Right._Myptr; _CmpResult != 0) { return _CmpResult; @@ -2429,24 +2429,24 @@ public: return this->_Myoff <=> _Right._Myoff; } #else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv - _NODISCARD_PURE_OP bool operator!=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD bool operator!=(const _Vb_const_iterator& _Right) const noexcept { return !(*this == _Right); } - _NODISCARD_PURE_OP bool operator<(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD bool operator<(const _Vb_const_iterator& _Right) const noexcept { _Compat(_Right); return this->_Myptr < _Right._Myptr || (this->_Myptr == _Right._Myptr && this->_Myoff < _Right._Myoff); } - _NODISCARD_PURE_OP bool operator>(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD bool operator>(const _Vb_const_iterator& _Right) const noexcept { return _Right < *this; } - _NODISCARD_PURE_OP bool operator<=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD bool operator<=(const _Vb_const_iterator& _Right) const noexcept { return !(_Right < *this); } - _NODISCARD_PURE_OP bool operator>=(const _Vb_const_iterator& _Right) const noexcept { + _NODISCARD bool operator>=(const _Vb_const_iterator& _Right) const noexcept { return !(*this < _Right); } #endif // !_HAS_CXX20 @@ -2502,7 +2502,7 @@ public: }; template -_NODISCARD_PURE_OP _CONSTEXPR20 _Vb_const_iterator<_Alvbase_wrapped> operator+( +_NODISCARD _CONSTEXPR20 _Vb_const_iterator<_Alvbase_wrapped> operator+( typename _Vb_const_iterator<_Alvbase_wrapped>::difference_type _Off, _Vb_const_iterator<_Alvbase_wrapped> _Right) noexcept { _Right += _Off; @@ -2527,7 +2527,7 @@ public: using _Mybase::_Mybase; - _NODISCARD_PURE_OP _CONSTEXPR20 reference operator*() const noexcept { + _NODISCARD _CONSTEXPR20 reference operator*() const noexcept { #if _ITERATOR_DEBUG_LEVEL != 0 const auto _Cont = static_cast(this->_Getcont()); _STL_VERIFY(_Cont, "cannot dereference value-initialized vector iterator"); @@ -2565,7 +2565,7 @@ public: return *this; } - _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_iterator operator+(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vb_iterator operator+(const difference_type _Off) const noexcept { _Vb_iterator _Tmp = *this; _Tmp += _Off; return _Tmp; @@ -2578,13 +2578,13 @@ public: using _Mybase::operator-; - _NODISCARD_PURE_OP _CONSTEXPR20 _Vb_iterator operator-(const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 _Vb_iterator operator-(const difference_type _Off) const noexcept { _Vb_iterator _Tmp = *this; _Tmp -= _Off; return _Tmp; } - _NODISCARD_PURE_OP _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { + _NODISCARD _CONSTEXPR20 reference operator[](const difference_type _Off) const noexcept { return *(*this + _Off); } @@ -2592,7 +2592,7 @@ public: }; template -_NODISCARD_PURE_OP _CONSTEXPR20 _Vb_iterator<_Alvbase_wrapped> operator+( +_NODISCARD _CONSTEXPR20 _Vb_iterator<_Alvbase_wrapped> operator+( typename _Vb_iterator<_Alvbase_wrapped>::difference_type _Off, _Vb_iterator<_Alvbase_wrapped> _Right) noexcept { _Right += _Off; return _Right; @@ -2871,39 +2871,39 @@ public: this->_Myvec.reserve(this->_Nw(_Count)); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type capacity() const noexcept { + _NODISCARD _CONSTEXPR20 size_type capacity() const noexcept { return this->_Myvec.capacity() * _VBITS; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator begin() noexcept { + _NODISCARD _CONSTEXPR20 iterator begin() noexcept { return iterator(this->_Myvec.data(), this); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator begin() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator begin() const noexcept { return const_iterator(this->_Myvec.data(), this); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 iterator end() noexcept { + _NODISCARD _CONSTEXPR20 iterator end() noexcept { return begin() + static_cast(this->_Mysize); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator end() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator end() const noexcept { return begin() + static_cast(this->_Mysize); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cbegin() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator cbegin() const noexcept { return begin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_iterator cend() const noexcept { + _NODISCARD _CONSTEXPR20 const_iterator cend() const noexcept { return end(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator crbegin() const noexcept { return rbegin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator crend() const noexcept { return rend(); } @@ -2939,19 +2939,19 @@ public: return _Tmp; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 reverse_iterator rbegin() noexcept { + _NODISCARD _CONSTEXPR20 reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 reverse_iterator rend() noexcept { + _NODISCARD _CONSTEXPR20 reverse_iterator rend() noexcept { return reverse_iterator(begin()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { + _NODISCARD _CONSTEXPR20 const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } @@ -2963,11 +2963,11 @@ public: } } - _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type size() const noexcept { + _NODISCARD _CONSTEXPR20 size_type size() const noexcept { return this->_Mysize; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 size_type max_size() const noexcept { + _NODISCARD _CONSTEXPR20 size_type max_size() const noexcept { constexpr auto _Diff_max = static_cast((numeric_limits::max)()); const size_type _Ints_max = this->_Myvec.max_size(); if (_Ints_max > _Diff_max / _VBITS) { // max_size bound by difference_type limits @@ -2982,11 +2982,11 @@ public: return this->_Mysize == 0; } - _NODISCARD_PURE_MTHD _CONSTEXPR20 allocator_type get_allocator() const noexcept { + _NODISCARD _CONSTEXPR20 allocator_type get_allocator() const noexcept { return static_cast(this->_Myvec.get_allocator()); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reference at(size_type _Off) const { + _NODISCARD _CONSTEXPR20 const_reference at(size_type _Off) const { if (size() <= _Off) { _Xran(); } @@ -2994,7 +2994,7 @@ public: return (*this)[_Off]; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reference at(size_type _Off) { + _NODISCARD _CONSTEXPR20 reference at(size_type _Off) { if (size() <= _Off) { _Xran(); } @@ -3002,7 +3002,7 @@ public: return (*this)[_Off]; } - _NODISCARD_PURE_OP _CONSTEXPR20 const_reference operator[](size_type _Off) const noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 const_reference operator[](size_type _Off) const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < this->_Mysize, "vector subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3012,7 +3012,7 @@ public: return *_It; } - _NODISCARD_ACCESS_OP _CONSTEXPR20 reference operator[](size_type _Off) noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 reference operator[](size_type _Off) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Off < this->_Mysize, "vector subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3022,7 +3022,7 @@ public: return *_It; } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reference front() noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 reference front() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "front() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3030,7 +3030,7 @@ public: return *begin(); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reference front() const noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 const_reference front() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "front() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3038,7 +3038,7 @@ public: return *begin(); } - _NODISCARD_ACCESS_MTHD _CONSTEXPR20 reference back() noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 reference back() noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "back() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3046,7 +3046,7 @@ public: return *(end() - 1); } - _NODISCARD_PURE_MTHD _CONSTEXPR20 const_reference back() const noexcept /* strengthened */ { + _NODISCARD _CONSTEXPR20 const_reference back() const noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(this->_Mysize != 0, "back() called on empty vector"); #endif // _CONTAINER_DEBUG_LEVEL > 0 @@ -3281,7 +3281,7 @@ struct hash> { _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef vector _ARGUMENT_TYPE_NAME; _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t _RESULT_TYPE_NAME; - _NODISCARD_PURE_OP size_t operator()(const vector& _Keyval) const noexcept { + _NODISCARD size_t operator()(const vector& _Keyval) const noexcept { return _Hash_array_representation(_Keyval._Myvec.data(), _Keyval._Myvec.size()); } }; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index f9a8291b4af..673f1dd4430 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -450,34 +450,6 @@ #define _NODISCARD_FRIEND _NODISCARD friend #endif // TRANSITION, VSO-568006 -#define _NODISCARD_PURE_ALG \ - _NODISCARD_MSG("This algorithm is not intended to have side effects; it is not useful to call this algorithm " \ - "and discard the return value") - -#define _NODISCARD_PURE_FN \ - _NODISCARD_MSG("This function is pure, i.e. has no side effects; it is not useful to call this function and " \ - "discard the return value") - -#define _NODISCARD_PURE_MTHD \ - _NODISCARD_MSG("This method is pure observer, i.e. has no side effects; it is not useful to call this method " \ - "and discard the return value") - -#define _NODISCARD_PURE_OP \ - _NODISCARD_MSG("This operator is pure obeserver, i.e. has no side effects; it is not useful to call this " \ - "operator and discard the return value") - -#define _NODISCARD_ACCESS_FN \ - _NODISCARD_MSG("This function returns a value that provides access to the passed object and has no side effects " \ - "otherwise; it is not useful to call this function and discard the return value") - -#define _NODISCARD_ACCESS_MTHD \ - _NODISCARD_MSG("This method returns an object that can access the state of the current object and has no other " \ - "side effects; it is not useful to call this method and discard the return value") - -#define _NODISCARD_ACCESS_OP \ - _NODISCARD_MSG("This operator provides an access to the state of the current object via the return value and has " \ - "no other side effects; it is not useful to call this operator and discard the return value") - #define _NODISCARD_REMOVE_ALG \ _NODISCARD_MSG( \ "The 'remove' and 'remove_if' algorithms return the iterator past the last non-removed element. " \ From 7223265a3d873e76969768503cc0b99ac233dbfd Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:00:53 +0300 Subject: [PATCH 39/73] +format --- stl/inc/yvals_core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 15b4360073c..d9d77bac054 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -443,7 +443,7 @@ #define _NODISCARD_CTOR #define _NODISCARD_CTOR_MSG(_Msg) #elif __has_cpp_attribute(nodiscard) >= 201907L -#define _NODISCARD_CTOR _NODISCARD +#define _NODISCARD_CTOR _NODISCARD #define _NODISCARD_CTOR_MSG(_Msg) _NODISCARD_MSG(_Msg) #else #define _NODISCARD_CTOR @@ -1540,9 +1540,9 @@ #define __cpp_lib_expected 202202L #endif // __cpp_lib_concepts -#define __cpp_lib_invoke_r 202106L -#define __cpp_lib_is_scoped_enum 202011L -#define __cpp_lib_move_only_function 202110L +#define __cpp_lib_invoke_r 202106L +#define __cpp_lib_is_scoped_enum 202011L +#define __cpp_lib_move_only_function 202110L #ifdef __cpp_lib_concepts #define __cpp_lib_out_ptr 202106L From 905922ad185a96d15a93c4dcad5a5a45bac3beaa Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:10:07 +0300 Subject: [PATCH 40/73] undo more changes --- stl/inc/algorithm | 51 ++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 41459e04a62..881b5d5e1a7 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -398,8 +398,7 @@ template = 0> -_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept -/* terminates */ { +_NODISCARD _FwdIt adjacent_find(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last) noexcept /* terminates */ { // find first matching successor return _STD adjacent_find(_STD forward<_ExPo>(_Exec), _First, _Last, equal_to{}); } @@ -423,8 +422,7 @@ namespace ranges { template requires indirect_binary_predicate, _Pj>, const _Ty*> - _NODISCARD constexpr range_difference_t<_Rng> operator()( - _Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { + _NODISCARD constexpr range_difference_t<_Rng> operator()(_Rng&& _Range, const _Ty& _Val, _Pj _Proj = {}) const { return _Count_unchecked(_Ubegin(_Range), _Uend(_Range), _Val, _Pass_fn(_Proj)); } // clang-format on @@ -683,8 +681,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {},_Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_STD move(_First1)); @@ -2036,8 +2034,8 @@ namespace ranges { template _Se, class _Ty, class _Pr = ranges::equal_to, class _Pj = identity> requires indirectly_comparable<_It, const _Ty*, _Pr, _Pj> - _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, - const iter_difference_t<_It> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const iter_difference_t<_It> _Count, + const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { _Adl_verify_range(_First, _Last); if (_Count <= 0) { @@ -2061,8 +2059,8 @@ namespace ranges { template requires indirectly_comparable, const _Ty*, _Pr, _Pj> - _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, - const range_difference_t<_Rng> _Count, const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, const range_difference_t<_Rng> _Count, + const _Ty& _Val, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _First = _RANGES begin(_Range); if (_Count <= 0) { @@ -2196,8 +2194,8 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2262,8 +2260,8 @@ namespace ranges { requires (forward_iterator<_It1> || sized_sentinel_for<_Se1, _It1>) && (forward_iterator<_It2> || sized_sentinel_for<_Se2, _It2>) && indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -2694,8 +2692,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, - _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr subrange<_It1> operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, + _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); auto _UFirst1 = _Get_unwrapped(_First1); @@ -2783,9 +2781,8 @@ _NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, _FwdIt1 _ const _FwdIt2 _Last2, _Pr _Pred) noexcept; // terminates template = 0> -_NODISCARD _FwdIt1 find_first_of( - _ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, const _FwdIt2 _Last2) noexcept -/* terminates */ { // look for one of [_First2, _Last2) that matches element +_NODISCARD _FwdIt1 find_first_of(_ExPo&& _Exec, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, + const _FwdIt2 _Last2) noexcept /* terminates */ { // look for one of [_First2, _Last2) that matches element return _STD find_first_of(_STD forward<_ExPo>(_Exec), _First1, _Last1, _First2, _Last2, equal_to{}); } #endif // _HAS_CXX17 @@ -2800,8 +2797,8 @@ namespace ranges { template _Se1, forward_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, - _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { + _NODISCARD constexpr _It1 operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { _Adl_verify_range(_First1, _Last1); _Adl_verify_range(_First2, _Last2); @@ -9095,8 +9092,7 @@ _NODISCARD constexpr _FwdIt max_element(_FwdIt _First, _FwdIt _Last) { // find l #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD _FwdIt max_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find largest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD max_element(_First, _Last, _Pass_fn(_Pred)); @@ -9187,8 +9183,7 @@ _NODISCARD constexpr _FwdIt min_element(_FwdIt _First, _FwdIt _Last) { // find s #if _HAS_CXX17 template = 0> -_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD _FwdIt min_element(_ExPo&&, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find smallest element // not parallelized at present, parallelism expected to be feasible in a future release return _STD min_element(_First, _Last, _Pass_fn(_Pred)); @@ -9317,8 +9312,7 @@ _NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _L } template = 0> -_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept -/* terminates */ { +_NODISCARD pair<_FwdIt, _FwdIt> minmax_element(_ExPo&&, _FwdIt _First, _FwdIt _Last) noexcept /* terminates */ { // find smallest and largest elements // not parallelized at present, parallelism expected to be feasible in a future release return _STD minmax_element(_First, _Last); @@ -9463,8 +9457,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr range_value_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( From 9942a0470ebbc510b5b51510ab22ed127bb48755 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:11:59 +0300 Subject: [PATCH 41/73] undo more changes --- stl/inc/algorithm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 881b5d5e1a7..62247252c2c 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -5955,8 +5955,7 @@ template = 0> -_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD bool is_heap(_ExPo&& _Exec, _RanIt _First, _RanIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is a heap return _STD is_heap_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } @@ -9527,8 +9526,7 @@ namespace ranges { template , _Pj>> _Pr = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rng>*> - _NODISCARD constexpr range_value_t<_Rng> operator()( - _Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { + _NODISCARD constexpr range_value_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const { auto _UFirst = _Ubegin(_Range); auto _ULast = _Uend(_Range); _STL_ASSERT( @@ -9938,8 +9936,7 @@ template = 0> -_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD bool is_sorted(_ExPo&& _Exec, _FwdIt _First, _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if range is ordered by predicate return _STD is_sorted_until(_STD forward<_ExPo>(_Exec), _First, _Last, _Pass_fn(_Pred)) == _Last; } From 0d5f2ca055e5fa32880f3a5f127517760ba5c289 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:16:57 +0300 Subject: [PATCH 42/73] /* strengthened */ --- stl/inc/array | 3 +-- stl/inc/cmath | 18 ++++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/stl/inc/array b/stl/inc/array index b15e418df8c..29769e622ce 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -529,8 +529,7 @@ public: return _Elems[_Pos]; } - _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept - /* strengthened */ { + _NODISCARD _CONSTEXPR17 reference operator[](_In_range_(0, _Size - 1) size_type _Pos) noexcept /* strengthened */ { #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY(_Pos < _Size, "array subscript out of range"); #endif // _CONTAINER_DEBUG_LEVEL > 0 diff --git a/stl/inc/cmath b/stl/inc/cmath index 1b21dfcda8a..c1158d26d67 100644 --- a/stl/inc/cmath +++ b/stl/inc/cmath @@ -75,8 +75,7 @@ _NODISCARD _Check_return_ inline float ceil(_In_ float _Xx) noexcept /* strength #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept -/* strengthened */ { +_NODISCARD _Check_return_ inline float copysign(_In_ float _Number, _In_ float _Sign) noexcept /* strengthened */ { #if _HAS_CMATH_INTRINSICS return __copysignf(_Number, _Sign); #elif defined(__clang__) @@ -132,8 +131,7 @@ _NODISCARD _Check_return_ inline float floor(_In_ float _Xx) noexcept /* strengt #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept -/* strengthened */ { +_NODISCARD _Check_return_ inline float fma(_In_ float _Xx, _In_ float _Yx, _In_ float _Zx) noexcept /* strengthened */ { return _CSTD fmaf(_Xx, _Yx, _Zx); } @@ -217,8 +215,7 @@ _NODISCARD _Check_return_ inline float nextafter(_In_ float _Xx, _In_ float _Yx) return _CSTD nextafterf(_Xx, _Yx); } -_NODISCARD _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept -/* strengthened */ { +_NODISCARD _Check_return_ inline float nexttoward(_In_ float _Xx, _In_ long double _Yx) noexcept /* strengthened */ { return _CSTD nexttowardf(_Xx, _Yx); } @@ -424,8 +421,7 @@ _NODISCARD _Check_return_ inline int ilogb(_In_ long double _Xx) noexcept /* str return _CSTD ilogbl(_Xx); } -_NODISCARD _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept -/* strengthened */ { +_NODISCARD _Check_return_ inline long double ldexp(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD ldexpl(_Xx, _Yx); } @@ -515,13 +511,11 @@ _NODISCARD _Check_return_ inline long double round(_In_ long double _Xx) noexcep #endif // ^^^ intrinsics unavailable ^^^ } -_NODISCARD _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept -/* strengthened */ { +_NODISCARD _Check_return_ inline long double scalbln(_In_ long double _Xx, _In_ long _Yx) noexcept /* strengthened */ { return _CSTD scalblnl(_Xx, _Yx); } -_NODISCARD _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept -/* strengthened */ { +_NODISCARD _Check_return_ inline long double scalbn(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ { return _CSTD scalbnl(_Xx, _Yx); } From 919342dd1c8696b653b46967d62da6e54922d871 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:20:34 +0300 Subject: [PATCH 43/73] /* terminates */ --- stl/inc/execution | 48 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/stl/inc/execution b/stl/inc/execution index 9f816a89799..f8053b410de 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -1138,8 +1138,7 @@ _NODISCARD bool any_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pr } template /* = 0 */> -_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD bool none_of(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if no element in [_First, _Last) satisfies _Pred with the indicated execution policy _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1336,8 +1335,7 @@ _FwdIt _Find_parallel_unchecked(_ExPo&&, const _FwdIt _First, const _FwdIt _Last } template /* = 0 */> -_NODISCARD _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept -/* terminates */ { +_NODISCARD _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // find first matching _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); using _UFwdIt = _Unwrapped_t; @@ -1349,8 +1347,7 @@ _NODISCARD _FwdIt find(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, const _ } template /* = 0 */> -_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find first satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); using _UFwdIt = _Unwrapped_t; @@ -1363,8 +1360,7 @@ _NODISCARD _FwdIt find_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr } template /* = 0 */> -_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD _FwdIt find_if_not(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // find first satisfying !_Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); using _UFwdIt = _Unwrapped_t; @@ -1701,8 +1697,7 @@ struct _Static_partitioned_count_if2 { }; template /* = 0 */> -_NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // count elements satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1736,8 +1731,7 @@ _NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _Fw } template /* = 0 */> -_NODISCARD _Iter_diff_t<_FwdIt> count(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept -/* terminates */ { +_NODISCARD _Iter_diff_t<_FwdIt> count(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // count elements that match _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1982,8 +1976,7 @@ struct _Static_partitioned_equal2 { }; template /* = 0 */> -_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { // compare [_First1, _Last1) to [_First2, ...) _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -2304,8 +2297,7 @@ struct _Static_partitioned_unary_transform2 { }; template /* = 0 */> -_FwdIt2 transform(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _Fn _Func) noexcept -/* terminates */ { +_FwdIt2 transform(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _Fn _Func) noexcept /* terminates */ { // transform [_First, _Last) with _Func _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -2428,8 +2420,7 @@ _FwdIt3 transform(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _F #pragma warning(pop) template /* = 0 */> -void replace(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Oldval, const _Ty& _Newval) noexcept -/* terminates */ { +void replace(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Oldval, const _Ty& _Newval) noexcept /* terminates */ { // replace each matching _Oldval with _Newval _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _STD for_each(_STD forward<_ExPo>(_Exec), _First, _Last, [&](auto&& _Value) { @@ -2440,8 +2431,7 @@ void replace(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& } template /* = 0 */> -void replace_if(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred, const _Ty& _Val) noexcept -/* terminates */ { +void replace_if(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred, const _Ty& _Val) noexcept /* terminates */ { // replace each satisfying _Pred with _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _STD for_each( @@ -2591,8 +2581,7 @@ _NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pre } template /* = 0 */> -_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept -/* terminates */ { +_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // remove each matching _Val return _STD remove_if(_STD forward<_ExPo>(_Exec), _First, _Last, [&_Val](auto&& _Lhs) { return _STD forward(_Lhs) == _Val; }); @@ -3200,8 +3189,7 @@ struct _Static_partitioned_is_partitioned { }; template /* = 0 */> -_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept -/* terminates */ { +_NODISCARD bool is_partitioned(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { // test if [_First, _Last) is partitioned by _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -4044,8 +4032,7 @@ struct _Static_partitioned_reduce2 { }; template /* = 0 */> -_NODISCARD _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept -/* terminates */ { +_NODISCARD _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept /* terminates */ { // return commutative and associative reduction of _Val and [_First, _Last), using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -4519,8 +4506,7 @@ struct _Static_partitioned_inclusive_scan2 { template /* = 0 */> -_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op, _Ty _Val) noexcept -/* terminates */ { +_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op, _Ty _Val) noexcept /* terminates */ { // compute partial noncommutative and associative reductions including _Val into _Dest, using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -4562,8 +4548,7 @@ _FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _B } template /* = 0 */> -_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op) noexcept -/* terminates */ { +_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op) noexcept /* terminates */ { // compute partial noncommutative and associative reductions into _Dest, using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -4984,8 +4969,7 @@ _FwdIt2 _Adjacent_difference_seq(_FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _D } template /* = 0 */> -_FwdIt2 adjacent_difference(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Diff_op) noexcept -/* terminates */ { +_FwdIt2 adjacent_difference(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Diff_op) noexcept /* terminates */ { // compute adjacent differences into _Dest _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); From 35e51317666dd95ab94059c2c1c111a5468156d5 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:21:06 +0300 Subject: [PATCH 44/73] /* terminates */ --- stl/inc/execution | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/stl/inc/execution b/stl/inc/execution index f8053b410de..9df2458b2e2 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -1697,7 +1697,8 @@ struct _Static_partitioned_count_if2 { }; template /* = 0 */> -_NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // count elements satisfying _Pred _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1731,7 +1732,8 @@ _NODISCARD _Iter_diff_t<_FwdIt> count_if(_ExPo&&, const _FwdIt _First, const _Fw } template /* = 0 */> -_NODISCARD _Iter_diff_t<_FwdIt> count(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { +_NODISCARD _Iter_diff_t<_FwdIt> count(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +/* terminates */ { // count elements that match _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -1976,7 +1978,8 @@ struct _Static_partitioned_equal2 { }; template /* = 0 */> -_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD bool equal(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _FwdIt2 _First2, _Pr _Pred) noexcept +/* terminates */ { // compare [_First1, _Last1) to [_First2, ...) _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -2297,7 +2300,8 @@ struct _Static_partitioned_unary_transform2 { }; template /* = 0 */> -_FwdIt2 transform(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _Fn _Func) noexcept /* terminates */ { +_FwdIt2 transform(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _Fn _Func) noexcept +/* terminates */ { // transform [_First, _Last) with _Func _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -2420,7 +2424,8 @@ _FwdIt3 transform(_ExPo&&, const _FwdIt1 _First1, const _FwdIt1 _Last1, const _F #pragma warning(pop) template /* = 0 */> -void replace(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Oldval, const _Ty& _Newval) noexcept /* terminates */ { +void replace(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Oldval, const _Ty& _Newval) noexcept +/* terminates */ { // replace each matching _Oldval with _Newval _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _STD for_each(_STD forward<_ExPo>(_Exec), _First, _Last, [&](auto&& _Value) { @@ -2431,7 +2436,8 @@ void replace(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& } template /* = 0 */> -void replace_if(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred, const _Ty& _Val) noexcept /* terminates */ { +void replace_if(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, _Pr _Pred, const _Ty& _Val) noexcept +/* terminates */ { // replace each satisfying _Pred with _Val _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _STD for_each( @@ -2581,7 +2587,8 @@ _NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pre } template /* = 0 */> -_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { +_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +/* terminates */ { // remove each matching _Val return _STD remove_if(_STD forward<_ExPo>(_Exec), _First, _Last, [&_Val](auto&& _Lhs) { return _STD forward(_Lhs) == _Val; }); @@ -4032,7 +4039,8 @@ struct _Static_partitioned_reduce2 { }; template /* = 0 */> -_NODISCARD _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept /* terminates */ { +_NODISCARD _Ty reduce(_ExPo&&, const _FwdIt _First, const _FwdIt _Last, _Ty _Val, _BinOp _Reduce_op) noexcept +/* terminates */ { // return commutative and associative reduction of _Val and [_First, _Last), using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt); _Adl_verify_range(_First, _Last); @@ -4506,7 +4514,8 @@ struct _Static_partitioned_inclusive_scan2 { template /* = 0 */> -_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op, _Ty _Val) noexcept /* terminates */ { +_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op, _Ty _Val) noexcept +/* terminates */ { // compute partial noncommutative and associative reductions including _Val into _Dest, using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -4548,7 +4557,8 @@ _FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _B } template /* = 0 */> -_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op) noexcept /* terminates */ { +_FwdIt2 inclusive_scan(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Reduce_op) noexcept +/* terminates */ { // compute partial noncommutative and associative reductions into _Dest, using _Reduce_op _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); @@ -4969,7 +4979,8 @@ _FwdIt2 _Adjacent_difference_seq(_FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _D } template /* = 0 */> -_FwdIt2 adjacent_difference(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Diff_op) noexcept /* terminates */ { +_FwdIt2 adjacent_difference(_ExPo&&, const _FwdIt1 _First, const _FwdIt1 _Last, _FwdIt2 _Dest, _BinOp _Diff_op) noexcept +/* terminates */ { // compute adjacent differences into _Dest _REQUIRE_PARALLEL_ITERATOR(_FwdIt1); _REQUIRE_PARALLEL_ITERATOR(_FwdIt2); From ec0020c823aa8b8decbd6fd5dd2aa487c930fc41 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:22:36 +0300 Subject: [PATCH 45/73] /* strengthened */ --- stl/inc/vector | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stl/inc/vector b/stl/inc/vector index d216e399c97..bd0af59e50d 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -1751,8 +1751,7 @@ public: return _My_data._Myfirst[_Pos]; } - _NODISCARD _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept - /* strengthened */ { + _NODISCARD _CONSTEXPR20 const _Ty& operator[](const size_type _Pos) const noexcept /* strengthened */ { auto& _My_data = _Mypair._Myval2; #if _CONTAINER_DEBUG_LEVEL > 0 _STL_VERIFY( From e1e37531cc1d3575112946819443beb01b9dd366 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:23:45 +0300 Subject: [PATCH 46/73] /* strengthened */ --- stl/inc/thread | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stl/inc/thread b/stl/inc/thread index b79198581fb..4681d7e7f7b 100644 --- a/stl/inc/thread +++ b/stl/inc/thread @@ -145,8 +145,7 @@ public: _NODISCARD id get_id() const noexcept; - _NODISCARD native_handle_type native_handle() noexcept - /* strengthened */ { // return Win32 HANDLE as void * + _NODISCARD native_handle_type native_handle() noexcept /* strengthened */ { // return Win32 HANDLE as void * return _Thr._Hnd; } From 2a8c01ce12e81168910fda18c9829b0a43fbec3c Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 12 Jun 2022 06:24:27 +0300 Subject: [PATCH 47/73] -space --- stl/inc/algorithm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 62247252c2c..a72b3c017c7 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -2194,7 +2194,7 @@ namespace ranges { template _Se1, input_iterator _It2, sentinel_for<_It2> _Se2, class _Pr = ranges::equal_to, class _Pj1 = identity, class _Pj2 = identity> requires indirectly_comparable<_It1, _It2, _Pr, _Pj1, _Pj2> - _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, + _NODISCARD constexpr bool operator()(_It1 _First1, _Se1 _Last1, _It2 _First2, _Se2 _Last2, _Pr _Pred = {}, _Pj1 _Proj1 = {}, _Pj2 _Proj2 = {}) const { // clang-format on _Adl_verify_range(_First1, _Last1); From ea9f209d7229669fcfc128926323b02640b464f6 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Wed, 22 Jun 2022 12:06:47 +0300 Subject: [PATCH 48/73] more informative emptiness --- stl/inc/array | 2 +- stl/inc/deque | 2 +- stl/inc/forward_list | 2 +- stl/inc/list | 2 +- stl/inc/queue | 4 ++-- stl/inc/xhash | 2 +- stl/inc/xstring | 2 +- stl/inc/xtree | 2 +- stl/inc/xutility | 6 +++--- stl/inc/yvals_core.h | 10 ++++++++++ 10 files changed, 22 insertions(+), 12 deletions(-) diff --git a/stl/inc/array b/stl/inc/array index 29769e622ce..a281c4ea2a6 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -688,7 +688,7 @@ public: return 0; } - _NODISCARD constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD_ARRAY constexpr bool empty() const noexcept { return true; } diff --git a/stl/inc/deque b/stl/inc/deque index 84bfc1d5be7..20a1e2d6fea 100644 --- a/stl/inc/deque +++ b/stl/inc/deque @@ -1001,7 +1001,7 @@ public: static_cast((numeric_limits::max)()), _Alty_traits::max_size(_Getal())); } - _NODISCARD bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD bool empty() const noexcept { return _Mysize() == 0; } diff --git a/stl/inc/forward_list b/stl/inc/forward_list index 2392dd7cf4a..ec68effd530 100644 --- a/stl/inc/forward_list +++ b/stl/inc/forward_list @@ -870,7 +870,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD bool empty() const noexcept { return _Mypair._Myval2._Myhead == nullptr; } diff --git a/stl/inc/list b/stl/inc/list index 3e923f166a0..fe05e6c9fcb 100644 --- a/stl/inc/list +++ b/stl/inc/list @@ -1179,7 +1179,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD bool empty() const noexcept { return _Mypair._Myval2._Mysize == 0; } diff --git a/stl/inc/queue b/stl/inc/queue index d798d5ed4f6..86a24c75216 100644 --- a/stl/inc/queue +++ b/stl/inc/queue @@ -72,7 +72,7 @@ public: : c(_STD move(_First), _STD move(_Last), _Al) {} #endif // _HAS_CXX23 - _NODISCARD bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_MTHD_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } @@ -296,7 +296,7 @@ public: _STD make_heap(c.begin(), c.end(), comp); } - _NODISCARD bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_MTHD_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/xhash b/stl/inc/xhash index 80f983cc888..51b91964f92 100644 --- a/stl/inc/xhash +++ b/stl/inc/xhash @@ -813,7 +813,7 @@ public: return _List.max_size(); } - _NODISCARD bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD bool empty() const noexcept { return _List.empty(); } diff --git a/stl/inc/xstring b/stl/inc/xstring index 8c684942bb2..4510e67df9c 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -4252,7 +4252,7 @@ public: } #endif // _HAS_CXX20 - _NODISCARD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD _CONSTEXPR20 bool empty() const noexcept { return _Mypair._Myval2._Mysize == 0; } diff --git a/stl/inc/xtree b/stl/inc/xtree index 106ab11eeae..0ecf2e7d9a0 100644 --- a/stl/inc/xtree +++ b/stl/inc/xtree @@ -1196,7 +1196,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD bool empty() const noexcept { + _NODISCARD_EMPTY_MTHD bool empty() const noexcept { return _Get_scary()->_Mysize == 0; } diff --git a/stl/inc/xutility b/stl/inc/xutility index 132dddb48be..c9bfc1ab91c 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1578,17 +1578,17 @@ _NODISCARD constexpr ptrdiff_t ssize(const _Ty (&)[_Size]) noexcept { #endif // _HAS_CXX20 template -_NODISCARD constexpr auto empty(const _Container& _Cont) -> decltype(_Cont.empty()) { +_NODISCARD_EMPTY_FUNCTION constexpr auto empty(const _Container& _Cont) -> decltype(_Cont.empty()) { return _Cont.empty(); } template -_NODISCARD constexpr bool empty(const _Ty (&)[_Size]) noexcept { +_NODISCARD_EMPTY_FUNCTION constexpr bool empty(const _Ty (&)[_Size]) noexcept { return false; } template -_NODISCARD constexpr bool empty(initializer_list<_Elem> _Ilist) noexcept { +_NODISCARD_EMPTY_FUNCTION constexpr bool empty(initializer_list<_Elem> _Ilist) noexcept { return _Ilist.size() == 0; } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index d9d77bac054..91743318292 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -477,6 +477,16 @@ "It is not useful to call this method and discard the returned value. " \ "There's no way to clear an array as its size is fixed") +#define _NODISCARD_EMPTY_FUNCTION \ + _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ + "has no other effects. It is not useful to call this method and discard the returned value. ") + +#define _NODISCARD_EMPTY_MTHD_ADAPTER \ + _NODISCARD_MSG( \ + "This method returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "There's no way to clear a queue or stack, it intentionally limist access to the udnerlying container") + #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") From 00dcaf0824bf7f244dd8efcc041e477a44636e37 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 23 Jun 2022 12:11:41 +0300 Subject: [PATCH 49/73] clang-format --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 91743318292..a871f6575c9 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -481,7 +481,7 @@ _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ "has no other effects. It is not useful to call this method and discard the returned value. ") -#define _NODISCARD_EMPTY_MTHD_ADAPTER \ +#define _NODISCARD_EMPTY_MTHD_ADAPTER \ _NODISCARD_MSG( \ "This method returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ From c6a0644d26090c04dca892f23da1cd71eaac4351 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 09:35:21 +0300 Subject: [PATCH 50/73] typo --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index a1e25f351d4..81f6ca17b9c 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -493,7 +493,7 @@ _NODISCARD_MSG( \ "This method returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ - "There's no way to clear a queue or stack, it intentionally limist access to the udnerlying container") + "There's no way to clear a queue or stack, it intentionally limits access to the udnerlying container. ") #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") From ff38a019afe0aef86daca1605e421661b44b214c Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 10:33:29 +0300 Subject: [PATCH 51/73] More [[nodiscard]] --- stl/inc/future | 7 ++++--- stl/inc/new | 2 +- stl/inc/scoped_allocator | 4 ++-- stl/inc/stack | 2 +- stl/inc/xmemory | 12 +++++++----- stl/inc/yvals_core.h | 24 ++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/stl/inc/future b/stl/inc/future index b90735556df..165d90db42e 100644 --- a/stl/inc/future +++ b/stl/inc/future @@ -1189,7 +1189,7 @@ public: _MyPromise._Swap(_Other._MyPromise); } - _NODISCARD future<_Ty> get_future() { + _NODISCARD_GET_FUTURE future<_Ty> get_future() { return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil{}); } @@ -1519,7 +1519,7 @@ _Associated_state::type>* _Get_associated_state(launc } template -_NODISCARD future<_Invoke_result_t, decay_t<_ArgTypes>...>> async( +_NODISCARD_ASYNC future<_Invoke_result_t, decay_t<_ArgTypes>...>> async( launch _Policy, _Fty&& _Fnarg, _ArgTypes&&... _Args) { // manages a callable object launched with supplied policy using _Ret = _Invoke_result_t, decay_t<_ArgTypes>...>; @@ -1532,7 +1532,8 @@ _NODISCARD future<_Invoke_result_t, decay_t<_ArgTypes>...>> async( } template -_NODISCARD future<_Invoke_result_t, decay_t<_ArgTypes>...>> async(_Fty&& _Fnarg, _ArgTypes&&... _Args) { +_NODISCARD_ASYNC future<_Invoke_result_t, decay_t<_ArgTypes>...>> async( + _Fty&& _Fnarg, _ArgTypes&&... _Args) { // manages a callable object launched with default policy return _STD async(launch::async | launch::deferred, _STD forward<_Fty>(_Fnarg), _STD forward<_ArgTypes>(_Args)...); } diff --git a/stl/inc/new b/stl/inc/new index 28d82a74ce1..da0f276cfda 100644 --- a/stl/inc/new +++ b/stl/inc/new @@ -28,7 +28,7 @@ inline constexpr destroying_delete_t destroying_delete{}; #if _HAS_CXX17 template -_NODISCARD constexpr _Ty* launder(_Ty* _Ptr) noexcept { +_NODISCARD_LAUNDER constexpr _Ty* launder(_Ty* _Ptr) noexcept { static_assert(!is_function_v<_Ty> && !is_void_v<_Ty>, "N4727 21.6.4 [ptr.launder]/3: The program is ill-formed if T is a function type or cv void."); return __builtin_launder(_Ptr); diff --git a/stl/inc/scoped_allocator b/stl/inc/scoped_allocator index c6dba39db06..cdc9ff6d604 100644 --- a/stl/inc/scoped_allocator +++ b/stl/inc/scoped_allocator @@ -206,12 +206,12 @@ public: return static_cast(*this); } - _NODISCARD __declspec(allocator) pointer + _NODISCARD_PTR_RAW_ALLOC_FN __declspec(allocator) pointer allocate(_CRT_GUARDOVERFLOW size_type _Count) { // allocate array of _Count elements, ignore hint return _Outer_traits::allocate(outer_allocator(), _Count); } - _NODISCARD __declspec(allocator) pointer allocate( + _NODISCARD_PTR_RAW_ALLOC_FN __declspec(allocator) pointer allocate( _CRT_GUARDOVERFLOW size_type _Count, const_void_pointer _Hint) { // allocate array of _Count elements, with hint return _Outer_traits::allocate(outer_allocator(), _Count, _Hint); } diff --git a/stl/inc/stack b/stl/inc/stack index 63643921611..59286d9ffa3 100644 --- a/stl/inc/stack +++ b/stl/inc/stack @@ -70,7 +70,7 @@ public: : c(_STD move(_First), _STD move(_Last), _Al) {} #endif // _HAS_CXX23 - _NODISCARD bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_MTHD_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 30e24936534..0c083e8ef06 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -832,19 +832,21 @@ public: _Deallocate<_New_alignof<_Ty>>(_Ptr, sizeof(_Ty) * _Count); } - _NODISCARD _CONSTEXPR20 __declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) { + _NODISCARD_PTR_RAW_ALLOC_FN _CONSTEXPR20 __declspec(allocator) _Ty* allocate( + _CRT_GUARDOVERFLOW const size_t _Count) { static_assert(sizeof(value_type) > 0, "value_type must be complete before calling allocate."); return static_cast<_Ty*>(_Allocate<_New_alignof<_Ty>>(_Get_size_of_n(_Count))); } #if _HAS_CXX23 - _NODISCARD constexpr allocation_result<_Ty*> allocate_at_least(_CRT_GUARDOVERFLOW const size_t _Count) { + _NODISCARD_PTR_RAW_ALLOC_FN constexpr allocation_result<_Ty*> allocate_at_least( + _CRT_GUARDOVERFLOW const size_t _Count) { return {allocate(_Count), _Count}; } #endif // _HAS_CXX23 #if _HAS_DEPRECATED_ALLOCATOR_MEMBERS - _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD __declspec(allocator) _Ty* allocate( + _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD_PTR_RAW_ALLOC_FN __declspec(allocator) _Ty* allocate( _CRT_GUARDOVERFLOW const size_t _Count, const void*) { return allocate(_Count); } @@ -1995,7 +1997,7 @@ _NODISCARD constexpr bool _Allocators_equal(const _Alloc& _Lhs, const _Alloc& _R } template -_NODISCARD _CONSTEXPR20 _FwdIt remove(_FwdIt _First, const _FwdIt _Last, const _Ty& _Val) { +_NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt remove(_FwdIt _First, const _FwdIt _Last, const _Ty& _Val) { // remove each matching _Val _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -2016,7 +2018,7 @@ _NODISCARD _CONSTEXPR20 _FwdIt remove(_FwdIt _First, const _FwdIt _Last, const _ } template -_NODISCARD _CONSTEXPR20 _FwdIt remove_if(_FwdIt _First, const _FwdIt _Last, _Pr _Pred) { +_NODISCARD_REMOVE_ALG _CONSTEXPR20 _FwdIt remove_if(_FwdIt _First, const _FwdIt _Last, _Pr _Pred) { // remove each satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 81f6ca17b9c..da1021df96f 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -485,6 +485,11 @@ "It is not useful to call this method and discard the returned value. " \ "There's no way to clear an array as its size is fixed") +#define _NODISCARD_EMPTY_MTHD_STACKTRACE \ + _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "std::stacktrace can be cleared by re-assigning with an empty value") + #define _NODISCARD_EMPTY_FUNCTION \ _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ "has no other effects. It is not useful to call this method and discard the returned value. ") @@ -514,10 +519,19 @@ _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ "not useful to call this function and discard the return value") + +#define _NODISCARD_PTR_RAW_ALLOC_FN \ + _NODISCARD_MSG("This function allocates some memory and returns a raw pointer. " \ + "It is an error to discard the result, it causes a memory leak") + #define _NODISCARD_ASSUME_ALIGNED \ _NODISCARD_MSG("Implementation might take advantage of alignment assumption only if the object is accesssed via " \ "the returned pointer") +#define _NODISCARD_LAUNDER \ + _NODISCARD_MSG("std::launder has an effect on the return value (not on the passed parameter). " \ + "It is not useful to call std::launder and discard the returned value") + #ifdef _NODISCARD_LOCK_SUPPRESS #define _NODISCARD_LOCK @@ -550,6 +564,16 @@ _NODISCARD_CTOR_MSG( \ "Construction of the object has no side effects; it is not useful to construct an object just to discard it") +#define _NODISCARD_ASYNC \ + _NODISCARD_MSG( \ + "Async should save the return value to a variable. If the return value is discarded, the temporary future is " \ + "destroyed, waiting for async result or evaluating deferred result, thus defeating std::async purpose.") + + +#define _NODISCARD_GET_FUTURE \ + _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that causes " \ + "exception to be throwns, so it is an error to get the future and discard it") + #pragma push_macro("msvc") #pragma push_macro("known_semantics") #pragma push_macro("noop_dtor") From d545220a7aef3c47674d7cbae0fd3d27144510df Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 10:38:49 +0300 Subject: [PATCH 52/73] more remove --- stl/inc/execution | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stl/inc/execution b/stl/inc/execution index 9df2458b2e2..c611f160b2c 100644 --- a/stl/inc/execution +++ b/stl/inc/execution @@ -2560,7 +2560,8 @@ struct _Static_partitioned_remove_if2 { }; template /* = 0 */> -_NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept /* terminates */ { +_NODISCARD_REMOVE_ALG _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept +/* terminates */ { // remove each satisfying _Pred _Adl_verify_range(_First, _Last); auto _UFirst = _Get_unwrapped(_First); @@ -2587,7 +2588,7 @@ _NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pre } template /* = 0 */> -_NODISCARD _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept +_NODISCARD_REMOVE_ALG _FwdIt remove(_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept /* terminates */ { // remove each matching _Val return _STD remove_if(_STD forward<_ExPo>(_Exec), _First, _Last, From d3bd5823866571c2fca92120d8ed06b63f1c5f8a Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 10:43:30 +0300 Subject: [PATCH 53/73] typos --- stl/inc/yvals_core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index da1021df96f..deb2e4fa924 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -529,8 +529,8 @@ "the returned pointer") #define _NODISCARD_LAUNDER \ - _NODISCARD_MSG("std::launder has an effect on the return value (not on the passed parameter). " \ - "It is not useful to call std::launder and discard the returned value") + _NODISCARD_MSG("'std::launder' has an effect on the return value (not on the passed parameter). " \ + "It is not useful to call 'std::launder' and discard the returned value") #ifdef _NODISCARD_LOCK_SUPPRESS @@ -571,8 +571,8 @@ #define _NODISCARD_GET_FUTURE \ - _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that causes " \ - "exception to be throwns, so it is an error to get the future and discard it") + _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that cause " \ + "exception to be thrown, so it is an error to get the future and discard it") #pragma push_macro("msvc") #pragma push_macro("known_semantics") From a3685baf30988046837fe15aa5fc6a4d4c5cac21 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 10:48:19 +0300 Subject: [PATCH 54/73] format --- stl/inc/yvals_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index deb2e4fa924..e21bd7c198b 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -528,7 +528,7 @@ _NODISCARD_MSG("Implementation might take advantage of alignment assumption only if the object is accesssed via " \ "the returned pointer") -#define _NODISCARD_LAUNDER \ +#define _NODISCARD_LAUNDER \ _NODISCARD_MSG("'std::launder' has an effect on the return value (not on the passed parameter). " \ "It is not useful to call 'std::launder' and discard the returned value") @@ -570,7 +570,7 @@ "destroyed, waiting for async result or evaluating deferred result, thus defeating std::async purpose.") -#define _NODISCARD_GET_FUTURE \ +#define _NODISCARD_GET_FUTURE \ _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that cause " \ "exception to be thrown, so it is an error to get the future and discard it") From 8a26528ab22e9ce9aa04c8f99233be0d6c6340a8 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 14:51:22 +0300 Subject: [PATCH 55/73] member function --- stl/inc/array | 4 +-- stl/inc/deque | 2 +- stl/inc/forward_list | 2 +- stl/inc/list | 2 +- stl/inc/queue | 4 +-- stl/inc/stacktrace | 2 +- stl/inc/vector | 4 +-- stl/inc/xhash | 2 +- stl/inc/xstring | 2 +- stl/inc/xtree | 2 +- stl/inc/yvals_core.h | 59 +++++++++++++++++++++++--------------------- 11 files changed, 44 insertions(+), 41 deletions(-) diff --git a/stl/inc/array b/stl/inc/array index f3d0f7ca130..0f177b58375 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -506,7 +506,7 @@ public: return _Size; } - _NODISCARD_EMPTY_MTHD_ARRAY constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN_ARRAY constexpr bool empty() const noexcept { return false; } @@ -685,7 +685,7 @@ public: return 0; } - _NODISCARD_EMPTY_MTHD_ARRAY constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN_ARRAY constexpr bool empty() const noexcept { return true; } diff --git a/stl/inc/deque b/stl/inc/deque index 468689806b5..69009e3f9a1 100644 --- a/stl/inc/deque +++ b/stl/inc/deque @@ -994,7 +994,7 @@ public: static_cast((numeric_limits::max)()), _Alty_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MTHD bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { return _Mysize() == 0; } diff --git a/stl/inc/forward_list b/stl/inc/forward_list index f149b8abc7c..13496fcc459 100644 --- a/stl/inc/forward_list +++ b/stl/inc/forward_list @@ -871,7 +871,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MTHD bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { return _Mypair._Myval2._Myhead == nullptr; } diff --git a/stl/inc/list b/stl/inc/list index 68365ccc1c7..809576aeb91 100644 --- a/stl/inc/list +++ b/stl/inc/list @@ -1181,7 +1181,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MTHD bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { return _Mypair._Myval2._Mysize == 0; } diff --git a/stl/inc/queue b/stl/inc/queue index 86a24c75216..7211dc3ae25 100644 --- a/stl/inc/queue +++ b/stl/inc/queue @@ -72,7 +72,7 @@ public: : c(_STD move(_First), _STD move(_Last), _Al) {} #endif // _HAS_CXX23 - _NODISCARD_EMPTY_MTHD_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_MEM_FN_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } @@ -296,7 +296,7 @@ public: _STD make_heap(c.begin(), c.end(), comp); } - _NODISCARD_EMPTY_MTHD_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_MEM_FN_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/stacktrace b/stl/inc/stacktrace index eeb84e0b659..f920a3489bf 100644 --- a/stl/inc/stacktrace +++ b/stl/inc/stacktrace @@ -232,7 +232,7 @@ public: return _Frames.crend(); } - _NODISCARD bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN_STACKTRACE bool empty() const noexcept { return _Frames.empty(); } diff --git a/stl/inc/vector b/stl/inc/vector index 9a5f333ba42..a411c43a3e7 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -1758,7 +1758,7 @@ public: return _Mypair._Myval2._Mylast; } - _NODISCARD_EMPTY_MTHD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN _CONSTEXPR20 bool empty() const noexcept { auto& _My_data = _Mypair._Myval2; return _My_data._Myfirst == _My_data._Mylast; } @@ -3038,7 +3038,7 @@ public: return _Ints_max * _VBITS; } - _NODISCARD_EMPTY_MTHD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN _CONSTEXPR20 bool empty() const noexcept { return this->_Mysize == 0; } diff --git a/stl/inc/xhash b/stl/inc/xhash index e6ad668ead6..f75ab8fac6d 100644 --- a/stl/inc/xhash +++ b/stl/inc/xhash @@ -822,7 +822,7 @@ public: return _List.max_size(); } - _NODISCARD_EMPTY_MTHD bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { return _List.empty(); } diff --git a/stl/inc/xstring b/stl/inc/xstring index b0cb7b636e2..89833b962af 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -4206,7 +4206,7 @@ public: } #endif // _HAS_CXX20 - _NODISCARD_EMPTY_MTHD _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN _CONSTEXPR20 bool empty() const noexcept { return _Mypair._Myval2._Mysize == 0; } diff --git a/stl/inc/xtree b/stl/inc/xtree index 9bfd994082c..26f96f94e20 100644 --- a/stl/inc/xtree +++ b/stl/inc/xtree @@ -1198,7 +1198,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MTHD bool empty() const noexcept { + _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { return _Get_scary()->_Mysize == 0; } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index e21bd7c198b..dd90a169f73 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -475,41 +475,46 @@ "The 'unique' algorithm returns the iterator past the last non-removed element. " \ "Normally you need to use the result to call container's 'erase' method afterwards to erase elements") -#define _NODISCARD_EMPTY_MTHD \ - _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "Use 'clear()' method if you intend to clear the container instead") - -#define _NODISCARD_EMPTY_MTHD_ARRAY \ - _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "There's no way to clear an array as its size is fixed") - -#define _NODISCARD_EMPTY_MTHD_STACKTRACE \ - _NODISCARD_MSG("This method returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "std::stacktrace can be cleared by re-assigning with an empty value") +#define _NODISCARD_EMPTY_MEM_FN \ + _NODISCARD_MSG( \ + "This member function returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "Use 'clear()' method if you intend to clear the container instead") + +#define _NODISCARD_EMPTY_MEM_FN_ARRAY \ + _NODISCARD_MSG( \ + "This member function returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "There's no way to clear an array as its size is fixed") + +#define _NODISCARD_EMPTY_MEM_FN_STACKTRACE \ + _NODISCARD_MSG( \ + "This member function returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ + "std::stacktrace can be cleared by re-assigning with an empty value") #define _NODISCARD_EMPTY_FUNCTION \ _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ "has no other effects. It is not useful to call this method and discard the returned value. ") -#define _NODISCARD_EMPTY_MTHD_ADAPTER \ - _NODISCARD_MSG( \ - "This method returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ +#define _NODISCARD_EMPTY_MEM_FN_ADAPTER \ + _NODISCARD_MSG( \ + "This member function returns a bool value whether the container is empty and has no other effects. " \ + "It is not useful to call this method and discard the returned value. " \ "There's no way to clear a queue or stack, it intentionally limits access to the udnerlying container. ") #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") -#define _NODISCARD_TRY_WAIT \ - _NODISCARD_MSG("This method returns the state of the synchronization object and does not do anything else; it is " \ - "not useful to call this method and discard the return value") +#define _NODISCARD_TRY_WAIT \ + _NODISCARD_MSG( \ + "This member function returns the state of the synchronization object and does not do anything else; it is " \ + "not useful to call this method and discard the return value") -#define _NODISCARD_TRY_CHANGE_STATE \ - _NODISCARD_MSG("This method returns whether the operation succeeds in modifying the state of the object or not. " \ - "It is dangerous to ignore the return value") +#define _NODISCARD_TRY_CHANGE_STATE \ + _NODISCARD_MSG( \ + "This member function returns whether the operation succeeds in modifying the state of the object or not. " \ + "It is dangerous to ignore the return value") #define _NODISCARD_TRY_CHANGE_STATE_FN \ _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ @@ -519,7 +524,6 @@ _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ "not useful to call this function and discard the return value") - #define _NODISCARD_PTR_RAW_ALLOC_FN \ _NODISCARD_MSG("This function allocates some memory and returns a raw pointer. " \ "It is an error to discard the result, it causes a memory leak") @@ -566,9 +570,8 @@ #define _NODISCARD_ASYNC \ _NODISCARD_MSG( \ - "Async should save the return value to a variable. If the return value is discarded, the temporary future is " \ - "destroyed, waiting for async result or evaluating deferred result, thus defeating std::async purpose.") - + "'std::async' result should be saved into a variable. If the return value is discarded, the temporary future " \ + "is destroyed, waiting for async result or evaluating deferred result, thus defeating 'std::async' purpose.") #define _NODISCARD_GET_FUTURE \ _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that cause " \ From f50cde536f4b9d3f3e6f2ba2fe09e1d780b775fd Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 14:54:48 +0300 Subject: [PATCH 56/73] punctuation --- stl/inc/yvals_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index dd90a169f73..5a679c41ffa 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -491,7 +491,7 @@ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ - "std::stacktrace can be cleared by re-assigning with an empty value") + "'std::stacktrace' can be cleared by re-assigning with an empty value") #define _NODISCARD_EMPTY_FUNCTION \ _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ @@ -501,7 +501,7 @@ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ - "There's no way to clear a queue or stack, it intentionally limits access to the udnerlying container. ") + "There's no way to clear a queue or stack, it intentionally limits access to the udnerlying container") #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") @@ -571,7 +571,7 @@ #define _NODISCARD_ASYNC \ _NODISCARD_MSG( \ "'std::async' result should be saved into a variable. If the return value is discarded, the temporary future " \ - "is destroyed, waiting for async result or evaluating deferred result, thus defeating 'std::async' purpose.") + "is destroyed, waiting for async result or evaluating deferred result, thus defeating 'std::async' purpose") #define _NODISCARD_GET_FUTURE \ _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that cause " \ From 3a9be2e41298fb85e0fb9be444ab34bc945fe985 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 1 Jul 2022 17:52:56 +0300 Subject: [PATCH 57/73] missed stack --- stl/inc/stack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/stack b/stl/inc/stack index 59286d9ffa3..3a0327aa45e 100644 --- a/stl/inc/stack +++ b/stl/inc/stack @@ -70,7 +70,7 @@ public: : c(_STD move(_First), _STD move(_Last), _Al) {} #endif // _HAS_CXX23 - _NODISCARD_EMPTY_MTHD_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_MEM_FN_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } From 19383b1610260d1662937b08a98322cf4a6cd2ba Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sat, 20 Aug 2022 17:20:10 +0300 Subject: [PATCH 58/73] formatting --- stl/inc/xutility | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index 6bc832248de..423a1b96a58 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1649,7 +1649,8 @@ _NODISCARD constexpr ptrdiff_t ssize(const _Ty (&)[_Size]) noexcept { #endif // _HAS_CXX20 template -_NODISCARD_EMPTY_FUNCTION constexpr auto empty(const _Container& _Cont) noexcept(noexcept(_Cont.empty())) /* strengthened */ +_NODISCARD_EMPTY_FUNCTION constexpr auto empty(const _Container& _Cont) noexcept( + noexcept(_Cont.empty())) /* strengthened */ -> decltype(_Cont.empty()) { return _Cont.empty(); } From c3d5a9d845cb49d6a70b7f8bb8911faa0d7f14a1 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 25 Aug 2022 13:14:46 +0300 Subject: [PATCH 59/73] undo trivial nodiscard message --- stl/inc/source_location | 2 +- stl/inc/yvals_core.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/stl/inc/source_location b/stl/inc/source_location index 983caf82f61..9bbea21608e 100644 --- a/stl/inc/source_location +++ b/stl/inc/source_location @@ -34,7 +34,7 @@ struct source_location { return _Result; } - _NODISCARD_CTOR_PURE constexpr source_location() noexcept = default; + _NODISCARD_CTOR constexpr source_location() noexcept = default; _NODISCARD constexpr uint_least32_t line() const noexcept { return _Line; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index ac9a7352eab..976b12af463 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -599,10 +599,6 @@ _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention? " \ "(You can add '.join()' to avoid this warning if so)") -#define _NODISCARD_CTOR_PURE \ - _NODISCARD_CTOR_MSG( \ - "Construction of the object has no side effects; it is not useful to construct an object just to discard it") - #define _NODISCARD_ASYNC \ _NODISCARD_MSG( \ "'std::async' result should be saved into a variable. If the return value is discarded, the temporary future " \ From 77d815f9f45fba92ee35702926256b40dfa57762 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 26 Aug 2022 15:29:59 -0700 Subject: [PATCH 60/73] Attempt to enable `_NODISCARD_MSG` for CUDA 11.6. --- stl/inc/yvals_core.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 02adf0bd410..a719ed02dcd 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -477,8 +477,7 @@ // TRANSITION, This should go to vcruntime.h #ifndef __has_cpp_attribute #define _NODISCARD_MSG(_Msg) -#elif __has_cpp_attribute(nodiscard) >= 201907L \ - && !defined(__CUDACC__) // TRANSITION, CUDA 10.1 version does not support [[nodiscard("message")]] +#elif __has_cpp_attribute(nodiscard) >= 201907L #define _NODISCARD_MSG(_Msg) [[nodiscard(_Msg)]] #elif __has_cpp_attribute(nodiscard) >= 201603L #define _NODISCARD_MSG(_Msg) [[nodiscard]] From 75537b014b414b95e630ffce73ef85eae119cfe1 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 26 Aug 2022 15:50:18 -0700 Subject: [PATCH 61/73] Rename to EMPTY_MEOW_MEMBER for clarity and consistency. --- stl/inc/array | 4 ++-- stl/inc/deque | 2 +- stl/inc/forward_list | 2 +- stl/inc/list | 2 +- stl/inc/queue | 4 ++-- stl/inc/stack | 2 +- stl/inc/stacktrace | 2 +- stl/inc/vector | 4 ++-- stl/inc/xhash | 2 +- stl/inc/xstring | 2 +- stl/inc/xtree | 2 +- stl/inc/xutility | 6 +++--- stl/inc/yvals_core.h | 10 +++++----- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/stl/inc/array b/stl/inc/array index 0313b6be84d..2f464061478 100644 --- a/stl/inc/array +++ b/stl/inc/array @@ -506,7 +506,7 @@ public: return _Size; } - _NODISCARD_EMPTY_MEM_FN_ARRAY constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_ARRAY_MEMBER constexpr bool empty() const noexcept { return false; } @@ -685,7 +685,7 @@ public: return 0; } - _NODISCARD_EMPTY_MEM_FN_ARRAY constexpr bool empty() const noexcept { + _NODISCARD_EMPTY_ARRAY_MEMBER constexpr bool empty() const noexcept { return true; } diff --git a/stl/inc/deque b/stl/inc/deque index 363873b4e23..04d535fc47b 100644 --- a/stl/inc/deque +++ b/stl/inc/deque @@ -1041,7 +1041,7 @@ public: static_cast((numeric_limits::max)()), _Alty_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER bool empty() const noexcept { return _Mysize() == 0; } diff --git a/stl/inc/forward_list b/stl/inc/forward_list index 7cd15c45b46..3def6d663bd 100644 --- a/stl/inc/forward_list +++ b/stl/inc/forward_list @@ -887,7 +887,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER bool empty() const noexcept { return _Mypair._Myval2._Myhead == nullptr; } diff --git a/stl/inc/list b/stl/inc/list index f600f7f4bf3..7d248f34dea 100644 --- a/stl/inc/list +++ b/stl/inc/list @@ -1191,7 +1191,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER bool empty() const noexcept { return _Mypair._Myval2._Mysize == 0; } diff --git a/stl/inc/queue b/stl/inc/queue index bf9fcee5b68..b38c28c6a8d 100644 --- a/stl/inc/queue +++ b/stl/inc/queue @@ -87,7 +87,7 @@ public: #endif // __cpp_lib_concepts #endif // _HAS_CXX23 - _NODISCARD_EMPTY_MEM_FN_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_ADAPTER_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } @@ -353,7 +353,7 @@ public: } #endif // _HAS_CXX23 && defined(__cpp_lib_concepts) - _NODISCARD_EMPTY_MEM_FN_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_ADAPTER_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/stack b/stl/inc/stack index 3ab27f5f626..aec28fddf2e 100644 --- a/stl/inc/stack +++ b/stl/inc/stack @@ -85,7 +85,7 @@ public: #endif // __cpp_lib_concepts #endif // _HAS_CXX23 - _NODISCARD_EMPTY_MEM_FN_ADAPTER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_ADAPTER_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/stacktrace b/stl/inc/stacktrace index 0a3d6a69eb1..e693af7add7 100644 --- a/stl/inc/stacktrace +++ b/stl/inc/stacktrace @@ -232,7 +232,7 @@ public: return _Frames.crend(); } - _NODISCARD_EMPTY_MEM_FN_STACKTRACE bool empty() const noexcept { + _NODISCARD_EMPTY_STACKTRACE_MEMBER bool empty() const noexcept { return _Frames.empty(); } diff --git a/stl/inc/vector b/stl/inc/vector index 2296ffa33b9..1d3062f6266 100644 --- a/stl/inc/vector +++ b/stl/inc/vector @@ -1922,7 +1922,7 @@ public: return _Mypair._Myval2._Mylast; } - _NODISCARD_EMPTY_MEM_FN _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER _CONSTEXPR20 bool empty() const noexcept { auto& _My_data = _Mypair._Myval2; return _My_data._Myfirst == _My_data._Mylast; } @@ -3224,7 +3224,7 @@ public: return _Ints_max * _VBITS; } - _NODISCARD_EMPTY_MEM_FN _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER _CONSTEXPR20 bool empty() const noexcept { return this->_Mysize == 0; } diff --git a/stl/inc/xhash b/stl/inc/xhash index bfa537dd851..4b36dd4989b 100644 --- a/stl/inc/xhash +++ b/stl/inc/xhash @@ -830,7 +830,7 @@ public: return _List.max_size(); } - _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER bool empty() const noexcept { return _List.empty(); } diff --git a/stl/inc/xstring b/stl/inc/xstring index 3018d0883df..715b2437e94 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -4317,7 +4317,7 @@ public: } #endif // _HAS_CXX20 - _NODISCARD_EMPTY_MEM_FN _CONSTEXPR20 bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER _CONSTEXPR20 bool empty() const noexcept { return _Mypair._Myval2._Mysize == 0; } diff --git a/stl/inc/xtree b/stl/inc/xtree index 6e6a1993393..6c6767e0c00 100644 --- a/stl/inc/xtree +++ b/stl/inc/xtree @@ -1198,7 +1198,7 @@ public: static_cast((numeric_limits::max)()), _Alnode_traits::max_size(_Getal())); } - _NODISCARD_EMPTY_MEM_FN bool empty() const noexcept { + _NODISCARD_EMPTY_MEMBER bool empty() const noexcept { return _Get_scary()->_Mysize == 0; } diff --git a/stl/inc/xutility b/stl/inc/xutility index 83051981a88..02daef1538c 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1649,19 +1649,19 @@ _NODISCARD constexpr ptrdiff_t ssize(const _Ty (&)[_Size]) noexcept { #endif // _HAS_CXX20 template -_NODISCARD_EMPTY_FUNCTION constexpr auto empty(const _Container& _Cont) noexcept( +_NODISCARD_EMPTY_NON_MEMBER constexpr auto empty(const _Container& _Cont) noexcept( noexcept(_Cont.empty())) /* strengthened */ -> decltype(_Cont.empty()) { return _Cont.empty(); } template -_NODISCARD_EMPTY_FUNCTION constexpr bool empty(const _Ty (&)[_Size]) noexcept { +_NODISCARD_EMPTY_NON_MEMBER constexpr bool empty(const _Ty (&)[_Size]) noexcept { return false; } template -_NODISCARD_EMPTY_FUNCTION constexpr bool empty(initializer_list<_Elem> _Ilist) noexcept { +_NODISCARD_EMPTY_NON_MEMBER constexpr bool empty(initializer_list<_Elem> _Ilist) noexcept { return _Ilist.size() == 0; } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index a719ed02dcd..17c99e8081e 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -513,29 +513,29 @@ "The 'unique' algorithm returns the iterator past the last non-removed element. " \ "Normally you need to use the result to call container's 'erase' method afterwards to erase elements") -#define _NODISCARD_EMPTY_MEM_FN \ +#define _NODISCARD_EMPTY_MEMBER \ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ "Use 'clear()' method if you intend to clear the container instead") -#define _NODISCARD_EMPTY_MEM_FN_ARRAY \ +#define _NODISCARD_EMPTY_ARRAY_MEMBER \ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ "There's no way to clear an array as its size is fixed") -#define _NODISCARD_EMPTY_MEM_FN_STACKTRACE \ +#define _NODISCARD_EMPTY_STACKTRACE_MEMBER \ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ "'std::stacktrace' can be cleared by re-assigning with an empty value") -#define _NODISCARD_EMPTY_FUNCTION \ +#define _NODISCARD_EMPTY_NON_MEMBER \ _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ "has no other effects. It is not useful to call this method and discard the returned value. ") -#define _NODISCARD_EMPTY_MEM_FN_ADAPTER \ +#define _NODISCARD_EMPTY_ADAPTER_MEMBER \ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ From 65976e39decabfa7a083da0d91b05a9ee25f1fc7 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 26 Aug 2022 16:09:37 -0700 Subject: [PATCH 62/73] Unify `_NODISCARD_TRY_CHANGE_STATE`. The Standard uses "function" to refer to both member functions and non-member functions. Unify "the state of the object" and "the state of the passed objects" into "object state", which avoids talking about how many objects are involved. --- stl/inc/mutex | 2 +- stl/inc/yvals_core.h | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/stl/inc/mutex b/stl/inc/mutex index 68eb941c446..2dcf0352080 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -347,7 +347,7 @@ int _Try_lock1(_Lock0& _Lk0, _Lock1& _Lk1) { } template -_NODISCARD_TRY_CHANGE_STATE_FN int try_lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks +_NODISCARD_TRY_CHANGE_STATE int try_lock(_Lock0& _Lk0, _Lock1& _Lk1, _LockN&... _LkN) { // try to lock multiple locks return _Try_lock1(_Lk0, _Lk1, _LkN...); } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 17c99e8081e..b86c2062e65 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -549,14 +549,9 @@ "This member function returns the state of the synchronization object and does not do anything else; it is " \ "not useful to call this method and discard the return value") -#define _NODISCARD_TRY_CHANGE_STATE \ - _NODISCARD_MSG( \ - "This member function returns whether the operation succeeds in modifying the state of the object or not. " \ - "It is dangerous to ignore the return value") - -#define _NODISCARD_TRY_CHANGE_STATE_FN \ - _NODISCARD_MSG("This function returns whether the operation succeeds in modifying the state of the passed " \ - "objects or not. It is dangerous to ignore the return value") +#define _NODISCARD_TRY_CHANGE_STATE \ + _NODISCARD_MSG("This function returns whether the operation succeeds in modifying object state or not. " \ + "It is dangerous to ignore the return value") #define _NODISCARD_PTR_ALLOC_FN \ _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ From a34658cd4bcf9ab7f8b53084bbaba1c06e07a6f8 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 26 Aug 2022 16:22:23 -0700 Subject: [PATCH 63/73] Rename `_NODISCARD_PTR_ALLOC_FN` to `_NODISCARD_SMART_PTR_ALLOC`. --- stl/inc/exception | 2 +- stl/inc/memory | 34 +++++++++++++++++----------------- stl/inc/yvals_core.h | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/stl/inc/exception b/stl/inc/exception index ad5eaba5097..3d7088805c8 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -316,7 +316,7 @@ template void* __GetExceptionInfo(_Ex); template -_NODISCARD_PTR_ALLOC_FN exception_ptr make_exception_ptr(_Ex _Except) noexcept { +_NODISCARD_SMART_PTR_ALLOC exception_ptr make_exception_ptr(_Ex _Except) noexcept { return exception_ptr::_Copy_exception(_STD addressof(_Except), __GetExceptionInfo(_Except)); } diff --git a/stl/inc/memory b/stl/inc/memory index 414e6c2ac46..fa11dd67c33 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -2736,18 +2736,18 @@ _NODISCARD shared_ptr<_Ty> _Make_shared_unbounded_array(const size_t _Count, con } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared(const size_t _Count) { +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> make_shared(const size_t _Count) { return _Make_shared_unbounded_array<_Ty>(_Count); } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> make_shared( const size_t _Count, const remove_extent_t<_Ty>& _Val) { return _Make_shared_unbounded_array<_Ty>(_Count, _Val); } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared() { +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> make_shared() { // make a shared_ptr to a bounded array const auto _Rx = new _Ref_count_bounded_array<_Ty>(); shared_ptr<_Ty> _Ret; @@ -2756,7 +2756,7 @@ _NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> ma } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> make_shared( const remove_extent_t<_Ty>& _Val) { // make a shared_ptr to a bounded array const auto _Rx = new _Ref_count_bounded_array<_Ty>(_Val); @@ -2766,7 +2766,7 @@ _NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> ma } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite() { +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite() { shared_ptr<_Ty> _Ret; if constexpr (is_array_v<_Ty>) { // make a shared_ptr to a bounded array @@ -2781,14 +2781,14 @@ _NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> make_shared_for_overwrite( const size_t _Count) { return _Make_shared_unbounded_array<_Ty>(_Count, _For_overwrite_tag{}); } #endif // _HAS_CXX20 template -_NODISCARD_PTR_ALLOC_FN +_NODISCARD_SMART_PTR_ALLOC #if _HAS_CXX20 enable_if_t, shared_ptr<_Ty>> #else // _HAS_CXX20 @@ -2849,19 +2849,19 @@ _NODISCARD shared_ptr<_Ty> _Allocate_shared_unbounded_array( } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const size_t _Count) { return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count); } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const size_t _Count, const remove_extent_t<_Ty>& _Val) { return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count, _Val); } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared(const _Alloc& _Al) { +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared(const _Alloc& _Al) { // make a shared_ptr to a bounded array using _Refc = _Ref_count_bounded_array_alloc, _Alloc>; using _Alblock = _Rebind_alloc_t<_Alloc, _Refc>; @@ -2876,7 +2876,7 @@ _NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> al } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared( const _Alloc& _Al, const remove_extent_t<_Ty>& _Val) { // make a shared_ptr to a bounded array using _Refc = _Ref_count_bounded_array_alloc, _Alloc>; @@ -2892,7 +2892,7 @@ _NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> al } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( const _Alloc& _Al) { shared_ptr<_Ty> _Ret; if constexpr (is_array_v<_Ty>) { @@ -2921,7 +2921,7 @@ _NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> } template -_NODISCARD_PTR_ALLOC_FN enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( +_NODISCARD_SMART_PTR_ALLOC enable_if_t, shared_ptr<_Ty>> allocate_shared_for_overwrite( const _Alloc& _Al, const size_t _Count) { return _Allocate_shared_unbounded_array<_Ty>(_Al, _Count, _For_overwrite_tag{}); } @@ -3428,12 +3428,12 @@ private: template , int> = 0> -_NODISCARD_PTR_ALLOC_FN _CONSTEXPR23 unique_ptr<_Ty> make_unique(_Types&&... _Args) { // make a unique_ptr +_NODISCARD_SMART_PTR_ALLOC _CONSTEXPR23 unique_ptr<_Ty> make_unique(_Types&&... _Args) { // make a unique_ptr return unique_ptr<_Ty>(new _Ty(_STD forward<_Types>(_Args)...)); } template && extent_v<_Ty> == 0, int> = 0> -_NODISCARD_PTR_ALLOC_FN _CONSTEXPR23 unique_ptr<_Ty> make_unique(const size_t _Size) { // make a unique_ptr +_NODISCARD_SMART_PTR_ALLOC _CONSTEXPR23 unique_ptr<_Ty> make_unique(const size_t _Size) { // make a unique_ptr using _Elem = remove_extent_t<_Ty>; return unique_ptr<_Ty>(new _Elem[_Size]()); } @@ -3443,13 +3443,13 @@ void make_unique(_Types&&...) = delete; #if _HAS_CXX20 template , int> = 0> -_NODISCARD_PTR_ALLOC_FN _CONSTEXPR23 unique_ptr<_Ty> make_unique_for_overwrite() { +_NODISCARD_SMART_PTR_ALLOC _CONSTEXPR23 unique_ptr<_Ty> make_unique_for_overwrite() { // make a unique_ptr with default initialization return unique_ptr<_Ty>(new _Ty); } template , int> = 0> -_NODISCARD_PTR_ALLOC_FN _CONSTEXPR23 unique_ptr<_Ty> make_unique_for_overwrite(const size_t _Size) { +_NODISCARD_SMART_PTR_ALLOC _CONSTEXPR23 unique_ptr<_Ty> make_unique_for_overwrite(const size_t _Size) { // make a unique_ptr with default initialization using _Elem = remove_extent_t<_Ty>; return unique_ptr<_Ty>(new _Elem[_Size]); diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index b86c2062e65..d1d8fff30b3 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -553,7 +553,7 @@ _NODISCARD_MSG("This function returns whether the operation succeeds in modifying object state or not. " \ "It is dangerous to ignore the return value") -#define _NODISCARD_PTR_ALLOC_FN \ +#define _NODISCARD_SMART_PTR_ALLOC \ _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ "not useful to call this function and discard the return value") From 96d7184c8c5a2ed3a07501ef2ecb95693f34c4d6 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 26 Aug 2022 16:23:15 -0700 Subject: [PATCH 64/73] Rename `_NODISCARD_PTR_RAW_ALLOC_FN` to `_NODISCARD_RAW_PTR_ALLOC`. --- stl/inc/scoped_allocator | 4 ++-- stl/inc/xmemory | 7 +++---- stl/inc/yvals_core.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/stl/inc/scoped_allocator b/stl/inc/scoped_allocator index 8746cd1899b..906b032287c 100644 --- a/stl/inc/scoped_allocator +++ b/stl/inc/scoped_allocator @@ -206,12 +206,12 @@ public: return static_cast(*this); } - _NODISCARD_PTR_RAW_ALLOC_FN __declspec(allocator) pointer + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) pointer allocate(_CRT_GUARDOVERFLOW size_type _Count) { // allocate array of _Count elements, ignore hint return _Outer_traits::allocate(outer_allocator(), _Count); } - _NODISCARD_PTR_RAW_ALLOC_FN __declspec(allocator) pointer allocate( + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) pointer allocate( _CRT_GUARDOVERFLOW size_type _Count, const_void_pointer _Hint) { // allocate array of _Count elements, with hint return _Outer_traits::allocate(outer_allocator(), _Count, _Hint); } diff --git a/stl/inc/xmemory b/stl/inc/xmemory index ccffcad4f27..685cf6a5de5 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -830,21 +830,20 @@ public: _Deallocate<_New_alignof<_Ty>>(_Ptr, sizeof(_Ty) * _Count); } - _NODISCARD_PTR_RAW_ALLOC_FN _CONSTEXPR20 __declspec(allocator) _Ty* allocate( - _CRT_GUARDOVERFLOW const size_t _Count) { + _NODISCARD_RAW_PTR_ALLOC _CONSTEXPR20 __declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) { static_assert(sizeof(value_type) > 0, "value_type must be complete before calling allocate."); return static_cast<_Ty*>(_Allocate<_New_alignof<_Ty>>(_Get_size_of_n(_Count))); } #if _HAS_CXX23 - _NODISCARD_PTR_RAW_ALLOC_FN constexpr allocation_result<_Ty*> allocate_at_least( + _NODISCARD_RAW_PTR_ALLOC constexpr allocation_result<_Ty*> allocate_at_least( _CRT_GUARDOVERFLOW const size_t _Count) { return {allocate(_Count), _Count}; } #endif // _HAS_CXX23 #if _HAS_DEPRECATED_ALLOCATOR_MEMBERS - _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD_PTR_RAW_ALLOC_FN __declspec(allocator) _Ty* allocate( + _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) _Ty* allocate( _CRT_GUARDOVERFLOW const size_t _Count, const void*) { return allocate(_Count); } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index d1d8fff30b3..0855ba702fe 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -557,7 +557,7 @@ _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ "not useful to call this function and discard the return value") -#define _NODISCARD_PTR_RAW_ALLOC_FN \ +#define _NODISCARD_RAW_PTR_ALLOC \ _NODISCARD_MSG("This function allocates some memory and returns a raw pointer. " \ "It is an error to discard the result, it causes a memory leak") From b2c39e7734ac44d1431dbca3582e954ed8ffa7f0 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 26 Aug 2022 16:38:07 -0700 Subject: [PATCH 65/73] Add more `_NODISCARD_RAW_PTR_ALLOC`. --- stl/inc/xmemory | 8 ++++---- stl/inc/xpolymorphic_allocator.h | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 685cf6a5de5..266978943ae 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -542,12 +542,12 @@ struct _Normal_allocator_traits { // defines traits for allocators template using rebind_traits = allocator_traits>; - _NODISCARD static _CONSTEXPR20 __declspec(allocator) pointer + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count) { return _Al.allocate(_Count); } - _NODISCARD static _CONSTEXPR20 __declspec(allocator) pointer + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count, const const_void_pointer _Hint) { if constexpr (_Has_allocate_hint<_Alloc, size_type, const_void_pointer>::value) { return _Al.allocate(_Count, _Hint); @@ -628,7 +628,7 @@ struct _Default_allocator_traits { // traits for std::allocator template using rebind_traits = allocator_traits>; - _NODISCARD static _CONSTEXPR20 __declspec(allocator) pointer + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count) { #if _HAS_CXX20 // TRANSITION, GH-1532 if (_STD is_constant_evaluated()) { @@ -642,7 +642,7 @@ struct _Default_allocator_traits { // traits for std::allocator } } - _NODISCARD static _CONSTEXPR20 __declspec(allocator) pointer + _NODISCARD_RAW_PTR_ALLOC static _CONSTEXPR20 __declspec(allocator) pointer allocate(_Alloc& _Al, _CRT_GUARDOVERFLOW const size_type _Count, const_void_pointer) { #if _HAS_CXX20 // TRANSITION, GH-1532 if (_STD is_constant_evaluated()) { diff --git a/stl/inc/xpolymorphic_allocator.h b/stl/inc/xpolymorphic_allocator.h index d065085328e..278843e3ba5 100644 --- a/stl/inc/xpolymorphic_allocator.h +++ b/stl/inc/xpolymorphic_allocator.h @@ -130,7 +130,7 @@ namespace pmr { public: virtual ~memory_resource() noexcept = default; - _NODISCARD __declspec(allocator) void* allocate(_CRT_GUARDOVERFLOW const size_t _Bytes, + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) void* allocate(_CRT_GUARDOVERFLOW const size_t _Bytes, const size_t _Align = alignof(max_align_t)) { // allocate _Bytes bytes of memory with alignment _Align _STL_ASSERT(_Is_pow_2(_Align), "memory_resource::allocate(): Alignment must be a power of two."); void* _Ptr = do_allocate(_Bytes, _Align); @@ -203,7 +203,7 @@ namespace pmr { polymorphic_allocator& operator=(const polymorphic_allocator&) = delete; - _NODISCARD __declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) { + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) { // get space for _Count objects of type _Ty from _Resource void* const _Vp = _Resource->allocate(_Get_size_of_n(_Count), alignof(_Ty)); return static_cast<_Ty*>(_Vp); @@ -216,7 +216,7 @@ namespace pmr { } #if _HAS_CXX20 - _NODISCARD __declspec(allocator) void* allocate_bytes( + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) void* allocate_bytes( const size_t _Bytes, const size_t _Align = alignof(max_align_t)) { return _Resource->allocate(_Bytes, _Align); } @@ -227,7 +227,8 @@ namespace pmr { } template - _NODISCARD __declspec(allocator) _Uty* allocate_object(_CRT_GUARDOVERFLOW const size_t _Count = 1) { + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) _Uty* allocate_object( + _CRT_GUARDOVERFLOW const size_t _Count = 1) { void* const _Vp = allocate_bytes(_Get_size_of_n(_Count), alignof(_Uty)); return static_cast<_Uty*>(_Vp); } @@ -238,7 +239,7 @@ namespace pmr { } template - _NODISCARD __declspec(allocator) _Uty* new_object(_Types&&... _Args) { + _NODISCARD_RAW_PTR_ALLOC __declspec(allocator) _Uty* new_object(_Types&&... _Args) { _Uty* const _Ptr = allocate_object<_Uty>(); _TRY_BEGIN construct(_Ptr, _STD forward<_Types>(_Args)...); From 317ccf8177b15e5bdfc2fc880cad4b462895de5d Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 27 Aug 2022 18:02:39 -0700 Subject: [PATCH 66/73] Use `_NODISCARD_GET_FUTURE` for `promise`, `promise`, and `packaged_task`. --- stl/inc/future | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/future b/stl/inc/future index b78c76c3d53..8e3f4be8da9 100644 --- a/stl/inc/future +++ b/stl/inc/future @@ -1251,7 +1251,7 @@ public: _MyPromise._Swap(_Other._MyPromise); } - _NODISCARD future<_Ty&> get_future() { + _NODISCARD_GET_FUTURE future<_Ty&> get_future() { return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil{}); } @@ -1305,7 +1305,7 @@ public: _MyPromise._Swap(_Other._MyPromise); } - _NODISCARD future get_future() { + _NODISCARD_GET_FUTURE future get_future() { return future(_MyPromise._Get_state_for_future(), _Nil{}); } @@ -1397,7 +1397,7 @@ public: return _MyPromise._Is_valid(); } - _NODISCARD future<_Ret> get_future() { + _NODISCARD_GET_FUTURE future<_Ret> get_future() { return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil{}); } From 02faf63fdccd0172ec4f0aab1ce65066607bb25b Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 27 Aug 2022 18:10:47 -0700 Subject: [PATCH 67/73] Mark `make_shared(_Types&&... _Args)` as `_NODISCARD_SMART_PTR_ALLOC`. --- stl/inc/memory | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/memory b/stl/inc/memory index fa11dd67c33..fcbef65aa45 100644 --- a/stl/inc/memory +++ b/stl/inc/memory @@ -2693,7 +2693,7 @@ private: #endif // _HAS_CXX20 template -_NODISCARD +_NODISCARD_SMART_PTR_ALLOC #if _HAS_CXX20 enable_if_t, shared_ptr<_Ty>> #else // _HAS_CXX20 From 95729f6d5ff095cb4ee7ca6bcb011d027d960b9c Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 27 Aug 2022 19:09:10 -0700 Subject: [PATCH 68/73] Rename control macro to `_SILENCE_NODISCARD_LOCK_WARNINGS`. --- stl/inc/yvals_core.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 0855ba702fe..fc624c76893 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -569,26 +569,26 @@ _NODISCARD_MSG("'std::launder' has an effect on the return value (not on the passed parameter). " \ "It is not useful to call 'std::launder' and discard the returned value") -#ifdef _NODISCARD_LOCK_SUPPRESS +#ifdef _SILENCE_NODISCARD_LOCK_WARNINGS #define _NODISCARD_LOCK #define _NODISCARD_CTOR_LOCK -#else // ^^^ defined(_NODISCARD_LOCK_SUPPRESS) ^^^ / vvv !defined(_NODISCARD_LOCK_SUPPRESS) vvv +#else // ^^^ defined(_SILENCE_NODISCARD_LOCK_WARNINGS) ^^^ / vvv !defined(_SILENCE_NODISCARD_LOCK_WARNINGS) vvv #define _NODISCARD_LOCK \ _NODISCARD_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ "current expression, using comma operator, please use cast to void to suppress this warning. " \ - "Alternatively, define _NODISCARD_LOCK_SUPPRESS)") + "Alternatively, define _SILENCE_NODISCARD_LOCK_WARNINGS)") #define _NODISCARD_CTOR_LOCK \ _NODISCARD_CTOR_MSG( \ "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ "current expression, using comma operator, please use cast to void to suppress this warning. " \ - "Alternatively, define _NODISCARD_LOCK_SUPPRESS)") + "Alternatively, define _SILENCE_NODISCARD_LOCK_WARNINGS)") -#endif // ^^^ !defined(_NODISCARD_LOCK_SUPPRESS) ^^^ +#endif // ^^^ !defined(_SILENCE_NODISCARD_LOCK_WARNINGS) ^^^ #define _NODISCARD_CTOR_THREAD \ _NODISCARD_CTOR_MSG("Thread is not joined or detached, 'terminate' will be called at the end of the statement") From f77160044249289c132b8e85316b22904b835881 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 27 Aug 2022 19:19:19 -0700 Subject: [PATCH 69/73] Fix message typos. --- stl/inc/yvals_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index fc624c76893..8cc2c456569 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -539,7 +539,7 @@ _NODISCARD_MSG( \ "This member function returns a bool value whether the container is empty and has no other effects. " \ "It is not useful to call this method and discard the returned value. " \ - "There's no way to clear a queue or stack, it intentionally limits access to the udnerlying container") + "There's no way to clear a queue or stack, it intentionally limits access to the underlying container") #define _NODISCARD_BARRIER_TOKEN \ _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") @@ -561,8 +561,8 @@ _NODISCARD_MSG("This function allocates some memory and returns a raw pointer. " \ "It is an error to discard the result, it causes a memory leak") -#define _NODISCARD_ASSUME_ALIGNED \ - _NODISCARD_MSG("Implementation might take advantage of alignment assumption only if the object is accesssed via " \ +#define _NODISCARD_ASSUME_ALIGNED \ + _NODISCARD_MSG("Implementation might take advantage of alignment assumption only if the object is accessed via " \ "the returned pointer") #define _NODISCARD_LAUNDER \ From 8aa1c0b6649a7cbc1626d558f68d189ee6fe1b5b Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 28 Aug 2022 01:16:30 -0700 Subject: [PATCH 70/73] Message phrasing overhaul. --- stl/inc/yvals_core.h | 158 +++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 8cc2c456569..62cc71dd1eb 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -502,72 +502,71 @@ #define _NODISCARD_FRIEND _NODISCARD friend #endif // TRANSITION, VSO-568006 -#define _NODISCARD_REMOVE_ALG \ - _NODISCARD_MSG( \ - "The 'remove' and 'remove_if' algorithms return the iterator past the last non-removed element. " \ - "Normally you need to use the result to call container's 'erase' method afterwards to erase elements. " \ - "In C++ 20 you can also use 'erase' and 'erase_if' functions to replace the two steps") - -#define _NODISCARD_UNIQUE_ALG \ - _NODISCARD_MSG( \ - "The 'unique' algorithm returns the iterator past the last non-removed element. " \ - "Normally you need to use the result to call container's 'erase' method afterwards to erase elements") - -#define _NODISCARD_EMPTY_MEMBER \ - _NODISCARD_MSG( \ - "This member function returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "Use 'clear()' method if you intend to clear the container instead") - -#define _NODISCARD_EMPTY_ARRAY_MEMBER \ - _NODISCARD_MSG( \ - "This member function returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "There's no way to clear an array as its size is fixed") - -#define _NODISCARD_EMPTY_STACKTRACE_MEMBER \ - _NODISCARD_MSG( \ - "This member function returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "'std::stacktrace' can be cleared by re-assigning with an empty value") - -#define _NODISCARD_EMPTY_NON_MEMBER \ - _NODISCARD_MSG("This function returns a bool value whether the container or container-like object is empty and " \ - "has no other effects. It is not useful to call this method and discard the returned value. ") - -#define _NODISCARD_EMPTY_ADAPTER_MEMBER \ - _NODISCARD_MSG( \ - "This member function returns a bool value whether the container is empty and has no other effects. " \ - "It is not useful to call this method and discard the returned value. " \ - "There's no way to clear a queue or stack, it intentionally limits access to the underlying container") +#define _NODISCARD_REMOVE_ALG \ + _NODISCARD_MSG("The 'remove' and 'remove_if' algorithms return the iterator past the last element " \ + "that should be kept. You need to call container.erase(result, container.end()) afterwards. " \ + "In C++20, 'std::erase' and 'std::erase_if' are simpler replacements for these two steps.") + +#define _NODISCARD_UNIQUE_ALG \ + _NODISCARD_MSG("The 'unique' algorithm returns the iterator past the last element that should be kept. " \ + "You need to call container.erase(result, container.end()) afterwards.") + +#define _NODISCARD_EMPTY_MEMBER \ + _NODISCARD_MSG( \ + "This member function returns a bool indicating whether the container is empty and has no other effects. " \ + "It is not useful to call this member function and discard the return value. " \ + "Use the 'clear()' member function if you want to erase all elements.") + +#define _NODISCARD_EMPTY_ARRAY_MEMBER \ + _NODISCARD_MSG( \ + "This member function returns a bool indicating whether the container is empty and has no other effects. " \ + "It is not useful to call this member function and discard the return value. " \ + "There's no way to clear an array as its size is fixed.") + +#define _NODISCARD_EMPTY_STACKTRACE_MEMBER \ + _NODISCARD_MSG( \ + "This member function returns a bool indicating whether the container is empty and has no other effects. " \ + "It is not useful to call this member function and discard the return value. " \ + "'std::stacktrace' can be cleared by assigning an empty value to it.") + +#define _NODISCARD_EMPTY_NON_MEMBER \ + _NODISCARD_MSG( \ + "This function returns a bool indicating whether the container or container-like object is empty and " \ + "has no other effects. It is not useful to call this function and discard the return value.") + +#define _NODISCARD_EMPTY_ADAPTER_MEMBER \ + _NODISCARD_MSG( \ + "This member function returns a bool indicating whether the container is empty and has no other effects. " \ + "It is not useful to call this member function and discard the return value. " \ + "Container adaptors don't provide 'clear()' member functions, but you can assign an empty object to them.") #define _NODISCARD_BARRIER_TOKEN \ - _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'") + _NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'.") -#define _NODISCARD_TRY_WAIT \ - _NODISCARD_MSG( \ - "This member function returns the state of the synchronization object and does not do anything else; it is " \ - "not useful to call this method and discard the return value") +#define _NODISCARD_TRY_WAIT \ + _NODISCARD_MSG( \ + "This member function returns the state of the synchronization object and does not do anything else; " \ + "it is not useful to call this member function and discard the return value.") -#define _NODISCARD_TRY_CHANGE_STATE \ - _NODISCARD_MSG("This function returns whether the operation succeeds in modifying object state or not. " \ - "It is dangerous to ignore the return value") +#define _NODISCARD_TRY_CHANGE_STATE \ + _NODISCARD_MSG("This function returns whether the operation succeeded in modifying object state. " \ + "It is dangerous to ignore the return value.") -#define _NODISCARD_SMART_PTR_ALLOC \ - _NODISCARD_MSG("This function constructs an object wrapped by a pointer, and has no other side effects; it is " \ - "not useful to call this function and discard the return value") +#define _NODISCARD_SMART_PTR_ALLOC \ + _NODISCARD_MSG("This function constructs an object wrapped by a smart pointer and has no other effects; " \ + "it is not useful to call this function and discard the return value.") -#define _NODISCARD_RAW_PTR_ALLOC \ - _NODISCARD_MSG("This function allocates some memory and returns a raw pointer. " \ - "It is an error to discard the result, it causes a memory leak") +#define _NODISCARD_RAW_PTR_ALLOC \ + _NODISCARD_MSG("This function allocates memory and returns a raw pointer. " \ + "Discarding the return value will cause a memory leak.") #define _NODISCARD_ASSUME_ALIGNED \ - _NODISCARD_MSG("Implementation might take advantage of alignment assumption only if the object is accessed via " \ - "the returned pointer") + _NODISCARD_MSG("'std::assume_aligned' has a potential effect on the return value (not on the passed argument). " \ + "It is not useful to call 'std::assume_aligned' and discard the return value.") -#define _NODISCARD_LAUNDER \ - _NODISCARD_MSG("'std::launder' has an effect on the return value (not on the passed parameter). " \ - "It is not useful to call 'std::launder' and discard the returned value") +#define _NODISCARD_LAUNDER \ + _NODISCARD_MSG("'std::launder' has an effect on the return value (not on the passed argument). " \ + "It is not useful to call 'std::launder' and discard the return value.") #ifdef _SILENCE_NODISCARD_LOCK_WARNINGS @@ -576,35 +575,36 @@ #else // ^^^ defined(_SILENCE_NODISCARD_LOCK_WARNINGS) ^^^ / vvv !defined(_SILENCE_NODISCARD_LOCK_WARNINGS) vvv -#define _NODISCARD_LOCK \ - _NODISCARD_MSG( \ - "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ - "current expression, using comma operator, please use cast to void to suppress this warning. " \ - "Alternatively, define _SILENCE_NODISCARD_LOCK_WARNINGS)") +#define _NODISCARD_LOCK \ + _NODISCARD_MSG("A lock should be stored in a variable to protect the scope. If you're intentionally constructing " \ + "a temporary to protect the rest of the current expression using the comma operator, you can cast " \ + "the temporary to void or define _SILENCE_NODISCARD_LOCK_WARNINGS to suppress this warning.") -#define _NODISCARD_CTOR_LOCK \ - _NODISCARD_CTOR_MSG( \ - "A lock should be saved in a variable to protect the scope. (If the intention is to protect the rest of the " \ - "current expression, using comma operator, please use cast to void to suppress this warning. " \ - "Alternatively, define _SILENCE_NODISCARD_LOCK_WARNINGS)") +#define _NODISCARD_CTOR_LOCK \ + _NODISCARD_CTOR_MSG( \ + "A lock should be stored in a variable to protect the scope. If you're intentionally constructing " \ + "a temporary to protect the rest of the current expression using the comma operator, you can cast " \ + "the temporary to void or define _SILENCE_NODISCARD_LOCK_WARNINGS to suppress this warning.") #endif // ^^^ !defined(_SILENCE_NODISCARD_LOCK_WARNINGS) ^^^ -#define _NODISCARD_CTOR_THREAD \ - _NODISCARD_CTOR_MSG("Thread is not joined or detached, 'terminate' will be called at the end of the statement") +#define _NODISCARD_CTOR_THREAD \ + _NODISCARD_CTOR_MSG("This temporary 'std::thread' is not joined or detached, " \ + "so 'std::terminate' will be called at the end of the statement.") -#define _NODISCARD_CTOR_JTHREAD \ - _NODISCARD_CTOR_MSG("Thread is implicitly joined at the end of the statement, is this an intention? " \ - "(You can add '.join()' to avoid this warning if so)") +#define _NODISCARD_CTOR_JTHREAD \ + _NODISCARD_CTOR_MSG("This temporary 'std::jthread' is implicitly joined at the end of the statement. " \ + "If this is intentional, you can add '.join()' to suppress this warning. " \ + "Otherwise, this 'std::jthread' should be stored in a variable.") -#define _NODISCARD_ASYNC \ - _NODISCARD_MSG( \ - "'std::async' result should be saved into a variable. If the return value is discarded, the temporary future " \ - "is destroyed, waiting for async result or evaluating deferred result, thus defeating 'std::async' purpose") +#define _NODISCARD_ASYNC \ + _NODISCARD_MSG("The result of 'std::async' should be stored in a variable. If the return value is discarded, " \ + "the temporary 'std::future' is destroyed, waiting for an async result or evaluating " \ + "a deferred result, thus defeating the purpose of 'std::async'.") -#define _NODISCARD_GET_FUTURE \ - _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future are errors that cause " \ - "exception to be thrown, so it is an error to get the future and discard it") +#define _NODISCARD_GET_FUTURE \ + _NODISCARD_MSG("Getting the future more than once or not satisfying the obtained future will throw a " \ + "future_error exception, so it is incorrect to call 'get_future' and discard the return value.") #pragma push_macro("msvc") #pragma push_macro("known_semantics") From 09c0c52ded0a5907addc74427ec939ee5dc3ad02 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 28 Aug 2022 01:17:22 -0700 Subject: [PATCH 71/73] Rename ADAPTER to ADAPTOR. --- stl/inc/queue | 4 ++-- stl/inc/stack | 2 +- stl/inc/yvals_core.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/queue b/stl/inc/queue index b38c28c6a8d..ffa2955de20 100644 --- a/stl/inc/queue +++ b/stl/inc/queue @@ -87,7 +87,7 @@ public: #endif // __cpp_lib_concepts #endif // _HAS_CXX23 - _NODISCARD_EMPTY_ADAPTER_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_ADAPTOR_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } @@ -353,7 +353,7 @@ public: } #endif // _HAS_CXX23 && defined(__cpp_lib_concepts) - _NODISCARD_EMPTY_ADAPTER_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_ADAPTOR_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/stack b/stl/inc/stack index aec28fddf2e..24d6afe6d9c 100644 --- a/stl/inc/stack +++ b/stl/inc/stack @@ -85,7 +85,7 @@ public: #endif // __cpp_lib_concepts #endif // _HAS_CXX23 - _NODISCARD_EMPTY_ADAPTER_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { + _NODISCARD_EMPTY_ADAPTOR_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ { return c.empty(); } diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 62cc71dd1eb..558eae072ff 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -534,7 +534,7 @@ "This function returns a bool indicating whether the container or container-like object is empty and " \ "has no other effects. It is not useful to call this function and discard the return value.") -#define _NODISCARD_EMPTY_ADAPTER_MEMBER \ +#define _NODISCARD_EMPTY_ADAPTOR_MEMBER \ _NODISCARD_MSG( \ "This member function returns a bool indicating whether the container is empty and has no other effects. " \ "It is not useful to call this member function and discard the return value. " \ From a20692615ddb85bccf25184e8919aac561871920 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 28 Aug 2022 23:25:39 +0300 Subject: [PATCH 72/73] a potential effect --- stl/inc/yvals_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 558eae072ff..4a427cd4086 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -564,8 +564,8 @@ _NODISCARD_MSG("'std::assume_aligned' has a potential effect on the return value (not on the passed argument). " \ "It is not useful to call 'std::assume_aligned' and discard the return value.") -#define _NODISCARD_LAUNDER \ - _NODISCARD_MSG("'std::launder' has an effect on the return value (not on the passed argument). " \ +#define _NODISCARD_LAUNDER \ + _NODISCARD_MSG("'std::launder' has a potential on the return value (not on the passed argument). " \ "It is not useful to call 'std::launder' and discard the return value.") #ifdef _SILENCE_NODISCARD_LOCK_WARNINGS From a09302e1226e91bc3b5e404c23e626bc299e1acd Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 28 Aug 2022 13:30:37 -0700 Subject: [PATCH 73/73] +effect --- stl/inc/yvals_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 4a427cd4086..313a9d0a791 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -564,8 +564,8 @@ _NODISCARD_MSG("'std::assume_aligned' has a potential effect on the return value (not on the passed argument). " \ "It is not useful to call 'std::assume_aligned' and discard the return value.") -#define _NODISCARD_LAUNDER \ - _NODISCARD_MSG("'std::launder' has a potential on the return value (not on the passed argument). " \ +#define _NODISCARD_LAUNDER \ + _NODISCARD_MSG("'std::launder' has a potential effect on the return value (not on the passed argument). " \ "It is not useful to call 'std::launder' and discard the return value.") #ifdef _SILENCE_NODISCARD_LOCK_WARNINGS