P
Phil Endecott
Dear C++ Experts,
What type should I use for an index into a std::string? In the past I
have used an unsigned int, e.g.
unsigned int p = s.find("foo");
string t = s.substr(p,10);
etc. etc.
but I now find that this doesn't work on 64-bit machines; I get warnings
when I compare with npos saying that the comparison will always be false
due to the different ranges of the types.
My guess is that I should be using std::string::size_type. Is this right?
--Phil.
What type should I use for an index into a std::string? In the past I
have used an unsigned int, e.g.
unsigned int p = s.find("foo");
string t = s.substr(p,10);
etc. etc.
but I now find that this doesn't work on 64-bit machines; I get warnings
when I compare with npos saying that the comparison will always be false
due to the different ranges of the types.
My guess is that I should be using std::string::size_type. Is this right?
--Phil.