Re: [Boost-bugs] [Boost C++ Libraries] #9840: phoenix V3 and stl container non const methods

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9840: phoenix V3 and stl container non const methods
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-07 13:42:08


#9840: phoenix V3 and stl container non const methods
-------------------------------------+----------------------------------
  Reporter: Theodore.Papadopoulo@… | Owner: theller
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: phoenix
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords: stl container method
-------------------------------------+----------------------------------

Comment (by djowel):

 Wait, I see the problem and it's not a phoenix bug nor a spirit bug. It's
 a usage bug.

 1) L is captured by value, by default. Use ref if you want to capture by
 reference
 2) Use boost::spirit::qi::_1 instead of boost::phoenix::arg_names::_1

 Here's the working code:

 {{{
     #include <boost/spirit/include/qi.hpp>
     #include <boost/spirit/include/phoenix.hpp>
     #include <boost/phoenix/stl.hpp>
     #include <boost/spirit/include/qi_uint.hpp>
     #include <boost/phoenix/phoenix.hpp>

     std::vector<unsigned> L;

     int
     main() {
         using namespace boost::spirit::qi;
         using namespace boost::phoenix;
         using boost::spirit::qi::_1;
         namespace phx = boost::phoenix;
         const std::string str("3 1 2 3");
         std::string::const_iterator first = str.begin();
         parse(first,str.end(), uint_[reserve(phx::ref(L),_1)] >>
 repeat(capacity(phx::cref(L)))[ uint_ ]);
     }
 }}}

 I'll leave it up to you to close this ticket.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9840#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC