123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #ifndef BOOST_ICL_OPEN_INTERVAL_HPP_JOFA_100930
- #define BOOST_ICL_OPEN_INTERVAL_HPP_JOFA_100930
- #include <functional>
- #include <boost/concept/assert.hpp>
- #include <boost/icl/detail/concept_check.hpp>
- #include <boost/icl/concept/interval.hpp>
- #include <boost/icl/type_traits/value_size.hpp>
- #include <boost/icl/type_traits/type_to_string.hpp>
- namespace boost{namespace icl
- {
- template <class DomainT,
- ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT)>
- class open_interval
- {
- public:
- typedef open_interval<DomainT,Compare> type;
- typedef DomainT domain_type;
- typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
- public:
-
-
-
-
- open_interval()
- : _lwb(identity_element<DomainT>::value()), _upb(identity_element<DomainT>::value())
- {
- BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
- BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- }
-
-
- explicit open_interval(const DomainT& val)
- : _lwb(pred(val)), _upb(succ(val))
- {
- BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
- BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
-
-
- BOOST_STATIC_ASSERT((icl::is_discrete<DomainT>::value));
- BOOST_ASSERT((numeric_minimum<DomainT, domain_compare, is_numeric<DomainT>::value >
- ::is_less_than(val) ));
- }
-
- open_interval(const DomainT& low, const DomainT& up) :
- _lwb(low), _upb(up)
- {
- BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
- BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
- }
- DomainT lower()const{ return _lwb; }
- DomainT upper()const{ return _upb; }
- private:
- DomainT _lwb;
- DomainT _upb;
- };
- template<class DomainT, ICL_COMPARE Compare>
- struct interval_traits< icl::open_interval<DomainT, Compare> >
- {
- typedef DomainT domain_type;
- typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
- typedef icl::open_interval<DomainT, Compare> interval_type;
- static interval_type construct(const domain_type& lo, const domain_type& up)
- {
- return interval_type(lo, up);
- }
- static domain_type lower(const interval_type& inter_val){ return inter_val.lower(); }
- static domain_type upper(const interval_type& inter_val){ return inter_val.upper(); }
- };
- template <class DomainT, ICL_COMPARE Compare>
- struct interval_bound_type< open_interval<DomainT,Compare> >
- {
- typedef interval_bound_type type;
- BOOST_STATIC_CONSTANT(bound_type, value = interval_bounds::static_open);
- };
- template <class DomainT, ICL_COMPARE Compare>
- struct type_to_string<icl::open_interval<DomainT,Compare> >
- {
- static std::string apply()
- { return "(I)<"+ type_to_string<DomainT>::apply() +">"; }
- };
- template<class DomainT, ICL_COMPARE Compare>
- struct value_size<icl::open_interval<DomainT,Compare> >
- {
- static std::size_t apply(const icl::open_interval<DomainT>&)
- { return 2; }
- };
- }}
- #endif
|