Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50719 - in sandbox/itl/boost/itl: . type_traits
From: afojgo_at_[hidden]
Date: 2009-01-22 04:32:15


Author: jofaber
Date: 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
New Revision: 50719
URL: http://svn.boost.org/trac/boost/changeset/50719

Log:
Refactored. Added is_intra/inter_combinable<T,U> for better overload resolution.
Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/interval_map.hpp | 10 ++
   sandbox/itl/boost/itl/interval_set.hpp | 5 +
   sandbox/itl/boost/itl/map.hpp | 5 +
   sandbox/itl/boost/itl/operators.hpp | 4
   sandbox/itl/boost/itl/separate_interval_set.hpp | 5 +
   sandbox/itl/boost/itl/set.hpp | 5 +
   sandbox/itl/boost/itl/split_interval_map.hpp | 10 ++
   sandbox/itl/boost/itl/split_interval_set.hpp | 5 +
   sandbox/itl/boost/itl/type_traits/is_combinable.hpp | 111 ++++++++++++++++++++++++++++++++++++---
   sandbox/itl/boost/itl/type_traits/is_interval_container.hpp | 6 +
   sandbox/itl/boost/itl/type_traits/is_map.hpp | 6 +
   11 files changed, 148 insertions(+), 24 deletions(-)

Modified: sandbox/itl/boost/itl/interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_map.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -1011,11 +1011,17 @@
 
 template <class KeyT, class DataT, class Traits>
 struct is_map<itl::interval_map<KeyT,DataT,Traits> >
-{ enum{value = true}; };
+{
+ typedef is_map<itl::interval_map<KeyT,DataT,Traits> > type;
+ enum{value = true};
+};
 
 template <class KeyT, class DataT, class Traits>
 struct is_interval_container<itl::interval_map<KeyT,DataT,Traits> >
-{ enum{value = true}; };
+{
+ typedef is_interval_container<itl::interval_map<KeyT,DataT,Traits> > type;
+ enum{value = true};
+};
 
 template <class KeyT, class DataT, class Traits>
 struct is_interval_splitter<itl::interval_map<KeyT,DataT,Traits> >

Modified: sandbox/itl/boost/itl/interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_set.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -386,7 +386,10 @@
 
 template <class Type>
 struct is_interval_container<itl::interval_set<Type> >
-{ enum{value = true}; };
+{
+ typedef is_interval_container<itl::interval_set<Type> > type;
+ enum{value = true};
+};
 
 template <class Type>
 struct is_interval_splitter<itl::interval_set<Type> >

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -676,7 +676,10 @@
 
     template <class DomainT, class CodomainT, class Traits>
     struct is_interval_container<itl::map<DomainT,CodomainT,Traits> >
- { enum{value = true}; };
+ {
+ typedef is_interval_container<itl::map<DomainT,CodomainT,Traits> > type;
+ enum{value = true};
+ };
 
     template <class DomainT, class CodomainT, class Traits>
     struct is_interval_splitter<itl::map<DomainT,CodomainT,Traits> >

Modified: sandbox/itl/boost/itl/operators.hpp
==============================================================================
--- sandbox/itl/boost/itl/operators.hpp (original)
+++ sandbox/itl/boost/itl/operators.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -56,12 +56,12 @@
 // Addability
 //------------------------------------------------------------------------------
 template<class ObjectT, class OperandT>
-typename boost::enable_if<is_interval_map_companion<ObjectT, OperandT>, ObjectT>::type
+typename boost::enable_if<is_intra_combinable<ObjectT, OperandT>, ObjectT>::type
 operator + (const ObjectT& object, const OperandT& operand)
 { return ObjectT(object) += operand; }
 
 template<class ObjectT, class OperandT>
-typename boost::enable_if<is_interval_map_companion<ObjectT, OperandT>, ObjectT>::type
+typename boost::enable_if<is_intra_combinable<ObjectT, OperandT>, ObjectT>::type
 operator + (const OperandT& operand, const ObjectT& object)
 { return ObjectT(object) += operand; }
 

Modified: sandbox/itl/boost/itl/separate_interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/separate_interval_set.hpp (original)
+++ sandbox/itl/boost/itl/separate_interval_set.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -265,7 +265,10 @@
 
 template <class Type>
 struct is_interval_container<itl::separate_interval_set<Type> >
-{ enum{value = true}; };
+{
+ typedef is_interval_container<itl::separate_interval_set<Type> > type;
+ enum{value = true};
+};
 
 template <class Type>
 struct is_interval_separator<itl::separate_interval_set<Type> >

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -457,7 +457,10 @@
 
     template <class Type>
     struct is_interval_container<itl::set<Type> >
- { enum{value = true}; };
+ {
+ typedef is_interval_container<itl::set<Type> > type;
+ enum{value = true};
+ };
 
     template <class Type>
     struct is_interval_splitter<itl::set<Type> >

Modified: sandbox/itl/boost/itl/split_interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/split_interval_map.hpp (original)
+++ sandbox/itl/boost/itl/split_interval_map.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -781,11 +781,17 @@
 
 template <class KeyT, class DataT, class Traits>
 struct is_map<itl::split_interval_map<KeyT,DataT,Traits> >
-{ enum{value = true}; };
+{
+ typedef is_map<itl::split_interval_map<KeyT,DataT,Traits> > type;
+ enum{value = true};
+};
 
 template <class KeyT, class DataT, class Traits>
 struct is_interval_container<itl::split_interval_map<KeyT,DataT,Traits> >
-{ enum{value = true}; };
+{
+ typedef is_interval_container<itl::split_interval_map<KeyT,DataT,Traits> > type;
+ enum{value = true};
+};
 
 template <class KeyT, class DataT, class Traits>
 struct is_interval_splitter<itl::split_interval_map<KeyT,DataT,Traits> >

Modified: sandbox/itl/boost/itl/split_interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/split_interval_set.hpp (original)
+++ sandbox/itl/boost/itl/split_interval_set.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -425,7 +425,10 @@
 
     template <class Type>
     struct is_interval_container<itl::split_interval_set<Type> >
- { enum{value = true}; };
+ {
+ typedef is_interval_container<itl::split_interval_set<Type> > type;
+ enum{value = true};
+ };
 
     template <class Type>
     struct is_interval_splitter<itl::split_interval_set<Type> >

Modified: sandbox/itl/boost/itl/type_traits/is_combinable.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_combinable.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_combinable.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -11,6 +11,8 @@
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/itl/type_traits/is_interval_splitter.hpp>
 
@@ -52,7 +54,24 @@
         enum{ value = false };
 };
 
+//==============================================================================
+//==============================================================================
+template<class Type>
+struct is_interval_map
+{
+ typedef is_interval_map<Type> type;
+ enum{value = mpl::and_<is_interval_container<Type>, is_map<Type> >::value};
+};
 
+template<class Type>
+struct is_interval_set
+{
+ typedef is_interval_set<Type> type;
+ enum{ value = mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_interval_map<Type> >
+ >::value
+ };
+};
 
 
 //------------------------------------------------------------------------------
@@ -100,7 +119,7 @@
 //------------------------------------------------------------------------------
 // is_interval_set_companion
 //------------------------------------------------------------------------------
-template<class Type, class CompanionT> struct is_interval_set_companion;
+template<class GuideT, class CompanionT> struct is_interval_set_companion;
 
 template
 <
@@ -111,8 +130,11 @@
 struct is_interval_set_companion<IntervalSet1<Dom,Cmp,Itv,Alc>,
                                      IntervalSet2<Dom,Cmp,Itv,Alc> >
 {
- enum{ value = IntervalSet2<Dom,Cmp,Itv,Alc>::fineness
- < IntervalSet1<Dom,Cmp,Itv,Alc>::fineness };
+ typedef IntervalSet1<Dom,Cmp,Itv,Alc> GuideT;
+ typedef IntervalSet2<Dom,Cmp,Itv,Alc> CompanionT;
+ typedef is_interval_set_companion<GuideT,CompanionT> type;
+
+ enum{ value = CompanionT::fineness < GuideT::fineness };
 };
 
 // Every IntervalSet can be a companion of every IntervalMap for
@@ -127,16 +149,25 @@
>
 struct is_interval_set_companion<IntervalMap<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc>,
                                      IntervalSet<Dom, Cmp, Itv,Alc> >
-{ enum{ value = true }; };
+{
+ typedef IntervalMap<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc> GuideT;
+ typedef IntervalSet<Dom, Cmp, Itv,Alc> CompanionT;
+ typedef is_interval_set_companion<GuideT,CompanionT> type;
 
-template<class Type, class CompanionT> struct is_interval_set_companion
-{ enum{ value = is_interval_set_derivative<Type,CompanionT>::value }; };
+ enum{ value = true };
+};
+
+template<class GuideT, class CompanionT> struct is_interval_set_companion
+{
+ typedef is_interval_set_companion<GuideT,CompanionT> type;
+ enum{ value = is_interval_set_derivative<GuideT,CompanionT>::value };
+};
 
 
 //------------------------------------------------------------------------------
 // is_interval_map_companion
 //------------------------------------------------------------------------------
-template<class Type, class CompanionT> struct is_interval_map_companion;
+template<class GuideT, class CompanionT> struct is_interval_map_companion;
 
 template
 <
@@ -150,14 +181,72 @@
 struct is_interval_map_companion<IntervalMap1<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc>,
                                      IntervalMap2<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc> >
 {
- enum{ value = IntervalMap2<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc>::fineness
- < IntervalMap1<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc>::fineness };
+ typedef IntervalMap1<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc> GuideT;
+ typedef IntervalMap2<Dom,Cod,Trt,Cmp,Cmb,Sec,Itv,Alc> CompanionT;
+ typedef is_interval_map_companion<GuideT,CompanionT> type;
+
+ enum{ value = CompanionT::fineness < GuideT::fineness };
 };
 
-template<class Type, class CompanionT> struct is_interval_map_companion
-{ enum{ value = is_interval_map_derivative<Type,CompanionT>::value }; };
+template<class GuideT, class CompanionT> struct is_interval_map_companion
+{
+ typedef is_interval_map_companion<GuideT,CompanionT> type;
+ enum{ value = is_interval_map_derivative<GuideT,CompanionT>::value };
+};
 
 
+//------------------------------------------------------------------------------
+// is_interval_{set,map}_combinable
+//------------------------------------------------------------------------------
+template<class GuideT, class CompanionT>
+struct is_interval_set_combinable
+{
+ typedef is_interval_set_combinable<GuideT,CompanionT> type;
+ enum{ value = mpl::and_< is_interval_set<GuideT>
+ , is_interval_set_companion<GuideT, CompanionT>
+ >::value
+ };
+};
+
+template<class GuideT, class CompanionT>
+struct is_interval_map_combinable
+{
+ typedef is_interval_map_combinable<GuideT,CompanionT> type;
+ enum{ value = mpl::and_< is_interval_map<GuideT>
+ , is_interval_map_companion<GuideT, CompanionT>
+ >::value
+ };
+};
+
+template<class GuideT, class CompanionT>
+struct is_intra_combinable
+{
+ typedef is_intra_combinable<GuideT,CompanionT> type;
+ enum
+ { value = mpl::or_
+ <
+ mpl::and_< is_interval_map<GuideT>
+ , is_interval_map_companion<GuideT, CompanionT> >
+ , mpl::and_< is_interval_set<GuideT>
+ , is_interval_set_companion<GuideT, CompanionT> >
+ >::value
+ };
+};
+
+template<class GuideT, class CompanionT>
+struct is_inter_combinable
+{
+ typedef is_inter_combinable<GuideT,CompanionT> type;
+ enum
+ { value = mpl::and_
+ < is_interval_map<GuideT>
+ , mpl::or_< is_interval_map_companion<GuideT, CompanionT>
+ , is_interval_set_companion<GuideT, CompanionT>
+ >
+ >::value
+ };
+};
+
 
 }} // namespace itl boost
 

Modified: sandbox/itl/boost/itl/type_traits/is_interval_container.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_interval_container.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_interval_container.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -12,7 +12,11 @@
 {
     template <class Type> struct is_interval_container;
 
- template <class Type> struct is_interval_container{ enum {value = false}; };
+ template <class Type> struct is_interval_container
+ {
+ typedef is_interval_container<Type> type;
+ enum {value = false};
+ };
 
 }} // namespace boost itl
 

Modified: sandbox/itl/boost/itl/type_traits/is_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_map.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_map.hpp 2009-01-22 04:32:13 EST (Thu, 22 Jan 2009)
@@ -12,7 +12,11 @@
 {
     template <class Type> struct is_map;
 
- template <class Type> struct is_map{ enum {value = false}; };
+ template <class Type> struct is_map
+ {
+ typedef is_map<Type> type;
+ enum {value = false};
+ };
 
 }} // 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