123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #ifndef BOOST_ICL_INTERVAL_HPP_JOFA_101014
- #define BOOST_ICL_INTERVAL_HPP_JOFA_101014
- #include <boost/icl/type_traits/interval_type_default.hpp>
- namespace boost{ namespace icl
- {
- template <class IntervalT, bool IsDiscrete, bound_type PretendedBounds, bound_type RepresentedBounds>
- struct static_interval;
- template <class DomainT, ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT)>
- struct interval
- {
- typedef typename interval_type_default<DomainT,Compare>::type interval_type;
- typedef interval_type type;
- #ifdef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
- static inline interval_type open(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_open
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
- static inline interval_type left_open(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_left_open
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
- static inline interval_type right_open(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_right_open
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
- static inline interval_type closed(const DomainT& low, const DomainT& up)
- {
- return
- static_interval
- < interval_type
- , is_discrete<typename interval_traits<interval_type>::domain_type>::value
- , interval_bounds::static_closed
- , interval_bound_type<interval_type>::value
- >
- ::construct(low, up);
- }
- static inline interval_type construct(const DomainT& low, const DomainT& up)
- { return icl::construct<interval_type>(low, up); }
- #else
- static inline interval_type right_open(const DomainT& low, const DomainT& up)
- { return icl::construct<interval_type>(low, up, interval_bounds::right_open()); }
- static inline interval_type left_open(const DomainT& low, const DomainT& up)
- { return icl::construct<interval_type>(low, up, interval_bounds::left_open()); }
- static inline interval_type open(const DomainT& low, const DomainT& up)
- { return icl::construct<interval_type>(low, up, interval_bounds::open()); }
- static inline interval_type closed(const DomainT& low, const DomainT& up)
- { return icl::construct<interval_type>(low, up, interval_bounds::closed()); }
- static inline interval_type construct(const DomainT& low, const DomainT& up)
- { return icl::construct<interval_type>(low, up); }
- #endif
- };
- template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
- struct static_interval<IntervalT, true, PretendedBounds, RepresentedBounds>
- {
- typedef typename interval_traits<IntervalT>::domain_type domain_type;
- static inline IntervalT construct(const domain_type& low, const domain_type& up)
- {
- return icl::construct<IntervalT>(
- shift_lower(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), low)
- , shift_upper(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), up )
- );
- }
- };
- template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
- struct static_interval<IntervalT, false, PretendedBounds, RepresentedBounds>
- {
- typedef typename interval_traits<IntervalT>::domain_type domain_type;
- static inline IntervalT construct(const domain_type& low, const domain_type& up)
- {
- BOOST_STATIC_ASSERT((is_discrete<domain_type>::value || PretendedBounds==RepresentedBounds));
-
-
-
-
-
-
-
-
- return icl::construct<IntervalT>(low, up);
- }
- };
- }}
- #endif
|