c++ - Is wstring::npos equal to -1 in cpp definitions? -


int fdstring:: reversefind(const fdstring& searchstring, int rend) const  {  return static_cast(mstring.rfind(searchstring.mstring), rend == npos ? string::npos : rend);  } 

here have defined

ifdef unicode #define string std::wstring #else #define string std::string #endif 

i sure std::string::npos defined in cpp reference -1 in wstring not sure if explicitly defined -1? can assume std::wstring::npos -1?

yes, can.

wstring typedef basic_string

typedef basic_string<wchar_t> wstring; 

on other hand, string typedef basic_string

typedef basic_string<char> string; 

nops defined in basic_string, should same in both types.

and defined as,

static const size_type npos = -1; 

refer


Comments