Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65644 - in sandbox/itl/boost/itl: . concept type_traits
From: afojgo_at_[hidden]
Date: 2010-09-27 18:07:10


Author: jofaber
Date: 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
New Revision: 65644
URL: http://svn.boost.org/trac/boost/changeset/65644

Log:
Refactoring: Replaced T() with construct functions. Improved is_continuous meta function. Stable{msvc-9.0, gcc-3.4.4}
Text files modified:
   sandbox/itl/boost/itl/closed_interval.hpp | 2 +-
   sandbox/itl/boost/itl/concept/interval.hpp | 40 +++++++++++++++++++---------------------
   sandbox/itl/boost/itl/concept/interval_set_value.hpp | 1 +
   sandbox/itl/boost/itl/discrete_interval.hpp | 8 ++++----
   sandbox/itl/boost/itl/gregorian.hpp | 7 +++++++
   sandbox/itl/boost/itl/ptime.hpp | 8 ++++++++
   sandbox/itl/boost/itl/type_traits/is_continuous.hpp | 39 +++------------------------------------
   7 files changed, 43 insertions(+), 62 deletions(-)

Modified: sandbox/itl/boost/itl/closed_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/closed_interval.hpp (original)
+++ sandbox/itl/boost/itl/closed_interval.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -34,7 +34,7 @@
     {
         BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
         BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));//JODO is_discrete?
+ BOOST_STATIC_ASSERT((itl::is_discrete<DomainT>::value));
     }
 
     //NOTE: Compiler generated copy constructor is used

Modified: sandbox/itl/boost/itl/concept/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/interval.hpp (original)
+++ sandbox/itl/boost/itl/concept/interval.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -60,7 +60,7 @@
 template<class Type>
 typename enable_if
 <
- mpl::and_< is_static_rightopen<Type>
+ mpl::and_< is_static_rightopen<Type>
              , is_discrete<typename interval_traits<Type>::domain_type> >
   , Type
>::type
@@ -73,35 +73,35 @@
 template<class Type>
 typename enable_if
 <
- mpl::and_< is_static_leftopen<Type>
+ mpl::and_< is_static_leftopen<Type>
              , is_discrete<typename interval_traits<Type>::domain_type> >
   , Type
>::type
 construct(const typename interval_traits<Type>::domain_type& value)
 {
     //ASSERT: This always creates an interval with exactly one element
- BOOST_ASSERT((std::numeric_limits<Type>::min)() < value);
+ BOOST_ASSERT((std::numeric_limits<Type>::min)() < value);
     return interval_traits<Type>::construct(itl::pred(value), value);
 }
 
 template<class Type>
 typename enable_if
 <
- mpl::and_< is_static_open<Type>
+ mpl::and_< is_static_open<Type>
              , is_discrete<typename interval_traits<Type>::domain_type> >
   , Type
>::type
 construct(const typename interval_traits<Type>::domain_type& value)
 {
     //ASSERT: This always creates an interval with exactly one element
- BOOST_ASSERT((std::numeric_limits<Type>::min)() < value);
+ BOOST_ASSERT((std::numeric_limits<Type>::min)() < value);
     return interval_traits<Type>::construct(itl::pred(value), itl::succ(value));
 }
 
 template<class Type>
 typename enable_if
 <
- mpl::and_< is_static_closed<Type>
+ mpl::and_< is_static_closed<Type>
              , is_discrete<typename interval_traits<Type>::domain_type> >
   , Type
>::type
@@ -125,7 +125,7 @@
 typename enable_if<is_asymmetric_interval<Type>, Type>::type
 construct(const typename interval_traits<Type>::domain_type& low,
           const typename interval_traits<Type>::domain_type& up,
- interval_bounds bounds = interval_bounds::right_open()) //JODO separate static intervals to avoid dependency
+ interval_bounds bounds = interval_bounds::right_open())
 {
     return interval_traits<Type>::construct(low, up);
 }
@@ -710,9 +710,8 @@
     else if(itl::is_empty(left))
         return right;
 
- //JODO return construct
     return
- Type
+ construct<Type>
         (
             (std::min)(lower(left), lower(right), interval_traits<Type>::domain_compare()),
             (std::max)(upper(left), upper(right), interval_traits<Type>::domain_compare())
@@ -735,7 +734,6 @@
     else if(itl::is_empty(left))
         return right;
 
- //JODO return construct<Type,std::less>
     return dynamic_interval_traits<Type>::construct_bounded
             (
                 lower_min(left, right),
@@ -762,8 +760,8 @@
 {
     if(exclusive_less(left_minuend, right))
         return right;
- //JODO return construct(left_minuend.upper(), right.upper());
- return Type(upper(left_minuend), upper(right));
+
+ return construct<Type>(upper(left_minuend), upper(right));
 }
 
 template<class Type>
@@ -800,8 +798,7 @@
 {
     if(exclusive_less(left, right_minuend))
         return left;
- return Type(lower(left), lower(right_minuend));
- //JODO return construct(left.lower(), right_minuend.lower());
+ return construct<Type>(lower(left), lower(right_minuend));
 }
 
 template<class Type>
@@ -815,10 +812,9 @@
 typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
 right_subtract(Type left, const Type& right_minuend)
 {
- //JODO s.o.
     if(exclusive_less(left, right_minuend))
         return left;
- //JODO return construct<Type,std::less>(left.lower(), right_minuend.lower(),
+
     return dynamic_interval_traits<Type>::construct_bounded
             ( bounded_lower(left), reverse_bounded_lower(right_minuend) );
 }
@@ -833,11 +829,14 @@
 operator & (Type left, const Type& right)
 {
     if(itl::is_empty(left) || itl::is_empty(right))
- return Type(); //JODO return neutron<Type>::value; neutron for new interval_types.
+ return neutron<Type>::value();
     else
         return
- Type((std::max)(itl::lower(left), itl::lower(right), interval_traits<Type>::domain_compare()),
- (std::min)(itl::upper(left), itl::upper(right), interval_traits<Type>::domain_compare()));
+ construct<Type>
+ (
+ (std::max)(itl::lower(left), itl::lower(right), interval_traits<Type>::domain_compare()),
+ (std::min)(itl::upper(left), itl::upper(right), interval_traits<Type>::domain_compare())
+ );
 }
 
 template<class Type>
@@ -852,9 +851,8 @@
 operator & (Type left, const Type& right)
 {
     if(itl::is_empty(left) || itl::is_empty(right))
- return Type(); //JODO return neutron<Type>::value; neutron for new interval_types.
+ return neutron<Type>::value();
     else
- //JODO return construct<Type,std::less>
         return dynamic_interval_traits<Type>::construct_bounded
                 (
                     lower_max(left, right),

Modified: sandbox/itl/boost/itl/concept/interval_set_value.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/interval_set_value.hpp (original)
+++ sandbox/itl/boost/itl/concept/interval_set_value.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -8,6 +8,7 @@
 #ifndef BOOST_ITL_CONCEPT_INTERVAL_SET_VALUE_HPP_JOFA_100924
 #define BOOST_ITL_CONCEPT_INTERVAL_SET_VALUE_HPP_JOFA_100924
 
+#include <boost/utility/enable_if.hpp>
 #include <boost/itl/type_traits/is_interval_container.hpp>
 
 namespace boost{ namespace itl

Modified: sandbox/itl/boost/itl/discrete_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/discrete_interval.hpp (original)
+++ sandbox/itl/boost/itl/discrete_interval.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -41,7 +41,7 @@
     {
         BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
         BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value)); //JODO
+ BOOST_STATIC_ASSERT((itl::is_discrete<DomainT>::value));
     }
 
     //NOTE: Compiler generated copy constructor is used
@@ -52,7 +52,7 @@
     {
         BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
         BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- //JODO BOOST_STATIC_ASSERT((itl::is_continuous<DomainT>::value)); //JODO
+ BOOST_STATIC_ASSERT((itl::is_discrete<DomainT>::value));
     }
 
     /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
@@ -63,7 +63,7 @@
     {
         BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
         BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- //JODO BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
+ BOOST_STATIC_ASSERT((itl::is_discrete<DomainT>::value));
     }
 
     domain_type lower()const { return _lwb; }
@@ -158,7 +158,7 @@
 struct is_discrete_interval<discrete_interval<DomainT,Compare> >
 {
     typedef is_discrete_interval<discrete_interval<DomainT,Compare> > type;
- BOOST_STATIC_CONSTANT(bool, value = !is_continuous<DomainT>::value); //JODO
+ BOOST_STATIC_CONSTANT(bool, value = is_discrete<DomainT>::value);
 };
 
 template <class DomainT, ITL_COMPARE Compare>

Modified: sandbox/itl/boost/itl/gregorian.hpp
==============================================================================
--- sandbox/itl/boost/itl/gregorian.hpp (original)
+++ sandbox/itl/boost/itl/gregorian.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -25,11 +25,18 @@
 #endif
 
 #include <boost/itl/type_traits/neutron.hpp>
+#include <boost/itl/type_traits/is_discrete.hpp>
 #include <boost/itl/type_traits/difference_type_of.hpp>
 #include <boost/itl/type_traits/size_type_of.hpp>
 
 namespace boost{namespace itl
 {
+ template<> struct is_discrete<boost::gregorian::date>
+ {
+ typedef is_discrete type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+
     template<>
     inline boost::gregorian::date neutron<boost::gregorian::date>::value()
     {

Modified: sandbox/itl/boost/itl/ptime.hpp
==============================================================================
--- sandbox/itl/boost/itl/ptime.hpp (original)
+++ sandbox/itl/boost/itl/ptime.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <string>
 #include <sstream>
+#include <boost/config.hpp>
 #include <boost/detail/workaround.hpp>
 
 #ifdef BOOST_MSVC
@@ -34,9 +35,16 @@
 #include <boost/itl/type_traits/neutron.hpp>
 #include <boost/itl/type_traits/difference_type_of.hpp>
 #include <boost/itl/type_traits/size_type_of.hpp>
+#include <boost/itl/type_traits/is_discrete.hpp>
 
 namespace boost{namespace itl
 {
+ template<> struct is_discrete<boost::posix_time::ptime>
+ {
+ typedef is_discrete type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+
     template<>
     inline boost::posix_time::ptime neutron<boost::posix_time::ptime>::value()
     {

Modified: sandbox/itl/boost/itl/type_traits/is_continuous.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_continuous.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_continuous.hpp 2010-09-27 18:07:06 EDT (Mon, 27 Sep 2010)
@@ -14,44 +14,11 @@
 
 namespace boost{ namespace itl
 {
- //JODO Dies waere eigentlich besser, funktioniert aber nicht
- //template <class Type> struct is_continuous
- //{
- // typedef is_continuous type;
- // BOOST_STATIC_CONSTANT(bool,
- // value = mpl::not_<is_discrete<Type> >::value);
- //};
-
- template <class Type> struct is_continuous;
-
- template<> struct is_continuous<float>
- {
- typedef is_continuous<float> type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
- template<> struct is_continuous<double>
- {
- typedef is_continuous<double> type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
- template<> struct is_continuous<long double>
- {
- typedef is_continuous<long double> type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
- template<> struct is_continuous<std::string>
- {
- typedef is_continuous<std::string> type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
-
     template <class Type> struct is_continuous
     {
- typedef is_continuous<Type> type;
- BOOST_STATIC_CONSTANT(bool, value = false);
+ typedef is_continuous type;
+ BOOST_STATIC_CONSTANT(bool,
+ value = mpl::not_<is_discrete<Type> >::value);
     };
 
 }} // namespace boost itl


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