Boost C++ Libraries: Ticket #2246: Phoenix2 lazy function compilation error https://svn.boost.org/trac10/ticket/2246 <p> I get a compilation error when trying to do a lazy Phoenix function. </p> <p> 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 <code>function</code>, <code>compose</code> and <code>function_eval</code> seems to allow (IIUC the function can be any Phoenix actor, just like its arguments). </p> <p> <br /> </p> <p> Repro: </p> <pre class="wiki">#include &lt;boost/spirit/include/qi.hpp&gt; using namespace ::boost::spirit; using namespace ::boost::spirit::qi; #include &lt;boost/spirit/include/phoenix_bind.hpp&gt; #include &lt;boost/spirit/include/phoenix_function.hpp&gt; #include &lt;boost/spirit/include/phoenix_operator.hpp&gt; using namespace ::boost::phoenix; template&lt; typename F &gt; function&lt; F &gt; make_function(const F&amp; f) { return function&lt; F &gt;(f); } struct Actor { typedef void result_type; template&lt; typename T = unused_type &gt; 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&lt; const wchar_t* &gt; r; // Not lazy, fine. r = eps[ make_function( a )(42) ]; // Lazy, compilation error. r = eps[ make_function( *bind( &amp;Context::pa, c ) )(42) ]; c.pa = &amp;a; const wchar_t* x = L""; parse(x, x, r); return 0; } </pre><p> The error is (note the '<code>&amp;</code>'): </p> <pre class="wiki">boost/spirit/home/phoenix/core/detail/function_eval.hpp:108: error: ‘const Actor&amp;’ is not a class, struct, or union type </pre><p> <br /> </p> <p> The attached patch (<code>remove_reference</code> when getting function type) solved it for me. </p> <p> Francois </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2246 Trac 1.4.3 François Barel <frabar666@…> Fri, 22 Aug 2008 16:05:58 GMT attachment set https://svn.boost.org/trac10/ticket/2246 https://svn.boost.org/trac10/ticket/2246 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Phoenix2_lazy.diff</span> </li> </ul> Ticket Joel de Guzman Fri, 03 Oct 2008 08:41:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2246#comment:1 https://svn.boost.org/trac10/ticket/2246#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket