Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
954f424
[[nodiscard]] messages
AlexGuteniev Sep 18, 2021
de17454
[[nodiscard]] messages
AlexGuteniev Sep 18, 2021
143ba6b
Merge branch 'nodiscard' of https://github.com/AlexGuteniev/STL into …
AlexGuteniev Sep 18, 2021
e36a545
clang format
AlexGuteniev Sep 18, 2021
0fbb82d
clang format
AlexGuteniev Sep 18, 2021
2c6d357
line len
AlexGuteniev Sep 18, 2021
06f082e
non-ctor lock
AlexGuteniev Sep 18, 2021
bcd7b1e
clang format
AlexGuteniev Sep 18, 2021
b7a1e0f
more formatting
AlexGuteniev Sep 18, 2021
baf36de
variable
AlexGuteniev Sep 18, 2021
49d8259
better spelling
AlexGuteniev Sep 18, 2021
feec5c9
Skip for CUDA
AlexGuteniev Sep 18, 2021
50d5404
Improve detection
AlexGuteniev Sep 18, 2021
70469ec
-misleading comment
AlexGuteniev Sep 18, 2021
8471d48
more formatting
AlexGuteniev Sep 18, 2021
b313c67
non
AlexGuteniev Sep 18, 2021
d72d9b2
Abbreviated
AlexGuteniev Sep 19, 2021
8005b8f
clang-format
AlexGuteniev Sep 19, 2021
6b81546
any accessor
AlexGuteniev Sep 19, 2021
8469c10
spelling
AlexGuteniev Sep 19, 2021
7f41c9a
typo
AlexGuteniev Sep 19, 2021
31f506c
unique
AlexGuteniev Sep 19, 2021
9c1db4a
)
AlexGuteniev Sep 19, 2021
2fdb8ab
fix build
AlexGuteniev Sep 19, 2021
26cb8f7
memory
AlexGuteniev Sep 19, 2021
317df86
cstddef
AlexGuteniev Sep 19, 2021
78038a3
cmath
AlexGuteniev Sep 19, 2021
1e258f5
exception
AlexGuteniev Sep 19, 2021
350c137
clang-format
AlexGuteniev Sep 19, 2021
147efb3
typo
AlexGuteniev Sep 19, 2021
1bcaa04
Tell to .join() explicitly to skip warning
AlexGuteniev Sep 20, 2021
7c535cc
clang-format
AlexGuteniev Sep 20, 2021
b5a2d0b
unique is unique
AlexGuteniev Sep 23, 2021
1dbeaa5
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Oct 23, 2021
5a893e1
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Nov 21, 2021
b4d3391
C++23
AlexGuteniev Nov 21, 2021
1662ade
overlong line
AlexGuteniev Nov 21, 2021
a299ec2
overlong line
AlexGuteniev Nov 21, 2021
4c341de
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Dec 18, 2021
6c41f25
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Jan 14, 2022
9e07a2a
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Jan 20, 2022
a719a9d
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Apr 9, 2022
a4512c8
clang format
AlexGuteniev Apr 9, 2022
f38a65a
clang format
AlexGuteniev Apr 9, 2022
27c9c93
- pure / accessor
AlexGuteniev Jun 12, 2022
ca9cf8f
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Jun 12, 2022
7223265
+format
AlexGuteniev Jun 12, 2022
905922a
undo more <algorithm> changes
AlexGuteniev Jun 12, 2022
9942a04
undo more <algorithm> changes
AlexGuteniev Jun 12, 2022
0d5f2ca
/* strengthened */
AlexGuteniev Jun 12, 2022
919342d
/* terminates */
AlexGuteniev Jun 12, 2022
35e5131
/* terminates */
AlexGuteniev Jun 12, 2022
ec0020c
/* strengthened */
AlexGuteniev Jun 12, 2022
e1e3753
/* strengthened */
AlexGuteniev Jun 12, 2022
2a8c01c
-space
AlexGuteniev Jun 12, 2022
ea9f209
more informative emptiness
AlexGuteniev Jun 22, 2022
00dcaf0
clang-format
AlexGuteniev Jun 23, 2022
4503a93
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Jul 1, 2022
c6a0644
typo
AlexGuteniev Jul 1, 2022
ff38a01
More [[nodiscard]]
AlexGuteniev Jul 1, 2022
d545220
more remove
AlexGuteniev Jul 1, 2022
d3bd582
typos
AlexGuteniev Jul 1, 2022
a3685ba
format
AlexGuteniev Jul 1, 2022
8a26528
member function
AlexGuteniev Jul 1, 2022
f50cde5
punctuation
AlexGuteniev Jul 1, 2022
3a9be2e
missed stack
AlexGuteniev Jul 1, 2022
61d88f9
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Aug 13, 2022
eb74992
Merge remote-tracking branch 'upstream/main' into nodiscard
AlexGuteniev Aug 20, 2022
19383b1
formatting
AlexGuteniev Aug 20, 2022
c3d5a9d
undo trivial nodiscard message
AlexGuteniev Aug 25, 2022
139b2c6
Merge branch 'main' into nodiscard
StephanTLavavej Aug 27, 2022
77d815f
Attempt to enable `_NODISCARD_MSG` for CUDA 11.6.
StephanTLavavej Aug 26, 2022
75537b0
Rename to EMPTY_MEOW_MEMBER for clarity and consistency.
StephanTLavavej Aug 26, 2022
65976e3
Unify `_NODISCARD_TRY_CHANGE_STATE`.
StephanTLavavej Aug 26, 2022
a34658c
Rename `_NODISCARD_PTR_ALLOC_FN` to `_NODISCARD_SMART_PTR_ALLOC`.
StephanTLavavej Aug 26, 2022
96d7184
Rename `_NODISCARD_PTR_RAW_ALLOC_FN` to `_NODISCARD_RAW_PTR_ALLOC`.
StephanTLavavej Aug 26, 2022
b2c39e7
Add more `_NODISCARD_RAW_PTR_ALLOC`.
StephanTLavavej Aug 26, 2022
317ccf8
Use `_NODISCARD_GET_FUTURE` for `promise<R&>`, `promise<void>`, and `…
StephanTLavavej Aug 28, 2022
02faf63
Mark `make_shared(_Types&&... _Args)` as `_NODISCARD_SMART_PTR_ALLOC`.
StephanTLavavej Aug 28, 2022
95729f6
Rename control macro to `_SILENCE_NODISCARD_LOCK_WARNINGS`.
StephanTLavavej Aug 28, 2022
f771600
Fix message typos.
StephanTLavavej Aug 28, 2022
8aa1c0b
Message phrasing overhaul.
StephanTLavavej Aug 28, 2022
09c0c52
Rename ADAPTER to ADAPTOR.
StephanTLavavej Aug 28, 2022
a206926
a potential effect
AlexGuteniev Aug 28, 2022
a09302e
+effect
StephanTLavavej Aug 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -3771,11 +3771,12 @@ _FwdIt2 remove_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _P

#if _HAS_CXX17
template <class _ExPo, class _FwdIt, class _Ty, _Enable_if_execution_policy_t<_ExPo> = 0>
_NODISCARD _FwdIt remove(
_NODISCARD_REMOVE_ALG _FwdIt remove(
_ExPo&& _Exec, const _FwdIt _First, const _FwdIt _Last, const _Ty& _Val) noexcept; // terminates

template <class _ExPo, class _FwdIt, class _Pr, _Enable_if_execution_policy_t<_ExPo> = 0>
_NODISCARD _FwdIt remove_if(_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates
_NODISCARD_REMOVE_ALG _FwdIt remove_if(
_ExPo&& _Exec, _FwdIt _First, const _FwdIt _Last, _Pr _Pred) noexcept; // terminates
#endif // _HAS_CXX17

#ifdef __cpp_lib_concepts
Expand All @@ -3787,7 +3788,8 @@ namespace ranges {
// clang-format off
template <permutable _It, sentinel_for<_It> _Se, class _Ty, class _Pj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<_It, _Pj>, const _Ty*>
_NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, const _Ty& _Val, _Pj _Proj = {}) const {
_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(
_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Val, _Pass_fn(_Proj));
Expand All @@ -3798,7 +3800,7 @@ namespace ranges {
template <forward_range _Rng, class _Ty, class _Pj = identity>
requires permutable<iterator_t<_Rng>>
&& indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rng>, _Pj>, const _Ty*>
_NODISCARD 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));

Expand Down Expand Up @@ -3839,7 +3841,8 @@ namespace ranges {

template <permutable _It, sentinel_for<_It> _Se, class _Pj = identity,
indirect_unary_predicate<projected<_It, _Pj>> _Pr>
_NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, _Pr _Pred, _Pj _Proj = {}) const {
_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(
_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj));
Expand All @@ -3851,7 +3854,8 @@ namespace ranges {
template <forward_range _Rng, class _Pj = identity,
indirect_unary_predicate<projected<iterator_t<_Rng>, _Pj>> _Pr>
requires permutable<iterator_t<_Rng>>
_NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred, _Pj _Proj = {}) const {
_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));

return _Rewrap_subrange<borrowed_subrange_t<_Rng>>(_Range, _STD move(_UResult));
Expand Down Expand Up @@ -4008,7 +4012,7 @@ namespace ranges {
#endif // __cpp_lib_concepts

template <class _FwdIt, class _Pr>
_NODISCARD _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);
Expand All @@ -4033,20 +4037,20 @@ _NODISCARD _CONSTEXPR20 _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) {
}

template <class _FwdIt>
_NODISCARD _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 <class _ExPo, class _FwdIt, class _Pr, _Enable_if_execution_policy_t<_ExPo> = 0>
_NODISCARD _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 <class _ExPo, class _FwdIt, _Enable_if_execution_policy_t<_ExPo> = 0>
_NODISCARD _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);
Expand All @@ -4061,7 +4065,8 @@ namespace ranges {

template <permutable _It, sentinel_for<_It> _Se, class _Pj = identity,
indirect_equivalence_relation<projected<_It, _Pj>> _Pr = ranges::equal_to>
_NODISCARD constexpr subrange<_It> operator()(_It _First, _Se _Last, _Pr _Pred = {}, _Pj _Proj = {}) const {
_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(
_Get_unwrapped(_STD move(_First)), _Get_unwrapped(_STD move(_Last)), _Pass_fn(_Pred), _Pass_fn(_Proj));
Expand All @@ -4073,7 +4078,8 @@ namespace ranges {
template <forward_range _Rng, class _Pj = identity,
indirect_equivalence_relation<projected<iterator_t<_Rng>, _Pj>> _Pr = ranges::equal_to>
requires permutable<iterator_t<_Rng>>
_NODISCARD constexpr borrowed_subrange_t<_Rng> operator()(_Rng&& _Range, _Pr _Pred = {}, _Pj _Proj = {}) const {
_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));

return _Rewrap_subrange<borrowed_subrange_t<_Rng>>(_Range, _STD move(_UResult));
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/array
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public:
return _Size;
}

_NODISCARD constexpr bool empty() const noexcept {
_NODISCARD_EMPTY_ARRAY_MEMBER constexpr bool empty() const noexcept {
return false;
}

Expand Down Expand Up @@ -685,7 +685,7 @@ public:
return 0;
}

_NODISCARD constexpr bool empty() const noexcept {
_NODISCARD_EMPTY_ARRAY_MEMBER constexpr bool empty() const noexcept {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion stl/inc/barrier
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public:
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)");
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/deque
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ public:
static_cast<size_type>((numeric_limits<difference_type>::max)()), _Alty_traits::max_size(_Getal()));
}

_NODISCARD bool empty() const noexcept {
_NODISCARD_EMPTY_MEMBER bool empty() const noexcept {
return _Mysize() == 0;
}

Expand Down
2 changes: 1 addition & 1 deletion stl/inc/exception
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ template <class _Ex>
void* __GetExceptionInfo(_Ex);

template <class _Ex>
_NODISCARD 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));
}

Expand Down
5 changes: 3 additions & 2 deletions stl/inc/execution
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,8 @@ struct _Static_partitioned_remove_if2 {
};

template <class _ExPo, class _FwdIt, class _Pr, _Enable_if_execution_policy_t<_ExPo> /* = 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);
Expand All @@ -2592,7 +2593,7 @@ _NODISCARD _FwdIt remove_if(_ExPo&&, _FwdIt _First, const _FwdIt _Last, _Pr _Pre
}

template <class _ExPo, class _FwdIt, class _Ty, _Enable_if_execution_policy_t<_ExPo> /* = 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,
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public:
static_cast<size_type>((numeric_limits<difference_type>::max)()), _Alnode_traits::max_size(_Getal()));
}

_NODISCARD bool empty() const noexcept {
_NODISCARD_EMPTY_MEMBER bool empty() const noexcept {
return _Mypair._Myval2._Myhead == nullptr;
}

Expand Down
13 changes: 7 additions & 6 deletions stl/inc/future
Original file line number Diff line number Diff line change
Expand Up @@ -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{});
}

Expand Down Expand Up @@ -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{});
}

Expand Down Expand Up @@ -1305,7 +1305,7 @@ public:
_MyPromise._Swap(_Other._MyPromise);
}

_NODISCARD future<void> get_future() {
_NODISCARD_GET_FUTURE future<void> get_future() {
return future<void>(_MyPromise._Get_state_for_future(), _Nil{});
}

Expand Down Expand Up @@ -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{});
}

Expand Down Expand Up @@ -1519,7 +1519,7 @@ _Associated_state<typename _P_arg_type<_Ret>::type>* _Get_associated_state(launc
}

template <class _Fty, class... _ArgTypes>
_NODISCARD future<_Invoke_result_t<decay_t<_Fty>, decay_t<_ArgTypes>...>> async(
_NODISCARD_ASYNC future<_Invoke_result_t<decay_t<_Fty>, 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<_Fty>, decay_t<_ArgTypes>...>;
Expand All @@ -1532,7 +1532,8 @@ _NODISCARD future<_Invoke_result_t<decay_t<_Fty>, decay_t<_ArgTypes>...>> async(
}

template <class _Fty, class... _ArgTypes>
_NODISCARD future<_Invoke_result_t<decay_t<_Fty>, decay_t<_ArgTypes>...>> async(_Fty&& _Fnarg, _ArgTypes&&... _Args) {
_NODISCARD_ASYNC future<_Invoke_result_t<decay_t<_Fty>, 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)...);
}
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/latch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/list
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ public:
static_cast<size_type>((numeric_limits<difference_type>::max)()), _Alnode_traits::max_size(_Getal()));
}

_NODISCARD bool empty() const noexcept {
_NODISCARD_EMPTY_MEMBER bool empty() const noexcept {
return _Mypair._Myval2._Mysize == 0;
}

Expand Down
Loading