Boost C++ Libraries: Ticket #5011: comparison/equal_to should work recursively https://svn.boost.org/trac10/ticket/5011 <p> Suppose I have a struct that is adapted to Fusion, and it contains an array: </p> <p> typedef int i100<a class="changeset" href="https://svn.boost.org/trac10/changeset/100" title="*** empty log message *** ">[100]</a>; <em> need a typedef due to ADAPT_STRUCT limitation struct with_ar { </em></p> <blockquote> <p> double d1; double d2; i100 ar; </p> </blockquote> <p> }; BOOST_FUSION_ADAPT_STRUCT(::with_ar, (double d1)(double d2)(i100, ar)); </p> <p> Now I want to use the Fusion comparisons with this: </p> <p> #include &lt;boost/fusion/comparison/equal_to.hpp&gt; with_ar wa1 = { 0.0, 0.0, {1, 2 } }, </p> <blockquote> <p> wa2 = { 0.0, 0.0, {1, 2 } }; </p> </blockquote> <p> assert(boost::fusion::equal_to(wa1, wa2)); </p> <p> What I expect is that equal_to compares d1 and d2, and then compares ar as a Fusion sequence (the array adapter is included). However, the assertion fails, because equal_to compares the arrays with ==, which compares addresses. equal_to should be recursive, using equal_to to compare elements that are Fusion sequences, and == only for other things. </p> <p> I have hacked my local Fusion to do this, and it seems to work fine, but the hack is very ugly because of the recursive dependency between comparison/equal_to.hpp and comparison/detail/equal_to.hpp. Basically, I just add another version of equal_to that just does == on the arguments. SFINAE on is_sequence is used to decide between the two. The element comparison in sequence_equal_to then calls equal_to on the elements instead of using ==. </p> <p> The only problem I can see would be that equal_to would be used for adapted structs that have a specialized ==, but I think that would be a rather strange case. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5011 Trac 1.4.3 Joel de Guzman Fri, 21 Jan 2011 07:19:41 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5011#comment:1 https://svn.boost.org/trac10/ticket/5011#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">wontfix</span> </li> </ul> <p> This is not possible without breaking compatibility with Boost.Tuples. I'll be closing this ticket as no-fix. If you have objections, let's discuss this on list. There are alternate solutions. </p> Ticket