Boost C++ Libraries: Ticket #9483: Can't get (translate) literal values with suffixes out of ptree https://svn.boost.org/trac10/ticket/9483 <p> Hello, </p> <p> I just figured that the property_tree lib cannot translate some acceptable literals. Here is an example to show this: </p> <pre class="wiki">#include &lt;boost/property_tree/ptree.hpp&gt; #include &lt;boost/optional.hpp&gt; #include &lt;iostream&gt; using namespace boost::property_tree; using namespace std; void printo(boost::optional&lt;long long&gt; o, const std::string &amp; name) { if(o) cout &lt;&lt; name &lt;&lt; " is: " &lt;&lt; *o &lt;&lt; endl; else cerr &lt;&lt; "couldn't get " &lt;&lt; name &lt;&lt; endl; } int main() { ptree p; p.put("good_long_long", "0"); long long test1 = 0; // show that 0 is an acceptable long long literal p.put("bad_long_long", "0LL"); long long test2 = 0LL; // show that 0LL is an acceptable long long literal auto good = p.get_optional&lt;long long&gt;("good_long_long"); auto bad = p.get_optional&lt;long long&gt;("bad_long_long"); printo(good, "good"); printo(bad, "bad"); return 0; } </pre><p> Apparently the stream_translator doesn't consume the 'L's and then the test <code>iss.get() != Traits::eof()</code>, in stream_translator.hpp, is true, resulting in an empty optional. </p> <p> Please feel free to contact me. I hope not, but I'm sorry if there is something stupid I am missing. </p> <p> Cheers, Ricardo Abreu </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9483 Trac 1.4.3 Sebastian Redl Tue, 10 Dec 2013 15:06:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9483#comment:1 https://svn.boost.org/trac10/ticket/9483#comment:1 <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> <p> The stream_translator, as it name indicates, uses an iostream (specifically, a stringstream) to convert data. It is therefore compatible with the data formats supported by iostreams. C++ language integer literal syntax is not supported by streams, and thus isn't supported by the stream_translator. If you need compatibility with such formats, you need to write your own translator. </p> Ticket