Boost C++ Libraries: Ticket #10443: [fusion] Compile errors with boost::fusion::invoke and boost::result_of using decltype https://svn.boost.org/trac10/ticket/10443 <p> The following example fails to compile with c++11 compliant compilers. </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/bind.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/function.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/fusion/functional.hpp&gt;</span><span class="cp"></span> <span class="kt">void</span> <span class="nf">Function</span><span class="p">(</span> <span class="kt">int</span> <span class="o">&amp;</span> <span class="n">output</span> <span class="p">)</span> <span class="p">{</span> <span class="n">output</span> <span class="o">=</span> <span class="mi">12</span><span class="p">;</span> <span class="p">}</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">(</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span> <span class="p">)</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">fusion</span><span class="o">::</span><span class="n">vector1</span><span class="o">&lt;</span> <span class="kt">int</span> <span class="o">&gt;</span> <span class="n">parameters</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">function</span><span class="o">&lt;</span> <span class="kt">void</span><span class="p">(</span> <span class="kt">int</span> <span class="o">&amp;</span> <span class="p">)</span> <span class="o">&gt;</span> <span class="n">function</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">Function</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">fusion</span><span class="o">::</span><span class="n">invoke</span><span class="p">(</span> <span class="n">function</span><span class="p">,</span> <span class="n">parameters</span> <span class="p">);</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> I think the problem is due to the implementation <code>boost::result</code> using decltype and <code>boost::fusion::invoke</code> expecting the old TR1 type behaviour. The example compiles fine when <code>BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK</code> is defined. </p> <p> Compiling the above with <strong>clang++ -std=c++11 main.cpp</strong> generates the following output: </p> <pre class="wiki">In file included from main.cpp:4: In file included from /usr/local/include/boost/fusion/functional.hpp:13: In file included from /usr/local/include/boost/fusion/functional/invocation.hpp:13: In file included from /usr/local/include/boost/fusion/functional/invocation/invoke.hpp:96: In file included from /usr/local/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52: /usr/local/include/boost/fusion/functional/invocation/invoke.hpp:205:55: error: no type named 'type' in 'boost::result_of&lt;boost::function&lt;void (int &amp;)&gt; (const int &amp;)&gt;' Function(BOOST_PP_ENUM(N,M,~)) &gt;::type result_type; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ /usr/local/include/boost/fusion/functional/invocation/invoke.hpp:161:38: note: in instantiation of template class 'boost::fusion::detail::invoke_impl&lt;boost::function&lt;void (int &amp;)&gt;, const boost::fusion::vector1&lt;int&gt;, 1, false, true&gt;' requested here typedef typename detail::invoke_impl&lt; ^ /usr/local/include/boost/fusion/functional/invocation/invoke.hpp:179:32: note: in instantiation of template class 'boost::fusion::result_of::invoke&lt;boost::function&lt;void (int &amp;)&gt;, const boost::fusion::vector1&lt;int&gt; &gt;' requested here inline typename result_of::invoke&lt;Function,Sequence const&gt;::type ^ /usr/local/include/boost/fusion/functional/invocation/invoke.hpp:180:5: note: while substituting deduced template arguments into function template 'invoke' [with Function = boost::function&lt;void (int &amp;)&gt;, Sequence = boost::fusion::vector1&lt;int&gt;] invoke(Function f, Sequence const &amp; s) ^ 1 error generated. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10443 Trac 1.4.3 James Whitworth <fun4jimmy@…> Tue, 02 Sep 2014 14:26:18 GMT <link>https://svn.boost.org/trac10/ticket/10443#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10443#comment:1</guid> <description> <p> This was my original stackoverflow question about this problem: <a class="ext-link" href="http://stackoverflow.com/questions/25621676/boostfusioninvoke-compiler-error-with-visual-studio-2013"><span class="icon">​</span>http://stackoverflow.com/questions/25621676/boostfusioninvoke-compiler-error-with-visual-studio-2013</a> </p> </description> <category>Ticket</category> </item> <item> <author>James Whitworth <fun4jimmy@…></author> <pubDate>Tue, 02 Sep 2014 14:37:14 GMT</pubDate> <title>summary changed https://svn.boost.org/trac10/ticket/10443#comment:2 https://svn.boost.org/trac10/ticket/10443#comment:2 <ul> <li><strong>summary</strong> <span class="trac-field-old">Compile errors with boost::fusion::invoke and boost::result_of using decltype</span> → <span class="trac-field-new">[fusion] Compile errors with boost::fusion::invoke and boost::result_of using decltype</span> </li> </ul> Ticket Agustín K-ballo Bergé <kaballo86@…> Fri, 05 Sep 2014 17:53:03 GMT <link>https://svn.boost.org/trac10/ticket/10443#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10443#comment:3</guid> <description> <p> We have discussed this on IRC with alfC, and come to the conclusion that the underlying issue is that <code>result_of::invoke</code> is not SFINAE-friendly (as defined by C++11). The proper fix for this issue is then to make it SFINAE-friendly for all C++ versions. </p> <p> Additionally, there are two <code>invoke</code> definitions: one for <code>Sequence&amp;</code> and another one for <code>Sequence const&amp;</code>. This is redundant at best, and should be simplified. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Sat, 06 Sep 2014 03:14:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10443#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10443#comment:4</guid> <description> <p> I've not followed recent updates in Boost.Fusion, so I might be wrong, but... </p> <p> Both C++03 and C++11 versions of <code>fusion::invoke</code> are not SFINAE-friendly, as demonstrated in this post ( <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.devel/233752/focus=233849"><span class="icon">​</span>Re: [result_of] now uses decltype on release branch</a> ): </p> <pre class="wiki">#include &lt;boost/fusion/include/invoke.hpp&gt; #include &lt;boost/fusion/include/vector.hpp&gt; struct F { template &lt;typename Sig&gt; struct result; template &lt;typename This&gt; struct result&lt;This(int&amp;)&gt; { typedef void type; }; void operator()(int&amp;) const {} }; int main (int argc, char* argv[]) { boost::fusion::vector&lt;int&gt; v(1); // Error; // trying to instantiate result_of&lt;F(const int&amp;)&gt; boost::fusion::invoke(F(), v); return 0; } </pre> </description> <category>Ticket</category> </item> <item> <author>Jared Grubb <jaredgrubb@…></author> <pubDate>Sun, 19 Oct 2014 17:50:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10443#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10443#comment:5</guid> <description> <p> Note I hit a very similar issue (<a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10676" title="#10676: Bugs: [fusion] Compile errors with boost::fusion::fold due to ... (closed: fixed)">#10676</a>) with boost::fusion::fold. I think there's a general issue with fusion's "result_of" detail classes (boost::fusion::result_of::Stuff) not being SFINAE compatible. </p> </description> <category>Ticket</category> </item> <item> <author>Jared Grubb <jaredgrubb@…></author> <pubDate>Sun, 19 Oct 2014 17:52:28 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/10443#comment:6 https://svn.boost.org/trac10/ticket/10443#comment:6 <ul> <li><strong>cc</strong> <span class="trac-author">jaredgrubb@…</span> added </li> </ul> Ticket Joel de Guzman Sun, 19 Oct 2014 22:25:34 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10443#comment:7 https://svn.boost.org/trac10/ticket/10443#comment:7 <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> <p> Fixed now in develop branch. invoke is now sfinae friendly. Please check to be sure. </p> Ticket Kohei Takahashi <flast@…> Wed, 22 Oct 2014 11:05:27 GMT cc, status changed; resolution deleted https://svn.boost.org/trac10/ticket/10443#comment:8 https://svn.boost.org/trac10/ticket/10443#comment:8 <ul> <li><strong>cc</strong> <span class="trac-author">flast@…</span> added </li> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> I think djowel's fix is incomplete. I open a pull-request to fix this issue completely. </p> <p> Please check it. ttps://github.com/boostorg/fusion/pull/24 </p> Ticket Joel de Guzman Fri, 12 Jun 2015 06:49:09 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10443#comment:9 https://svn.boost.org/trac10/ticket/10443#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket