c++ - boost string_algo return value on find failure -


i want find first space on line using boost::string_algo's find first:

const boost::iterator_range<std::string::iterator> token_range = boost::find_first(line, " "); 

i can't seem find in docs says returns if doesn't find space, though. need test token_range.end() against line.end() or something?

thanks!

i think should test token_range.empty(), this:

const boost::iterator_range<std::string::iterator> token_range = boost::find_first(line, " "); if (!token_range.empty()) {     // found a match } 

boost::iterator_range has bool conversion operator, can drop empty() function call, , write:

const boost::iterator_range<std::string::iterator> token_range = boost::find_first(line, " "); if (token_range) {     // found a match } 

Comments