[Boost-bugs] [Boost C++ Libraries] #5011: comparison/equal_to should work recursively

Subject: [Boost-bugs] [Boost C++ Libraries] #5011: comparison/equal_to should work recursively
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-12-22 09:20:37


#5011: comparison/equal_to should work recursively
------------------------------+---------------------------------------------
 Reporter: cornedbee | Owner: djowel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: fusion
  Version: Boost 1.45.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5011>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:05 UTC