Opened 14 years ago
Closed 14 years ago
#2246 closed Bugs (fixed)
Phoenix2 lazy function compilation error
Reported by: | Owned by: | Joel de Guzman | |
---|---|---|---|
Milestone: | Boost 1.37.0 | Component: | spirit |
Version: | Boost 1.36.0 | Severity: | Problem |
Keywords: | phoenix lazy function | Cc: |
Description
I get a compilation error when trying to do a lazy Phoenix function.
By that I mean a Phoenix function (for use in a Spirit action) which is in fact the result of calling another Phoenix actor (in my case a phoenix::bind) -- as the implementation of function
, compose
and function_eval
seems to allow (IIUC the function can be any Phoenix actor, just like its arguments).
Repro:
#include <boost/spirit/include/qi.hpp> using namespace ::boost::spirit; using namespace ::boost::spirit::qi; #include <boost/spirit/include/phoenix_bind.hpp> #include <boost/spirit/include/phoenix_function.hpp> #include <boost/spirit/include/phoenix_operator.hpp> using namespace ::boost::phoenix; template< typename F > function< F > make_function(const F& f) { return function< F >(f); } struct Actor { typedef void result_type; template< typename T = unused_type > struct result { typedef result_type type; }; void operator()(int) const { assert( this != NULL ); } }; struct Context { const Actor* pa; }; int main() { Context c = { NULL }; Actor a; rule< const wchar_t* > r; // Not lazy, fine. r = eps[ make_function( a )(42) ]; // Lazy, compilation error. r = eps[ make_function( *bind( &Context::pa, c ) )(42) ]; c.pa = &a; const wchar_t* x = L""; parse(x, x, r); return 0; }
The error is (note the '&
'):
boost/spirit/home/phoenix/core/detail/function_eval.hpp:108: error: ‘const Actor&’ is not a class, struct, or union type
The attached patch (remove_reference
when getting function type) solved it for me.
Francois
Attachments (1)
Change History (2)
by , 14 years ago
Attachment: | Phoenix2_lazy.diff added |
---|
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.