Opened 6 years ago

Last modified 6 years ago

#12621 new Bugs

property_tree::read_json does not work with BOOST_BIND_NO_PLACEHOLDERS

Reported by: ja2222ja@… Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost 1.61.0 Severity: Regression
Keywords: Cc: kaballo86@…

Description

Minimal code example:

#define BOOST_BIND_NO_PLACEHOLDERS
#include <boost/property_tree/json_parser.hpp>
#include <functional>
using namespace std::placeholders;

int main () {
    boost::property_tree::ptree pt;
    boost::property_tree::read_json("lol", pt);
}

Visual Studio 2015 Update 3 with v120 toolkit generates:

\lib\native\include\boost\bind\bind.hpp(319): error C2664: 'void boost::_mfi::mf1<void,boost::property_tree::json_parser::detail::standard_callbacks<Ptree>,char>::operator ()(T *,A1) const' : cannot convert argument 2 from 'std::_Ph<1>' to 'char'
1>          with
1>          [
1>              Ptree=boost::property_tree::ptree
1>  ,            T=boost::property_tree::json_parser::detail::standard_callbacks<boost::property_tree::ptree>
1>  ,            A1=char
1>          ]
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

First affected version: 1.59 [which introduces the new json parser]

My investigation shows that property_tree::json_parser::detail::standard_callbacks::operator() uses unqualified _1 symbol. Since #define BOOST_BIND_NO_PLACEHOLDERS is used, compiler don't know nothing about _1.

Error msg generated in msvc shows that boost::bind is messed up with std::placeholders::_1. The problem might be causes by no two-phase-lookup in cl. using namespace std::placeholders affects mentioned _1 usage in operator() since lookup for non dependent _1 is done later. Fixing issue in boost should workaround the msvc issue.

Please note that without #define BOOST_BIND_NO_PLACEHOLDERS everything works ok.

Change History (2)

comment:1 by Agustín K-ballo Bergé <kaballo86@…>, 6 years ago

Cc: kaballo86@… added

comment:2 by ja2222ja@…, 6 years ago

Error msg from gcc:

/usr/local/boost-1.62.0/include/boost/property_tree/json_parser/detail/parser.hpp: In member function 'void boost::property_tree::json_parser::detail::string_callback_adapter<Callbacks, Encoding, Iterator, std::input_iterator_tag>::process_codepoint(Sentinel, EncodingErrorFn)':
/usr/local/boost-1.62.0/include/boost/property_tree/json_parser/detail/parser.hpp:217:52: error: '_1' was not declared in this scope
                             boost::ref(callbacks), _1),
Note: See TracTickets for help on using tickets.