You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::regex_result type has two methods: difference_type length(size_type n = 0) const and bool empty() const
However, they are not an exact match for each other with respect to the readability-container-size-empty check, in particular, when the index n is supplied, since there is no corresponding empty(size_type n) overload.
Yet, this (trimmed) code is claimed to violate the readability-container-size-empty check:
#include<regex>
#include<string>booltest(const std::string& val) {
staticconst std::regex re("([0-9]+)/([A-B]+)");
if (std::smatch m; std::regex_match(val, m, re)) {
return m.length(2) > 0;
}
returnfalse;
}
Here is how it was originally reported against a similar fragment in our code base:
/home/ilyak/veo/crux/app/bbr/key.cpp:37:9: error: the 'empty' method should be used to check for emptiness instead of 'length' [readability-container-size-empty,-warnings-as-errors]
37 | if (m.length(4) > 0) {
| ^~~~~~~~~~~~~~~
| !m.empty()
/home/ilyak/veo/oe-scarthgap/tmp/build-glibc/sysroots/intel-skylake-64/usr/lib/x86_64-oe-linux/13.2.0/../../../include/c++/13.2.0/bits/regex.h:1887:7: note: method 'match_results'::empty() defined here
1887 | empty() const noexcept
| ^
std::regex_result
type has two methods:difference_type length(size_type n = 0) const
andbool empty() const
However, they are not an exact match for each other with respect to the readability-container-size-empty check, in particular, when the index
n
is supplied, since there is no correspondingempty(size_type n)
overload.Yet, this (trimmed) code is claimed to violate the readability-container-size-empty check:
Here is how it was originally reported against a similar fragment in our code base:
Reproducible in clang-tidy (master) via: https://godbolt.org/z/eocdWo7j4
The text was updated successfully, but these errors were encountered: