Skip to content

Commit 3697ebb

Browse files
authored
<yvals_core.h>: avoid using the 'container' word for something that has empty() member in [[nodiscard]] messages (#4572)
1 parent 886ef10 commit 3697ebb

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

stl/inc/queue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public:
8484
: c(_RANGES to<_Container>(_STD forward<_Rng>(_Range), _Al)) {}
8585
#endif // _HAS_CXX23
8686

87-
_NODISCARD_EMPTY_ADAPTOR_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
87+
_NODISCARD_EMPTY_MEMBER_NO_CLEAR bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
8888
return c.empty();
8989
}
9090

@@ -354,7 +354,7 @@ public:
354354
}
355355
#endif // _HAS_CXX23
356356

357-
_NODISCARD_EMPTY_ADAPTOR_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
357+
_NODISCARD_EMPTY_MEMBER_NO_CLEAR bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
358358
return c.empty();
359359
}
360360

stl/inc/stack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public:
8282
: c(_RANGES to<_Container>(_STD forward<_Rng>(_Range), _Al)) {}
8383
#endif // _HAS_CXX23
8484

85-
_NODISCARD_EMPTY_ADAPTOR_MEMBER bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
85+
_NODISCARD_EMPTY_MEMBER_NO_CLEAR bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
8686
return c.empty();
8787
}
8888

stl/inc/stacktrace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public:
232232
return _Frames.crend();
233233
}
234234

235-
_NODISCARD_EMPTY_STACKTRACE_MEMBER bool empty() const noexcept {
235+
_NODISCARD_EMPTY_MEMBER_NO_CLEAR bool empty() const noexcept {
236236
return _Frames.empty();
237237
}
238238

stl/inc/yvals_core.h

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -597,34 +597,27 @@
597597
_NODISCARD_MSG("The 'unique' algorithm returns the iterator past the last element that should be kept. " \
598598
"You need to call container.erase(result, container.end()) afterwards.")
599599

600-
#define _NODISCARD_EMPTY_MEMBER \
601-
_NODISCARD_MSG( \
602-
"This member function returns a bool indicating whether the container is empty and has no other effects. " \
603-
"It is not useful to call this member function and discard the return value. " \
600+
#define _NODISCARD_EMPTY_MEMBER \
601+
_NODISCARD_MSG( \
602+
"This member function returns a bool indicating whether the collection is empty and has no other effects. " \
603+
"It is not useful to call this member function and discard the return value. " \
604604
"Use the 'clear()' member function if you want to erase all elements.")
605605

606-
#define _NODISCARD_EMPTY_ARRAY_MEMBER \
607-
_NODISCARD_MSG( \
608-
"This member function returns a bool indicating whether the container is empty and has no other effects. " \
609-
"It is not useful to call this member function and discard the return value. " \
606+
#define _NODISCARD_EMPTY_ARRAY_MEMBER \
607+
_NODISCARD_MSG( \
608+
"This member function returns a bool indicating whether the array is empty and has no other effects. " \
609+
"It is not useful to call this member function and discard the return value. " \
610610
"There's no way to clear an array as its size is fixed.")
611611

612-
#define _NODISCARD_EMPTY_STACKTRACE_MEMBER \
613-
_NODISCARD_MSG( \
614-
"This member function returns a bool indicating whether the container is empty and has no other effects. " \
615-
"It is not useful to call this member function and discard the return value. " \
616-
"'std::stacktrace' can be cleared by assigning an empty value to it.")
612+
#define _NODISCARD_EMPTY_MEMBER_NO_CLEAR \
613+
_NODISCARD_MSG( \
614+
"This member function returns a bool indicating whether the collection is empty and has no other effects. " \
615+
"It is not useful to call this member function and discard the return value. " \
616+
"This collection can be cleared by assigning an empty value to it.")
617617

618-
#define _NODISCARD_EMPTY_NON_MEMBER \
619-
_NODISCARD_MSG( \
620-
"This function returns a bool indicating whether the container or container-like object is empty and " \
621-
"has no other effects. It is not useful to call this function and discard the return value.")
622-
623-
#define _NODISCARD_EMPTY_ADAPTOR_MEMBER \
624-
_NODISCARD_MSG( \
625-
"This member function returns a bool indicating whether the container is empty and has no other effects. " \
626-
"It is not useful to call this member function and discard the return value. " \
627-
"Container adaptors don't provide 'clear()' member functions, but you can assign an empty object to them.")
618+
#define _NODISCARD_EMPTY_NON_MEMBER \
619+
_NODISCARD_MSG("This function returns a bool indicating whether the collection is empty and " \
620+
"has no other effects. It is not useful to call this function and discard the return value.")
628621

629622
#define _NODISCARD_BARRIER_TOKEN \
630623
_NODISCARD_MSG("The token from 'arrive()' should not be discarded; it should be passed to 'wait()'.")

0 commit comments

Comments
 (0)