annotate DEPENDENCIES/generic/include/boost/icl/interval.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*-----------------------------------------------------------------------------+
Chris@16 2 Copyright (c) 2010-2010: Joachim Faulhaber
Chris@16 3 +------------------------------------------------------------------------------+
Chris@16 4 Distributed under the Boost Software License, Version 1.0.
Chris@16 5 (See accompanying file LICENCE.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 +-----------------------------------------------------------------------------*/
Chris@16 8 #ifndef BOOST_ICL_INTERVAL_HPP_JOFA_101014
Chris@16 9 #define BOOST_ICL_INTERVAL_HPP_JOFA_101014
Chris@16 10
Chris@16 11
Chris@16 12 #include <boost/icl/type_traits/interval_type_default.hpp>
Chris@16 13
Chris@16 14
Chris@16 15 namespace boost{ namespace icl
Chris@16 16 {
Chris@16 17
Chris@16 18 template <class IntervalT, bool IsDiscrete, bound_type PretendedBounds, bound_type RepresentedBounds>
Chris@16 19 struct static_interval;
Chris@16 20
Chris@16 21 template <class DomainT, ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT)>
Chris@16 22 struct interval
Chris@16 23 {
Chris@16 24 typedef typename interval_type_default<DomainT,Compare>::type interval_type;
Chris@16 25 typedef interval_type type;
Chris@16 26
Chris@16 27 #ifdef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
Chris@16 28
Chris@16 29 static inline interval_type open(const DomainT& low, const DomainT& up)
Chris@16 30 {
Chris@16 31 return
Chris@16 32 static_interval
Chris@16 33 < interval_type // if the domain_type is discrete ...
Chris@16 34 , is_discrete<typename interval_traits<interval_type>::domain_type>::value
Chris@16 35 , interval_bounds::static_open // 'pretended' bounds will be transformed to
Chris@16 36 , interval_bound_type<interval_type>::value // the represented bounds
Chris@16 37 >
Chris@16 38 ::construct(low, up);
Chris@16 39 }
Chris@16 40
Chris@16 41 static inline interval_type left_open(const DomainT& low, const DomainT& up)
Chris@16 42 {
Chris@16 43 return
Chris@16 44 static_interval
Chris@16 45 < interval_type
Chris@16 46 , is_discrete<typename interval_traits<interval_type>::domain_type>::value
Chris@16 47 , interval_bounds::static_left_open
Chris@16 48 , interval_bound_type<interval_type>::value
Chris@16 49 >
Chris@16 50 ::construct(low, up);
Chris@16 51 }
Chris@16 52
Chris@16 53 static inline interval_type right_open(const DomainT& low, const DomainT& up)
Chris@16 54 {
Chris@16 55 return
Chris@16 56 static_interval
Chris@16 57 < interval_type
Chris@16 58 , is_discrete<typename interval_traits<interval_type>::domain_type>::value
Chris@16 59 , interval_bounds::static_right_open
Chris@16 60 , interval_bound_type<interval_type>::value
Chris@16 61 >
Chris@16 62 ::construct(low, up);
Chris@16 63 }
Chris@16 64
Chris@16 65 static inline interval_type closed(const DomainT& low, const DomainT& up)
Chris@16 66 {
Chris@16 67 return
Chris@16 68 static_interval
Chris@16 69 < interval_type
Chris@16 70 , is_discrete<typename interval_traits<interval_type>::domain_type>::value
Chris@16 71 , interval_bounds::static_closed
Chris@16 72 , interval_bound_type<interval_type>::value
Chris@16 73 >
Chris@16 74 ::construct(low, up);
Chris@16 75 }
Chris@16 76
Chris@16 77 static inline interval_type construct(const DomainT& low, const DomainT& up)
Chris@16 78 { return icl::construct<interval_type>(low, up); }
Chris@16 79
Chris@16 80 #else // ICL_USE_DYNAMIC_INTERVAL_BORDER_DEFAULTS
Chris@16 81 static inline interval_type right_open(const DomainT& low, const DomainT& up)
Chris@16 82 { return icl::construct<interval_type>(low, up, interval_bounds::right_open()); }
Chris@16 83
Chris@16 84 static inline interval_type left_open(const DomainT& low, const DomainT& up)
Chris@16 85 { return icl::construct<interval_type>(low, up, interval_bounds::left_open()); }
Chris@16 86
Chris@16 87 static inline interval_type open(const DomainT& low, const DomainT& up)
Chris@16 88 { return icl::construct<interval_type>(low, up, interval_bounds::open()); }
Chris@16 89
Chris@16 90 static inline interval_type closed(const DomainT& low, const DomainT& up)
Chris@16 91 { return icl::construct<interval_type>(low, up, interval_bounds::closed()); }
Chris@16 92
Chris@16 93 static inline interval_type construct(const DomainT& low, const DomainT& up)
Chris@16 94 { return icl::construct<interval_type>(low, up); }
Chris@16 95
Chris@16 96 #endif
Chris@16 97 };
Chris@16 98
Chris@16 99 template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
Chris@16 100 struct static_interval<IntervalT, true, PretendedBounds, RepresentedBounds>
Chris@16 101 {// is_discrete<domain_type<IntervalT>>
Chris@16 102 typedef typename interval_traits<IntervalT>::domain_type domain_type;
Chris@16 103
Chris@16 104 static inline IntervalT construct(const domain_type& low, const domain_type& up)
Chris@16 105 {
Chris@16 106 return icl::construct<IntervalT>(
Chris@16 107 shift_lower(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), low)
Chris@16 108 , shift_upper(interval_bounds(PretendedBounds), interval_bounds(RepresentedBounds), up )
Chris@16 109 );
Chris@16 110 }
Chris@16 111 };
Chris@16 112
Chris@16 113 template <class IntervalT, bound_type PretendedBounds, bound_type RepresentedBounds>
Chris@16 114 struct static_interval<IntervalT, false, PretendedBounds, RepresentedBounds>
Chris@16 115 {// !is_discrete<domain_type<IntervalT>>
Chris@16 116 typedef typename interval_traits<IntervalT>::domain_type domain_type;
Chris@16 117
Chris@16 118 static inline IntervalT construct(const domain_type& low, const domain_type& up)
Chris@16 119 {
Chris@16 120 BOOST_STATIC_ASSERT((is_discrete<domain_type>::value || PretendedBounds==RepresentedBounds));
Chris@16 121 // For domain_types that are not discrete, e.g. interval<float>
Chris@16 122 // one of the following must hold: If you call
Chris@16 123 // interval<T>::right_open(x,y) then interval<T>::type must be static_right_open
Chris@16 124 // interval<T>::left_open(x,y) then interval<T>::type must be static_left_open
Chris@16 125 // interval<T>::open(x,y) then interval<T>::type must be static_open
Chris@16 126 // interval<T>::closed(x,y) then interval<T>::type must be static_closed
Chris@16 127 // Conversion between 'PretendedBounds' and 'RepresentedBounds' is only possible
Chris@16 128 // for discrete domain_types.
Chris@16 129 return icl::construct<IntervalT>(low, up);
Chris@16 130 }
Chris@16 131 };
Chris@16 132
Chris@16 133 }} // namespace boost icl
Chris@16 134
Chris@16 135 #endif // BOOST_ICL_INTERVAL_HPP_JOFA_101014
Chris@16 136