【发布时间】:2012-09-28 03:54:29
【问题描述】:
是否有标准库函数来检查字符串 S 是否属于 T 类型,因此可以转换为 T 类型的变量?
我知道有一个 istringstream STL 类,它可以使用 operator>> 用从字符串转换的值填充 T 类型的变量。但是,如果字符串内容不是T类型的格式,则会被无意义填充。
【问题讨论】:
-
it will be filled with nonesense if the string content did not have the format of type T.那是因为它没有初始化。 -
字符串没有类型。你能做的最好的就是猜测,使用类似
boost::lexical_cast