Re: [Boost-bugs] [Boost C++ Libraries] #6095: boost::icl::is_empty fails for certain open intervals

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6095: boost::icl::is_empty fails for certain open intervals
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-08 08:12:12


#6095: boost::icl::is_empty fails for certain open intervals
----------------------------------------------------------------+-----------
  Reporter: Marvin Sielenkemper <m.sielenkemper@…> | Owner: jofaber
      Type: Bugs | Status: assigned
 Milestone: Boost 1.48.0 | Component: ICL
   Version: Boost 1.47.0 | Severity: Problem
Resolution: | Keywords: icl, open interval, integer overflow
----------------------------------------------------------------+-----------

Comment (by Marvin Sielenkemper <m.sielenkemper@…>):

 Hi Joachim,

 no problem :)

 But I would like to propose a maybe even more nifty fix:[[br]]
 An open interval {{{]a, b[}}} is empty if {{{b <= a || b <= a + 1}}}.

 This does not only avoid the second increment, it even avoids the first
 one in many cases due to the short circuit {{{||}}}-operator and does
 ''never'' run into the overflow case:[[br]]
 If the first check fails, we know that {{{a < b}}} and hence that there is
 at least one element to increment to without overflowing.

 So this should even work for bound types that are less forgiving than
 {{{int}}} when hitting their bounds, (e.g. throw exceptions).

 Best regards,[[br]]
 Marvin

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6095#comment:4>
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:07 UTC