M
Mike Copeland
The C++ "find" functions seem more cumbersome than their C ancestors.
To me, string::find is more difficult to use than, say, strchr. For
example,
char *ptr = strchr("AEMT", 'A');
if(ptr != NULL) do_something_if_found;
else do_not_found;
Is there a simpler C++ way to code the following?
std::string valids = "AEMT";
size_t idx = valids.find('A');
if(idx != string::npos) do_something_if_found;
else do_not_found;
To me, string::find is more difficult to use than, say, strchr. For
example,
char *ptr = strchr("AEMT", 'A');
if(ptr != NULL) do_something_if_found;
else do_not_found;
Is there a simpler C++ way to code the following?
std::string valids = "AEMT";
size_t idx = valids.find('A');
if(idx != string::npos) do_something_if_found;
else do_not_found;