What is the best way to convert a std::string to bool? I am calling a function that returns either \"0\" or \"1\", and I need a clean solution for turning this into a boole
Write a free function:
bool ToBool( const std::string & s ) {
return s.at(0) == '1';
}
This is about the simplest thing that might work, but you need to ask yourself:
I'm sure there are others - this is the joy of API design!