Somewhat my code looks like below:
static int myfunc(const string& stringInput)
{
string word;
stringstream ss;
ss << stringInput;
while(ss >> word)
{
++counters[word];
}
...
}
The purpose here is to get an input string (separated by white space ' ') into the string variable word
, but the code here seems to have a lot of overhead -- convert the input string to a string stream and read from the string stream into the target string.
Is there a more elegant way to accomplish the same purpose?