File indexing completed on 2025-01-18 09:38:22
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330
0009 #define BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330
0010
0011 #include <boost/utility/enable_if.hpp>
0012 #include <boost/icl/detail/design_config.hpp>
0013
0014 namespace boost{namespace icl
0015 {
0016
0017 typedef unsigned char bound_type;
0018
0019 class interval_bounds
0020 {
0021 public:
0022 BOOST_STATIC_CONSTANT(bound_type, static_open = 0);
0023 BOOST_STATIC_CONSTANT(bound_type, static_left_open = 1);
0024 BOOST_STATIC_CONSTANT(bound_type, static_right_open = 2);
0025 BOOST_STATIC_CONSTANT(bound_type, static_closed = 3);
0026 BOOST_STATIC_CONSTANT(bound_type, dynamic = 4);
0027 BOOST_STATIC_CONSTANT(bound_type, undefined = 5);
0028
0029 BOOST_STATIC_CONSTANT(bound_type, _open = 0);
0030 BOOST_STATIC_CONSTANT(bound_type, _left_open = 1);
0031 BOOST_STATIC_CONSTANT(bound_type, _right_open = 2);
0032 BOOST_STATIC_CONSTANT(bound_type, _closed = 3);
0033
0034 BOOST_STATIC_CONSTANT(bound_type, _right = 1);
0035 BOOST_STATIC_CONSTANT(bound_type, _left = 2);
0036 BOOST_STATIC_CONSTANT(bound_type, _all = 3);
0037
0038 public:
0039 interval_bounds():_bits(){}
0040 explicit interval_bounds(bound_type bounds): _bits(bounds){}
0041 interval_bounds all ()const { return interval_bounds(_bits & _all ); }
0042 interval_bounds left ()const { return interval_bounds(_bits & _left ); }
0043 interval_bounds right()const { return interval_bounds(_bits & _right); }
0044 interval_bounds reverse_left ()const { return interval_bounds((bound_type(~_bits)>>1) & _right); }
0045 interval_bounds reverse_right()const { return interval_bounds((bound_type(~_bits)<<1) & _left ); }
0046
0047 bound_type bits()const{ return _bits; }
0048
0049 static interval_bounds open() { return interval_bounds(_open); }
0050 static interval_bounds left_open() { return interval_bounds(_left_open); }
0051 static interval_bounds right_open(){ return interval_bounds(_right_open);}
0052 static interval_bounds closed() { return interval_bounds(_closed); }
0053
0054 public:
0055 bound_type _bits;
0056 };
0057
0058
0059 template<class DomainT>
0060 class bounded_value
0061 {
0062 public:
0063 typedef DomainT domain_type;
0064 typedef bounded_value<DomainT> type;
0065 public:
0066 bounded_value(const domain_type& value, interval_bounds bound)
0067 : _value(value), _bound(bound) {}
0068
0069 domain_type value()const { return _value; }
0070 interval_bounds bound()const { return _bound; }
0071
0072 private:
0073 domain_type _value;
0074 interval_bounds _bound;
0075 };
0076
0077 }}
0078
0079 #endif
0080