Opened 11 years ago

Closed 10 years ago

Last modified 9 years ago

#6785 closed Bugs (fixed)

read_json does not compile on GCC 4.7.0 with std=c++11

Reported by: Wojciech Cierpucha <cierpuchaw@…> Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost 1.49.0 Severity: Problem
Keywords: ptree read_json Cc:

Description

Just as the summary says it is impossible to use read_json(...) from Boost.PropertyTree with GCC 4.7.0 with std=c++11.

The error is in json_parser_read.hpp:105 - context<PTree>::a_literal_val::operator():

c.stack.back()->push_back(std::make_pair(c.name, Str(b, e)));

Error message:

/usr/include/boost/property_tree/detail/json_parser_read.hpp:105:17: error: no matching function for call to ‘boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::push_back(std::pair<std::basic_string<char>, std::basic_string<char> >)’
/usr/include/boost/property_tree/detail/json_parser_read.hpp:105:17: note: candidate is:
In file included from /usr/include/boost/property_tree/ptree.hpp:516:0,
                 from main.cpp:4:
/usr/include/boost/property_tree/detail/ptree_implementation.hpp:362:9: note: boost::property_tree::basic_ptree<Key, Data, KeyCompare>::iterator boost::property_tree::basic_ptree<Key, Data, KeyCompare>::push_back(const value_type&) [with Key = std::basic_string<char>; Data = std::basic_string<char>; KeyCompare = std::less<std::basic_string<char> >; boost::property_tree::basic_ptree<Key, Data, KeyCompare>::value_type = std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >]
/usr/include/boost/property_tree/detail/ptree_implementation.hpp:362:9: note:   no known conversion for argument 1 from ‘std::pair<std::basic_string<char>, std::basic_string<char> >’ to ‘const value_type& {aka const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >&}’

It compiles successfully on 4.7.0 with -std=c++98 and on both 4.6.3 and 4.5.3 in both c++98 and c++0x modes.

It seems strange to me that it compiles at all in c++98 mode and with an older gcc version, since (according to docs) ptree::push_back wants a pair<string, ptree>. In quoted line of code it gets a pair<string, string> and ptree(string) constructor is declared explicit. I have no idea why it was permitted without an explicit conversion before.

Attachments (1)

read_json_gcc47_cpp11.cpp (284 bytes ) - added by Wojciech Cierpucha <cierpuchaw@…> 11 years ago.
Simple test case that does not compile.

Download all attachments as: .zip

Change History (5)

by Wojciech Cierpucha <cierpuchaw@…>, 11 years ago

Attachment: read_json_gcc47_cpp11.cpp added

Simple test case that does not compile.

comment:1 by pierre.imai@…, 10 years ago

I noticed the same problem, but managed to fix it by simply replacing

c.stack.back()->push_back(std::make_pair(c.name, Str(b, e)));

with

c.stack.back()->push_back(std::make_pair(c.name, Ptree(Str(b, e))));

comment:2 by Sebastian Redl, 10 years ago

Fixed on trunk as Pierre suggested.

comment:3 by Sebastian Redl, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r78679.

comment:4 by cbvora, 9 years ago

where is d sol of Nox openflow controller

installation $cd /etc/apt/sources.list.d $sudo wget

openflowswitch.org/downloads/debian/nox.list

(falllllll) so …at here i got fall it said “N: Ignoring file ‘nox.list.1′ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?”

Note: See TracTickets for help on using tickets.