Opened 11 years ago

Closed 5 years ago

#6751 closed Bugs (invalid)

phoenix v3 yields compilation failure in spirit

Reported by: Li He <I.demonstrate@…> Owned by: Thomas Heller
Milestone: To Be Determined Component: spirit
Version: Boost 1.49.0 Severity: Problem
Keywords: spirit, phoenix Cc:

Description

Here is a simple code

//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>

namespace spirit = boost::spirit ;
namespace qi = boost::spirit::qi ;
namespace ascii = boost::spirit::ascii ;
namespace phoenix = boost::phoenix ;

using qi::int_ ;
using qi::_1 ;
using phoenix::push_back ;
using phoenix::ref ;
using phoenix::if_ ;

int
main (int argc, char* argv[]) {
  std::string line ;
  std::getline (std::cin, line) ;

  std::vector<int> v ;
  bool r = spirit::qi::phrase_parse
    (line.begin (), line.end (),
     int_ [if_(_1 % 2 == 0)[push_back (ref(v), _1)]] % ',',
     ascii::space) ;

  if (r) {
    std::cout << "vector: " ;
    std::copy (v.begin(), v.end(),
               std::ostream_iterator<int> (std::cout, ", ")) ;
    std::cout << std::endl ;
  }
  return 0 ;
}

Uncommenting the first line will trigger compilation errors.

Change History (3)

comment:1 by Joel de Guzman, 11 years ago

Owner: changed from Joel de Guzman to Thomas Heller

comment:2 by Nikita Kniazev <nok.raven@…>, 5 years ago

The problem here that you are using qi::_1 while you have to phoenix::placeholders::_1.

comment:3 by Joel de Guzman, 5 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.