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
If you need "true" and "false" string support consider Boost...
BOOST_TEST(convert( "true", cnv(std::boolalpha)).value_or(false) == true);
BOOST_TEST(convert("false", cnv(std::boolalpha)).value_or( true) == false);
BOOST_TEST(convert("1", cnv(std::noboolalpha)).value_or(false) == true);
BOOST_TEST(convert("0", cnv(std::noboolalpha)).value_or( true) == false);
https://www.boost.org/doc/libs/1_71_0/libs/convert/doc/html/boost_convert/converters_detail/stream_converter.html