且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从一个std ::字符串转换为bool

更新时间:2023-02-03 08:28:55

这很可能会矫枉过正你,但我会使用boost::lexical_cast

It'll probably be overkill for you, but I'd use boost::lexical_cast

boost::lexical_cast<bool>("1") // returns true
boost::lexical_cast<bool>("0") // returns false