Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65955 - in sandbox/itl: boost/itl boost/itl/concept boost/itl/type_traits boost/itl_xt boost/validate/gentor libs/itl/test libs/validate/example/labat_polygon_
From: afojgo_at_[hidden]
Date: 2010-10-14 10:55:05


Author: jofaber
Date: 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
New Revision: 65955
URL: http://svn.boost.org/trac/boost/changeset/65955

Log:
Refactoring: Removed all applications and includes of old itl::intervals. Removed is_universal_interval predicate. Fall back version for renaming of itl::_interval<T> to itl::interval<T> Stable{msvc-9.0, gcc-3.4.4}
Removed:
   sandbox/itl/boost/itl/type_traits/is_universal_interval.hpp
   sandbox/itl/libs/itl/test/test_calls.hpp
Text files modified:
   sandbox/itl/boost/itl/concept/interval.hpp | 86 --
   sandbox/itl/boost/itl/interval.hpp | 1306 +++------------------------------------
   sandbox/itl/boost/itl/interval_base_set.hpp | 1
   sandbox/itl/boost/itl/type_traits/interval_type_default.hpp | 118 ---
   sandbox/itl/boost/itl_xt/random.hpp | 1
   sandbox/itl/boost/itl_xt/typed_episode.hpp | 3
   sandbox/itl/boost/validate/gentor/gentorprofile.hpp | 2
   sandbox/itl/boost/validate/gentor/rangegentor.hpp | 3
   sandbox/itl/libs/itl/test/test_value_maker.hpp | 1
   sandbox/itl/libs/validate/example/labat_polygon_/polygon_gentor.hpp | 3
   10 files changed, 130 insertions(+), 1394 deletions(-)

Modified: sandbox/itl/boost/itl/concept/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/interval.hpp (original)
+++ sandbox/itl/boost/itl/concept/interval.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -24,7 +24,6 @@
 #include <boost/itl/type_traits/is_discrete.hpp>
 #include <boost/itl/type_traits/is_continuous.hpp>
 #include <boost/itl/type_traits/is_asymmetric_interval.hpp>
-#include <boost/itl/type_traits/is_universal_interval.hpp>
 #include <boost/itl/type_traits/is_discrete_interval.hpp>
 #include <boost/itl/type_traits/is_continuous_interval.hpp>
 
@@ -434,14 +433,6 @@
     return domain_less_equal<Type>(upper(object), succ(lower(object)));
 }
 
-
-template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, bool>::type
-is_empty(const Type& object)
-{
- return object.empty();
-}
-
 template<class Type>
 typename boost::enable_if<is_discrete_interval<Type>, bool>::type
 is_empty(const Type& object)
@@ -478,13 +469,6 @@
     }
 
     template<class Type>
- inline typename boost::enable_if<is_universal_interval<Type>, bool>::type
- exclusive_less(const Type& left, const Type& right)
- {
- return left.exclusive_less(right);
- }
-
- template<class Type>
     inline typename boost::enable_if<is_discrete_interval<Type>, bool>::type
     exclusive_less(const Type& left, const Type& right)
     {
@@ -592,13 +576,6 @@
 }
 
 template<class Type>
-inline typename boost::enable_if<is_universal_interval<Type>, bool>::type
-exclusive_less(const Type& left, const Type& right)
-{
- return left.exclusive_less(right);
-}
-
-template<class Type>
 inline typename boost::enable_if<is_discrete_interval<Type>, bool>::type
 exclusive_less(const Type& left, const Type& right)
 {
@@ -635,13 +612,6 @@
 }
     
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, bool>::type
-lower_less(const Type& left, const Type& right)
-{
- return left.lower_less(right);
-}
-
-template<class Type>
 typename boost::enable_if<is_discrete_interval<Type>, bool>::type
 lower_less(const Type& left, const Type& right)
 {
@@ -668,13 +638,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, bool>::type
-upper_less(const Type& left, const Type& right)
-{
- return left.upper_less(right);
-}
-
-template<class Type>
 typename boost::enable_if<is_discrete_interval<Type>, bool>::type
 upper_less(const Type& left, const Type& right)
 {
@@ -737,13 +700,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, bool>::type
-lower_equal(const Type& left, const Type& right)
-{
- return left.lower_equal(right);
-}
-
-template<class Type>
 typename boost::enable_if<has_symmetric_bounds<Type>, bool>::type
 lower_equal(const Type& left, const Type& right)
 {
@@ -775,13 +731,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, bool>::type
-upper_equal(const Type& left, const Type& right)
-{
- return left.upper_equal(right);
-}
-
-template<class Type>
 typename boost::enable_if<has_symmetric_bounds<Type>, bool>::type
 upper_equal(const Type& left, const Type& right)
 {
@@ -865,13 +814,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, bool>::type
-touches(const Type& left, const Type& right)
-{
- return left.touches(right);
-}
-
-template<class Type>
 typename boost::enable_if<is_discrete_interval<Type>, bool>::type
 touches(const Type& left, const Type& right)
 {
@@ -1026,13 +968,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, Type>::type
-hull(Type left, const Type& right)
-{
- return left.extend(right);
-}
-
-template<class Type>
 typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
 hull(Type left, const Type& right)
 {
@@ -1092,13 +1027,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, Type>::type
-left_subtract(Type right, const Type& left_minuend)
-{
- return right.left_subtract(left_minuend);
-}
-
-template<class Type>
 typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
 left_subtract(Type right, const Type& left_minuend)
 {
@@ -1151,13 +1079,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, Type>::type
-right_subtract(Type left, const Type& right_minuend)
-{
- return left.right_subtract(right_minuend);
-}
-
-template<class Type>
 typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
 right_subtract(Type left, const Type& right_minuend)
 {
@@ -1208,13 +1129,6 @@
 }
 
 template<class Type>
-typename boost::enable_if<is_universal_interval<Type>, Type>::type
-operator & (Type left, const Type& right)
-{
- return left &= right;
-}
-
-template<class Type>
 typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
 operator & (Type left, const Type& right)
 {

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -1,1200 +1,136 @@
 /*-----------------------------------------------------------------------------+
-Copyright (c) 2007-2009: Joachim Faulhaber
-Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
+Copyright (c) 2010-2010: Joachim Faulhaber
 +------------------------------------------------------------------------------+
    Distributed under the Boost Software License, Version 1.0.
       (See accompanying file LICENCE.txt or copy at
            http://www.boost.org/LICENSE_1_0.txt)
 +-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_INTERVAL_HPP_JOFA_000626
-#define BOOST_ITL_INTERVAL_HPP_JOFA_000626
+#ifndef BOOST_ITL_INTERVAL_HPP_JOFA_101014
+#define BOOST_ITL_INTERVAL_HPP_JOFA_101014
 
-#include <ostream>
-#include <functional>
-#include <limits>
-#include <string>
-#include <boost/assert.hpp>
-#include <boost/call_traits.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/concept_check.hpp>
-#include <boost/next_prior.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/assert.hpp>
-#include <boost/itl/detail/notate.hpp>
-#include <boost/itl/detail/design_config.hpp>
-#include <boost/itl/detail/exclusive_less_than.hpp>
-#include <boost/itl/type_traits/identity_element.hpp>
-#include <boost/itl/type_traits/unit_element.hpp>
-#include <boost/itl/type_traits/infinity.hpp>
-#include <boost/itl/type_traits/is_continuous.hpp>
-#include <boost/itl/type_traits/difference_type_of.hpp>
-#include <boost/itl/type_traits/size_type_of.hpp>
-#include <boost/itl/type_traits/value_size.hpp>
-#include <boost/itl/type_traits/to_string.hpp>
-#include <boost/itl/type_traits/is_universal_interval.hpp>
-#include <boost/itl/interval_bounds.hpp>
-#include <boost/itl/concept/interval.hpp>
-
-//JODO For the migration from old to new itl::intervals activate this code:
-//
-//#ifdef ITL_NEW_INTERVAL_IMPL
-//
-//#include <boost/itl/type_traits/interval_type_of.hpp>
-//#include <boost/itl/discrete_interval.hpp>
-//#include <boost/itl/continuous_interval.hpp>
-//
-//namespace boost{namespace itl
-//{
-//
-//template <class DomainT, ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)>
-//class interval
-//{
-//public:
-// typedef typename interval_type_of<DomainT,Compare>::type type;
-//
-// /** Closed interval <tt>[low,up]</tt> */
-// static type closed(const DomainT& low, const DomainT& up)
-// { return type(low, up, interval_bounds::closed()); }
-//
-// /** Rightopen interval <tt>[low,up)</tt> */
-// static type right_open(const DomainT& low, const DomainT& up)
-// { return type(low, up, interval_bounds::right_open); }
-//
-// /** Leftopen interval <tt>(low,up]</tt> */
-// static type left_open(const DomainT& low, const DomainT& up)
-// { return type(low, up, interval_bounds::left_open); }
-//
-// /** Open interval <tt>(low,up)</tt> */
-// static type open(const DomainT& low, const DomainT& up)
-// { return type(low, up, interval_bounds::open); }
-//
-//};
-//
-///// Comparison functor on intervals implementing an overlap free less
-//template <class IntervalT>
-//struct exclusive_less_than {
-// /** Operator <tt>operator()</tt> implements a strict weak ordering on intervals. */
-// bool operator()(const IntervalT& left, const IntervalT& right)const
-// { return exclusive_less(left, right); }
-//};
-//
-//}} // namespace itl boost
-//
-//#else //ITL_NEW_INTERVAL_IMPL
 
-namespace boost{namespace itl
-{
-
-/// Constants for interval bounds
-enum BoundTypes {
- /// Both open: <tt>(x,y)</tt>
- open_bounded = 0, // '00'
- /// Left open right closed: <tt>(x,y]</tt>
- left_open_bounded = 1, // '01'
- /// Left closed right open: <tt>[x,y)</tt>
- right_open_bounded = 2, // '10'
- /// Both closed: <tt>[x,y]</tt>
- closed_bounded = 3 // '11'
-} ;
-
-
-typedef unsigned char bound_type;
-
-/** \brief A class template for intervals */
-template <class DomainT, ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)>
-class interval
-{
-public:
- //==========================================================================
- //= Associated types
- //==========================================================================
- typedef interval<DomainT,Compare> type;
-
- //--------------------------------------------------------------------------
- //- Associated types: Data
- //--------------------------------------------------------------------------
- /// The domain type of the interval
- typedef DomainT domain_type;
- /// The codomaintype is the same as domain_type
- typedef DomainT codomain_type;
- /// The element type of the interval
- typedef DomainT element_type;
- /// The segment type is the interval's type
- typedef type segment_type;
- /// The interval type is the interval's type
- typedef type interval_type;
-
- //--------------------------------------------------------------------------
- //- Associated types: Implementation and stl related
- //--------------------------------------------------------------------------
- typedef DomainT key_type;
- typedef DomainT data_type;
- typedef DomainT value_type;
-
- /// Compare order on the data
- typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
- typedef domain_compare key_compare;
-
- /// The difference type of an interval which is sometimes different form the domain_type
- typedef typename itl::difference_type_of<DomainT>::type difference_type;
-
- /// The size type of an interval which is mostly std::size_t
- typedef typename itl::size_type_of<DomainT>::type size_type;
-
-public:
- //==========================================================================
- //= Construct, copy, destruct
- //==========================================================================
- /** Default constructor; yields an empty interval <tt>[1,0]</tt> */
- interval() : _lwb(unit_element<DomainT>::value()), _upb(identity_element<DomainT>::value()),
- _boundtype(itl::closed_bounded)
- {
- BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
- BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- }
-
- //NOTE: Compiler generated copy constructor is used
-
- /** Constructor for a closed singleton interval <tt>[val,val]</tt> */
- explicit interval(const DomainT& val) :
- _lwb(val), _upb(val), _boundtype(itl::closed_bounded)
- {
- BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
- BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- }
-
- /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
- interval(const DomainT& low, const DomainT& up, itl::bound_type bounds = itl::closed_bounded) :
- _lwb(low), _upb(up), _boundtype(bounds)
- {
- BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
- BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- }
-
- /** Closed interval <tt>[low,up]</tt> */
- static interval closed(const DomainT& low, const DomainT& up)
- { return interval(low, up, itl::closed_bounded); }
-
- /** Rightopen interval <tt>[low,up)</tt> */
- static interval right_open(const DomainT& low, const DomainT& up)
- { return interval(low, up, itl::right_open_bounded); }
-
- /** Leftopen interval <tt>(low,up]</tt> */
- static interval left_open(const DomainT& low, const DomainT& up)
- { return interval(low, up, itl::left_open_bounded); }
-
- /** Open interval <tt>(low,up)</tt> */
- static interval open(const DomainT& low, const DomainT& up)
- { return interval(low, up, itl::open_bounded); }
-
- //NOTE: Compiler generated assignment operator = used
-
- //==========================================================================
- //= Containedness
- //==========================================================================
- /** Is the interval empty? */
- bool empty()const;
-
- /** Set the interval empty */
- void clear()
- { set_lwb(unit_element<DomainT>::value()); set_upb(identity_element<DomainT>::value());
- _boundtype=itl::closed_bounded; }
-
- /** Does the interval contain <tt>x</tt>? */
- bool contains(const DomainT& x)const;
- /** <tt>*this</tt> is superset of <tt>sub</tt> */
- bool contains(const interval& sub)const;
-
- /** <tt>*this</tt> is subset of <tt>super</tt> */
- bool contained_in(const interval& super)const ;
-
- /** <tt>sub</tt> is proper subset of <tt>*this</tt> and does not touch the borders of <tt>*this</tt> */
- bool free_contains(const interval& sub)const;
-
- /** <tt>sub</tt> is proper subset of <tt>*this</tt> */
- bool proper_contains(const interval& sub)const;
-
- /** <tt>*this</tt> and <tt>x2</tt> are disjoint; their intersection is empty */
- bool is_disjoint(const interval& x2)const
- { return exclusive_less(x2) || x2.exclusive_less(*this); }
-
- /** <tt>*this</tt> and <tt>x2</tt> have a non empty intersection */
- bool intersects(const interval& x2)const
- { return !is_disjoint(x2); }
-
- //==========================================================================
- //= Size
- //==========================================================================
- /** Cardinality of the interval: The number of elements */
- size_type cardinality()const;
-
- /** Arithmetic size of the interval */
- difference_type length()const;
-
- /** Size of the interval */
- size_type size()const { return cardinality(); }
-
- //==========================================================================
- //= Range
- //==========================================================================
- /** Lower bound of the interval */
- DomainT lower()const { return _lwb; }
- /** Upper bound of the interval */
- DomainT upper()const { return _upb; }
-
- /** First (smallest) element of the interval */
- DomainT first()const;
- /** Last (largest) element of the interval */
- DomainT last()const;
-
- //==========================================================================
- //= Selection
- //==========================================================================
-
- /** Typ of interval bounds */
- bound_type boundtype()const { return _boundtype; }
-
- //==========================================================================
- //= Addition
- //==========================================================================
-
- /** Extend <tt>*this</tt> to <tt>x2</tt> yielding an interval from the
- minimum of lower bounds to the
- maximum of upper bounds */
- interval& extend(const interval& x2);
-
- /** Extend \c *this interval to the minimum of the lower bounds of
- \c this and \c left_extension. */
- interval& left_extend(const interval& left_extension);
-
- /** Extend \c *this interval to the maximum of the upper bounds of
- \c this and \c right_extension. */
- interval& right_extend(const interval& right_extension);
-
- /** Set the lower bound and bound type according to interval \c left. */
- interval& left_set(const interval& left);
-
- /** Set the upper bound and bound type according to interval \c right. */
- interval& right_set(const interval& right);
-
- /** Interval spanning from lower bound of \c *this interval to the upper bound of \c rhs.
- Bordertypes according to the lower bound of \c *this and the upper bound of \c rhs. */
- interval span(const interval& rhs)const
- {
- if(empty()) return rhs;
- else if(rhs.empty()) return *this;
- else return
- interval(_lwb, rhs._upb, span(boundtype(), rhs.boundtype()));
- }
-
-
- //==========================================================================
- //= Subtraction
- //==========================================================================
-
- /** subtract \c left_minuend from \c *this interval on it's left side.
-\code
-*this = *this - left_minuend; //on the left.
-... d) : *this
-... c) : left_minuend
- [c d) : *this
-\endcode
- */
- interval& left_subtract(const interval& left_minuend);
-
- /** subtract \c right_minuend from \c *this interval on it's right side.
-\code
-*this = *this - right_minuend; //on the right side.
-[a ... : *this
- [b ... : right_minuend
-[a b) : *this
-\endcode
- */
- interval& right_subtract(const interval& right_minuend);
-
- //==========================================================================
- //= Intersection
- //==========================================================================
-
- /** Intersection with the interval <tt>x2</tt>; assign result to <tt>isec</tt> */
- interval& operator &= (const interval& sectant)
- {
- if(empty())
- return *this;
- if(sectant.empty())
- { clear(); return *this; }
-
- set_lwb(lwb_max(sectant));
- set_upb(upb_min(sectant));
- return *this;
- }
-
- //==========================================================================
- //= Representation
- //==========================================================================
-
- /** Object as string */
- const std::string as_string()const;
-
- //==========================================================================
- //= Predicates
- //==========================================================================
-
- /** What type is the interval?
-\code
-interval.is(closed_bounded); //[x, y] a closed interval
-interval.is(right_open); //[x, y) a right-open interval (also left-closed interval)
-interval.is(left_open); //(x, y] a left-open interval (also right-closed interval)
-interval.is(open_bounded); //(x, y) an open interval
-\endcode
- */
- bool is(bound_type bounded)const { return _boundtype == bounded; }
-
- /** What bound type is the left interval border?
-\code
-interval.is_left(closed_bounded); //[x, y] or [x, y)
-interval.is_left(open_bounded); //(x, y] or (x, y)
-\endcode
- */
- bool is_left(bound_type bounded)const
- {
- BOOST_ASSERT(bounded == itl::open_bounded || bounded == itl::closed_bounded);
- return ((_boundtype & right_open)>>1) == (bounded>>1);
- }
-
- /** What bound type is the right interval border?
-\code
-interval.is_right(closed_bounded); //[x, y] or (x, y]
-interval.is_right(open_bounded); //[x, y) or (x, y)
-\endcode
- */
- bool is_right(bound_type bounded)const
- {
- BOOST_ASSERT(bounded == itl::open_bounded || bounded == itl::closed_bounded);
- return ((_boundtype & left_open) == (bounded>>1));
- }
-
-
- /** There is no gap between <tt>*this</tt> and <tt>x2</tt> but they have no element in common */
- bool touches(const interval& x2)const;
-
- /** Maximal element of <tt>*this</tt> is less than the minimal element of <tt>x2</tt> */
- bool exclusive_less(const interval& x2)const;
-
- /** Maximal element of <tt>*this</tt> is less than the minimal element of <tt>x2</tt>
- and there is at least one element in between. */
- bool distant_less(const interval& x2)const;
-
- /** Set \c *this interval to from \c low to \c up with boundtype \c bounds */
- interval& set(const DomainT& low, const DomainT& up, bound_type bounds)
- { _lwb=low; _upb=up; _boundtype=bounds; return *this; }
-
- /** Transforms the interval to the bound-type <tt>bounded</tt> without
- changing it's content. Requires Integral<domain_type>.
-\code
-interval.as(closed_bounded).is(closed_bounded) &&
-interval.as(right_open).is(right_open) &&
-interval.as(left_open).is(left_open) &&
-interval.as(open_bounded).is(open_bounded)
-\endcode
- */
- interval& as(bound_type bounded);
-
- /** An interval that covers the complete range of it's domain_type */
- static interval whole()
- { return interval<DomainT>::closed((std::numeric_limits<DomainT>::min)(),
- (std::numeric_limits<DomainT>::max)()); }
-
-
- /** First element of \c *this is less than first element of \c x2 */
- bool lower_less(const interval& x2)const;
- /** Last element of \c *this is less than last element of \c x2 */
- bool upper_less(const interval& x2)const;
- /** First element of \c *this is less than or equal to the first element of \c x2 */
- bool lower_less_equal(const interval& x2)const;
- /** Last element of \c *this is less than or equal to the last element of \c x2 */
- bool upper_less_equal(const interval& x2)const;
- /** First element of \c *this is equal to the first element of \c x2 */
- bool lower_equal(const interval& x2)const;
- /** Last element of \c *this is equal to the last element of \c x2 */
- bool upper_equal(const interval& x2)const;
-
-private:
- typedef std::pair<DomainT, bound_type> BoundT;
-
-private:
- void set_lwb(DomainT lw) { _lwb=lw; }
- void set_upb(DomainT up) { _upb=up; }
-
- void set_lwb_type(bound_type bounds)
- { _boundtype = (unsigned char)((left_open & _boundtype) | (right_open & bounds)); }
-
- void set_upb_type(bound_type bounds)
- { _boundtype = (unsigned char)((right_open & _boundtype) | (left_open & bounds)); }
-
- static bound_type span(bound_type left, bound_type right)
- { return (unsigned char)((left_open | left) & (right_open | right)) ; }
-
- bound_type succession_bounds()const;
-
- void set_lwb(const BoundT& lw) { _lwb=lw.first; set_lwb_type(lw.second); }
- void set_upb(const BoundT& up) { _upb=up.first; set_upb_type(up.second); }
-
- BoundT lwb_min(const interval& x2)const;
- BoundT lwb_max(const interval& x2)const;
- BoundT upb_min(const interval& x2)const;
- BoundT upb_max(const interval& x2)const;
-
- BoundT lwb_right_of(const interval& x2)const;
- BoundT upb_left_of(const interval& x2)const;
-
-private:
- DomainT _lwb;
- DomainT _upb;
- bound_type _boundtype;
-} ;
-
-
-template <class DomainT, ITL_COMPARE Compare>
-bound_type interval<DomainT,Compare>::succession_bounds()const
-{
- if(_boundtype==itl::right_open) return itl::right_open;
- if(_boundtype==itl::left_open) return itl::left_open;
- if(_boundtype==itl::closed_bounded) return itl::open_bounded;
- return itl::closed_bounded;
-}
-
-
-template<class IntervalT>
-struct continuous_type
-{
- typedef typename IntervalT::domain_type domain_type;
- typedef typename boost::call_traits<domain_type>::param_type DomainP;
-
- static bool open_bound_less_equal(DomainP x, DomainP y)
- { return IntervalT::domain_less_equal(x,y); } //{ return x <= y; }
- static bool open_bound_less (DomainP x, DomainP y)
- { return IntervalT::domain_less(x,y); } //{ return x < y; }
-};
-
-template<class IntervalT>
-struct discrete_type
-{
- typedef typename IntervalT::domain_type domain_type;
- typedef typename boost::call_traits<domain_type>::param_type DomainP;
-
- static bool open_bound_less_equal(DomainP x, DomainP y)
- { return IntervalT::domain_less_equal(x, succ(y)); } //{ return x <= succ(y); }
- static bool open_bound_less (DomainP x, DomainP y)
- { return IntervalT::domain_less(succ(x),y); } //{ return succ(x) < y ; }
-};
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::empty()const
-{
- using namespace boost::mpl;
-
- if(is_right(closed_bounded) && is_left(closed_bounded)) return domain_less(_upb, _lwb); //_upb < _lwb;
- if(is_right(open_bounded) && is_left(closed_bounded)) return domain_less_equal(_upb, _lwb); //_upb <= _lwb;
- if(is_right(closed_bounded) && is_left(open_bounded)) return domain_less_equal(_upb, _lwb); //_upb <= _lwb;
-
- // OTHERWISE (is_right(open_bounded) && is_left(open_bounded))
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less_equal(_upb, _lwb);
-}
-
-template<class IntervalT>
-struct continuous_interval_
-{
- static typename IntervalT::size_type cardinality(const IntervalT& x)
- {
- typedef typename IntervalT::size_type SizeT;
- if(itl::is_empty(x))
- return itl::identity_element<SizeT>::value();
- else if(x.is(itl::closed_bounded) && IntervalT::domain_equal(x.lower(), x.upper()))
- return itl::unit_element<SizeT>::value();
- else
- return infinity<SizeT>::value();
- }
-
- static typename IntervalT::difference_type
- length(const IntervalT& x)
- {
- return x.empty() ? itl::identity_element<typename IntervalT::difference_type>::value()
- : x.upper() - x.lower();
- }
-
- static typename IntervalT::difference_type
- distance(const IntervalT& x1, const IntervalT& x2)
- {
- if(x1.empty() || x2.empty())
- return itl::identity_element<typename IntervalT::difference_type>::value();
- else if(IntervalT::domain_less(x1.upper(), x2.lower()))
- return x2.lower() - x1.upper();
- else if(IntervalT::domain_less(x2.upper(), x1.lower()))
- return x1.lower() - x2.upper();
- else
- return itl::identity_element<typename IntervalT::difference_type>::value();
- }
-
- static bool unaligned_lwb_equal(const IntervalT&, const IntervalT&)
- { return false; }
-
- static bool unaligned_upb_equal(const IntervalT&, const IntervalT&)
- { return false; }
-
- static bool has_equal_border_touch(const IntervalT&, const IntervalT&)
- { return false; }
-};
-
-template<class IntervalT>
-struct discrete_interval_
-{
- typedef typename IntervalT::domain_type domain_type;
-
- static typename IntervalT::size_type
- cardinality(const IntervalT& x)
- {
- return itl::is_empty(x)? itl::identity_element<typename IntervalT::size_type>::value()
- : static_cast<typename IntervalT::size_type>(succ(last(x) - first(x)));
- }
-
- static typename IntervalT::difference_type length(const IntervalT& x)
- {
- return itl::is_empty(x) ? itl::identity_element<typename IntervalT::difference_type>::value()
- : static_cast<typename IntervalT::difference_type>(succ(last(x) - first(x)));
- }
-
- static typename IntervalT::difference_type
- distance(const IntervalT& x1, const IntervalT& x2)
- {
- if(itl::is_empty(x1) || itl::is_empty(x2))
- return itl::identity_element<typename IntervalT::difference_type>::value();
- else if(IntervalT::domain_less(x1.last(), x2.first()))
- return static_cast<typename IntervalT::difference_type>(pred(x2.first() - x1.last()));
- else if(IntervalT::domain_less(x2.last(), x1.first()))
- return static_cast<typename IntervalT::difference_type>(pred(x1.first() - x2.last()));
- else
- return itl::identity_element<typename IntervalT::difference_type>::value();
- }
-
- static bool unaligned_lwb_equal(const IntervalT& x1, const IntervalT& x2)
- {
- if(x1.is_left(open_bounded) && x2.is_left(closed_bounded))
- return IntervalT::domain_equal(succ(x1.lower()), x2.lower() );
- else return IntervalT::domain_equal( x1.lower(), succ(x2.lower()));
- }
-
- static bool unaligned_upb_equal(const IntervalT& x1, const IntervalT& x2)
- {
- if(x1.is_right(closed_bounded) && x2.is_right(open_bounded))
- return IntervalT::domain_equal(succ(x1.upper()), x2.upper() );
- else return IntervalT::domain_equal( x1.upper(), succ(x2.upper()));
- }
-
- static bool has_equal_border_touch(const IntervalT& x1, const IntervalT& x2)
- {
- if(x1.is_right(closed_bounded) && x2.is_left(closed_bounded))
- return IntervalT::domain_equal(succ(x1.upper()), x2.lower());
- if(x1.is_right(open_bounded) && x2.is_left(open_bounded) )
- return IntervalT::domain_equal(x1.upper(), succ(x2.lower()));
- return false;
- }
-
-};
-
-// NOTE structural similarities between empty and exclusive_less!
-// emptieness can be defined as being exclusive less to oneself.
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::exclusive_less(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_right(closed_bounded) && x2.is_left(closed_bounded)) return domain_less(_upb, x2._lwb); //_upb < x2._lwb
- if(is_right(open_bounded) && x2.is_left(closed_bounded)) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
- if(is_right(closed_bounded) && x2.is_left(open_bounded) ) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
-
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less_equal(_upb, x2._lwb);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::distant_less(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_right(open_bounded) && x2.is_left(closed_bounded)) return domain_less(_upb, x2._lwb); //_upb < x2._lwb;
- if(is_right(closed_bounded) && x2.is_left(open_bounded) ) return domain_less(_upb, x2._lwb); //_upb < x2._lwb;
- if(is_right(open_bounded) && x2.is_left(open_bounded) ) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
-
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less(_upb, x2._lwb);
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::lower_less(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_left(closed_bounded) && x2.is_left(closed_bounded)) return domain_less(_lwb, x2._lwb);
- if(is_left(open_bounded) && x2.is_left(open_bounded)) return domain_less(_lwb, x2._lwb);
- if(is_left(closed_bounded) && x2.is_left(open_bounded)) return domain_less_equal(_lwb, x2._lwb);//domain_less_equal(_lwb, x2._lwb);
-
- // OTHERWISE (is_left(open_bounded) && x2.is_left(closed_bounded))
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less(_lwb, x2._lwb);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::upper_less(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_right(closed_bounded) && x2.is_right(closed_bounded)) return domain_less(_upb, x2._upb);
- if(is_right(open_bounded) && x2.is_right(open_bounded)) return domain_less(_upb, x2._upb);
- if(is_right(open_bounded) && x2.is_right(closed_bounded)) return domain_less_equal(_upb, x2._upb);//domain_less_equal(_upb, x2._upb);
-
- // OTHERWISE (is_right(closed_bounded) && x2.is_right(open_bounded))
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less(_upb, x2._upb);
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::lower_less_equal(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_left(closed_bounded) && x2.is_left(closed_bounded)) return domain_less_equal(_lwb, x2._lwb);
- if(is_left(open_bounded) && x2.is_left(open_bounded)) return domain_less_equal(_lwb, x2._lwb);
- if(is_left(open_bounded) && x2.is_left(closed_bounded)) return domain_less(_lwb, x2._lwb);
-
- // OTHERWISE (is_left(closed_bounded) && x2.is_left(open_bounded))
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less_equal(_lwb, x2._lwb);
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::upper_less_equal(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_right(closed_bounded) && x2.is_right(closed_bounded)) return domain_less_equal(_upb, x2._upb);
- if(is_right(open_bounded) && x2.is_right(open_bounded)) return domain_less_equal(_upb, x2._upb);
- if(is_right(closed_bounded) && x2.is_right(open_bounded)) return domain_less(_upb, x2._upb);
-
- // OTHERWISE (is_right(open_bounded) && x2.is_right(closed_bounded))
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_type<interval<DomainT,Compare> >,
- discrete_type<interval<DomainT,Compare> >
- >
- ::type::open_bound_less_equal(_upb, x2._upb);
-}
-
-
-//NOTE THINK: This implementation is rather interesting wrt. continuous value types.
-// An alternative implementation was x.lwb_equal(y)={return x.lower_less_equal(y) && y.lower_less_equal(x)}
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::lower_equal(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_left(closed_bounded) && x2.is_left(closed_bounded)) return domain_equal(_lwb, x2._lwb);
- if(is_left(open_bounded) && x2.is_left(open_bounded) ) return domain_equal(_lwb, x2._lwb);
-
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::unaligned_lwb_equal(*this, x2);
-}
-
-//NOTE THINK: This implementation is rather interesting wrt. continuous value types.
-// An alternative implementation was x.lwb_equal(y)={return x.lower_less_equal(y) && y.lower_less_equal(x)}
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::upper_equal(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_right(closed_bounded) && x2.is_right(closed_bounded)) return domain_equal(_upb, x2._upb);
- if(is_right(open_bounded) && x2.is_right(open_bounded) ) return domain_equal(_upb, x2._upb);
-
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::unaligned_upb_equal(*this, x2);
-}
-
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::lwb_min(const interval& x2)const
-{
- if( x2.lower_less(*this) )
- return BoundT(x2._lwb, x2.boundtype());
- else
- return BoundT(_lwb, boundtype());
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::upb_max(const interval& x2)const
-{
- if( upper_less(x2) )
- return BoundT(x2._upb, x2.boundtype());
- else
- return BoundT(_upb, boundtype());
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::lwb_max(const interval& x2)const
-{
- if( lower_less(x2) )
- return BoundT(x2._lwb, x2.boundtype());
- else
- return BoundT(_lwb, boundtype());
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::upb_min(const interval& x2)const
-{
- if( x2.upper_less(*this) )
- return BoundT(x2._upb, x2.boundtype());
- else
- return BoundT(_upb, boundtype());
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::upb_left_of(const interval& x2)const
-{
- return BoundT(x2._lwb, x2.succession_bounds());
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::lwb_right_of(const interval& x2)const
-{
- return BoundT(x2._upb, x2.succession_bounds());
-}
-
-
-// NOTE non symmetric version: *this[upb].touches(x2[lwb])
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::touches(const interval& x2)const
-{
- using namespace boost::mpl;
- if(is_right(open_bounded) && x2.is_left(closed_bounded)) return domain_equal(_upb, x2._lwb);
- if(is_right(closed_bounded) && x2.is_left(open_bounded)) return domain_equal(_upb, x2._lwb);
-
- return
- if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::has_equal_border_touch(*this, x2);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::contains(const DomainT& x)const
-{
- if(is_right(closed_bounded) && is_left(closed_bounded)) return domain_less_equal(_lwb, x) && domain_less_equal(x, _upb);
- if(is_right(closed_bounded) && is_left(open_bounded) ) return domain_less(_lwb, x) && domain_less_equal(x, _upb);
- if(is_right(open_bounded) && is_left(closed_bounded)) return domain_less_equal(_lwb, x) && domain_less(x, _upb);
- return domain_less(_lwb, x) && domain_less(x, _upb);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::contained_in(const interval& super)const
-{ return super.lower_less_equal(*this) && upper_less_equal(super); }
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::contains(const interval& sub)const
-{ return lower_less_equal(sub) && sub.upper_less_equal(*this); }
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::free_contains(const interval& sub)const
-{ return lower_less(sub) && sub.upper_less(*this); }
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool interval<DomainT,Compare>::proper_contains(const interval& sub)const
-{ return contains(sub) && (lower_less(sub) || sub.upper_less(*this)); }
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::extend(const interval<DomainT,Compare>& x2)
-{
- if(x2.empty())
- return *this;
- else if(empty())
- return *this = x2;
- else
- {
- set_lwb(lwb_min(x2));
- set_upb(upb_max(x2));
- return *this;
- }
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::left_extend(const interval<DomainT,Compare>& x2)
-{
- if(x2.empty())
- return *this;
- else if(empty())
- return *this = x2;
- else
- {
- set_lwb(lwb_min(x2));
- return *this;
- }
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::right_extend(const interval<DomainT,Compare>& x2)
-{
- if(x2.empty())
- return *this;
- else if(empty())
- return *this = x2;
- else
- {
- set_upb(upb_max(x2));
- return *this;
- }
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::left_set(const interval<DomainT,Compare>& x2)
-{
- if(x2.empty())
- return *this;
- else if(empty())
- return *this = x2;
- else
- {
- set_lwb(BoundT(x2._lwb, x2.boundtype()));
- return *this;
- }
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::right_set(const interval<DomainT,Compare>& x2)
-{
- if(x2.empty())
- return *this;
- else if(empty())
- return *this = x2;
- else
- {
- set_upb(BoundT(x2._upb, x2.boundtype()));
- return *this;
- }
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::left_subtract(const interval& x2)
-{
- if(!x2.exclusive_less(*this))
- set_lwb( BoundT(x2._upb, x2.succession_bounds()) );
- return *this;
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::right_subtract(const interval& x2)
-{
- if(!exclusive_less(x2))
- set_upb( BoundT(x2._lwb, x2.succession_bounds()) );
- return *this;
-}
-
-
-template <class DomainT, ITL_COMPARE Compare>
-const std::string interval<DomainT,Compare>::as_string()const
-{
- std::string itvRep("");
- std::string lwbRep, ubpRep;
-
- itvRep += is_left(open_bounded) ? "(" : "[" ;
- itvRep += itl::to_string<DomainT>::apply(_lwb);
- itvRep += ",";
- itvRep += itl::to_string<DomainT>::apply(_upb);
- itvRep += is_right(open_bounded) ? ")" : "]" ;
-
- return itvRep;
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline DomainT interval<DomainT,Compare>::first()const
-{
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
- return is_left(closed_bounded) ? _lwb : succ(_lwb);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline DomainT interval<DomainT,Compare>::last()const
-{
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
- return is_right(closed_bounded) ? _upb : pred(_upb);
-}
-
-//------------------------------------------------------------------------------
-// There is an error C2244 under msvc-8 with memeber function
-// size_type interval::cardinality()const.
-// It seems that the compiler is unable to substitute
-//
-// typename interval<DomainT,Compare>::size_type
-// by
-// typename itl::size<DomainT>::type
-//
-// If msvc-8 is not supported any more result type
-// typename itl::size<DomainT>::type can be rplaced with the more systematic
-// typename interval<DomainT,Compare>::size_type
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename itl::size_type_of<DomainT>::type interval<DomainT,Compare>::cardinality()const
-{
- using namespace boost::mpl;
- return if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::cardinality(*this);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline typename interval<DomainT,Compare>::difference_type interval<DomainT,Compare>::length()const
-{
- using namespace boost::mpl;
- return if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::length(*this);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline interval<DomainT,Compare>& interval<DomainT,Compare>::as(bound_type bounded)
-{
- switch(bounded)
- {
- case itl::closed_bounded: set(first(), last(), bounded); break;
- case itl::right_open : set(first(), succ(last()), bounded); break;
- case itl::left_open : set(pred(first()), last(), bounded); break;
- case itl::open_bounded : set(pred(first()), succ(last()), bounded); break;
- }
- return *this;
-}
-
-//==============================================================================
-//= Equivalences and Orderings
-//==============================================================================
-/** Equality on intervals */
-template <class DomainT, ITL_COMPARE Compare>
-inline bool operator == (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
-{
- return (lhs.empty() && rhs.empty()) || (lhs.lower_equal(rhs) && lhs.upper_equal(rhs));
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool operator != (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
-{ return !(lhs == rhs); }
-
-/** Strict weak less oredering on intervals */
-template <class DomainT, ITL_COMPARE Compare>
-inline bool operator < (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
-{
- if(lhs.empty()) return !rhs.empty();
- else return lhs.lower_less(rhs) || (lhs.lower_equal(rhs) && lhs.upper_less(rhs));
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool operator > (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
-{ return rhs < lhs; }
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool operator <= (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
-{ return !(lhs > rhs); }
-
-template <class DomainT, ITL_COMPARE Compare>
-inline bool operator >= (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
-{ return !(lhs < rhs); }
-
-
-/** Returns true if the intersection of \c left and \c right is not empty. */
-template <class DomainT, ITL_COMPARE Compare>
-inline bool intersects(const itl::interval<DomainT,Compare>& left,
- const itl::interval<DomainT,Compare>& right)
-{
- return left.intersects(right);
-}
-
-/** Returns true if \c left and \c right do not intersect. */
-template <class DomainT, ITL_COMPARE Compare>
-inline bool is_disjoint(const itl::interval<DomainT,Compare>& left,
- const itl::interval<DomainT,Compare>& right)
-{
- return left.is_disjoint(right);
-}
-
-//==============================================================================
-//= Complement
-//==============================================================================
-
-template <class DomainT, ITL_COMPARE Compare,
- ITL_INTERVAL(ITL_COMPARE) Interval>
-ITL_INTERVAL_TYPE(Interval,DomainT,Compare)
- inner_complement(const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& left,
- const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& right)
-{
- if(left.exclusive_less(right))
- return hull(left, right).left_subtract(left).right_subtract(right);
- else if(right.exclusive_less(left))
- return hull(right, left).left_subtract(right).right_subtract(left);
- else
- return identity_element<ITL_INTERVAL_TYPE(Interval,DomainT,Compare) >::value();
-}
-
-//==============================================================================
-//= Distance
-//==============================================================================
-
-template <class DomainT, ITL_COMPARE Compare,
- ITL_INTERVAL(ITL_COMPARE) Interval>
-inline typename ITL_INTERVAL_TYPE(Interval,DomainT,Compare)::difference_type
- distance(const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& left,
- const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& right)
-{
- using namespace boost::mpl;
- return if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::distance(left, right);
-}
-
-template <class DomainT, ITL_COMPARE Compare,
- ITL_INTERVAL(ITL_COMPARE) Interval>
-inline typename ITL_INTERVAL_TYPE(Interval,DomainT,Compare)::difference_type
- length(const ITL_INTERVAL_TYPE(Interval,DomainT,Compare)& inter_val)
-{
- using namespace boost::mpl;
- return if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_<interval<DomainT,Compare> >,
- discrete_interval_<interval<DomainT,Compare> >
- >
- ::type::length(inter_val);
-}
-
-
-
-//==============================================================================
-//= Representation
-//==============================================================================
-
-template<class CharType, class CharTraits, class DomainT, ITL_COMPARE Compare>
-std::basic_ostream<CharType, CharTraits>& operator <<
- (std::basic_ostream<CharType, CharTraits> &stream, interval<DomainT,Compare> const& x)
-{
- if(x.empty())
- return stream << "[]";
- else
- {
- return stream << std::string(x.is_left(open_bounded) ? "(" : "[")
- << x.lower() << "," << x.upper()
- << std::string(x.is_right(open_bounded)? ")" : "]");
- }
-}
-
-
-
-//------------------------------------------------------------------------------
-//- dynamic_interval_traits: Adapt interval class to interval concept
-//------------------------------------------------------------------------------
-template<class DomainT, ITL_COMPARE Compare>
-struct dynamic_interval_traits< itl::interval<DomainT,Compare> >
-{
- typedef boost::itl::interval<DomainT,Compare> interval_type;
-
- static interval_type apply(const DomainT& lo, const DomainT& up, interval_bounds bounds)
- {
- return interval_type(lo, up, bounds.bits());
- }
-};
-
-
-
-//==============================================================================
-//= Type traits
-//==============================================================================
-template <class DomainT, ITL_COMPARE Compare>
-struct is_interval<itl::interval<DomainT,Compare> >
-{
- typedef is_interval<itl::interval<DomainT,Compare> > type;
- BOOST_STATIC_CONSTANT(bool, value = true);
-};
-
-template <class DomainT, ITL_COMPARE Compare>
-struct is_universal_interval<itl::interval<DomainT,Compare> >
-{
- typedef is_universal_interval<itl::interval<DomainT,Compare> > type;
- BOOST_STATIC_CONSTANT(bool, value = true);
-};
-
-template <class DomainT, ITL_COMPARE Compare>
-struct type_to_string<itl::interval<DomainT,Compare> >
-{
- static std::string apply()
- { return "itv<"+ type_to_string<DomainT>::apply() +">"; }
-};
+#include <boost/itl/type_traits/interval_type_default.hpp>
 
 
-template<class DomainT>
-struct value_size<itl::interval<DomainT> >
+namespace boost{ namespace itl
 {
- static std::size_t apply(const itl::interval<DomainT>& value)
- { return 2; }
-};
 
-}} // namespace itl boost
+ template <class DomainT, ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)>
+ struct _interval
+ {
+ typedef typename interval_type_default<DomainT,Compare>::type interval_type;
+ typedef interval_type type;
+
+#ifdef ITL_USE_STATIC_INTERVAL_BORDER_DEFAULTS
+
+ static inline interval_type open(const DomainT& low, const DomainT& up)
+ {
+ return
+ static_interval
+ < interval_type // if the domain_type is discrete ...
+ , is_discrete<typename interval_traits<interval_type>::domain_type>::value
+ , interval_bounds::static_open // 'pretended' bounds will be transformed to
+ , interval_bound_type<interval_type>::value // the represented bounds
+ >
+ ::construct(low, up);
+ }
+
+ static inline interval_type left_open(const DomainT& low, const DomainT& up)
+ {
+ return
+ static_interval
+ < interval_type
+ , is_discrete<typename interval_traits<interval_type>::domain_type>::value
+ , interval_bounds::static_left_open
+ , interval_bound_type<interval_type>::value
+ >
+ ::construct(low, up);
+ }
+
+ static inline interval_type right_open(const DomainT& low, const DomainT& up)
+ {
+ return
+ static_interval
+ < interval_type
+ , is_discrete<typename interval_traits<interval_type>::domain_type>::value
+ , interval_bounds::static_right_open
+ , interval_bound_type<interval_type>::value
+ >
+ ::construct(low, up);
+ }
+
+ static inline interval_type closed(const DomainT& low, const DomainT& up)
+ {
+ return
+ static_interval
+ < interval_type
+ , is_discrete<typename interval_traits<interval_type>::domain_type>::value
+ , interval_bounds::static_closed
+ , interval_bound_type<interval_type>::value
+ >
+ ::construct(low, up);
+ }
+
+ static inline interval_type construct(const DomainT& low, const DomainT& up)
+ { return itl::construct<interval_type>(low, up); }
+
+#else // ITL_USE_DYNAMIC_INTERVAL_BORDER_DEFAULTS
+ static inline interval_type right_open(const DomainT& low, const DomainT& up)
+ { return itl::construct<interval_type>(low, up, interval_bounds::right_open()); }
+
+ static inline interval_type left_open(const DomainT& low, const DomainT& up)
+ { return itl::construct<interval_type>(low, up, interval_bounds::left_open()); }
+
+ static inline interval_type open(const DomainT& low, const DomainT& up)
+ { return itl::construct<interval_type>(low, up, interval_bounds::open()); }
+
+ static inline interval_type closed(const DomainT& low, const DomainT& up)
+ { return itl::construct<interval_type>(low, up, interval_bounds::closed()); }
+
+ static inline interval_type construct(const DomainT& low, const DomainT& up)
+ { return itl::construct<interval_type>(low, up); }
+
+#endif
+ };
+
+ template <class IntervalT, bool IsDiscrete, bound_type PretendedBounds, bound_type RepresentedBounds>
+ struct static_interval;
+
+ template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
+ struct static_interval<IntervalT, true, PretendedBounds, RepresentedBounds>
+ {// is_discrete<domain_type<IntervalT>>
+ typedef typename interval_traits<IntervalT>::domain_type domain_type;
+
+ static inline IntervalT construct(const domain_type& low, const domain_type& up)
+ {
+ return itl::construct<IntervalT>(
+ shift_lower(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), low)
+ , shift_upper(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), up )
+ );
+ }
+ };
+
+ template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
+ struct static_interval<IntervalT, false, PretendedBounds, RepresentedBounds>
+ {// !is_discrete<domain_type<IntervalT>>
+ typedef typename interval_traits<IntervalT>::domain_type domain_type;
+
+ static inline IntervalT construct(const domain_type& low, const domain_type& up)
+ {
+ BOOST_STATIC_ASSERT((is_discrete<domain_type>::value || PretendedBounds==RepresentedBounds));
+ // For domain_types that are not discrete, e.g. interval<float>
+ // one of the following must hold: If you call
+ // interval<T>::right_open(x,y) then interval<T>::type must be static_right_open
+ // interval<T>::left_open(x,y) then interval<T>::type must be static_left_open
+ // interval<T>::open(x,y) then interval<T>::type must be static_open
+ // interval<T>::closed(x,y) then interval<T>::type must be static_closed
+ // Conversion between 'PretendedBounds' and 'RepresentedBounds' is only possible
+ // for discrete domain_types.
+ return itl::construct<IntervalT>(low, up);
+ }
+ };
 
-//JODO interval migration #endif // ITL_NEW_INTERVAL_IMPL
+}} // namespace boost itl
 
-#endif // BOOST_ITL_INTERVAL_HPP_JOFA_000626
+#endif // BOOST_ITL_INTERVAL_HPP_JOFA_101014
 

Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -12,6 +12,7 @@
 #include <limits>
 #include <boost/next_prior.hpp>
 #include <boost/itl/type_traits/interval_type_default.hpp>
+#include <boost/itl/interval.hpp>
 #include <boost/itl/type_traits/infinity.hpp>
 #include <boost/itl/type_traits/is_interval_joiner.hpp>
 #include <boost/itl/type_traits/is_interval_separator.hpp>

Modified: sandbox/itl/boost/itl/type_traits/interval_type_default.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/interval_type_default.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/interval_type_default.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -48,124 +48,6 @@
 #endif
     };
 
-
-//==============================================================================
-//JODO move?
- template <class DomainT, ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT)>
- struct _interval
- {
- typedef typename interval_type_default<DomainT>::type interval_type;
- typedef interval_type type;
-
-#ifdef ITL_USE_STATIC_INTERVAL_BORDER_DEFAULTS
-
- static inline interval_type open(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type // if the domain_type is discrete ...
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_open // 'pretended' bounds will be transformed to
- , interval_bound_type<interval_type>::value // the represented bounds
- >
- ::construct(low, up);
- }
-
- static inline interval_type left_open(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_left_open
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
-
- static inline interval_type right_open(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_right_open
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
-
- static inline interval_type closed(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_closed
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
-
- static inline interval_type construct(const DomainT& low, const DomainT& up)
- { return itl::construct<interval_type>(low, up); }
-
-#else // ITL_USE_DYNAMIC_INTERVAL_BORDER_DEFAULTS
- static inline interval_type right_open(const DomainT& low, const DomainT& up)
- { return itl::construct<interval_type>(low, up, interval_bounds::right_open()); }
-
- static inline interval_type left_open(const DomainT& low, const DomainT& up)
- { return itl::construct<interval_type>(low, up, interval_bounds::left_open()); }
-
- static inline interval_type open(const DomainT& low, const DomainT& up)
- { return itl::construct<interval_type>(low, up, interval_bounds::open()); }
-
- static inline interval_type closed(const DomainT& low, const DomainT& up)
- { return itl::construct<interval_type>(low, up, interval_bounds::closed()); }
-
- static inline interval_type construct(const DomainT& low, const DomainT& up)
- { return itl::construct<interval_type>(low, up); }
-
-#endif
- };
-
- template <class IntervalT, bool IsDiscrete, bound_type PretendedBounds, bound_type RepresentedBounds>
- struct static_interval;
-
- template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
- struct static_interval<IntervalT, true, PretendedBounds, RepresentedBounds>
- {// is_discrete<domain_type<IntervalT>>
- typedef typename interval_traits<IntervalT>::domain_type domain_type;
-
- static inline IntervalT construct(const domain_type& low, const domain_type& up)
- {
- return itl::construct<IntervalT>(
- shift_lower(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), low)
- , shift_upper(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), up )
- );
- }
- };
-
- template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
- struct static_interval<IntervalT, false, PretendedBounds, RepresentedBounds>
- {// !is_discrete<domain_type<IntervalT>>
- typedef typename interval_traits<IntervalT>::domain_type domain_type;
-
- static inline IntervalT construct(const domain_type& low, const domain_type& up)
- {
- BOOST_STATIC_ASSERT((is_discrete<domain_type>::value || PretendedBounds==RepresentedBounds));
- // For domain_types that are not discrete, e.g. interval<float>
- // one of the following must hold: If you call
- // interval<T>::right_open(x,y) then interval<T>::type must be static_right_open
- // interval<T>::left_open(x,y) then interval<T>::type must be static_left_open
- // interval<T>::open(x,y) then interval<T>::type must be static_open
- // interval<T>::closed(x,y) then interval<T>::type must be static_closed
- // Conversion between 'PretendedBounds' and 'RepresentedBounds' is only possible
- // for discrete domain_types.
- return itl::construct<IntervalT>(low, up);
- }
- };
-
 }} // namespace boost itl
 
 #endif

Deleted: sandbox/itl/boost/itl/type_traits/is_universal_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_universal_interval.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
+++ (empty file)
@@ -1,26 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_TYPE_TRAITS_IS_UNIVERSAL_INTERVAL_HPP_JOFA_100327
-#define BOOST_ITL_TYPE_TRAITS_IS_UNIVERSAL_INTERVAL_HPP_JOFA_100327
-
-#include <boost/itl/type_traits/is_interval.hpp>
-
-namespace boost{ namespace itl
-{
-
-template <class Type> struct is_universal_interval
-{
- typedef is_universal_interval<Type> type;
- BOOST_STATIC_CONSTANT(bool, value = false);
-};
-
-}} // namespace boost itl
-
-#endif
-
-

Modified: sandbox/itl/boost/itl_xt/random.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/random.hpp (original)
+++ sandbox/itl/boost/itl_xt/random.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -32,6 +32,7 @@
 #include <functional>
 #include <stdlib.h>
 #include <boost/assert.hpp>
+#include <boost/itl/type_traits/interval_type_default.hpp>
 #include <boost/itl/interval.hpp>
 
 namespace boost{namespace itl

Modified: sandbox/itl/boost/itl_xt/typed_episode.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/typed_episode.hpp (original)
+++ sandbox/itl/boost/itl_xt/typed_episode.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -30,7 +30,8 @@
 #ifndef BOOST_ITL_TYPED_EPISODE_HPP_HPP_JOFA_011015
 #define BOOST_ITL_TYPED_EPISODE_HPP_HPP_JOFA_011015
 
-//JODO #include <boost/itl/interval.hpp>
+#include <boost/itl/type_traits/interval_type_default.hpp>
+//REV #include <boost/itl/interval.hpp>
 #include <boost/itl/right_open_interval.hpp>
 #include <boost/itl_xt/ordered_type.hpp>
 

Modified: sandbox/itl/boost/validate/gentor/gentorprofile.hpp
==============================================================================
--- sandbox/itl/boost/validate/gentor/gentorprofile.hpp (original)
+++ sandbox/itl/boost/validate/gentor/gentorprofile.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -11,8 +11,8 @@
 
 #include <math.h>
 #include <boost/validate/type/nat.hpp>
-#include <boost/itl/interval.hpp>
 #include <boost/itl/type_traits/interval_type_default.hpp>
+#include <boost/itl/interval.hpp>
 
 namespace boost{namespace itl
 {

Modified: sandbox/itl/boost/validate/gentor/rangegentor.hpp
==============================================================================
--- sandbox/itl/boost/validate/gentor/rangegentor.hpp (original)
+++ sandbox/itl/boost/validate/gentor/rangegentor.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -31,7 +31,8 @@
 --------------------------------------------------------------------*/
 #pragma once
 
-#include <boost/itl/interval.hpp>
+#include <boost/itl/type_traits/interval_type_default.hpp>
+//REV #include <boost/itl/interval.hpp>
 #include <boost/itl_xt/gentorit.hpp>
 #include <boost/itl_xt/numbergentor.hpp>
 

Deleted: sandbox/itl/libs/itl/test/test_calls.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_calls.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
+++ (empty file)
@@ -1,49 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------------+
-Function templates to call functions in object oriented or namespace glabal
-versions.
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_TEST_CALLS_H_JOFA_100908
-#define BOOST_ITL_TEST_CALLS_H_JOFA_100908
-
-#include <boost/itl/detail/notate.hpp>
-#include <boost/itl/detail/design_config.hpp>
-
-namespace boost{namespace itl
-{
-
-namespace call{
-
-template<class Type, class CoType>
-bool contains(const Type& object, const CoType& co_object)
-{
-#ifdef ITL_PURE_CONCEPTUAL
- return object.contains(co_object);
-#else
- return itl::contains(object, co_object);
-#endif
-}
-
-template<class Type, class CoType>
-bool within(const Type& object, const CoType& co_object)
-{
-#ifdef ITL_PURE_CONCEPTUAL
- return object.within(co_object);
-#else
- return itl::within(object, co_object);
-#endif
-}
-
-} // namespace call
-
-}} // namespace itl boost
-
-#endif // BOOST_ITL_TEST_CALLS_H_JOFA_100908
-

Modified: sandbox/itl/libs/itl/test/test_value_maker.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_value_maker.hpp (original)
+++ sandbox/itl/libs/itl/test/test_value_maker.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -10,7 +10,6 @@
 
 #include <boost/itl/type_traits/identity_element.hpp>
 #include <boost/itl/interval_bounds.hpp>
-#include "test_calls.hpp"
 
 namespace boost{ namespace itl
 {

Modified: sandbox/itl/libs/validate/example/labat_polygon_/polygon_gentor.hpp
==============================================================================
--- sandbox/itl/libs/validate/example/labat_polygon_/polygon_gentor.hpp (original)
+++ sandbox/itl/libs/validate/example/labat_polygon_/polygon_gentor.hpp 2010-10-14 10:55:00 EDT (Thu, 14 Oct 2010)
@@ -8,7 +8,8 @@
 #ifndef __polygon_gentor_H_JOFA_000724__
 #define __polygon_gentor_H_JOFA_000724__
 
-#include <boost/itl/interval.hpp>
+#include <boost/itl/type_traits/interval_type_default.hpp>
+//REV #include <boost/itl/interval.hpp>
 #include <boost/itl_xt/gentorit.hpp>
 #include <boost/itl_xt/list.hpp>
 


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