Re: What's type of member1 in closure<name, Type1>?
Larry Evans <cppljevans <at> suddenlink.net>
2007-12-02 20:00:18 GMT
On 11/29/07 22:20, Joel de Guzman wrote:
> Larry Evans wrote:
[snip]
>> OOPS. Spoke too soon. Changed end_tag to:
>>
>> end_tag = f_ch_p(close_delimiter(element.tag)) ;
>>
>> to that the char passed to f_ch_p matched the char for start_tag but
>> this gave:
>>
>> open_close_list_parser.cpp:63: error: no matching function for call to
[snip]
> You'll either have to make close_delimiter a phoenix "lazy" function
> or use phoenix bind (which does the same thing).
Thanks. The first way works, but I'm having trouble with bind. Here's
what end_tag was changed to:
<-- cut here --
#if 0
phoenix::function_ptr<char, char> const close_delim_lazy
= &close_delimiter;
end_tag = f_ch_p(close_delim_lazy(children.tag)) ;
#else
end_tag = f_ch_p(phoenix::bind(&close_delimiter));
#endif
>-- cut here --
With '#if 1' instead of '#if 0' and the following driver snippet:
<-- cut here --
demo_print_tree("root{x{a,b,c},y{}}");
demo_print_tree
( debug_utility::demangled_name
< boost::spirit::grammar
< utility::tree_parse_print
>
>()
);
>-- cut here --
I get the expected output:
<-- cut here --
testing.unit-test
../../../../../bin.v2/sandbox/lje/libs/utility/example/gcc-4.1/debug/str_tree_print_demo.passed
Parse:root{x{a,b,c},y{}}
Printing:
root
{ x
{ a
, b
, c
}
, y
{
}
}
-------------------------
Parsing succeeded
-------------------------
Parse:boost::spirit::grammar<utility::tree_parse_print,
boost::spirit::parser_context<boost::spirit::nil_t> >
Printing:
boost::spirit::grammar
< utility::tree_parse_print
, boost::spirit::parser_context
< boost::spirit::nil_t
>
>
-------------------------
Parsing succeeded
-------------------------
>-- cut here --
However, with '#if 0' I get compile error:
<-- cut here --
str_tree_print_demo.cpp:41: instantiated from here
../../../../../boost/spirit/attribute/parametric.hpp:32: error: cannot
convert 'phoenix::actor<phoenix::composite<phoenix::eq_op,
phoenix::actor<phoenix::value<char> >,
phoenix::actor<phoenix::composite<phoenix::function_ptr_action<char,
char, phoenix::nil_t, phoenix::nil_t, phoenix::nil_t>, phoenix::nil_t,
phoenix::nil_t, phoenix::nil_t, phoenix::nil_t> >, phoenix::nil_t,
phoenix::nil_t> >' to 'bool' in return
>-- cut here --
and this despite the apparent claim of the documentation:
<-- cut here --
bind(&foo_)
This bind expression results to a lazy-function (see functions) that is
lazily evaluated. This bind expression is also equivalent to:
function_ptr<void, int> foo = &foo_;
>-- cut here --
Now it's no big deal for me to use the longer function_ptr method;
however, I'm just wondering why bind doesn't seem to work as advertised.
Any ideas?
(BTW, thanks for you help on this so far :) )
-regards,
Larry
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4