I'm trying to compile the following source code
#include <boost/property_tree/ptree.hpp>
int main() {
boost::property_tree::ptree b;
b.push_back(std::make_pair("a", "b"));
return 9;
}
using the following compiler and instructions:
$ g++ ./source.cpp --std=c++11
$ g++ --version
g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ # boost version is 1.55
and I'm getting the following error
./source.cpp: In function ‘int main()’:
./source.cpp:5:41: error: no matching function for call to ‘boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::push_back(std::pair<const char*, const char*>)’
b.push_back(std::make_pair("a", "b"));
^
In file included from /opt/boost/boost_1_55_0/boost/property_tree/ptree.hpp:516:0,
from ./source.cpp:1:
/opt/boost/boost_1_55_0/boost/property_tree/detail/ptree_implementation.hpp:362:9: note: candidate: 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> > >]
basic_ptree<K, D, C>::push_back(const value_type &value)
^
/opt/boost/boost_1_55_0/boost/property_tree/detail/ptree_implementation.hpp:362:9: note: no known conversion for argument 1 from ‘std::pair<const char*, const 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> > >&}’
NOTE: if I'm compiling this without --std=c++11 the error disappears
QUESTION: how may I compile it using c++11 standard or higher? I've found https://svn.boost.org/trac10/ticket/6785 , but in boost-1.55 it has been already fixed. thank you in advance!
See Question&Answers more detail:os