Reputation: 61
int FDString::
ReverseFind(const FDString& searchString, int rend) const
{
return static_cast(mString.rfind(searchString.mString), rend == nPos ? String::npos : rend);
}
Here i have defined
ifdef UNICODE
#define String std::wstring
#else
#define String std::string
#endif
I am sure std::string::npos is defined in cpp reference as -1 but in wstring i am not sure if its explicitly defined as -1? so can i assume std::wstring::npos is also -1?
Upvotes: 2
Views: 2050
Reputation: 2953
npos is defined in std::basic_string
which is the base class of std::string
and std::wstring
.
So it is the same in both classes.
Upvotes: 1
Reputation: 1426
Yes, you can.
wstring
is a typedef
to basic_string
typedef basic_string<wchar_t> wstring;
On the other hand, string
is also typedef
to basic_string
typedef basic_string<char> string;
nops
is defined in basic_string
, so is should be same in both types.
and it is defined as,
static const size_type npos = -1;
refer
Upvotes: 3