|
Boost Users : |
Subject: Re: [Boost-users] [xpressive] Calling a function with captured text as a parameter from a rule action
From: Eric Niebler (eric_at_[hidden])
Date: 2009-10-01 11:26:39
Hi Ami,
Some answers are inline below... You were very close.
Ami Ganguli wrote:
> Here's the important bits of my code:
>
> My function object:
>
> struct append_element_impl
> {
> typedef void result_type;
> void operator()(std::string& text) const
-----------------------^^^^^^^^^^^^^^^^^
Make this std::string const &. Note the const.
> {
> std::cout << "appending " << text;
> }
> };
> function<append_element_impl>::type const append_element = {{}};
>
> The part of the parser that calls the function:
>
> h1 = "=" >> +blank >> * (s1= ~_ln) >> eol
> [append_element(as<std::string>(s1))];
---------------------------^^^^^^^^^^^^^^^
as<std::string> should not be necessary.
<snip>
> /usr/local/include/boost/proto/context/default.hpp:357: error:
> return-statement with a value, in function returning 'void'
This one is a little strange. I assume you're using gcc. It's possible
that once the other errors are corrected, this one will go away. If not,
change the return type of append_element_impl to int, and return just 0.
Hope that helps,
-- Eric Niebler BoostPro Computing http://www.boostpro.com
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