annotate DEPENDENCIES/generic/include/boost/range/sub_range.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 // Boost.Range library
Chris@16 2 //
Chris@16 3 // Copyright Neil Groves 2009.
Chris@16 4 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
Chris@16 5 // distribution is subject to the Boost Software License, Version
Chris@16 6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 //
Chris@16 9 // For more information, see http://www.boost.org/libs/range/
Chris@16 10 //
Chris@16 11
Chris@16 12 #ifndef BOOST_RANGE_SUB_RANGE_HPP
Chris@16 13 #define BOOST_RANGE_SUB_RANGE_HPP
Chris@16 14
Chris@16 15 #include <boost/detail/workaround.hpp>
Chris@16 16
Chris@16 17 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
Chris@16 18 #pragma warning( push )
Chris@16 19 #pragma warning( disable : 4996 )
Chris@16 20 #endif
Chris@16 21
Chris@16 22 #include <boost/range/config.hpp>
Chris@16 23 #include <boost/range/iterator_range.hpp>
Chris@16 24 #include <boost/range/value_type.hpp>
Chris@16 25 #include <boost/range/size_type.hpp>
Chris@16 26 #include <boost/range/difference_type.hpp>
Chris@16 27 #include <boost/range/algorithm/equal.hpp>
Chris@16 28 #include <boost/assert.hpp>
Chris@16 29 #include <boost/type_traits/is_reference.hpp>
Chris@16 30 #include <boost/type_traits/remove_reference.hpp>
Chris@16 31
Chris@16 32 namespace boost
Chris@16 33 {
Chris@16 34
Chris@16 35 template< class ForwardRange >
Chris@16 36 class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
Chris@16 37 {
Chris@16 38 typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
Chris@16 39 typedef iterator_range< iterator_t > base;
Chris@16 40
Chris@16 41 typedef BOOST_DEDUCED_TYPENAME base::impl impl;
Chris@16 42 public:
Chris@16 43 typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type value_type;
Chris@16 44 typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator;
Chris@16 45 typedef BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type const_iterator;
Chris@16 46 typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
Chris@16 47 typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
Chris@16 48 typedef BOOST_DEDUCED_TYPENAME base::reference reference;
Chris@16 49
Chris@16 50 public: // for return value of front/back
Chris@16 51 typedef BOOST_DEDUCED_TYPENAME
Chris@16 52 boost::mpl::if_< boost::is_reference<reference>,
Chris@16 53 const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&,
Chris@16 54 reference >::type const_reference;
Chris@16 55
Chris@16 56 public:
Chris@16 57 sub_range() : base()
Chris@16 58 { }
Chris@16 59
Chris@16 60 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
Chris@16 61 sub_range( const sub_range& r )
Chris@16 62 : base( static_cast<const base&>( r ) )
Chris@16 63 { }
Chris@16 64 #endif
Chris@16 65
Chris@16 66 template< class ForwardRange2 >
Chris@16 67 sub_range( ForwardRange2& r ) :
Chris@16 68
Chris@16 69 #if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
Chris@16 70 base( impl::adl_begin( r ), impl::adl_end( r ) )
Chris@16 71 #else
Chris@16 72 base( r )
Chris@16 73 #endif
Chris@16 74 { }
Chris@16 75
Chris@16 76 template< class ForwardRange2 >
Chris@16 77 sub_range( const ForwardRange2& r ) :
Chris@16 78
Chris@16 79 #if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
Chris@16 80 base( impl::adl_begin( r ), impl::adl_end( r ) )
Chris@16 81 #else
Chris@16 82 base( r )
Chris@16 83 #endif
Chris@16 84 { }
Chris@16 85
Chris@16 86 template< class Iter >
Chris@16 87 sub_range( Iter first, Iter last ) :
Chris@16 88 base( first, last )
Chris@16 89 { }
Chris@16 90
Chris@16 91 template< class ForwardRange2 >
Chris@16 92 sub_range& operator=( ForwardRange2& r )
Chris@16 93 {
Chris@16 94 base::operator=( r );
Chris@16 95 return *this;
Chris@16 96 }
Chris@16 97
Chris@16 98 template< class ForwardRange2 >
Chris@16 99 sub_range& operator=( const ForwardRange2& r )
Chris@16 100 {
Chris@16 101 base::operator=( r );
Chris@16 102 return *this;
Chris@16 103 }
Chris@16 104
Chris@16 105 sub_range& operator=( const sub_range& r )
Chris@16 106 {
Chris@16 107 base::operator=( static_cast<const base&>(r) );
Chris@16 108 return *this;
Chris@16 109 }
Chris@16 110
Chris@16 111 public:
Chris@16 112
Chris@16 113 iterator begin() { return base::begin(); }
Chris@16 114 const_iterator begin() const { return base::begin(); }
Chris@16 115 iterator end() { return base::end(); }
Chris@16 116 const_iterator end() const { return base::end(); }
Chris@16 117 difference_type size() const { return base::size(); }
Chris@16 118
Chris@16 119
Chris@16 120 public: // convenience
Chris@16 121 reference front()
Chris@16 122 {
Chris@16 123 return base::front();
Chris@16 124 }
Chris@16 125
Chris@16 126 const_reference front() const
Chris@16 127 {
Chris@16 128 return base::front();
Chris@16 129 }
Chris@16 130
Chris@16 131 reference back()
Chris@16 132 {
Chris@16 133 return base::back();
Chris@16 134 }
Chris@16 135
Chris@16 136 const_reference back() const
Chris@16 137 {
Chris@16 138 return base::back();
Chris@16 139 }
Chris@16 140
Chris@16 141 reference operator[]( difference_type sz )
Chris@16 142 {
Chris@16 143 return base::operator[](sz);
Chris@16 144 }
Chris@16 145
Chris@16 146 const_reference operator[]( difference_type sz ) const
Chris@16 147 {
Chris@16 148 return base::operator[](sz);
Chris@16 149 }
Chris@16 150
Chris@16 151 };
Chris@16 152
Chris@16 153 template< class ForwardRange, class ForwardRange2 >
Chris@16 154 inline bool operator==( const sub_range<ForwardRange>& l,
Chris@16 155 const sub_range<ForwardRange2>& r )
Chris@16 156 {
Chris@16 157 return boost::equal( l, r );
Chris@16 158 }
Chris@16 159
Chris@16 160 template< class ForwardRange, class ForwardRange2 >
Chris@16 161 inline bool operator!=( const sub_range<ForwardRange>& l,
Chris@16 162 const sub_range<ForwardRange2>& r )
Chris@16 163 {
Chris@16 164 return !boost::equal( l, r );
Chris@16 165 }
Chris@16 166
Chris@16 167 template< class ForwardRange, class ForwardRange2 >
Chris@16 168 inline bool operator<( const sub_range<ForwardRange>& l,
Chris@16 169 const sub_range<ForwardRange2>& r )
Chris@16 170 {
Chris@16 171 return iterator_range_detail::less_than( l, r );
Chris@16 172 }
Chris@16 173
Chris@16 174
Chris@16 175 } // namespace 'boost'
Chris@16 176
Chris@16 177 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
Chris@16 178 #pragma warning( pop )
Chris@16 179 #endif
Chris@16 180
Chris@16 181 #endif
Chris@16 182