Skip to content

Commit 30bb186

Browse files
authored
[clang-tidy] Mention std::forward_list in container-size-empty doc (#120701)
Mentioned `std::forward_list` as example of a container without `size()`.
1 parent f38c40b commit 30bb186

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace clang::tidy::readability {
1919
///
2020
/// The emptiness of a container should be checked using the `empty()` method
2121
/// instead of the `size()`/`length()` method. It shows clearer intent to use
22-
/// `empty()`. Furthermore some containers may implement the `empty()` method
23-
/// but not implement the `size()` or `length()` method. Using `empty()`
24-
/// whenever possible makes it easier to switch to another container in the
25-
/// future.
22+
/// `empty()`. Furthermore some containers (for example, a `std::forward_list`)
23+
/// may implement the `empty()` method but not implement the `size()` or
24+
/// `length()` method. Using `empty()` whenever possible makes it easier to
25+
/// switch to another container in the future.
2626
class ContainerSizeEmptyCheck : public ClangTidyCheck {
2727
public:
2828
ContainerSizeEmptyCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/docs/clang-tidy/checks/readability/container-size-empty.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ with a call to ``empty()``.
99

1010
The emptiness of a container should be checked using the ``empty()`` method
1111
instead of the ``size()``/``length()`` method. It shows clearer intent to use
12-
``empty()``. Furthermore some containers may implement the ``empty()`` method
13-
but not implement the ``size()`` or ``length()`` method. Using ``empty()``
14-
whenever possible makes it easier to switch to another container in the future.
12+
``empty()``. Furthermore some containers (for example, a ``std::forward_list``)
13+
may implement the ``empty()`` method but not implement the ``size()`` or
14+
``length()`` method. Using ``empty()`` whenever possible makes it easier to
15+
switch to another container in the future.
1516

1617
The check issues warning if a container has ``empty()`` and ``size()`` or
1718
``length()`` methods matching following signatures:

0 commit comments

Comments
 (0)