Opened 4 years ago

Last modified 4 years ago

#13565 new Bugs

Compilation issue with property_tree on VS2017 15.7

Reported by: Pavel Pokutnev <pavel.pokutnev@…> Owned by: Sebastian Redl
Milestone: Boost 1.68.0 Component: property_tree
Version: Boost 1.67.0 Severity: Showstopper
Keywords: Cc:

Description

The new Visual Studio 2017 15.7 with following compiler settings:

Conformance mode: Yes(/permissive-) C++ Language Standard: ISO C++17 Standard (/std:c++17)

generates following error:

Error C3203 'iterator': unspecialized class template can't be used as a template argument for template parameter 'Iterator', expected a real type

: public boost::reverse_iterator<iterator>

during the compilation of the following code:

std::string value = { "[GENERAL]\n"

"MyValue=42" };

namespace bpt = boost::property_tree; bpt::ptree tree; try {

std::istringstream input(value); bpt::read_ini(input, tree); Parse the INI-File into the property tree.

} catch (...) { }

int const v = tree.get<int>("GENERAL.MyValue", 0);

It looks like it has something todo with the deprecation of std::iterator in C++17. In case the Conformance mode is switched to "No", the code compiles without any errors. It is also dependent on project configuration and include order, since my first try to create an isolated project for demonstration didn't resulted in the same error. But I didn't invest much time for it.

Here is my proposal for the solution of the issue: Prefix the template parameter to make them fully qualified.

Change lines 112 and 122:

class basic_ptree<K, D, C>::reverse_iterator

: public boost::reverse_iterator<iterator>

and

class basic_ptree<K, D, C>::const_reverse_iterator

: public boost::reverse_iterator<const_iterator>

to:

class basic_ptree<K, D, C>::reverse_iterator

: public boost::reverse_iterator<basic_ptree<K, D, C>::iterator>

and

class basic_ptree<K, D, C>::const_reverse_iterator

: public boost::reverse_iterator<basic_ptree<K, D, C>::const_iterator>

This resolves the issue on my side.

Attachments (1)

ptree_implementation.hpp (30.8 KB ) - added by Pavel Pokutnev <pavel.pokutnev@…> 4 years ago.

Download all attachments as: .zip

Change History (3)

by Pavel Pokutnev <pavel.pokutnev@…>, 4 years ago

Attachment: ptree_implementation.hpp added

comment:1 by Pavel Pokutnev <pavel.pokutnev@…>, 4 years ago

Here is the corresponding pull request: https://github.com/boostorg/property_tree/pull/32

comment:2 by Pavel Pokutnev <pavel.pokutnev@…>, 4 years ago

Just tested the new code with older compiler version VS 2017 15.4.1. It generates following error during the compilation:

error C2923: 'boost::iterators::reverse_iterator': 'boost::property_tree::basic_ptree<K,D,C>::iterator' is not a valid template type argument for parameter 'Iterator' 1> : public boost::reverse_iterator<basic_ptree<K, D, C>::iterator>

Looks I need to prefix it with 'typename'!

Note: See TracTickets for help on using tickets.