Hello,
Is the function below the simplest way to produce an iterator to the next
non-space in a string? (Or the upper-bound iterator if none is found).
Searching for a sequence is overkill and inefficient IMO.
#include <string>
#include <algorithm>
#include <functional>
std::string::it erator find_not_space( std::string &s)
{
char chSpace = ' ';
return std::search(s.b egin(), s.end(), &chSpace , &chSpace+1,
std::not_equal_ to<char>());
}
Is the function below the simplest way to produce an iterator to the next
non-space in a string? (Or the upper-bound iterator if none is found).
Searching for a sequence is overkill and inefficient IMO.
#include <string>
#include <algorithm>
#include <functional>
std::string::it erator find_not_space( std::string &s)
{
char chSpace = ' ';
return std::search(s.b egin(), s.end(), &chSpace , &chSpace+1,
std::not_equal_ to<char>());
}
Comment