[Boost-bugs] [Boost C++ Libraries] #9483: Can't get (translate) literal values with suffixes out of ptree

Subject: [Boost-bugs] [Boost C++ Libraries] #9483: Can't get (translate) literal values with suffixes out of ptree
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-12-10 14:52:56


#9483: Can't get (translate) literal values with suffixes out of ptree
-----------------------------------------------+---------------------------
 Reporter: Ricardo Abreu <ricardolafabreu@…> | Owner: cornedbee
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_tree
  Version: Boost Development Trunk | Severity: Problem
 Keywords: ptree literal suffix |
-----------------------------------------------+---------------------------
 Hello,

 I just figured that the property_tree lib cannot translate some acceptable
 literals. Here is an example to show this:

 {{{
 #include <boost/property_tree/ptree.hpp>
 #include <boost/optional.hpp>
 #include <iostream>

 using namespace boost::property_tree;
 using namespace std;

 void printo(boost::optional<long long> o, const std::string & name)
 {
     if(o)
       cout << name << " is: " << *o << endl;
     else
       cerr << "couldn't get " << name << 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<long long>("good_long_long");
   auto bad = p.get_optional<long long>("bad_long_long");
   printo(good, "good");
   printo(bad, "bad");

   return 0;
 }
 }}}

 Apparently the stream_translator doesn't consume the 'L's and then the
 test {{{iss.get() != Traits::eof()}}}, in stream_translator.hpp, is true,
 resulting in an empty optional.

 Please feel free to contact me. I hope not, but I'm sorry if there is
 something stupid I am missing.

 Cheers,
 Ricardo Abreu

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9483>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC