1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2010-2010: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef BOOST_ICL_TYPE_TRAITS_IS_INTERVAL_HPP_JOFA_100327
9 #define BOOST_ICL_TYPE_TRAITS_IS_INTERVAL_HPP_JOFA_100327
11 #include <boost/mpl/or.hpp>
12 #include <boost/icl/interval_bounds.hpp>
13 #include <boost/icl/interval_traits.hpp>
15 namespace boost{ namespace icl
19 struct interval_bound_type
21 typedef interval_bound_type type;
22 BOOST_STATIC_CONSTANT(bound_type, value = (interval_bounds::undefined));
25 template <class Type> struct is_interval
27 typedef is_interval<Type> type;
28 BOOST_STATIC_CONSTANT(bool,
29 value = ((interval_bound_type<Type>::value) < interval_bounds::undefined));
33 template <class Type> struct has_static_bounds
35 typedef has_static_bounds<Type> type;
36 BOOST_STATIC_CONSTANT(bool,
37 value = ((interval_bound_type<Type>::value) < interval_bounds::dynamic));
40 template <class Type> struct has_dynamic_bounds
42 typedef has_dynamic_bounds<Type> type;
43 BOOST_STATIC_CONSTANT(bool,
44 value = (interval_bound_type<Type>::value == interval_bounds::dynamic));
47 template <class Type> struct has_asymmetric_bounds
49 typedef has_asymmetric_bounds<Type> type;
50 BOOST_STATIC_CONSTANT(bound_type, bounds = (interval_bound_type<Type>::value));
51 BOOST_STATIC_CONSTANT(bool,
52 value = ( bounds == interval_bounds::static_left_open
53 || bounds == interval_bounds::static_right_open));
56 template <class Type> struct has_symmetric_bounds
58 typedef has_symmetric_bounds<Type> type;
59 BOOST_STATIC_CONSTANT(bound_type, bounds = (interval_bound_type<Type>::value));
60 BOOST_STATIC_CONSTANT(bool,
61 value = ( bounds == interval_bounds::static_closed
62 || bounds == interval_bounds::static_open));
65 //------------------------------------------------------------------------------
66 template <class Type> struct is_discrete_static
68 typedef is_discrete_static type;
69 typedef typename interval_traits<Type>::domain_type domain_type;
70 BOOST_STATIC_CONSTANT(bool,
71 value = (mpl::and_< has_static_bounds<Type>
72 , is_discrete<domain_type> >::value) );
75 //------------------------------------------------------------------------------
76 template <class Type> struct is_continuous_static
78 typedef is_continuous_static type;
79 typedef typename interval_traits<Type>::domain_type domain_type;
80 BOOST_STATIC_CONSTANT(bool,
81 value = (mpl::and_< has_static_bounds<Type>
82 , is_continuous<domain_type>
83 , has_asymmetric_bounds<Type> >::value) );
86 //------------------------------------------------------------------------------
87 template <class Type> struct is_static_right_open
89 typedef is_static_right_open<Type> type;
90 BOOST_STATIC_CONSTANT(bool,
91 value = (interval_bound_type<Type>::value == interval_bounds::static_right_open));
94 template <class Type> struct is_static_left_open
96 typedef is_static_left_open<Type> type;
97 BOOST_STATIC_CONSTANT(bool,
98 value = (interval_bound_type<Type>::value == interval_bounds::static_left_open));
101 template <class Type> struct is_static_open
103 typedef is_static_open<Type> type;
104 BOOST_STATIC_CONSTANT(bool,
105 value = (interval_bound_type<Type>::value == interval_bounds::static_open));
108 template <class Type> struct is_static_closed
110 typedef is_static_closed<Type> type;
111 BOOST_STATIC_CONSTANT(bool,
112 value = (interval_bound_type<Type>::value == interval_bounds::static_closed));
115 template <class Type> struct is_discrete_static_closed
117 typedef is_static_closed<Type> type;
118 typedef typename interval_traits<Type>::domain_type domain_type;
120 BOOST_STATIC_CONSTANT( bool,
121 value = (mpl::and_< is_static_closed<Type>
122 , is_discrete<domain_type> >::value) );
125 template <class Type> struct is_discrete_static_open
127 typedef is_static_closed<Type> type;
128 typedef typename interval_traits<Type>::domain_type domain_type;
130 BOOST_STATIC_CONSTANT( bool,
131 value = (mpl::and_< is_static_open<Type>
132 , is_discrete<domain_type> >::value) );
135 //------------------------------------------------------------------------------
136 template <class Type> struct is_continuous_right_open
138 typedef is_continuous_right_open<Type> type;
139 typedef typename interval_traits<Type>::domain_type domain_type;
140 BOOST_STATIC_CONSTANT(bool,
141 value = (mpl::and_<is_static_right_open<Type>, is_continuous<domain_type> >::value));
144 template <class Type> struct is_continuous_left_open
146 typedef is_continuous_left_open<Type> type;
147 typedef typename interval_traits<Type>::domain_type domain_type;
148 BOOST_STATIC_CONSTANT(bool,
149 value = (mpl::and_<is_static_left_open<Type>, is_continuous<domain_type> >::value));
152 //------------------------------------------------------------------------------
154 template <class Type> struct is_singelizable
156 typedef is_singelizable type;
157 typedef typename interval_traits<Type>::domain_type domain_type;
159 BOOST_STATIC_CONSTANT(bool,
161 (mpl::or_< has_dynamic_bounds<Type>
162 , is_discrete<domain_type>
167 }} // namespace boost icl