[clang-tools-extra] [clang-tidy] Adjust size-empty doc because C++11 size() is constant-time (PR #117629)
Niels Dekker via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 25 14:04:28 PST 2024
N-Dekker wrote:
> You understand that this check does not apply only to std:: containers but also to boost and other custom one that have size and empty methods. In such case claim is still valid.
Thanks for your prompt reply, Piotr. I thought of custom containers too, but then again, I would rather not make any claim about the efficiency of `size()` and `empty()` methods of _arbitrary_ custom containers. I mean, they could do anything!
In order for the documentation to make claims about `size()` versus `empty()`, I think they should behave like those of std:: containers, including their time complexity. Otherwise it's hard to reason about them in a general way.
But then, do you happen to know whether there are indeed still Boost containers that have a `size()` method which has a greater-than-constant time complexity? If so, can you possibly name one?
> If you change check description, then check documentation also should be updated to be in sync.
Thanks! So this pull request should make some more adjustments before it can be merged (if it would be accepted at all)?
https://github.com/llvm/llvm-project/pull/117629
More information about the cfe-commits
mailing list