Project revived from Feb2017
[EroSomnia.git] / deps / boost_1_63_0 / boost / icl / interval_bounds.hpp
blobedf16d01ec2b418c9d47af5b8907152e62c31570
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_INTERVAL_BOUNDS_HPP_JOFA_100330
9 #define BOOST_ICL_INTERVAL_BOUNDS_HPP_JOFA_100330
11 #include <boost/utility/enable_if.hpp>
12 #include <boost/icl/detail/design_config.hpp>
14 namespace boost{namespace icl
17 typedef unsigned char bound_type;
19 class interval_bounds
21 public:
22 BOOST_STATIC_CONSTANT(bound_type, static_open = 0);
23 BOOST_STATIC_CONSTANT(bound_type, static_left_open = 1);
24 BOOST_STATIC_CONSTANT(bound_type, static_right_open = 2);
25 BOOST_STATIC_CONSTANT(bound_type, static_closed = 3);
26 BOOST_STATIC_CONSTANT(bound_type, dynamic = 4);
27 BOOST_STATIC_CONSTANT(bound_type, undefined = 5);
29 BOOST_STATIC_CONSTANT(bound_type, _open = 0);
30 BOOST_STATIC_CONSTANT(bound_type, _left_open = 1);
31 BOOST_STATIC_CONSTANT(bound_type, _right_open = 2);
32 BOOST_STATIC_CONSTANT(bound_type, _closed = 3);
34 BOOST_STATIC_CONSTANT(bound_type, _right = 1);
35 BOOST_STATIC_CONSTANT(bound_type, _left = 2);
36 BOOST_STATIC_CONSTANT(bound_type, _all = 3);
38 public:
39 interval_bounds():_bits(){}
40 explicit interval_bounds(bound_type bounds): _bits(bounds){}
41 interval_bounds all ()const { return interval_bounds(_bits & _all ); }
42 interval_bounds left ()const { return interval_bounds(_bits & _left ); }
43 interval_bounds right()const { return interval_bounds(_bits & _right); }
44 interval_bounds reverse_left ()const { return interval_bounds((~_bits>>1) & _right); }
45 interval_bounds reverse_right()const { return interval_bounds((~_bits<<1) & _left ); }
47 bound_type bits()const{ return _bits; }
49 static interval_bounds open() { return interval_bounds(_open); }
50 static interval_bounds left_open() { return interval_bounds(_left_open); }
51 static interval_bounds right_open(){ return interval_bounds(_right_open);}
52 static interval_bounds closed() { return interval_bounds(_closed); }
54 public:
55 bound_type _bits;
59 template<class DomainT>
60 class bounded_value
62 public:
63 typedef DomainT domain_type;
64 typedef bounded_value<DomainT> type;
65 public:
66 bounded_value(const domain_type& value, interval_bounds bound)
67 : _value(value), _bound(bound) {}
69 domain_type value()const { return _value; }
70 interval_bounds bound()const { return _bound; }
72 private:
73 domain_type _value;
74 interval_bounds _bound;
77 }} // namespace icl boost
79 #endif