[boost/foreach] What is wrong with BOOST_FOREACH(const std::string &name, m_modules)?

I am trying to compile this example http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.ht... and I am getting the error "/usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’" in this line: BOOST_FOREACH(const std::string &name, m_modules){ pt.put("debug.modules.module", name, true); } My full error message is: make all Building file: ../src/Boost_property_tree.cpp Invoking: GCC C++ Compiler g++ -I/home/mori/Demetrio/WSs/Test/VanManagerParser/json_spirit -I/usr/local/boost_1_47_0/ -I/usr/local/boost_1_47_0/boost/spirit -I/usr/local/curl-7.21.7/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Boost_property_tree.d" -MT"src/Boost_property_tree.d" -o "src/Boost_property_tree.o" "../src/Boost_property_tree.cpp" ../src/Boost_property_tree.cpp: In member function ‘void debug_settings::save(const std::string&)’: ../src/Boost_property_tree.cpp:80:5: error: invalid initialization of reference of type ‘std::string&’ from expression of type ‘const std::basic_string<char>’ In file included from /usr/local/boost_1_47_0/boost/property_tree/ptree.hpp:516:0, from ../src/Boost_property_tree.cpp:4: /usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp: In member function ‘void boost::property_tree::basic_ptree<Key, Data, KeyCompare>::put_value(const Type&, Translator) [with Type = std::basic_string<char>, Translator = bool, Key = std::basic_string<char>, Data = std::basic_string<char>, KeyCompare = std::less<std::basic_string<char> >]’: /usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:817:13: instantiated from ‘boost::property_tree::basic_ptree<K, D, C>& boost::property_tree::basic_ptree<Key, Data, KeyCompare>::put(boost::property_tree::basic_ptree<Key, Data, KeyCompare>::path_type&, const Type&, Translator) [with Type = std::basic_string<char>, Translator = bool, 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>::path_type = boost::property_tree::string_path<std::basic_string<char>, boost::property_tree::id_translator<std::basic_string<char> > >]’ ../src/Boost_property_tree.cpp:81:50: instantiated from here /usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’ make: *** [src/Boost_property_tree.o] Error 1 **** Build Finished ****

On 9/9/2011 12:51 PM, Demetrio Car wrote:
../src/Boost_property_tree.cpp:80:5: error: invalid initialization of reference of type ‘std::string&’ from expression of type ‘const std::basic_string<char>’
What does line 80 of Boost_property_tree.cpp look like? -- Eric Niebler BoostPro Computing http://www.boostpro.com

AMDG On 09/09/2011 09:51 AM, Demetrio Car wrote:
I am trying to compile this example http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.ht... and I am getting the error "/usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’" in this line: BOOST_FOREACH(const std::string &name, m_modules){ pt.put("debug.modules.module", name, true); }
My full error message is:
<snip>
I'd guess that this is a breaking change between 1.42 and 1.47. I checked the documentation for 1.47 and the example has definitely changed. In Christ, Steven Watanabe

On 9/9/2011 1:31 PM, Steven Watanabe wrote:
AMDG
On 09/09/2011 09:51 AM, Demetrio Car wrote:
I am trying to compile this example http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.ht... and I am getting the error "/usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’" in this line: BOOST_FOREACH(const std::string &name, m_modules){ pt.put("debug.modules.module", name, true); }
My full error message is:
<snip>
I'd guess that this is a breaking change between 1.42 and 1.47. I checked the documentation for 1.47 and the example has definitely changed.
Steven, a breaking change in what? Which example has changed? Where? Is this a problem in BOOST_FOREACH or in property_tree? -- Eric Niebler BoostPro Computing http://www.boostpro.com

AMDG On 09/09/2011 10:40 AM, Eric Niebler wrote:
On 9/9/2011 1:31 PM, Steven Watanabe wrote:
On 09/09/2011 09:51 AM, Demetrio Car wrote:
I am trying to compile this example http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.ht... and I am getting the error "/usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’" in this line: BOOST_FOREACH(const std::string &name, m_modules){ pt.put("debug.modules.module", name, true); }
My full error message is:
<snip>
I'd guess that this is a breaking change between 1.42 and 1.47. I checked the documentation for 1.47 and the example has definitely changed.
Steven, a breaking change in what? Which example has changed? Where? Is this a problem in BOOST_FOREACH or in property_tree?
It has to be in property_tree. The error is inside property_tree, and m_modules is just a std::set<std::string>. In Christ, Steven Watanabe

On 09.09.2011, at 20:00, Steven Watanabe wrote:
AMDG
On 09/09/2011 10:40 AM, Eric Niebler wrote:
On 9/9/2011 1:31 PM, Steven Watanabe wrote:
On 09/09/2011 09:51 AM, Demetrio Car wrote:
I am trying to compile this example http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.ht... and I am getting the error "/usr/local/boost_1_47_0/boost/property_tree/detail/ptree_implementation.hpp:795:54: error: request for member ‘put_value’ in ‘tr’, which is of non-class type ‘bool’" in this line: BOOST_FOREACH(const std::string &name, m_modules){ pt.put("debug.modules.module", name, true); }
My full error message is:
<snip>
I'd guess that this is a breaking change between 1.42 and 1.47. I checked the documentation for 1.47 and the example has definitely changed.
Steven, a breaking change in what? Which example has changed? Where? Is this a problem in BOOST_FOREACH or in property_tree?
It has to be in property_tree. The error is inside property_tree, and m_modules is just a std::set<std::string>.
Basically, the bool-parameter version of put() no longer exists; there are now put() and add(). I can't remember what the boolean meant exactly, so I don't know which one is right for this situation. The error happens because the third parameter is unconditionally interpreted as a translator object, which is why the function attempts to call put_value() on it. Sebastian
participants (4)
-
Demetrio Car
-
Eric Niebler
-
Sebastian Redl
-
Steven Watanabe