Open liigo opened 1 month ago
I will consider changing to -1 because of some other reason, but it is more complicated: In c++, npos is of type size_t which is unsigned the largest number possible, but switching type or relying on the value of npos is not good. There are some functions, e.g. cstr_subview(s, pos, len), where you can pass in c_POS for len, and it will return to the end of the view (it stops at which comes first). I think this is also how it is working for some functions in c++.
in C++, the
std::string::npos
is -1, so someone may write:but STC's
c_NPOS
is defined asINTPTR_MAX
which is not -1. if you checki >= 0
, then the code is error-prone.