File indexing completed on 2025-01-19 09:47:48
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_RANGE_FUNCTIONS_MAY_16_2006_0720_PM)
0008 #define BOOST_SPIRIT_RANGE_FUNCTIONS_MAY_16_2006_0720_PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <limits>
0015
0016 namespace boost { namespace spirit { namespace support { namespace detail
0017 {
0018 template <typename Range>
0019 inline bool
0020 is_valid(Range const& range)
0021 {
0022
0023 return range.first <= range.last;
0024 }
0025
0026 template <typename Range>
0027 inline bool
0028 includes(Range const& range, Range const& other)
0029 {
0030
0031 return (range.first <= other.first) && (range.last >= other.last);
0032 }
0033
0034 template <typename Range>
0035 inline bool
0036 includes(Range const& range, typename Range::value_type val)
0037 {
0038
0039 return (range.first <= val) && (range.last >= val);
0040 }
0041
0042 template <typename Range>
0043 inline bool
0044 can_merge(Range const& range, Range const& other)
0045 {
0046
0047
0048
0049 typedef typename Range::value_type value_type;
0050 typedef std::numeric_limits<value_type> limits;
0051
0052 value_type decr_first =
0053 range.first == (limits::min)()
0054 ? range.first : range.first-1;
0055
0056 value_type incr_last =
0057 range.last == (limits::max)()
0058 ? range.last : range.last+1;
0059
0060 return (decr_first <= other.last) && (incr_last >= other.first);
0061 }
0062
0063 template <typename Range>
0064 inline void
0065 merge(Range& result, Range const& other)
0066 {
0067
0068 if (result.first > other.first)
0069 result.first = other.first;
0070 if (result.last < other.last)
0071 result.last = other.last;
0072 }
0073
0074 template <typename Range>
0075 struct range_compare
0076 {
0077
0078
0079 typedef typename Range::value_type value_type;
0080
0081 bool operator()(Range const& x, const value_type y) const
0082 {
0083 return x.first < y;
0084 }
0085
0086 bool operator()(value_type const x, Range const& y) const
0087 {
0088 return x < y.first;
0089 }
0090
0091 bool operator()(Range const& x, Range const& y) const
0092 {
0093 return x.first < y.first;
0094 }
0095 };
0096 }}}}
0097
0098 #endif