Boost C++ Libraries: Ticket #13536: boost::lexical_cast<int>(" 1 ") can no longer handle whitespace https://svn.boost.org/trac10/ticket/13536 <p> boost::lexical_cast can no longer handle whitespace when converting strings to integers: </p> <pre class="wiki"> #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;boost/lexical_cast.hpp&gt; int main() { auto i = boost::lexical_cast&lt;int&gt;(" 1 "); std::cout &lt;&lt; i &lt;&lt; '\n'; } </pre><p> The above incorrectly throws an exception. </p> <p> The correct result of boost::lexical_cast&lt;int&gt;(" 1 ") is <code>1</code> and no exception. </p> <p> At least boost version 1.54 did not have this problem. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13536 Trac 1.4.3 Antony Polukhin Fri, 27 Apr 2018 07:58:25 GMT <link>https://svn.boost.org/trac10/ticket/13536#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13536#comment:1</guid> <description> <p> <a class="missing wiki">LexicalCast</a> should not handle that inpit. There's even a test that is at least 13 years old to make sure that <a class="ext-link" href="https://github.com/boostorg/lexical_cast/blame/master/test/lexical_cast_test.cpp#L190"><span class="icon">​</span>lexical cast throws on whitespaces in input</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Fri, 27 Apr 2018 07:58:46 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/13536#comment:2 https://svn.boost.org/trac10/ticket/13536#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket