I'm writing a simple parser in c++.
I would like to remove leading whitespaces with std::ws
.
bool Parser::readWhiteSpace()
{
std::cout << "Before : str=[" << this->_ss.str() << "], peek=[" << (char)this->_ss.peek() << ']'<< std::endl;
this->_ss >> std::ws;
std::cout << "After : str=[" << this->_ss.str() << "], peek=[" << (char)this->_ss.peek() << ']'<< std::endl;
return (true);
}
The output is :
Before : str=[ something], peek=[ ]
After : str=[ something], peek=[s]
I don't understand why the stream and the str from the stream are not synchronized. Is it not supposed to affect the str ?