47得票9回答
非常糟糕的boost::lexical_cast性能

Windows XP SP3. Core 2 Duo 2.0 GHz. 我发现boost::lexical_cast的性能非常慢。想找出加速代码的方法。 使用visual c++2008上的/O2优化,并与java 1.6和python 2.6.2进行比较,得到以下结果。 整数转换:c++: ...

26得票2回答
std::to_string、boost::to_string和boost::lexical_cast<std::string>之间有何区别?

boost::to_string(位于boost/exception/to_string.hpp中)的目的是什么?它与boost::lexical_cast&lt;std::string&gt;和std::to_string有何不同之处?

22得票2回答
如何扩展词法转换以支持枚举类型?

我有一个将字符串转换为数字类型的函数:template &lt;typename T&gt; bool ConvertString(const std::string&amp; theString, T&amp; theResult) { std::istringstream iss(...

22得票3回答
如何使用boost::lexical_cast和std::boolalpha?即boost::lexical_cast< bool >("true")。

我看到一些回答其他boost::lexical_cast问题的答案声称可能会出现以下情况:bool b = boost::lexical_cast&lt; bool &gt;("true"); 对我来说,使用g++ 4.4.3 boost 1.43并不起作用。(也许在默认情况下设置了std::...

13得票3回答
lexical_cast将整数转换为字符串。

当将int转换为std::string时,忽略boost::lexical_cast的异常是否安全?

12得票3回答
为什么 lexical_cast 要求 operator>> 在匹配的命名空间中?

以下是一个测试用例: #include &lt;istream&gt; #include &lt;boost/lexical_cast.hpp&gt; namespace N { enum class alarm_code_t { BLAH }; } st...

9得票1回答
C++使用boost::lexical_cast类的方法

我想使用Test类配合boost::lexical_cast使用。我已经重载了operator&lt;&lt;和operator&gt;&gt;,但是这给了我运行时错误。 以下是我的代码: #include &lt;iostream&gt; #include &lt;boost/lexica...

9得票3回答
boost::lexical_cast何时无法将其转换为std::string?

我正在编写单元测试,并尝试覆盖我的所有代码。 在我的代码中,我有像这样的一些内容: template&lt;typename ValueType&gt; std::string ConvertToStringUsingBoost(ValueType const&amp; v) { ...

9得票1回答
boost::lexical_cast无法识别重载的istream运算符

I have the following code: #include &lt;iostream&gt; #include &lt;boost\lexical_cast.hpp&gt; struct vec2_t { float x; float y; }; std::i...

8得票1回答
启用与boost::lexical_cast一起使用的类

这是从lexical_cast中的代码片段: class lexical_castable { public: lexical_castable() {}; lexical_castable(const std::string s) : s_(s) {}; friend std...