Boost logo

Boost Users :

Subject: [Boost-users] [qi and lambda] Get wrong reaction of the qi::rule if I use lambda for the action
From: boost_mailinglist_at_[hidden]
Date: 2011-08-15 06:50:24


Hello,

if I execute the following example, I get the following output "The bad
one The good one a" but I only expected "The good one a".

Why does it happens? Boost 1.47.0 was used.

#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/lambda/lambda.hpp>

#include <iostream>

int main()
{
     using boost::spirit::qi::char_;
     using boost::spirit::qi::parse;

     char const *first = "{a}", *last = first + std::strlen(first);

     parse(first, last, '{' >> char_("a")[std::cout << "The good one "
<< boost::lambda::_1 << '\n'] |
         char_("b")[std::cout << "The bad one " << boost::lambda::_1 <<
'\n'] >> '}');

     return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net