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
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 check
i >= 0
, then the code is error-prone.The text was updated successfully, but these errors were encountered: