[clang-tools-extra] [clang-tidy] Sync ContainerSizeEmptyCheck with container-size-empty doc (PR #118459)

Niels Dekker via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 4 02:38:44 PST 2024


================
@@ -18,10 +18,11 @@ namespace clang::tidy::readability {
 /// a call to `empty()`.
 ///
 /// The emptiness of a container should be checked using the `empty()` method
-/// instead of the `size()` method. It shows clearer intent to use `empty()`.
-/// Furthermore some containers may implement the `empty()` method but not
-/// implement the `size()` method. Using `empty()` whenever possible makes it
-/// easier to switch to another container in the future.
+/// instead of the `size()`/`length()` method. It shows clearer intent to use
+/// `empty()`. Furthermore some containers may implement the `empty()` method
+/// but not implement the `size()` or `length()` method. Using `empty()`
+/// whenever possible makes it easier to switch to another container in the
+/// future.
----------------
N-Dekker wrote:

Thank you both for your approval, @HerrCai0907 and @carlosgalvezp. I'm considering to propose mentioning `std::forward_list` here, as it is _the_ one STL container that does not implement `size()`. But maybe first wait for this one (#118459) to get merged... 

https://github.com/llvm/llvm-project/pull/118459


More information about the cfe-commits mailing list