/usr/include/boost/icl/continuous_interval.hpp is in libboost1.49-dev 1.49.0-3.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /*-----------------------------------------------------------------------------+
Copyright (c) 2010-2010: Joachim Faulhaber
+------------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------------------------------------*/
#ifndef BOOST_ICL_CONTINUOUS_INTERVAL_HPP_JOFA_100327
#define BOOST_ICL_CONTINUOUS_INTERVAL_HPP_JOFA_100327
#include <functional>
#include <boost/static_assert.hpp>
#include <boost/concept/assert.hpp>
#include <boost/icl/detail/concept_check.hpp>
#include <boost/icl/concept/interval.hpp>
#include <boost/icl/concept/container.hpp>
#include <boost/icl/type_traits/value_size.hpp>
#include <boost/icl/type_traits/type_to_string.hpp>
#include <boost/icl/type_traits/is_continuous.hpp>
#include <boost/icl/type_traits/is_continuous_interval.hpp>
#include <boost/icl/interval_bounds.hpp>
namespace boost{namespace icl
{
template <class DomainT,
ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT)>
class continuous_interval
{
public:
typedef continuous_interval<DomainT,Compare> type;
typedef DomainT domain_type;
typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
typedef typename bounded_value<DomainT>::type bounded_domain_type;
public:
//==========================================================================
//= Construct, copy, destruct
//==========================================================================
/** Default constructor; yields an empty interval <tt>[0,0)</tt>. */
continuous_interval()
: _lwb(identity_element<DomainT>::value()), _upb(identity_element<DomainT>::value())
, _bounds(interval_bounds::right_open())
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
BOOST_STATIC_ASSERT((icl::is_continuous<DomainT>::value));
}
//NOTE: Compiler generated copy constructor is used
/** Constructor for a closed singleton interval <tt>[val,val]</tt> */
explicit continuous_interval(const DomainT& val)
: _lwb(val), _upb(val), _bounds(interval_bounds::closed())
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
BOOST_STATIC_ASSERT((icl::is_continuous<DomainT>::value));
}
/** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
continuous_interval(const DomainT& low, const DomainT& up,
interval_bounds bounds = interval_bounds::right_open(),
continuous_interval* = 0)
: _lwb(low), _upb(up), _bounds(bounds)
{
BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
BOOST_STATIC_ASSERT((icl::is_continuous<DomainT>::value));
}
domain_type lower()const { return _lwb; }
domain_type upper()const { return _upb; }
interval_bounds bounds()const{ return _bounds; }
static continuous_interval open (const DomainT& lo, const DomainT& up){ return continuous_interval(lo, up, interval_bounds::open()); }
static continuous_interval right_open(const DomainT& lo, const DomainT& up){ return continuous_interval(lo, up, interval_bounds::right_open());}
static continuous_interval left_open (const DomainT& lo, const DomainT& up){ return continuous_interval(lo, up, interval_bounds::left_open()); }
static continuous_interval closed (const DomainT& lo, const DomainT& up){ return continuous_interval(lo, up, interval_bounds::closed()); }
private:
domain_type _lwb;
domain_type _upb;
interval_bounds _bounds;
};
//==============================================================================
//=T continuous_interval -> concept interval
//==============================================================================
template<class DomainT, ICL_COMPARE Compare>
struct interval_traits< icl::continuous_interval<DomainT, Compare> >
{
typedef interval_traits type;
typedef DomainT domain_type;
typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
typedef icl::continuous_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(); };
};
//==============================================================================
//=T continuous_interval -> concept dynamic_interval
//==============================================================================
template<class DomainT, ICL_COMPARE Compare>
struct dynamic_interval_traits<boost::icl::continuous_interval<DomainT,Compare> >
{
typedef dynamic_interval_traits type;
typedef boost::icl::continuous_interval<DomainT,Compare> interval_type;
typedef DomainT domain_type;
typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
static interval_type construct(const domain_type lo, const domain_type up, interval_bounds bounds)
{
return icl::continuous_interval<DomainT,Compare>(lo, up, bounds,
static_cast<icl::continuous_interval<DomainT,Compare>* >(0) );
}
static interval_type construct_bounded(const bounded_value<DomainT>& lo,
const bounded_value<DomainT>& up)
{
return icl::continuous_interval<DomainT,Compare>
(
lo.value(), up.value(),
lo.bound().left() | up.bound().right(),
static_cast<icl::continuous_interval<DomainT,Compare>* >(0)
);
}
};
//==============================================================================
//= Type traits
//==============================================================================
template <class DomainT, ICL_COMPARE Compare>
struct interval_bound_type< continuous_interval<DomainT,Compare> >
{
typedef interval_bound_type type;
BOOST_STATIC_CONSTANT(bound_type, value = interval_bounds::dynamic);
};
template <class DomainT, ICL_COMPARE Compare>
struct is_continuous_interval<continuous_interval<DomainT,Compare> >
{
typedef is_continuous_interval<continuous_interval<DomainT,Compare> > type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template <class DomainT, ICL_COMPARE Compare>
struct type_to_string<icl::continuous_interval<DomainT,Compare> >
{
static std::string apply()
{ return "cI<"+ type_to_string<DomainT>::apply() +">"; }
};
template<class DomainT>
struct value_size<icl::continuous_interval<DomainT> >
{
static std::size_t apply(const icl::continuous_interval<DomainT>&)
{ return 2; }
};
}} // namespace icl boost
#endif
|