File indexing completed on 2025-01-18 09:38:22
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_ICL_LEFT_OPEN_INTERVAL_HPP_JOFA_100930
0009 #define BOOST_ICL_LEFT_OPEN_INTERVAL_HPP_JOFA_100930
0010
0011 #include <functional>
0012 #include <boost/static_assert.hpp>
0013 #include <boost/concept/assert.hpp>
0014 #include <boost/icl/detail/concept_check.hpp>
0015 #include <boost/icl/concept/interval.hpp>
0016 #include <boost/icl/type_traits/succ_pred.hpp>
0017 #include <boost/icl/type_traits/value_size.hpp>
0018 #include <boost/icl/type_traits/type_to_string.hpp>
0019
0020 namespace boost{namespace icl
0021 {
0022
0023 template <class DomainT,
0024 ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT)>
0025 class left_open_interval
0026 {
0027 public:
0028 typedef left_open_interval<DomainT,Compare> type;
0029 typedef DomainT domain_type;
0030 typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
0031
0032 public:
0033
0034
0035
0036
0037 left_open_interval()
0038 : _lwb(identity_element<DomainT>::value()), _upb(identity_element<DomainT>::value())
0039 {
0040 BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
0041 BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
0042 }
0043
0044
0045
0046
0047 explicit left_open_interval(const DomainT& val)
0048 : _lwb(predecessor<DomainT,domain_compare>::apply(val)), _upb(val)
0049 {
0050 BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
0051 BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
0052
0053
0054 BOOST_STATIC_ASSERT((icl::is_discrete<DomainT>::value));
0055 BOOST_ASSERT((numeric_minimum<DomainT, domain_compare, is_numeric<DomainT>::value >
0056 ::is_less_than(val) ));
0057 }
0058
0059
0060 left_open_interval(const DomainT& low, const DomainT& up) :
0061 _lwb(low), _upb(up)
0062 {
0063 BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
0064 BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
0065 }
0066
0067 DomainT lower()const{ return _lwb; }
0068 DomainT upper()const{ return _upb; }
0069
0070 private:
0071 DomainT _lwb;
0072 DomainT _upb;
0073 };
0074
0075
0076
0077
0078 template<class DomainT, ICL_COMPARE Compare>
0079 struct interval_traits< icl::left_open_interval<DomainT, Compare> >
0080 {
0081 typedef DomainT domain_type;
0082 typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
0083 typedef icl::left_open_interval<DomainT, Compare> interval_type;
0084
0085 static interval_type construct(const domain_type& lo, const domain_type& up)
0086 {
0087 return interval_type(lo, up);
0088 }
0089
0090 static domain_type lower(const interval_type& inter_val){ return inter_val.lower(); }
0091 static domain_type upper(const interval_type& inter_val){ return inter_val.upper(); }
0092 };
0093
0094
0095
0096
0097
0098 template <class DomainT, ICL_COMPARE Compare>
0099 struct interval_bound_type< left_open_interval<DomainT,Compare> >
0100 {
0101 typedef interval_bound_type type;
0102 BOOST_STATIC_CONSTANT(bound_type, value = interval_bounds::static_left_open);
0103 };
0104
0105 template <class DomainT, ICL_COMPARE Compare>
0106 struct type_to_string<icl::left_open_interval<DomainT,Compare> >
0107 {
0108 static std::string apply()
0109 { return "(I]<"+ type_to_string<DomainT>::apply() +">"; }
0110 };
0111
0112 template<class DomainT, ICL_COMPARE Compare>
0113 struct value_size<icl::left_open_interval<DomainT,Compare> >
0114 {
0115 static std::size_t apply(const icl::left_open_interval<DomainT>&)
0116 { return 2; }
0117 };
0118
0119 }}
0120
0121 #endif