diff --git a/doc/html/range/reference/adaptors/adaptors_general_requirements.html b/doc/html/range/reference/adaptors/adaptors_general_requirements.html deleted file mode 100644 index a815bae..0000000 --- a/doc/html/range/reference/adaptors/adaptors_general_requirements.html +++ /dev/null @@ -1,141 +0,0 @@ - -
- -![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- In the description of generator expressions, the following notation is - used: -
-fwdRng
is an expression
- of a type R
that models
- ForwardRange
-biRng
is an expression
- of a type R
that models
- BidirectionalRange
-rndRng
is an expression
- of a type R
that models
- RandomAccessRange
-pred
is an expression
- of a type that models UnaryPredicate
-bi_pred
is an expression
- of a type that models BinaryPredicate
-fun
is an expression
- of a type that models UnaryFunction
-value
, new_value
and old_value
- are objects convertible to boost::range_value<R>::type
-n,m
are integer expressions convertible
- to range_difference<R>::type
-
- Also note that boost::range_value<R>::type
must be implicitly convertible to
- the type arguments to pred
,
- bi_pred
and fun
.
-
- Range Category in the following adaptor descriptions refers to the minimum - range concept required by the range passed to the adaptor. The resultant - range is a model of the same range concept as the input range unless specified - otherwise. -
-
- Returned Range Category is the concept of the returned range. In some cases
- the returned range is of a lesser category than the range passed to the
- adaptor. For example, the filtered
- adaptor returns only a ForwardRange
- regardless of the input.
-
- Furthermore, the following rules apply to any expression of the form -
-rng | boost::adaptors::adaptor_generator --
-
-
- 1. Applying operator|()
- to a range R
(always left
- argument) and a range adapter RA
- (always right argument) yields a new range type which may not conform to
- the same range concept as R
.
-
- 2. The return-type of operator|()
is otherwise unspecified.
-
- 3. operator|()
- is found by Argument Dependent Lookup (ADL) because a range adaptor is
- implemented in namespace boost::adaptors
.
-
- 4. operator|()
- is used to add new behaviour lazily
- and never modifies its left argument.
-
- 5. All iterators extracted from the left argument are extracted using qualified
- calls to boost::begin()
- and boost::end()
.
-
- 6. In addition to the throw
-clauses
- below, operator|()
- may throw exceptions as a result of copying iterators. If such copying
- cannot throw an exception, then neither can the whole expression.
-
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- A Range Adaptor is a class that wraps - an existing Range to provide a new Range with different behaviour. Since - the behaviour of Ranges is determined by their associated iterators, a - Range Adaptor simply wraps the underlying iterators with new special iterators. - In this example -
-- -
-#include <boost/range/adaptors.hpp> -#include <boost/range/algorithm.hpp> -#include <iostream> -#include <vector> - -std::vector<int> vec; -boost::copy( vec | boost::adaptors::reversed, - std::ostream_iterator<int>(std::cout) ); --
-
-
- the iterators from vec
- are wrapped reverse_iterator
s.
- The type of the underlying Range Adapter is not documented because you
- do not need to know it. All that is relevant is that the expression
-
- -
-vec | boost::adaptors::reversed --
-
-
- returns a Range Adaptor where the iterator type is now the iterator type
- of the range vec
wrapped
- in reverse_iterator
. The
- expression boost::adaptors::reversed
is called an Adaptor
- Generator.
-
- There are two ways of constructing a range adaptor. The first is by using
- operator|()
.
- This is my preferred technique, however while discussing range adaptors
- with others it became clear that some users of the library strongly prefer
- a more familiar function syntax, so equivalent functions of the present
- tense form have been added as an alternative syntax. The equivalent to
- rng |
- reversed
is adaptors::reverse(rng)
for example.
-
- Why do I prefer the operator|
syntax? The answer is readability:
-
- -
-std::vector<int> vec; -boost::copy( boost::adaptors::reverse(vec), - std::ostream_iterator<int>(std::cout) ); --
-
-- This might not look so bad, but when we apply several adaptors, it becomes - much worse. Just compare -
-- -
-std::vector<int> vec; -boost::copy( boost::adaptors::unique( boost::adaptors::reverse( vec ) ), - std::ostream_iterator<int>(std::cout) ); --
-
-- to -
-- -
-std::vector<int> vec; -boost::copy( vec | boost::adaptors::reversed - | boost::adaptors::uniqued, - std::ostream_iterator<int>(std::cout) ); --
-
-
- Furthermore, some of the adaptor generators take arguments themselves and
- these arguments are expressed with function call notation too. In those
- situations, you will really appreciate the succinctness of operator|()
.
-
- Range Adaptors are a powerful complement to Range algorithms. The reason - is that adaptors are orthogonal - to algorithms. For example, consider these Range algorithms: -
-boost::copy( rng, out )
boost::count( rng, pred )
- What should we do if we only want to copy an element a
- if it satisfies some predicate, say pred(a)
?
- And what if we only want to count the elements that satisfy the same predicate?
- The naive answer would be to use these algorithms:
-
boost::copy_if(
- rng,
- pred,
- out )
boost::count_if(
- rng,
- pred )
- These algorithms are only defined to maintain a one to one relationship
- with the standard library algorithms. This approach of adding algorithm
- suffers a combinatorial explosion. Inevitably many algorithms are missing
- _if
variants and there
- is redundant development overhead for each new algorithm. The Adaptor Generator
- is the design solution to this problem.
-
- -
-boost::copy_if( rng, pred, out ); --
- can be expressed as -
-boost::copy( rng | boost::adaptors::filtered(pred), out ); --
-
-- -
-boost::count_if( rng, pred ); --
- can be expressed as -
-boost::count( rng | boost::adaptors::filtered(pred), out ); --
-
-
- What this means is that no
- algorithm with the _if
- suffix is needed. Furthermore, it turns out that algorithms with the _copy
suffix are not needed either. Consider
- the somewhat misdesigned replace_copy_if()
which may be used as
-
- -
-std::vector<int> vec; -boost::replace_copy_if( rng, std::back_inserter(vec), pred ); --
-
-- With adaptors and algorithms we can express this as -
-- -
-std::vector<int> vec; -boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value)); --
-
-- The latter code has several benefits: -
-
- 1. it is more efficient
- because we avoid extra allocations as might happen with std::back_inserter
-
- 2. it is flexible - as we can subsequently apply even more adaptors, for example: -
-boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value) - | boost::adaptors::reversed); --
-
-- 3. it is safer because - there is no use of an unbounded output iterator. -
-- In this manner, the composition - of Range Adaptors has the following consequences: -
-
- 1. we no longer need _if
,
- _copy
, _copy_if
- and _n
variants of algorithms.
-
- 2. we can generate a multitude of new algorithms on the fly, for example,
- above we generated reverse_replace_copy_if()
-
- In other words: -
-- Range Adaptors are to algorithms what algorithms - are to containers -
-- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- The library provides the following Adapter Generator expressions: -
-- -
-rng | boost::adaptors::adjacent_filtered(bi_pred) -rng | boost::adaptors::copied(n,m) -rng | boost::adaptors::filtered(pred) -rng | boost::adaptors::indexed -rng | boost::adaptors::indirected -rng | boost::adaptors::map_keys -rng | boost::adaptors::map_values -rng | boost::adaptors::replaced(new_value, old_value) -rng | boost::adaptors::replaced_if(pred, new_value) -rng | boost::adaptors::reversed -rng | boost::adaptors::sliced(n, m) -rng | boost::adaptors::strided(n) -rng | boost::adaptors::tokenized( <see arguments below> ) -rng | boost::adaptors::transformed(fun) -rng | boost::adaptors::uniqued --
-
-- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- Three types of objects are currently supported by the library: -
-std::pair<iterator,iterator>
- Even though the behavior of the primary templates are exactly such that
- standard containers will be supported by default, the requirements are
- much lower than the standard container requirements. For example, the utility
- class iterator_range
implements the
- minimal interface required
- to make the class a Forward
- Range.
-
- Please also see Range concepts for - more details. -
-- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- The Boost.Range library provides some of the more commonly required ranges. -
-- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- -
-template< class Incrementable > inline -iterator_range< counting_iterator<Incrementable> > -counting_range(Incrementable first, Incrementable last); - -template< class SinglePassRange > inline -iterator_range< counting_iterator<typename range_iterator<SinglePassRange>::type > -counting_range(const SinglePassRange& rng); - -template< class SinglePassRange > inline -iterator_range< counting_iterator<typename range_iterator<SinglePassRange>::type > -counting_range(SinglePassRange& rng); --
-
-
- counting_range
is a function
- to generator that generates an iterator_range
- wrapping a counting_iterator
- (from Boost.Iterator).
-
- Defined in header file boost/range/counting_range.hpp
-
Incrementable
is a
- model of the Incrementable
- Concept.
- - | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- -
-template<class Integer> -integer_range< range_detail::integer_iterator<Integer> > -irange(Integer first, Integer last); - -template<class Integer, class StepSize> -integer_range< range_detail::integer_iterator_with_step<Integer, StepSize> > -irange(Integer first, Integer last, StepSize step_size); --
-
-
- irange
is a function
- to generate an Integer Range.
-
- irange
allows treating
- integers as a model of the Random
- Access Range Concept. It should be noted that the first
and last
- parameters denoted a half-open range.
-
- Defined in the header file boost/range/irange.hpp
-
Integer
is a model
- of the Integer
Concept.
- StepSize
is a model
- of the SignedInteger
- Concept.
- - Constant. Since this function generates a new range the most significant - performance cost is incurred through the iteration of the generated range. -
-- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- -
-template< class Type, class Elem, class Traits > inline -iterator_range< std::istream_iterator<Type, Elem, Traits> > -istream_range(std::basic_istream<Elem, Traits>& in); --
-
-
- istream_range
is a function
- to generator that generates an iterator_range
- wrapping a std::istream_iterator
.
-
- Defined in header file boost/range/istream_range.hpp
-
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- - Expression - - |
-
- - Return type - - |
-
- - Returns - - |
-
- - Complexity - - |
-
---|---|---|---|
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - - - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
- - constant time - - |
-
-
- |
-
-
- |
-
-
- |
-
-
- linear time for pointers to a string or arrays of |
-
-
- |
-
-
- |
-
-
- |
-- |
- The special const_
-named
- functions are useful when you want to document clearly that your code is
- read-only.
-
- as_literal()
- can be used internally
- in string algorithm libraries such that arrays of characters are handled
- correctly.
-
- as_array()
- can be used with string algorithm libraries to make it clear that arrays
- of characters are handled like an array and not like a string.
-
- Notice that the above functions should always be called with qualification
- (boost::
)
- to prevent unintended
- Argument Dependent Lookup (ADL).
-
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- - Expression - - |
-
- - Return type - - |
-
- - Complexity - - |
-
---|---|---|
-
- |
-
- - - -T::iterator -P::first_type -A* -- - - |
-
- - compile time - - |
-
-
- |
-
- - - -T::const_iterator -P::first_type -const A* -- - - |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
-
- |
-
-
- |
-
- - compile time - - |
-
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- -
-namespace boost -{ - // - // Single Pass Range metafunctions - // - - template< class T > - struct range_iterator; - - template< class T > - struct range_value; - - template< class T > - struct range_reference; - - template< class T > - struct range_pointer; - - template< class T > - struct range_category; - - // - // Forward Range metafunctions - // - - template< class T > - struct range_difference; - - // - // Bidirectional Range metafunctions - // - - template< class T > - struct range_reverse_iterator; - - // - // Single Pass Range functions - // - - template< class T > - typename range_iterator<T>::type - begin( T& r ); - - template< class T > - typename range_iterator<const T>::type - begin( const T& r ); - - template< class T > - typename range_iterator<T>::type - end( T& r ); - - template< class T > - typename range_iterator<const T>::type - end( const T& r ); - - template< class T > - bool - empty( const T& r ); - - // - // Forward Range functions - // - - template< class T > - typename range_difference<T>::type - distance( const T& r ); - - // - // Bidirectional Range functions - // - - template< class T > - typename range_reverse_iterator<T>::type - rbegin( T& r ); - - template< class T > - typename range_reverse_iterator<const T>::type - rbegin( const T& r ); - - template< class T > - typename range_reverse_iterator<T>::type - rend( T& r ); - - template< class T > - typename range_reverse_iterator<const T>::type - rend( const T& r ); - - // - // Random Access Range functions - // - - template< class T > - typename range_difference<T>::type - size( const T& r ); - - // - // Special const Range functions - // - - template< class T > - typename range_iterator<const T>::type - const_begin( const T& r ); - - template< class T > - typename range_iterator<const T>::type - const_end( const T& r ); - - template< class T > - typename range_reverse_iterator<const T>::type - const_rbegin( const T& r ); - - template< class T > - typename range_reverse_iterator<const T>::type - const_rend( const T& r ); - - // - // String utilities - // - - template< class T > - iterator_range< ... see below ... > - as_literal( T& r ); - - template< class T > - iterator_range< ... see below ... > - as_literal( const T& r ); - - template< class T > - iterator_range< typename range_iterator<T>::type > - as_array( T& r ); - - template< class T > - iterator_range< typename range_iterator<const T>::type > - as_array( const T& r ); - -} // namespace 'boost' --
-
-- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- Boost version 1.35 introduced some larger refactorings of the library: -
-as_literal
()
.
- size
- now requires a Random
- Access Range. The old behavior is provided as distance
()
.
- range_size<T>::type
has been completely removed in favor
- of range_difference<T>::type
-boost_range_begin()
- and boost_range_end()
- have been renamed range_begin()
and range_end()
respectively.
- range_result_iterator<T>::type
and range_reverse_result_iterator<T>::type
- have been renamed range_iterator<T>::type
- and range_reverse_iterator<T>::type
.
- - | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- The intention of the iterator_range
- class is to encapsulate two iterators so they fulfill the Forward
- Range concept. A few other functions are also provided for convenience.
-
- If the template argument is not a model of Forward
- Traversal Iterator, one can still use a subset of the interface.
- In particular, size()
- requires Random Access Traversal Iterators whereas empty()
only requires Single Pass Iterators.
-
- Recall that many default constructed iterators are singular
- and hence can only be assigned, but not compared or incremented or anything.
- However, if one creates a default constructed iterator_range
,
- then one can still call all its member functions. This design decision avoids
- the iterator_range
imposing
- limitations upon ranges of iterators that are not singular. Any singularity
- limitation is simply propogated from the underlying iterator type.
-
- -
-namespace boost -{ - template< class ForwardTraversalIterator > - class iterator_range - { - public: // Forward Range types - typedef ForwardTraversalIterator iterator; - typedef ForwardTraversalIterator const_iterator; - typedef iterator_difference<iterator>::type difference_type; - - public: // construction, assignment - template< class ForwardTraversalIterator2 > - iterator_range( ForwardTraversalIterator2 Begin, ForwardTraversalIterator2 End ); - - template< class ForwardRange > - iterator_range( ForwardRange& r ); - - template< class ForwardRange > - iterator_range( const ForwardRange& r ); - - template< class ForwardRange > - iterator_range& operator=( ForwardRange& r ); - - template< class ForwardRange > - iterator_range& operator=( const ForwardRange& r ); - - public: // Forward Range functions - iterator begin() const; - iterator end() const; - - public: // convenience - operator unspecified_bool_type() const; - bool equal( const iterator_range& ) const; - value_type& front() const; - value_type& back() const; - iterator_range& advance_begin(difference_type n); - iterator_range& advance_end(difference_type n); - bool empty() const; - // for Random Access Range only: - reference operator[]( difference_type at ) const; - value_type operator()( difference_type at ) const; - size_type size() const; - }; - - // stream output - template< class ForwardTraversalIterator, class T, class Traits > - std::basic_ostream<T,Traits>& - operator<<( std::basic_ostream<T,Traits>& Os, - const iterator_range<ForwardTraversalIterator>& r ); - - // comparison - template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > - bool operator==( const iterator_range<ForwardTraversalIterator>& l, - const iterator_range<ForwardTraversalIterator2>& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator==( const iterator_range<ForwardTraversalIterator>& l, - const ForwardRange& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator==( const ForwardRange& l, - const iterator_range<ForwardTraversalIterator>& r ); - - template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > - bool operator!=( const iterator_range<ForwardTraversalIterator>& l, - const iterator_range<ForwardTraversalIterator2>& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator!=( const iterator_range<ForwardTraversalIterator>& l, - const ForwardRange& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator!=( const ForwardRange& l, - const iterator_range<ForwardTraversalIterator>& r ); - - template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > - bool operator<( const iterator_range<ForwardTraversalIterator>& l, - const iterator_range<ForwardTraversalIterator2>& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator<( const iterator_range<ForwardTraversalIterator>& l, - const ForwardRange& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator<( const ForwardRange& l, - const iterator_range<ForwardTraversalIterator>& r ); - - // external construction - template< class ForwardTraversalIterator > - iterator_range< ForwardTraversalIterator > - make_iterator_range( ForwardTraversalIterator Begin, - ForwardTraversalIterator End ); - - template< class ForwardRange > - iterator_range< typename range_iterator<ForwardRange>::type > - make_iterator_range( ForwardRange& r ); - - template< class ForwardRange > - iterator_range< typename range_iterator<const ForwardRange>::type > - make_iterator_range( const ForwardRange& r ); - - template< class Range > - iterator_range< typename range_iterator<Range>::type > - make_iterator_range( Range& r, - typename range_difference<Range>::type advance_begin, - typename range_difference<Range>::type advance_end ); - - template< class Range > - iterator_range< typename range_iterator<const Range>::type > - make_iterator_range( const Range& r, - typename range_difference<const Range>::type advance_begin, - typename range_difference<const Range>::type advance_end ); - - // convenience - template< class Sequence, class ForwardRange > - Sequence copy_range( const ForwardRange& r ); - -} // namespace 'boost' --
-
-
- If an instance of iterator_range
- is constructed by a client with two iterators, the client must ensure that
- the two iterators delimit a valid closed-open range [begin,end).
-
- It is worth noticing that the templated constructors and assignment operators
- allow conversion from iterator_range<iterator>
to iterator_range<const_iterator>
. Similarly, since the comparison operators
- have two template arguments, we can compare ranges whenever the iterators
- are comparable; for example when we are dealing with const and non-const
- iterators from the same container.
-
- operator unspecified_bool_type() const;
-
--
-- Returns
-!empty();
--
-
- bool equal( iterator_range& r ) const;
-
--
-- Returns
-begin() == r.begin() && - end() - == r.end();
--
-
- bool operator==( const ForwardRange1&
- l, const ForwardRange2& r );
-
--
-- Returns
-size(l) != size(r) ? false - : std::equal( begin(l), end(l), begin(r) );
--
-
- bool operator!=( const ForwardRange1&
- l, const ForwardRange2& r );
-
--
-- Returns
-!( l == r );
--
-
- bool operator<( const ForwardRange1&
- l, const ForwardRange2& r );
-
--
-- Returns
-std::lexicographical_compare( - begin(l), end(l), begin(r), end(r) );
--
-
- -
-iterator_range make_iterator_range( Range& r, - typename range_difference<Range>::type advance_begin, - typename range_difference<Range>::type advance_end ); --
-
---
-- Effects: -
--
-
- -
-iterator new_begin = begin( r ), -iterator new_end = end( r ); -std::advance( new_begin, advance_begin ); -std::advance( new_end, advance_end ); -return make_iterator_range( new_begin, new_end ); --
-
-
- Sequence copy_range( const ForwardRange& r );
-
--
-- Returns
-Sequence( - begin(r), end(r) );
--
-
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
- The intention of the join
- function is to join two ranges into one longer range.
-
- The resultant range will have the lowest common traversal of the two ranges - supplied as parameters. -
-- Note that the joined range incurs a performance cost due to the need to check - if the end of a range has been reached internally during traversal. -
-- -
-template<typename SinglePassRange1, typename SinglePassRange2> -iterator_range<range_detail::join_iterator< - typename range_iterator<const SinglePassRange1>::type, - typename range_iterator<const SinglePassRange2>::type, - typename add_const< - typename range_value<const SinglePassRange1>::type>::type> -> -join(const SinglePassRange1& rng1, const SinglePassRange2& rng2) - -template<typename SinglePassRange1, typename SinglePassRange2> -iterator_range<range_detail::join_iterator< - typename range_iterator<SinglePassRange1>::type, - typename range_iterator<SinglePassRange2>::type, - typename range_value<SinglePassRange1>::type> -> -join(SinglePassRange1& rng1, SinglePassRange2& rng2); --
-
-
- The expression join(irange(0,5), irange(5,10))
would
- evaluate to a range representing an integer range [0,10)
-
- | - |
![]() |
-Home | -Libraries | -People | -FAQ | -More | -
sub_range
-
- The sub_range
class inherits
- all its functionality from the iterator_range
class. The sub_range
class is often easier to use
- because one must specify the Forward
- Range template argument instead of an iterator. Moreover, the sub_range
class can propagate constness
- since it knows what a corresponding const_iterator
- is.
-
- -
-namespace boost -{ - template< class ForwardRange > - class sub_range : public iterator_range< typename range_iterator<ForwardRange>::type > - { - public: - typedef typename range_iterator<ForwardRange>::type iterator; - typedef typename range_iterator<const ForwardRange>::type const_iterator; - typedef typename iterator_difference<iterator>::type difference_type; - - public: // construction, assignment - template< class ForwardTraversalIterator > - sub_range( ForwardTraversalIterator Begin, ForwardTraversalIterator End ); - - template< class ForwardRange2 > - sub_range( ForwardRange2& r ); - - template< class ForwardRange2 > - sub_range( const Range2& r ); - - template< class ForwardRange2 > - sub_range& operator=( ForwardRange2& r ); - - template< class ForwardRange2 > - sub_range& operator=( const ForwardRange2& r ); - - public: // Forward Range functions - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - public: // convenience - value_type& front(); - const value_type& front() const; - value_type& back(); - const value_type& back() const; - // for Random Access Range only: - value_type& operator[]( size_type at ); - const value_type& operator[]( size_type at ) const; - - public: - // rest of interface inherited from iterator_range - }; - -} // namespace 'boost' --
-
-
- The class should be trivial to use as seen below. Imagine that we have an
- algorithm that searches for a sub-string in a string. The result is an iterator_range,
- that delimits the match. We need to store the result from this algorithm.
- Here is an example of how we can do it with and without sub_range
-
- -
-std::string str("hello"); -iterator_range<std::string::iterator> ir = find_first( str, "ll" ); -sub_range<std::string> sub = find_first( str, "ll" ); --
-
-- | - |