Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72405 - in branches/release: boost/icl boost/icl/concept boost/icl/type_traits libs/icl/test libs/icl/test/fix_tickets_ libs/icl/test/test_casual_ libs/icl/test/test_doc_code_
From: afojgo_at_[hidden]
Date: 2011-06-05 09:36:26


Author: jofaber
Date: 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
New Revision: 72405
URL: http://svn.boost.org/trac/boost/changeset/72405

Log:
Merging changes [71736-72403]. Fixed tickets #5482, #5559, #5562.
Properties modified:
   branches/release/boost/icl/ (props changed)
   branches/release/libs/icl/test/ (props changed)
   branches/release/libs/icl/test/test_doc_code_/ (props changed)
Text files modified:
   branches/release/boost/icl/closed_interval.hpp | 1
   branches/release/boost/icl/concept/element_set.hpp | 2
   branches/release/boost/icl/concept/interval.hpp | 52 ++++++++++++++++++++++++++-------------
   branches/release/boost/icl/concept/interval_bounds.hpp | 6 ----
   branches/release/boost/icl/continuous_interval.hpp | 1
   branches/release/boost/icl/discrete_interval.hpp | 1
   branches/release/boost/icl/left_open_interval.hpp | 3 +
   branches/release/boost/icl/open_interval.hpp | 4 ++
   branches/release/boost/icl/type_traits/is_numeric.hpp | 20 ++++++++++----
   branches/release/libs/icl/test/fix_tickets_/fix_tickets.cpp | 14 ++++++++++
   branches/release/libs/icl/test/test_casual_/test_casual.cpp | 1
   11 files changed, 72 insertions(+), 33 deletions(-)

Modified: branches/release/boost/icl/closed_interval.hpp
==============================================================================
--- branches/release/boost/icl/closed_interval.hpp (original)
+++ branches/release/boost/icl/closed_interval.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -22,6 +22,7 @@
 public:
     typedef closed_interval<DomainT,Compare> type;
     typedef DomainT domain_type;
+ typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
 
 public:
     //==========================================================================

Modified: branches/release/boost/icl/concept/element_set.hpp
==============================================================================
--- branches/release/boost/icl/concept/element_set.hpp (original)
+++ branches/release/boost/icl/concept/element_set.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -93,7 +93,7 @@
 
 template<class Type>
 inline typename enable_if<is_element_set<Type>, Type>::type&
-operator ^= (Type& object, const typename Type::element_tpye& operand)
+operator ^= (Type& object, const typename Type::element_type& operand)
 {
     return icl::flip(object, operand);
 }

Modified: branches/release/boost/icl/concept/interval.hpp
==============================================================================
--- branches/release/boost/icl/concept/interval.hpp (original)
+++ branches/release/boost/icl/concept/interval.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -107,8 +107,10 @@
 singleton(const typename interval_traits<Type>::domain_type& value)
 {
     //ASSERT: This always creates an interval with exactly one element
- typedef typename interval_traits<Type>::domain_type domain_type;
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(value) ));
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(value) ));
 
     return interval_traits<Type>::construct(domain_prior<Type>(value), value);
 }
@@ -118,8 +120,10 @@
 singleton(const typename interval_traits<Type>::domain_type& value)
 {
     //ASSERT: This always creates an interval with exactly one element
- typedef typename interval_traits<Type>::domain_type domain_type;
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(value)));
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(value)));
 
     return interval_traits<Type>::construct( domain_prior<Type>(value)
                                            , domain_next<Type>(value));
@@ -172,8 +176,10 @@
>::type
 unit_trail(const typename interval_traits<Type>::domain_type& value)
 {
- typedef typename interval_traits<Type>::domain_type domain_type;
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(value) ));
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(value) ));
 
     return interval_traits<Type>::construct(domain_prior<Type>(value), value);
 }
@@ -187,8 +193,10 @@
>::type
 unit_trail(const typename interval_traits<Type>::domain_type& value)
 {
- typedef typename interval_traits<Type>::domain_type domain_type;
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(value)));
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(value)));
 
     return interval_traits<Type>::construct( domain_prior<Type>(value)
                                            , domain_next<Type>(value));
@@ -279,15 +287,18 @@
 hull(const typename interval_traits<Type>::domain_type& left,
      const typename interval_traits<Type>::domain_type& right)
 {
- typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
     if(interval_traits<Type>::domain_compare()(left,right))
     {
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(left) ));
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(left) ));
         return construct<Type>(domain_prior<Type>(left), right);
     }
     else
     {
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(right) ));
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(right) ));
         return construct<Type>(domain_prior<Type>(right), left);
     }
 }
@@ -308,16 +319,19 @@
 hull(const typename interval_traits<Type>::domain_type& left,
      const typename interval_traits<Type>::domain_type& right)
 {
- typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
     if(interval_traits<Type>::domain_compare()(left,right))
     {
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(left) ));
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(left) ));
         return construct<Type>( domain_prior<Type>(left)
                               , domain_next<Type>(right));
     }
     else
     {
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(right) ));
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
+ ::is_less_than(right) ));
         return construct<Type>( domain_prior<Type>(right)
                               , domain_next<Type>(left));
     }
@@ -402,8 +416,9 @@
          , typename interval_traits<Type>::domain_type>::type
 last(const Type& object)
 {
- typedef typename interval_traits<Type>::domain_type domain_type;
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value>
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
                                  ::is_less_than(upper(object)) ));
     return domain_prior<Type>(upper(object));
 }
@@ -413,8 +428,9 @@
                           typename interval_traits<Type>::domain_type>::type
 last(const Type& object)
 {
- typedef typename interval_traits<Type>::domain_type domain_type;
- BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value>
+ typedef typename interval_traits<Type>::domain_type domain_type;
+ typedef typename interval_traits<Type>::domain_compare domain_compare;
+ BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
                                  ::is_less_than_or(upper(object), is_right_closed(object.bounds())) ));
     return is_right_closed(object.bounds()) ?
                                   upper(object) :

Modified: branches/release/boost/icl/concept/interval_bounds.hpp
==============================================================================
--- branches/release/boost/icl/concept/interval_bounds.hpp (original)
+++ branches/release/boost/icl/concept/interval_bounds.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -85,10 +85,7 @@
 shift_lower(interval_bounds decl, interval_bounds repr, const Type& low)
 {
     if(is_left_closed(decl) && !is_left_closed(repr))
- {
- BOOST_ASSERT((numeric_minimum<Type, is_numeric<Type>::value >::is_less_than(low) ));
         return icl::pred(low);
- }
     else if(!is_left_closed(decl) && is_left_closed(repr))
         return icl::succ(low);
     else
@@ -100,10 +97,7 @@
 shift_upper(interval_bounds decl, interval_bounds repr, const Type& up)
 {
     if(!is_right_closed(decl) && is_right_closed(repr))
- {
- BOOST_ASSERT((numeric_minimum<Type, is_numeric<Type>::value >::is_less_than(up) ));
         return icl::pred(up);
- }
     else if(is_right_closed(decl) && !is_right_closed(repr))
         return icl::succ(up);
     else

Modified: branches/release/boost/icl/continuous_interval.hpp
==============================================================================
--- branches/release/boost/icl/continuous_interval.hpp (original)
+++ branches/release/boost/icl/continuous_interval.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -30,6 +30,7 @@
 public:
     typedef continuous_interval<DomainT,Compare> type;
     typedef DomainT domain_type;
+ typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
     typedef typename bounded_value<DomainT>::type bounded_domain_type;
 
 public:

Modified: branches/release/boost/icl/discrete_interval.hpp
==============================================================================
--- branches/release/boost/icl/discrete_interval.hpp (original)
+++ branches/release/boost/icl/discrete_interval.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -30,6 +30,7 @@
 public:
     typedef discrete_interval<DomainT,Compare> type;
     typedef DomainT domain_type;
+ typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
     typedef typename bounded_value<DomainT>::type bounded_domain_type;
 
 public:

Modified: branches/release/boost/icl/left_open_interval.hpp
==============================================================================
--- branches/release/boost/icl/left_open_interval.hpp (original)
+++ branches/release/boost/icl/left_open_interval.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -49,7 +49,8 @@
         // Only for discrete types this ctor creates an interval containing
         // a single element only.
         BOOST_STATIC_ASSERT((icl::is_discrete<DomainT>::value));
- BOOST_ASSERT((numeric_minimum<DomainT, is_numeric<DomainT>::value >::is_less_than(val) ));
+ BOOST_ASSERT((numeric_minimum<DomainT, domain_compare, is_numeric<DomainT>::value >
+ ::is_less_than(val) ));
     }
 
     /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */

Modified: branches/release/boost/icl/open_interval.hpp
==============================================================================
--- branches/release/boost/icl/open_interval.hpp (original)
+++ branches/release/boost/icl/open_interval.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -24,6 +24,7 @@
 public:
     typedef open_interval<DomainT,Compare> type;
     typedef DomainT domain_type;
+ typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
 
 public:
     //==========================================================================
@@ -48,7 +49,8 @@
         // Only for discrete types this ctor creates an interval containing
         // a single element only.
         BOOST_STATIC_ASSERT((icl::is_discrete<DomainT>::value));
- BOOST_ASSERT((numeric_minimum<DomainT, is_numeric<DomainT>::value >::is_less_than(val) ));
+ BOOST_ASSERT((numeric_minimum<DomainT, domain_compare, is_numeric<DomainT>::value >
+ ::is_less_than(val) ));
     }
 
     /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */

Modified: branches/release/boost/icl/type_traits/is_numeric.hpp
==============================================================================
--- branches/release/boost/icl/type_traits/is_numeric.hpp (original)
+++ branches/release/boost/icl/type_traits/is_numeric.hpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -54,20 +54,28 @@
 };
 
 //--------------------------------------------------------------------------
-template<class Type, bool Enable = false> struct numeric_minimum;
-
-template<class Type>
-struct numeric_minimum<Type, false>
+template<class Type, class Compare, bool Enable = false>
+struct numeric_minimum
 {
     static bool is_less_than(Type){ return true; }
     static bool is_less_than_or(Type, bool){ return true; }
 };
 
 template<class Type>
-struct numeric_minimum<Type, true>
+struct numeric_minimum<Type, std::less<Type>, true>
+{
+ static bool is_less_than(Type value)
+ { return std::less<Type>()((std::numeric_limits<Type>::min)(), value); }
+
+ static bool is_less_than_or(Type value, bool cond)
+ { return cond || is_less_than(value); }
+};
+
+template<class Type>
+struct numeric_minimum<Type, std::greater<Type>, true>
 {
     static bool is_less_than(Type value)
- { return (std::numeric_limits<Type>::min)() < value; }
+ { return std::greater<Type>()((std::numeric_limits<Type>::max)(), value); }
 
     static bool is_less_than_or(Type value, bool cond)
     { return cond || is_less_than(value); }

Modified: branches/release/libs/icl/test/fix_tickets_/fix_tickets.cpp
==============================================================================
--- branches/release/libs/icl/test/fix_tickets_/fix_tickets.cpp (original)
+++ branches/release/libs/icl/test/fix_tickets_/fix_tickets.cpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -40,3 +40,17 @@
     BOOST_CHECK_EQUAL(m2.iterative_size(), 1);
 }
 
+
+#include <boost/cstdint.hpp>
+BOOST_AUTO_TEST_CASE(ticket_5559_Denis)
+{
+ //Submitted by Denis
+ typedef boost::icl::interval_set<boost::uint32_t, std::greater> Set;
+ const uint32_t ui32_max = (std::numeric_limits<uint32_t>::max)();
+
+ Set q1( Set::interval_type::closed(ui32_max, 0) );
+ Set q5( Set::interval_type::closed(0, 0) );
+
+ BOOST_CHECK_EQUAL(q1, q1+q5);
+}
+

Modified: branches/release/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- branches/release/libs/icl/test/test_casual_/test_casual.cpp (original)
+++ branches/release/libs/icl/test/test_casual_/test_casual.cpp 2011-06-05 09:36:25 EDT (Sun, 05 Jun 2011)
@@ -239,6 +239,7 @@
     BOOST_CHECK_EQUAL(m1.iterative_size(), m2.iterative_size());
 }
 
+
 BOOST_AUTO_TEST_CASE(casual)
 {
     typedef int T;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk