[Boost-bugs] [Boost C++ Libraries] #2246: Phoenix2 lazy function compilation error

Subject: [Boost-bugs] [Boost C++ Libraries] #2246: Phoenix2 lazy function compilation error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-08-22 16:05:27

#2246: Phoenix2 lazy function compilation error
 Reporter: François Barel <frabar666_at_[hidden]> | Owner: djowel
     Type: Bugs | Status: new
Milestone: Boost 1.37.0 | Component: spirit
  Version: Boost 1.36.0 | Severity: Problem
 Keywords: phoenix lazy function |
 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).



 #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 '{{{&}}}'):

   error: ‘const Actor&’ is not a class, struct, or union type


 The attached patch ({{{remove_reference}}} when getting function type)
 solved it for me.


Ticket URL: <http://svn.boost.org/trac/boost/ticket/2246>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC