Boost C++ Libraries: Ticket #10676: [fusion] Compile errors with boost::fusion::fold due to boost::result_of picking wrong overload https://svn.boost.org/trac10/ticket/10676 <p> I was updating from boost-1.51 to boost-1.56 and some of a parsing library I have now fails to compile. </p> <p> Notice how the errors occur in overloads requiring "const long&amp;" but the Visitor takes mutable values (long&amp;). Somehow, it picks const and then digs down. </p> <p> I have two workarounds: </p> <ul><li>use BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK </li><li>add an explicit instantiation of boost::fusion::result_of to disable the selection that is causing the problem. </li></ul><pre class="wiki">#include &lt;boost/fusion/container/vector.hpp&gt; #include &lt;boost/fusion/algorithm/iteration/fold.hpp&gt; #if WORKAROUND struct Visitor; namespace boost { namespace fusion { namespace result_of { template&lt;typename Seq&gt; struct fold&lt;Seq const, int const, Visitor&gt; { /* Missing 'type' to disable this selection earlier */ }; } } } #endif struct Visitor { using result_type = int; int operator()(int sum, long&amp;) { return sum; } }; int main() { boost::fusion::vector&lt;long&gt; vec; Visitor visitor{}; boost::fusion::fold(vec, 0, visitor); } </pre><p> Error: </p> <pre class="wiki">$ clang++ --version Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.0.0 Thread model: posix [ Using boost-1.51 ] $ clang++ x.cpp --std=c++11 -DWORKAROUND $ clang++ x.cpp --std=c++11 [ Using boost-1.56 ] $ clang++ x.cpp --std=c++11 -DWORKAROUND $ clang++ x.cpp --std=c++11 -DBOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK $ clang++ x.cpp --std=c++11 In file included from x.cpp:2: In file included from /Users/grubber/Downloads/boost_1_56_0/boost/fusion/algorithm/iteration/fold.hpp:33: /Users/grubber/Downloads/boost_1_56_0/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp:265:24: error: no type named 'type' in 'boost::result_of&lt;Visitor (const int &amp;, const long &amp;)&gt;' &gt;::type ~~~^~~~ /Users/grubber/Downloads/boost_1_56_0/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp:278:17: note: in instantiation of template class 'boost::fusion::detail::result_of_first_unrolledfold&lt;const int &amp;, boost::fusion::vector_iterator&lt;const boost::fusion::vector&lt;long, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_&gt;, 0&gt;, Visitor, 1&gt;' requested here result_of_first_unrolledfold&lt; ^ /Users/grubber/Downloads/boost_1_56_0/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp:314:13: note: in instantiation of template class 'boost::fusion::detail::fold_impl&lt;1, const int &amp;, const boost::fusion::vector&lt;long, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_&gt;, Visitor&gt;' requested here : fold_impl&lt; ^ /Users/grubber/Downloads/boost_1_56_0/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp:328:13: note: in instantiation of template class 'boost::fusion::detail::result_of_fold&lt;const boost::fusion::vector&lt;long, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_&gt;, const int, Visitor, false&gt;' requested here : detail::result_of_fold&lt; ^ /Users/grubber/Downloads/boost_1_56_0/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp:352:32: note: in instantiation of template class 'boost::fusion::result_of::fold&lt;const boost::fusion::vector&lt;long, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_&gt;, const int, Visitor&gt;' requested here inline typename result_of::fold&lt; ^ x.cpp:29:5: note: while substituting deduced template arguments into function template 'fold' [with Seq = boost::fusion::vector&lt;long, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_&gt;, State = int, F = Visitor] boost::fusion::fold(vec, 0, visitor); ^ 1 error generated. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10676 Trac 1.4.3 Joel de Guzman Sun, 19 Oct 2014 22:07:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10676#comment:1 https://svn.boost.org/trac10/ticket/10676#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> <p> Fixed in develop branch. for now, we'll use tr1_result_of. we'll have to do an overhaul of the fold implementation because making it sfinae friendly goes deep down into the low level internals. </p> Ticket Jürgen Hunold Sun, 26 Oct 2014 16:04:04 GMT attachment set https://svn.boost.org/trac10/ticket/10676 https://svn.boost.org/trac10/ticket/10676 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fusion_error.txt</span> </li> </ul> <p> full error messages </p> Ticket Jürgen Hunold Sun, 26 Oct 2014 16:05:29 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/10676#comment:2 https://svn.boost.org/trac10/ticket/10676#comment:2 <ul> <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> This breaks code here. </p> <p> In file included from BOOST_ROOT/boost/fusion/support/detail/segmented_fold_until_impl.hpp:14: BOOST_ROOT/boost/utility/result_of.hpp:189:46: error: 'result' following the 'template' keyword does not refer to a template struct result_of_nested_result : F::template result&lt;FArgs&gt; </p> <p> Full message attached file "fusion_error.txt". </p> Ticket Joel de Guzman Sun, 26 Oct 2014 23:50:45 GMT <link>https://svn.boost.org/trac10/ticket/10676#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:3</guid> <description> <p> Are you using the test case above? I can't reproduce the error you are getting. Did you pull boost from develop branch? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 27 Oct 2014 07:05:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10676#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:4</guid> <description> <p> I'm using Boost.Trunk from develop branch of course, as the commit is not yet merged to master. Our own code breaks. Please drop me a note if you need a test case. Though it might take some days to extract it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 27 Oct 2014 07:34:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10676#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:5</guid> <description> <p> Yes please. I can't repro your problem from the test case above. All fusion tests pass as well. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jürgen Hunold</dc:creator> <pubDate>Mon, 27 Oct 2014 09:53:17 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/10676 https://svn.boost.org/trac10/ticket/10676 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">fold.cpp</span> </li> </ul> <p> Test case </p> Ticket Jürgen Hunold Mon, 27 Oct 2014 09:56:36 GMT <link>https://svn.boost.org/trac10/ticket/10676#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:6</guid> <description> <p> Attached test file "fold.cpp". Fails to compile with: </p> <ul><li>Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5) </li><li>gcc version 4.9.1 (Ubuntu 4.9.1-3ubuntu2~14.04.1) </li><li>clang trunk </li></ul><p> on fusion develop. master branch works fine. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 27 Oct 2014 12:09:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10676#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:7</guid> <description> <p> Ok, gotya. New fix pushed to develop. Please check. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 27 Oct 2014 12:10:10 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10676#comment:8 https://svn.boost.org/trac10/ticket/10676#comment:8 <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 Jürgen Hunold Mon, 27 Oct 2014 14:08:04 GMT <link>https://svn.boost.org/trac10/ticket/10676#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:9</guid> <description> <p> Thanks for the quick fix. The original code works again. Does it make sense to add the test case to the Fusion test suite? The planned massive overhaul would worry me otherwise. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Mon, 27 Oct 2014 14:32:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10676#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10676#comment:10</guid> <description> <p> Yes, I plan to do just that. Don't worry about the overhaul. It will be limited to fold only. I think it's best to do incremental evolution for C++14 instead of fighting with the old code. </p> </description> <category>Ticket</category> </item> </channel> </rss>