Opened 12 years ago

Closed 12 years ago

#5011 closed Bugs (wontfix)

comparison/equal_to should work recursively

Reported by: Sebastian Redl Owned by: Joel de Guzman
Milestone: To Be Determined Component: fusion
Version: Boost 1.45.0 Severity: Problem
Keywords: Cc:

Description

Suppose I have a struct that is adapted to Fusion, and it contains an array:

typedef int i100[100]; need a typedef due to ADAPT_STRUCT limitation struct with_ar {

double d1; double d2; i100 ar;

}; BOOST_FUSION_ADAPT_STRUCT(::with_ar, (double d1)(double d2)(i100, ar));

Now I want to use the Fusion comparisons with this:

#include <boost/fusion/comparison/equal_to.hpp> with_ar wa1 = { 0.0, 0.0, {1, 2 } },

wa2 = { 0.0, 0.0, {1, 2 } };

assert(boost::fusion::equal_to(wa1, wa2));

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.

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 ==.

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.

Change History (1)

comment:1 by Joel de Guzman, 12 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.