diff --git a/doc/boost_range.html b/doc/boost_range.html deleted file mode 100644 index b9fd0ca..0000000 --- a/doc/boost_range.html +++ /dev/null @@ -1,769 +0,0 @@ - - - - Boost.Range Reference - - - - - - - - - -


- Boost.Range -

-
-

Synopsis and Reference -

- -
- -

Overview

-

- Three types of objects are currently supported by the library: -

- 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. -

- -

Synopsis

-

-

-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' 
-
-
-

- -

Semantics

-

notation

-

- - - - - - - - - - - - - - - - -
- Type - - Object - - Describes -
X - x - any type
T - t - denotes behavior of the primary templates
P - p - denotes std::pair<iterator,iterator>
A[sz] - a - denotes an array of type A of size sz -
Char* - s - denotes either char* or wchar_t*
-

-

- Please notice in tables below that when four lines appear in a cell, the first - line will describe the primary template, the second line pairs of iterators, - the third line arrays and the last line null-terminated strings. -

-

Metafunctions

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Expression - Return type - Complexity
range_iterator<X>::typeT::iterator
- P::first_type
- A*
- -
compile time
range_iterator<const X>::typeT::const_iterator
- P::first_type
- const A*
- -
compile time
range_value<X>::typeboost::iterator_value<range_iterator<X>::type>::type - compile time
range_reference<X>::typeboost::iterator_reference<range_iterator<X>::type>::type - compile time
range_pointer<X>::typeboost::iterator_pointer<range_iterator<X>::type>::type - compile time
range_category<X>::typeboost::iterator_category<range_iterator<X>::type>::type - compile time
range_difference<X>::type - boost::iterator_difference<range_iterator<X>::type>::typecompile time
range_reverse_iterator<X>::typeboost::reverse_iterator<range_iterator<X>::type>
-
compile time
range_reverse_iterator<const X>::typeboost::reverse_iterator<range_iterator<const X>::type> -
-
compile time
-

-

Functions

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Expression - Return type - Returns - Complexity
begin(x)range_iterator<X>::type - p.first if p is of type std::pair<T>
- a if a is an array
- range_begin(x) if that expression would invoke a function found by ADL
- t.begin() otherwise - -
constant time
end(x)range_iterator<X>::type - p.second if p is of type std::pair<T>
- a + sz if a is an array of size sz - -
- range_end(x) if that expression would invoke a function found by ADL
- t.end() otherwise - -
- constant time
empty(x)boolboost::begin(x) == boost::end(x)
-
constant time
-
distance(x)range_difference<X>::type - - std::distance(boost::begin(x),boost::end(x)) - - -
size(x)range_difference<X>::type boost::end(x) - boost::begin(x) - - constant time
rbegin(x)range_reverse_iterator<X>::typerange_reverse_iterator<X>::type( boost::end(x) ) -
-
constant time -
rend(x)range_reverse_iterator<X>::typerange_reverse_iterator<X>::type( boost::begin(x) ) - constant time
const_begin(x)range_iterator<const X>::typerange_iterator<const X>::type( boost::begin(x) ) -
-
constant time -
const_end(x)range_iterator<const X>::typerange_iterator<const X>::type( boost::end(x) ) - constant time
const_rbegin(x)range_reverse_iterator<const X>::typerange_reverse_iterator<const X>::type( boost::rbegin(x) ) -
-
constant time -
const_rend(x)range_reverse_iterator<const X>::typerange_reverse_iterator<const X>::type( boost::rend(x) ) - - constant time
as_literal(x)iterator_range<U> where U is - Char* if x is a pointer to a - string and U is - range_iterator<X>::type otherwise - - - - [s,s + std::char_traits<X>::length(s)) if s is a Char* or an array of Char -
- [boost::begin(x),boost::end(x)) otherwise - - - -
linear time for pointers to a string or arrays of - Char, constant time otherwise
as_array(x)iterator_range<X> - [boost::begin(x),boost::end(x)) - - - - - constant time otherwise
-

-

- 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 librararies 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). -

-
- -

Extending the library

- - - - - -

Method 1: provide member functions and nested types

- -

- This procedure assumes that you have control over the types that should be made - conformant to a Range concept. If not, see method 2. -

- -

- The primary templates in this library are implemented such that standard - containers will work automatically and so will boost::array. - Below is given an overview of which member functions and member types a class - must specify to be useable as a certain Range concept. -

-

- - - - - - - - - - - - -
- Member function - Related concept
begin()Single Pass Range
end() - Single Pass Range
-

-

- Notice that rbegin() and rend() member functions are - not needed even though the container can support bidirectional iteration. -

-

- The required member types are: -

-

- - - - - - - - - - - - - -
- Member type - Related concept
iteratorSingle Pass Range
const_iteratorSingle Pass Range
-

-

- Again one should notice that member types reverse_iterator and const_reverse_iterator - are not needed. -

- -

Method 2: provide free-standing functions and specialize metafunctions

- -

- This procedure assumes that you cannot (or do not wish to) change the types that should be made - conformant to a Range concept. If this is not true, see method 1. -

- -

- The primary templates in this library are implemented such that - certain functions are found via argument-dependent-lookup (ADL). - Below is given an overview of which free-standing functions a class - must specify to be useable as a certain Range concept. - Let x be a variable (const or mutable) - of the class in question. -

-

- - - - - - - - - - - - - -
- Function - Related concept
range_begin(x)Single Pass Range
range_end(x) - Single Pass Range
-

-

range_begin() and range_end() must be - overloaded for both const and mutable reference arguments. -

- -

- You must also specialize two metafunctions for your type X: -

-

- - - - - - - - - - - - - -
- Metafunction - Related concept
boost::range_mutable_iteratorSingle Pass Range
boost::range_const_iteratorSingle Pass Range
-

-

- A complete example is given here: -

-
-
-#include <boost/range.hpp>
-#include <iterator>         // for std::iterator_traits, std::distance()
-
-namespace Foo
-{
-    //
-    // Our sample UDT. A 'Pair'
-    // will work as a range when the stored
-    // elements are iterators.
-    //
-    template< class T >
-    struct Pair
-    {
-        T first, last;  
-    };
-
-} // namespace 'Foo'
-
-namespace boost
-{
-    //
-    // Specialize metafunctions. We must include the range.hpp header.
-    // We must open the 'boost' namespace.
-    //
-
-    template< class T >
-    struct range_mutable_iterator< Foo::Pair<T> >
-    {
-        typedef T type;
-    };
-
-    template< class T >
-    struct range_const_iterator< Foo::Pair<T> >
-    {
-        //
-        // Remark: this is defined similar to 'range_mutable_iterator'
-        //         because the 'Pair' type does not distinguish
-        //         between an iterator and a const_iterator.
-        //
-        typedef T type;
-    };
-
-} // namespace 'boost'
-
-namespace Foo
-{
-    //
-    // The required functions. These should be defined in
-    // the same namespace as 'Pair', in this case 
-    // in namespace 'Foo'.
-    //
-    
-    template< class T >
-    inline T range_begin( Pair<T>& x )
-    { 
-        return x.first;
-    }
-
-    template< class T >
-    inline T range_begin( const Pair<T>& x )
-    { 
-        return x.first;
-    }
-
-    template< class T >
-    inline T range_end( Pair<T>& x )
-    { 
-        return x.last;
-    }
-
-    template< class T >
-    inline T range_end( const Pair<T>& x )
-    { 
-        return x.last;
-    }
-
-} // namespace 'Foo'
-
-#include <vector>
-
-int main()
-{
-    typedef std::vector<int>::iterator  iter;
-    std::vector<int>                    vec;
-    Foo::Pair<iter>                     pair  = { vec.begin(), vec.end() };
-    const Foo::Pair<iter>&              cpair = pair; 
-    //
-    // Notice that we call 'begin' etc with qualification. 
-    //
-    iter i = boost::begin( pair );
-    iter e = boost::end( pair );
-    i      = boost::begin( cpair );
-    e      = boost::end( cpair );
-    boost::range_difference< Foo::Pair<iter> >::type s = boost::size( pair );
-    s      = boost::size( cpair );
-    boost::range_reverse_iterator< const Foo::Pair<iter> >::type
-    ri     = boost::rbegin( cpair ),
-    re     = boost::rend( cpair );
-}    
-
-
- -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt) -

-
-
-
-
-
-
-
-
-
-
-
-
- - diff --git a/doc/counting_range.html b/doc/counting_range.html deleted file mode 100755 index c44edcc..0000000 --- a/doc/counting_range.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Boost.Range Utilities - - - - - - - - - -

Boost.Range

-

Function counting_range

-

- The intention of the counting_range function is to construct - a new range with iterators that are wrapped in a - counting_iterator (from Boost.Iterator) -

- -

Synopsis

- -
namespace boost
-{
-    template< class Incrementable > inline
-    range< counting_iterator<Incrementable> >
-    counting_range(Incrementable first, Incrementable last);
-
-    template< class SinglePassRange > inline
-    range< counting_iterator<typename range_iterator<SinglePassRange>::type >
-    counting_range(const Range& rng);
-
-    template< class SinglePassRange > inline
-    range< counting_iterator<typename range_iterator<SinglePassRange>::type >
-    counting_range(Range& rng);
-            
-} // namespace 'boost'
-    
- -

- © Copyright Neil Groves 2009. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/examples.html b/doc/examples.html deleted file mode 100644 index d1f9887..0000000 --- a/doc/examples.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - Boost.Range Examples - - - - - - - - - - -

Boost.Range

- -

Examples

-

- Some examples are given in the accompanying test files: -

- - - -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/faq.html b/doc/faq.html deleted file mode 100644 index fcacf98..0000000 --- a/doc/faq.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - Boost.Range FAQ - - - - - - - - - - -

Boost.Range

- -

-

FAQ

-
    -
  1. - Why is there no difference between range_iterator<C>::type - and range_const_iterator<C>::type for std::pair<iterator, iterator>. - -

    - In general it is not possible nor desirable to find a corresponding const_iterator. - When it is possible to come up with one, the client might choose to construct a std::pair<const_iterator,const_iterator> - object. -

    -

    - Note that an iterator_range - is somewhat more convenient than a pair and that a sub_range does - propagate const-ness.

    -
  2. -
  3. - Why is there not supplied more types or more functions? -

    - The library has been kept small because its current interface will - serve most - purposes. If and when a genuine need arises for more functionality, it can be - implemented. -

    -
  4. -
  5. - How should I implement generic algorithms for ranges? -

    - One should always start with a generic algorithm that takes two iterators (or - more) as input. Then use Boost.Range to build handier versions on top of the - iterator based algorithm. Please notice that once the range version of the - algorithm is done, it makes sense not to expose the iterator version in - the public interface. -

    -
  6. -
  7. - Why is there no Incrementable Range concept? -

    - Even though we speak of incrementable iterators, it would not make - much sense for ranges; for example, we cannot determine the size and - emptiness of a range since we cannot even compare - its iterators. -

    -

    - Note also that incrementable iterators are derived from output - iterators and so there exist no output range. -

    -
  8. - - -
- - -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/headers.html b/doc/headers.html deleted file mode 100644 index c896bff..0000000 --- a/doc/headers.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - Boost.Range Headers - - - - - - - - - - -

Boost.Range

- -

-

Library headers

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HeaderIncludesRelated concept
<boost/range.hpp>everything-
<boost/range/metafunctions.hpp>every metafunction-
<boost/range/functions.hpp>every function-
<boost/range/value_type.hpp>range_valueSingle Pass Range
<boost/range/iterator.hpp>range_iteratorSingle Pass Range
<boost/range/mutable_iterator.hpp>range_mutable_iteratorSingle Pass Range
<boost/range/const_iterator.hpp>range_const_iteratorSingle Pass Range
<boost/range/difference_type.hpp>range_differenceForward Range
<boost/range/pointer.hpp>range_pointer-
<boost/range/category.hpp>range_category-
<boost/range/reverse_iterator.hpp>range_reverse_iteratorBidirectional Range
<boost/range/begin.hpp> - begin and - const_begin - Single Pass Range
<boost/range/end.hpp> - end and - const_end - Single Pass Range
<boost/range/empty.hpp>emptySingle Pass Range
<boost/range/distance.hpp>distanceForward Range
<boost/range/size.hpp>sizeRandom Access Range -
<boost/range/rbegin.hpp> - rbegin and - const_rbegin - Bidirectional Range
<boost/range/rend.hpp> - rend and - const_rend - Bidirectional Range
<boost/range/as_array.hpp> - as_array - -
<boost/range/as_literal.hpp> - as_literal - -
<boost/range/iterator_range.hpp>iterator_range-
<boost/range/sub_range.hpp>sub_range-
<boost/range/concepts.hpp>concept checks-
-
-

- - -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/history_ack.html b/doc/history_ack.html deleted file mode 100755 index 3191dd0..0000000 --- a/doc/history_ack.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - Boost.Range History and Acknowledgement - - - - - - - - - - -

Boost.Range

- -

History and Acknowledgement

-

- The library was under way for a long time. Dietmar Kühl originally intended - to submit an array_traits class template which had most of - the functionality present now, but only for arrays and standard containers. - I believe this was back in 2001 or 2002. -

- -

- Meanwhile work on algorithms for containers in various contexts showed the - need for handling pairs of iterators, and string libraries needed special - treatment of character arrays. In the end it made sense to formalize the - minimal requirements of these similar concepts. And the results are the - Range concepts found in this library.

- -

- The term Range was adopted because of paragraph 24.1/7 from the -C++ standard:

- Most of the library's algorithmic templates that operate on data - structures have interfaces that use ranges. A range is a pair of - iterators that designate the beginning and end of the computation. A - range [i, i) is an empty range; in general, a range [i, j) refers to - the elements in the data structure starting with the one pointed to - by i and up to but not including the one pointed to by j. Range [i, - j) is valid if and only if j is reachable from i. The result of the - application of functions in the library to invalid ranges is - undefined. -
- -

- Special thanks goes to -

-

-

- The concept checks and their documentation was provided by Daniel Walker. - -


-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_introduction.html b/doc/html/range/reference/range_algorithm/range_algorithm_introduction.html deleted file mode 100644 index e24351f..0000000 --- a/doc/html/range/reference/range_algorithm/range_algorithm_introduction.html +++ /dev/null @@ -1,257 +0,0 @@ - - - -Introduction and motivation - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

- - Introduction and motivation -

-

- In its most simple form a Range Algorithm - (or range-based algorithm) is simply an iterator-based algorithm where - the two iterator arguments have been replaced by - one range argument. For example, we may write -

-

- -

-
#include <boost/range/algorithm.hpp>
-#include <vector>
-
-std::vector<int> vec = ...;
-boost::sort(vec);
-
-

-

-

- instead of -

-

- -

-
std::sort(vec.begin(), vec.end());
-
-

-

-

- However, the return type of range algorithms is almost always different - from that of existing iterator-based algorithms. -

-

- One group of algorithms, like boost::sort(), will simply return the same range so - that we can continue to pass the range around and/or further modify it. - Because of this we may write -

-
boost:unique(boost::sort(vec));
-
-

- to first sort the range and then run unique() on the sorted range. -

-

- Algorithms like boost::unique() - fall into another group of algorithms that return (potentially) narrowed - views of the original range. By default boost::unique(rng) returns the range [boost::begin(rng), found) - where found denotes the - iterator returned by std::unique(boost::begin(rng), boost::end(rng)) -

-

- Therefore exactly the unique values can be copied by writing -

-
boost::copy(boost::unique(boost::sort(vec)),
-            std::ostream_iterator<int>(std::cout));
-
-

-

-

- Algorithms like boost::unique usually return the same range: - [boost::begin(rng), found). However, this behaviour may be changed - by supplying the algorithms with a template argument: -

-
---- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Expression -

-
-

- Return -

-
-

- boost::unique<boost::return_found>(rng) -

-
-

- returns a single iterator like std::unique -

-
-

- boost::unique<boost::return_begin_found>(rng) -

-
-

- returns the range [boost::begin(rng), - found) - (this is the default) -

-
-

- boost::unique<boost::return_begin_next>(rng) -

-
-

- returns the range [boost::begin(rng), - boost::next(found)) -

-
-

- boost::unique<boost::return_found_end>(rng) -

-
-

- returns the range [found, - boost::end(rng)) -

-
-

- boost::unique<boost::return_next_end>(rng) -

-
-

- returns the range [boost::next(found),boost::end(rng)) -

-
-

- boost::unique<boost::return_begin_end>(rng) -

-
-

- returns the entire original range. -

-
-

- This functionality has the following advantages: -

-
    -
  1. - it allows for seamless functional-style - programming where you do not need to use named - local variables to store intermediate results -
  2. -
  3. - it is very safe - because the algorithm can verify out-of-bounds conditions and handle - tricky conditions that lead to empty ranges -
  4. -
-

- For example, consider how easy we may erase the duplicates in a sorted - container: -

-

- -

-
std::vector<int> vec = ...;
-boost::erase(vec, boost::unique<boost::return_found_end>(boost::sort(vec)));
-
-

-

-

- Notice the use of boost::return_found_end. - What if we wanted to erase all the duplicates except one of them? In old-fashined - STL-programming we might write -

-

- -

-
// assume 'vec' is already sorted
-std::vector<int>::iterator i = std::unique(vec.begin(), vec.end());
-
-// remember this check or you get into problems
-if (i != vec.end())
-    ++i;
-    
-vec.erase(i, vec.end());
-
-

-

-

- The same task may be accomplished simply with -

-
boost::erase(vec, boost::unique<boost::return_next_end>(vec));
-
-

- and there is no need to worry about generating an invalid range. Furthermore, - if the container is complex, calling vec.begin() several times will be more expensive - than using a range algorithm. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms.html b/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms.html deleted file mode 100644 index 5c11829..0000000 --- a/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms.html +++ /dev/null @@ -1,50 +0,0 @@ - - - -Mutating algorithms - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-

- - Mutating algorithms -

-
-
- Range Algorithm - copy
-
- Range Algorithm - copy_backward
-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy.html b/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy.html deleted file mode 100644 index 4bf5ab0..0000000 --- a/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy.html +++ /dev/null @@ -1,115 +0,0 @@ - - - -Range Algorithm - copy - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-
- - Range Algorithm - copy -
-
- - Prototype -
-

- -

-
template<class SinglePassRange, class OutputIterator>
-OutputIterator copy(const SinglePassRange& source_rng, OutputIterator out_it);
-
-

-

-
- - Description -
-

- copy copies all elements - from source_rng to the - range [out_it, out_it - + distance(source_rng)). The return value is out_it + - distance(source_rng) -

-
- - Definition -
-

- Defined in the header file boost/range/algorithm/copy.hpp -

-
- - Requirements -
-
-
- - Precondition: -
-
-
- - Complexity -
-

- Linear. Exactly distance(source_rng) assignments are performed. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy_backward.html b/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy_backward.html deleted file mode 100644 index de14a89..0000000 --- a/doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy_backward.html +++ /dev/null @@ -1,124 +0,0 @@ - - - -Range Algorithm - copy_backward - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
-
- - Range Algorithm - copy_backward -
-
- - Prototype -
-

- -

-
template<class BidirectionalRange, class BidirectionalOutputIterator>
-    BidirectionalOutputIterator
-        copy_backward(const BidirectionalRange& source_rng,
-                      BidirectionalOutputIterator out_it);
-
-

-

-
- - Description -
-

- copy_backward copies - all elements from source_rng - to the range [out_it - - distance(source_rng), out_it). -

-

- The values are copied in reverse order. The return value is out_it - - distance(source_rng). -

-

- Note well that unlike all other standard algorithms out_it - denotes the end of the output sequence. -

-
- - Definition -
-

- Defined in the header file boost/range/algorithm/copy_backward.hpp -

-
- - Requirements -
-
-
- - Precondition: -
-
-
- - Complexity -
-

- Linear. Exactly distance(source_rng) assignments are performed. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_new_algorithms.html b/doc/html/range/reference/range_algorithm/range_algorithm_new_algorithms.html deleted file mode 100644 index a7f08e5..0000000 --- a/doc/html/range/reference/range_algorithm/range_algorithm_new_algorithms.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-

-??? -

- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html b/doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html deleted file mode 100644 index 9974a92..0000000 --- a/doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html +++ /dev/null @@ -1,42 +0,0 @@ - - - -Non-mutating algorithms - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-

- - Non-mutating algorithms -

- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/intro.html b/doc/intro.html deleted file mode 100644 index 89d3504..0000000 --- a/doc/intro.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - Boost.Range Introduction - - - - - - - - - - -

Boost.Range

- -

Introduction

-

- Generic algorithms have so far been specified in terms of two or more - iterators. Two iterators would together form a range of values that the - algorithm could work on. This leads to a very general interface, but also - to a somewhat clumsy use of the algorithms with redundant specification - of container names. Therefore we would like to raise the abstraction level - for algorithms so they specify their interface in terms of Ranges as much as possible. -

- -

- The most common form of ranges we are used to work with is standard library - containers. However, one - often finds it desirable to extend that code to work with other types that - offer - enough functionality to satisfy the needs of the generic code - if a suitable layer of indirection is applied . For - example, raw arrays are often suitable for use with generic code that - works with containers, provided a suitable adapter is used. -

- -

- This library therefore provides the means to adapt standard-like - containers, std::pairs of iterators, and raw arrays (and - more), such that - the same generic code can work with them all. -The basic idea is to add another layer of indirection using metafunctions and -free-standing functions so syntactic and/or semantic differences can be removed. -

- -

- The main advantages are -

-

-

Below is given a small example (the complete example can be found here):

-
-
-    //
-    // example: extracting bounds in a generic algorithm
-    //
-    template< class ForwardReadableRange, class T >
-    inline typename boost::range_iterator< ForwardReadableRange >::type
-    find( ForwardReadableRange& c, const T& value )
-    {
-       return std::find( boost::begin( c ), boost::end( c ), value );
-    }
-
-    template< class ForwardReadableRange, class T >
-    inline typename boost::range_iterator< const ForwardReadableRange >::type
-    find( const ForwardReadableRange& c, const T& value )
-    {
-       return std::find( boost::begin( c ), boost::end( c ), value );
-    }
-
-    //
-    // replace first value and return its index
-    //
-    template< class ForwardReadableWriteableRange, class T >
-    inline typename boost::range_difference< ForwardReadableWriteableRange >::type
-    my_generic_replace( ForwardReadableWriteableRange& c, const T& value, const T& replacement )
-    {
-       typename boost::range_iterator< ForwardReadableWriteableRange >::type found = find( c, value );
-
-       if( found != boost::end( c ) )
-           *found = replacement;
-       return std::distance( boost::begin( c ), found );
-    }
-
-    //
-    // usage
-    //
-    const int N = 5;
-    std::vector<int> my_vector;
-    int values[] = { 1,2,3,4,5,6,7,8,9 };
-    
-    my_vector.assign( values, boost::end( values ) );
-    typedef std::vector<int>::iterator iterator;
-    std::pair<iterator,iterator>       my_view( boost::begin( my_vector ),
-                                                boost::begin( my_vector ) + N );
-    char  str_val[] = "a string";
-    char* str       = str_val;
-
-    std::cout << my_generic_replace( my_vector, 4, 2 );
-    std::cout << my_generic_replace( my_view, 4, 2 );
-    std::cout << my_generic_replace( str, 'a', 'b' );
-
-    // prints '3', '5' and '0'     
-    
-
- - By using the free-standing functions and metafunctions, the code automatically - works for all the types supported by this library; now and in the future. -Notice that we have to - provide two version of find() since we cannot forward a non-const - rvalue with reference arguments (see this article about The - Forwarding Problem ). - -

- - -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/istream_range.html b/doc/istream_range.html deleted file mode 100755 index 8f41fc4..0000000 --- a/doc/istream_range.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - Boost.Range Utilities - - - - - - - - - -

Boost.Range

-

Function istream_range

-

- The intention of the istream_range function is to construct - a new range with a pair of std::istream_iterators that wrap a - specified std::basic_istream instance. -

- -

Synopsis

- -
-namespace boost
-{
-    template< class 
-        Type, class 
-            Elem, class Traits > inline
-    range< std::istream_iterator<Type, Elem, Traits> >
-    istream_range(std::basic_istream<Elem, Traits>& in);
-}    
- -

- © Copyright Neil Groves 2009. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/mfc_atl.html b/doc/mfc_atl.html deleted file mode 100644 index cc8eeb0..0000000 --- a/doc/mfc_atl.html +++ /dev/null @@ -1,581 +0,0 @@ - - - - - - -Boost Range MFC/ATL Extension - - - - - - -
-

Boost Range MFC/ATL Extension

- --- - - - - - - - - - -
Author:Shunsuke Sogame
Contact:mb2act@yahoo.co.jp
Date:26th of May 2006
Copyright:Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt).
-
-

Overview

-

Boost.Range MFC/ATL Extension provides Boost.Range support for MFC/ATL collection and string types.

-
-CTypedPtrArray<CPtrArray, CList<CString> *> myArray;
-...
-BOOST_FOREACH (CList<CString> *theList, myArray)
-{
-    BOOST_FOREACH (CString& str, *theList)
-    {
-        boost::to_upper(str);
-        std::sort(boost::begin(str), boost::end(str));
-        ...
-    }
-}
-
- -
-
-

Requirements

- -
-
-

MFC Ranges

-

If the <boost/range/mfc.hpp> is included before or after Boost.Range headers, -the MFC collections and strings become models of Range. -The table below lists the Traversal Category and range_reference of MFC ranges.

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RangeTraversal Categoryrange_reference<Range>::type
CArray<T,A>Random AccessT&
CList<T,A>BidirectionalT&
CMap<K,AK,M,AM>ForwardRange::CPair&
CTypedPtrArray<B,T*>Random AccessT* const
CTypedPtrList<B,T*>BidirectionalT* const
CTypedPtrMap<B,T*,V*>Forwardstd::pair<T*,V*> const
CByteArrayRandom AccessBYTE&
CDWordArrayRandom AccessDWORD&
CObArrayRandom AccessCObject* &
CPtrArrayRandom Accessvoid* &
CStringArrayRandom AccessCString&
CUIntArrayRandom AccessUINT&
CWordArrayRandom AccessWORD&
CObListBidirectionalCObject* &
CPtrListBidirectionalvoid* &
CStringListBidirectionalCString&
CMapPtrToWordForwardstd::pair<void*,WORD> const
CMapPtrToPtrForwardstd::pair<void*,void*> const
CMapStringToObForwardstd::pair<String,CObject*> const
CMapStringToStringForwardRange::CPair&
CMapWordToObForwardstd::pair<WORD,CObject*> const
CMapWordToPtrForwardstd::pair<WORD,void*> const
-

Other Boost.Range metafunctions are defined by the following. -Let Range be any type listed above and ReF be the same as range_reference<Range>::type. -range_value<Range>::type is the same as remove_reference<remove_const<Ref>::type>::type, -range_difference<Range>::type is the same as std::ptrdiff_t, and -range_pointer<Range>::type is the same as add_pointer<remove_reference<Ref>::type>::type. -As for const Range, see const Ranges.

-
-
-

ATL Ranges

-

If the <boost/range/atl.hpp> is included before or after Boost.Range headers, -the ATL collections and strings become models of Range. -The table below lists the Traversal Category and range_reference of ATL ranges.

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RangeTraversal Categoryrange_reference<Range>::type
CAtlArray<E,ET>Random AccessE&
CAutoPtrArray<E>Random AccessE&
CInterfaceArray<I,pi>Random AccessCComQIPtr<I,pi>&
CAtlList<E,ET>BidirectionalE&
CAutoPtrList<E>BidirectionalE&
CHeapPtrList<E,A>BidirectionalE&
CInterfaceList<I,pi>BidirectionalCComQIPtr<I,pi>&
CAtlMap<K,V,KT,VT>ForwardRange::CPair&
CRBTree<K,V,KT,VT>BidirectionalRange::CPair&
CRBMap<K,V,KT,VT>BidirectionalRange::CPair&
CRBMultiMap<K,V,KT,VT>BidirectionalRange::CPair&
CSimpleStringT<B,b>Random AccessB&
CStringT<B,ST>Random AccessB&
CFixedStringT<S,n>Random Accessrange_reference<S>::type
CStringT<B,ST>Random AccessB&
CComBSTRRandom AccessOLECHAR&
CSimpleArray<T,TE>Random AccessT&
-

Other Boost.Range metafunctions are defined by the following. -Let Range be any type listed above and ReF be the same as range_reference<Range>::type. -range_value<Range>::type is the same as remove_reference<Ref>::type, -range_difference<Range>::type is the same as std::ptrdiff_t, and -range_pointer<Range>::type is the same as add_pointer<remove_reference<Ref>::type>::type. -As for const Range, see const Ranges.

-
-
-

const Ranges

-

range_reference<const Range>::type is defined by the following algorithm. -Let Range be any type listed above and ReF be the same as range_reference<Range>::type.

-
-if (Range is CObArray || Range is CObList)
-    return CObject const * &
-else if (Range is CPtrArray || Range is CPtrList)
-    return void const * &
-else if (there is a type X such that X& is the same as ReF)
-    return X const &
-else if (there is a type X such that X* const is the same as ReF)
-    return X const * const
-else
-    return ReF
-
-

Other Boost.Range metafunctions are defined by the following. -range_value<const Range>::type is the same as range_value<Range>::type, -range_difference<const Range>::type is the same as std::ptrdiff_t, and -range_pointer<const Range>::type is the same as add_pointer<remove_reference<range_reference<const Range>::type>::type>::type.

-
-
-

References

- -
-
- - diff --git a/doc/portability.html b/doc/portability.html deleted file mode 100644 index bb73e78..0000000 --- a/doc/portability.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - Boost.Range Portability - - - - - - - - - - -

Boost.Range

- -

Portability

- -

- A huge effort has been made to port the library to as many compilers as possible. -

- -

- Full support for built-in arrays require that the compiler supports class - template partial specialization. For non-conforming compilers there might be a - chance that it works anyway thanks to workarounds in the type traits library. -

-

Visual C++ 6/7.0 has a limited support for arrays: as long as the arrays - are of built-in type it should work. -

-

- Notice also that some compilers cannot do function template ordering properly. - In that case one must rely on range_iterator - and a single function definition instead of overloaded versions for const and - non-const arguments. - - So if one cares about old compilers, one should not pass rvalues to the - functions. -

- -

- For maximum portability you should follow these guidelines: - -

    -
  1. - do not use built-in arrays, -
  2. - do not pass rvalues to begin(), end() and - iterator_range Range constructors and assignment operators, -
  3. - use const_begin() - and const_end() - whenever your code by intention is read-only; this will also solve - most rvalue problems, -
  4. - do not rely on ADL: - - -
-

- -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

> - -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/range.html b/doc/range.html deleted file mode 100644 index 8646141..0000000 --- a/doc/range.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - Range Concepts - - - - - - - - -

Boost.Range

- -

Range concepts

- - - - -
-

Overview

- -

- A Range is a concept similar to the STL Container concept. A - Range provides iterators for accessing a half-open range -[first,one_past_last) of elements and provides - information about the number of elements in the Range. However, a Range has - much fewer requirements than a Container. -

-

- The motivation for the Range concept is - that there are many useful Container-like types that do not meet the full - requirements of Container, and many algorithms that can be written with this - reduced set of requirements. In particular, a Range does not necessarily - -

- - - Because of the second requirement, a Range object must be passed by - (const or non-const) reference in generic code. - -

-

- The operations that can be performed on a Range is dependent on the - traversal -category of the underlying iterator type. Therefore - the range concepts are named to reflect which traversal category their - iterators support. See also terminology and style - guidelines. for more information about naming of ranges.

- -

The concepts described below specifies associated types as -metafunctions and all -functions as free-standing functions to allow for a layer of indirection.

- - - -
- -

Single Pass Range

- -

Notation

- - - - - - - - - -
XA type that is a model of Single Pass Range.
aObject of type X.
- - -

Description

-

- A range X where boost::range_iterator<X>::type is a model of -Single Pass Iterator - -

- - -

Associated types

- - - - - - - - - - - - - -
Iterator typeboost::range_iterator<X>::typeThe type of iterator used to iterate through a Range's elements. - The iterator's value type is expected to be the Range's value type. A - conversion from the iterator type to the const iterator type must exist. -
Const iterator typeboost::range_iterator<const X>::typeA type of iterator that may be used to examine, but not to - modify, a Range's elements.
- - -

Valid expressions

- - The following expressions must be valid. -

- - - - - - - - - - - - - - - - - -
NameExpressionReturn type
Beginning of rangeboost::begin(a)boost::range_iterator<X>::type if -a is mutable, boost::range_iterator<const X>::type -otherwise
End of rangeboost::end(a)boost::range_iterator<X>::type if -a is mutable, boost::range_iterator<const X>::type -otherwise
-

Expression semantics

- - - - - - - - - - - - - - - - - - -
ExpressionSemanticsPostcondition
boost::begin(a)Returns an iterator pointing to the first element in the Range.boost::begin(a) is either dereferenceable or past-the-end. - It is past-the-end if and only if boost::distance(a) == 0.
boost::end(a)Returns an iterator pointing one past the last element in the - Range.boost::end(a) is past-the-end.
- -

Complexity guarantees

- - boost::end(a) is at most amortized linear time, boost::begin(a) is - amortized constant time. For most practical - purposes, one can expect both to be amortized constant time. - -

Invariants

- - - - - - - - - -
Valid rangeFor any Range a, [boost::begin(a),boost::end(a)) is - a valid range, that is, boost::end(a) is reachable from boost::begin(a) - in a finite number of increments.
CompletenessAn algorithm that iterates through the range [boost::begin(a),boost::end(a)) - will pass through every element of a.
- - -

See also

-

Extending the library for UDTs

-

Implementation of - metafunctions

- -

Implementation of - functions

-

- Container -

- - -
-

Forward Range

- -

Notation

- - - - - - - - - -
XA type that is a model of Forward Range.
aObject of type X.
- -

Description

-

- A range X where boost::range_iterator<X>::type is a model -of Forward Traversal Iterator -

- -

Refinement of

Single Pass -Range - -

- -
- -

Bidirectional Range

- -

Notation

- - - - - - - - - -
XA type that is a model of Bidirectional Range.
aObject of type X.
- -

Description

This concept provides access to iterators that traverse in - both directions (forward and reverse). The -boost::range_iterator<X>::type iterator must meet all of the requirements -of Bidirectional Traversal Iterator. - -

Refinement of

Forward Range - - -

- -
- -

Random Access Range

-

Description

-

- A range X where boost::range_iterator<X>::type is a model -of Random Access Traversal Iterator -

- -

Refinement of

-

- Bidirectional Range -

- -
- -

Concept Checking

- - Each of the range concepts has a corresponding concept checking - class in the file <boost/range/concepts.hpp>. These classes may be - used in conjunction with the Boost Concept - Check library to insure that the type of a template parameter - is compatible with a range concept. If not, a meaningful compile - time error is generated. Checks are provided for the range - concepts related to iterator traversal categories. For example, - the following line checks that the type T models the - ForwardRange concept. - -
-    function_requires<ForwardRangeConcept<T> >();
-    
- - An additional concept check is required for the value access - property of the range based on the range's iterator type. For - example to check for a ForwardReadableRange, the following code is - required. - -
-    function_requires<ForwardRangeConcept<T> >();
-    function_requires<
-        ReadableIteratorConcept<
-            typename range_iterator<T>::type
-        >
-    >();
-    
- - The following range concept checking classes are provided. - - -

See also

-

Range Terminology and style guidelines

-

Iterator Concepts

-

Boost Concept Check library

- -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

-
-
-
-
-
-
-
-
-
-
- - - diff --git a/doc/style.html b/doc/style.html deleted file mode 100644 index 4240a8c..0000000 --- a/doc/style.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - Boost.Range Terminology and Style Guidelines - - - - - - - - - - -

Boost.Range

- -

Terminology and style guidelines

- -

- The use of a consistent terminology is as important for Ranges - and range-based algorithms as it is for iterators and iterator-based algorithms. - If a conventional set of names are adopted, we can avoid misunderstandings and - write generic function prototypes that are self-documenting. -

- -

- Since ranges are characterized by a specific underlying iterator type, we get a - type of range for each type of iterator. Hence we can speak of the following - types of ranges: -

- Notice how we have used the categories from the new - style iterators. - -

- Notice that an iterator (and therefore an range) has one traversal - property and one or more properties from the value access category. So in - reality we will mostly talk about mixtures such as -

- By convention, we should always specify the traversal property first as - done above. This seems reasonable since there will only be one traversal - property, but perhaps many value access properties. -

- -

- It might, however, be reasonable to specify only one category if the other - category does not matter. For example, the iterator_range can be constructed from - a Forward Range. This means that we do not care about what value access - properties the Range has. Similarly, a Readable Range will be one that has the - lowest possible traversal property (Single Pass). -

- -

- As another example, consider how we specify the interface of std::sort(). - Algorithms are usually more cumbersome to specify the interface of since both traversal - and value access properties must be exactly defined. The iterator-based - version looks like this: - -

-   template< class RandomAccessTraversalReadableWritableIterator >
-   void sort( RandomAccessTraversalReadableWritableIterator first,
-              RandomAccessTraversalReadableWritableIterator last );
-   
- For ranges the interface becomes - -
-   template< class RandomAccessReadableWritableRange >
-   void sort( RandomAccessReadableWritableRange& r );
-   
-

-

- -

- -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

-
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/upgrading.html b/doc/upgrading.html deleted file mode 100644 index 2d76111..0000000 --- a/doc/upgrading.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - Boost.Range Upgrading - - - - - - - - - -

Boost.Range

- -

Upgrading from Boost v. 1.34.*

-

- Boost v. 1.35 introduced some larger refactorings of the library: -

- - - -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/utility_class.html b/doc/utility_class.html deleted file mode 100644 index 956bf99..0000000 --- a/doc/utility_class.html +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - Boost.Range Utilities - - - - - - - - - -

Boost.Range

- -

Utilities

-

- Having an abstraction that encapsulates a pair of iterators is very useful. The - standard library uses std::pair in some circumstances, but that - class is cumbersome to use because we need to specify two template arguments, - and for all range algorithm purposes we must enforce the two template arguments - to be the same. Moreover, std::pair<iterator,iterator> is hardly - self-documenting whereas more domain specific class names are. Therefore these - two classes are provided: - -

- - The iterator_range class is templated on a Forward - Traversal Iterator and should be used whenever fairly general code is needed. - The sub_range class is templated on a Forward Range and it is less general, - but a bit easier to use since its template - argument is easier to specify. The biggest difference is, however, that a - sub_range can propagate constness because it knows what a -corresponding const_iterator is.

- -

- Both classes can be used as ranges since they implement the minimal interface - required for this to work automatically. -

- -
-

Class iterator_range

-

- 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 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. Likewise, if one creates a default constructed - iterator_range, then one have to be careful about not doing - anything besides copying.

- -

Synopsis

- -
-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;
-        difference_type size() const;
-        bool            empty() const;
-        
-    public: // convenience
-        operator        unspecified_bool_type() const;
-        bool            equal( const iterator_range& ) const;
-        reference       front() const;
-        reference       back() const;
-        iterator_range& advance_begin( difference_type n );
-        iterator_range& advance_end( difference_type n );
-        // for Random Access Range only: 
-        reference       operator[]( difference_type at ) const;
-        value_type      operator()( difference_type at ) 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<Range>::type advance_begin,
-                         typename range_difference<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.

- -

Details member functions

- -

- -operator unspecified_bool_type() const; -

-Returns !empty(); -
-

- -

- -bool equal( iterator_range& r ) const; -

- Returns begin() == r.begin() && end() == r.end(); -
-

- -

Details functions

- -

- -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) ); -
-

- -
-

Class 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. - -

Synopsis

- -
-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 ForwardRange2& 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[]( difference_type at );
-        const value_type& operator[]( difference_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, as_literal("ll") );
-    sub_range<std::string>               sub = find_first( str, as_literal("ll") );
-
-

- -
-

- © Copyright Thorsten Ottosen 2008. -

- -

- Distributed under the Boost Software License, Version 1.0. (See - accompanying file LICENSE_1_0.txt or copy - at www.boost.org/LICENSE_1_0.txt) -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - -