Re: [Boost-bugs] [Boost C++ Libraries] #5482: iterative_size() not the same for interval_maps using std::less and std::greater

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5482: iterative_size() not the same for interval_maps using std::less and std::greater
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-04-16 10:02:16


#5482: iterative_size() not the same for interval_maps using std::less and
std::greater
-------------------------------------+--------------------------------------
  Reporter: boicotinho@… | Owner: jofaber
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: ICL
   Version: Boost 1.46.1 | Severity: Problem
Resolution: | Keywords: interval, iteration
-------------------------------------+--------------------------------------

Comment (by jofaber):

 Hi,

 thank you for this interesting bug report. In generic programming we may
 forget to vary template paramteres in tests, specifically if we have many
 of them ;) The problem you have found has to do with interval
 initialization of singleton intervals [x, ++x), because x < ++x is only
 valid with std::less and not with std::greater.

 Replying to [ticket:5482 boicotinho@…]:
> The assertion at the bottom fails.
>
> {{{
> typedef interval_map<int,int,partial_absorber,std::less> m1_t;
> typedef interval_map<int,int,partial_absorber,std::greater> m2_t;
> m1_t m1;
> m2_t m2;
> m1.insert(make_pair(m1_t::interval_type(1), 20));
> m1.insert(make_pair(m1_t::interval_type(2), 20));
> m1.insert(make_pair(m1_t::interval_type(3), 20));
>
> m2.insert(make_pair(m2_t::interval_type(1), 20));
> m2.insert(make_pair(m2_t::interval_type(2), 20));
> m2.insert(make_pair(m2_t::interval_type(3), 20));
> Assert::IsTrue(m1.iterative_size() == m2.iterative_size());
>
> }}}

 I will fix that bug for the general case ASAP. For the time being, you
 could use a work around that seems to work. Construct intervals explicitly
 with two values:

 {{{
 typedef interval_map<int,int,partial_absorber,std::less> m1_t;
 typedef interval_map<int,int,partial_absorber,std::greater> m2_t;
 m1_t m1;
 m2_t m2;
 m1.insert(make_pair(m1_t::interval_type(1), 20));
 m1.insert(make_pair(m1_t::interval_type(2), 20));
 m1.insert(make_pair(m1_t::interval_type(3), 20));

 m2.insert(make_pair(m2_t::interval_type(3,2), 20)); //Singleton intervals
 m2.insert(make_pair(m2_t::interval_type(2,1), 20)); //constructed
 explicitly
 m2.insert(make_pair(m2_t::interval_type(1,0), 20)); //with std::greater
 ordering
 BOOST_CHECK_EQUAL(m1.iterative_size(), m2.iterative_size());
 }}}

 Alas I can't guarantee that there aren't more problems lurking with
 std::greater, since as you detected, I haven't tested these cases
 carefully enough yet.

 Best regards,
 Joachim

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5482#comment:1>
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:06 UTC