boostorg / property_tree

Boost.org property_tree module
http://boost.org/libs/property_tree
55 stars 92 forks source link

simple example in documentation does not work regarding const_iterator #95

Closed TomFD closed 10 months ago

TomFD commented 2 years ago

Hi,

the simple example found here, https://www.boost.org/doc/libs/1_78_0/doc/html/property_tree/accessing.html gives the error below on the full code:

#include <boost/property_tree/xml_parser.hpp>
#include <iostream>

using boost::property_tree::ptree;

int main() {
    ptree pt;
    pt.push_back(ptree::value_type("pi", ptree("3.14159")));
    ptree::const_iterator it = pt.find("pi");
}

C:\Users\tsch\source\repos\ConsoleApplication2\ConsoleApplication2.cpp(10,45): error C2440: "Initialisierung": "boost::property_tree::basic_ptree<std::string,std::string,std::less>::assoc_iterator" kann nicht in "boost::property_tree::basic_ptree<std::string,std::string,std::less>::const_iterator" konvertiert werden 1> with 1> [ 1> Key=std::string 1> ]

of course, it works with 'assoc_iterator', but if this is intended, the documentation needs a change.

Thomas

madmongo1 commented 2 years ago

Thank you for highlighting.