Open
Description
Opening this issue for tracking.
For std::string
and std::string_view
, an element is (not) found when comparing find()
against std::string::npos
or std::string_view::npos
, not end()
. This is not causing false positives since comparing a find()
result to end()
doesn't make sense to begin with in those classes, so in fact the check would probably be fixing bugs. (Is there a bugprone-string-find-end
check?)
As of C++23 the following transformations and derivatives can be added to the check:
string.find(...) != std::string::npos; // -> string.contains(...)
string.find(...) != string.npos; // -> string.contains(...)
// Ideally, make this work for any npos, e.g. llvm::StringRef::npos.