How do I use boost::lexical_cast and std::boolalpha? i.e. boost::lexical_cast< bool >(“true”)
问题 I've seen some answers to other boost::lexical_cast questions that assert the following is possible: bool b = boost::lexical_cast< bool >("true"); This doesn't work for me with g++ 4.4.3 boost 1.43. (Maybe it's true that it works on a platform where std::boolalpha is set by default) This is a nice solution to the string to bool problem but it lacks input validation that boost::lexical_cast provides. 回答1: I'm posting the answer to my own question here for others who may be looking for