std::find is not evaluating as I expected.
I have a vector lexeme_ defined as
static const std::string delimiters_[] = {" ", ",", "(", ")", ";", "=", ".", "*", "-"};
static std::vector<std::string> lexeme_(std::begin(delimiters_), std::end(delimiters_));
I have an evaluation using std::find
defined as
while ( std::find(lexeme_.begin(),lexeme_.end(),std::string(&commandLine_.at(position_))) == lexeme_.end())
{
// Concat each successive alphanumeric character to 'token'
token += commandLine_.at(position_);
// Update the index into 'commandLine'
position_ += 1;
}
The evaluation is supposed to compare a char
in lexeme_ to a char
in commandLine similar to this Java expression
!lexeme.contains(Character.toString(commandLine.charAt(position)))
The evaluation is supposed to compare char
s and if it determines a char
in delimiters
is satisfied in the comparison, then the while loop will exit.
Testcase
#include<algorithm>
#include<iostream>
static const std::string delimiters_[] = {" ", ",", "(", ")", ";", "=", ".", "*", "-"};
static std::vector<std::string> lexeme_(std::begin(delimiters_), std::end(delimiters_));
std::string commandLine = "check me";
while (std::find(lexeme_.begin(),lexeme_.end(),std::string(&commandLine_.at(position_))) == lexeme_.end())
{
std::cout "I should stop printing when encountering a space ' ' << std::endl;
}