Search code examples
c++boostboost-propertytree

boost::property_tree::ordered_end() missing


I am trying to iterate over a boost property tree. The docs state that

You can get an ordered view of all children by using ordered_begin() and ordered_end().

However, when I write

for ( boost::property_tree::ptree::const_assoc_iterator it =
            myPropTree.ordered_begin();
    it != myPropTree.ordered_end();
    it++ )

The compiler complains

error: 'boost::property_tree::ptree' has no member named 'ordered_end'
boost v1.55
mingw
code::blocks

Solution

  • The ptree documentation says:

    assoc_iterator ordered_begin();

    Returns an iterator to the first child, in key order.

    const_assoc_iterator ordered_begin() const;

    Returns an iterator to the first child, in key order.

    assoc_iterator not_found();

    Returns the not-found iterator. Equivalent to end() in a real associative container.

    const_assoc_iterator not_found() const;

    Returns the not-found iterator. Equivalent to end() in a real associative container.

    So basically theordered_end function is called not_found