diff --git a/doc/boost_range.html b/doc/boost_range.html deleted file mode 100644 index 79b54c1..0000000 --- a/doc/boost_range.html +++ /dev/null @@ -1,547 +0,0 @@ - - - - Boost.Range Range Implementation - - - - - - - - - - - -


- Boost.Range

- -

Synopsis and Reference

- - -
- - -

Overview

-

- Four 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_value;
-                 
-    template< class T >
-    struct range_iterator;
-    
-    template< class T >
-    struct range_const_iterator;
-    
-    //
-    // Forward Range metafunctions
-    //
-    
-    template< class T >
-    struct range_difference;
-    
-    template< class T >
-    struct range_size;
-    
-    //
-    // Bidirectional Range metafunctions
-    //
-    
-    template< class T >
-    struct range_reverse_iterator;
-
-    template< class T >
-    struct range_const_reverse_iterator;
-    
-    //
-    // Special metafunctions
-    //
-    
-    template< class T >
-    struct range_result_iterator;
-                 
-    template< class T >
-    struct range_reverse_result_iterator;
-
-    //
-    // Single Pass Range functions
-    //
-    
-    template< class T >
-    typename range_iterator<T>::type
-    begin( T& c );
-    
-    template< class T >
-    typename range_const_iterator<T>::type
-    begin( const T& c );
-        
-    template< class T >
-    typename range_iterator<T>::type
-    end( T& c );
-                      
-    template< class T >
-    typename range_const_iterator<T>::type
-    end( const T& c );
-    
-    template< class T >
-    bool
-    empty( const T& c );
-               
-    //
-    // Forward Range functions
-    //
-    
-    template< class T >
-    typename range_size<T>::type
-    size( const T& c );
-                            
-    //
-    // Bidirectional Range functions
-    //
-                     
-    template< class T >
-    typename range_reverse_iterator<T>::type
-    rbegin( T& c );
-    
-    template< class T >
-    typename range_const_reverse_iterator<T>::type
-    rbegin( const T& c );
-        
-    template< class T >
-    typename range_reverse_iterator<T>::type
-    rend( T& c );
-                      
-    template< class T >
-    typename range_const_reverse_iterator<T>::type
-    rend( const T& c );
-    
-    //
-    // Special const Range functions
-    // 
-    
-    template< class T >
-    typename range_const_iterator<T>::type 
-    const_begin( const T& r );
-    
-    template< class T >
-    typename range_const_iterator<T>::type 
-    const_end( const T& r );
-    
-    template< class T >
-    typename range_const_reverse_iterator<T>::type 
-    const_rbegin( const T& r );
-    
-    template< class T >
-    typename range_const_reverse_iterator<T>::type 
-    const_rend( 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

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionReturn typeComplexity
range_value<X>::typeT::value_type
- boost::iterator_value<P::first_type>::type
- A
- Char -
compile time
range_iterator<X>::typeT::iterator
- P::first_type
- A*
- Char* -
compile time
range_const_iterator<X>::typeT::const_iterator
- P::first_type
- const A*
- const Char* -
compile time
range_difference<X>::typeT::difference_type
- boost::iterator_difference<P::first_type>::type
- std::ptrdiff_t
- std::ptrdiff_t
-
compile time
range_size<X>::typeT::size_type
- std::size_t
- std::size_t
- std::size_t
-
compile time
range_result_iterator<X>::typerange_const_iterator<X>::type if X is const
- range_iterator<X>::type otherwise
compile time
range_reverse_iterator<X>::typeboost::reverse_iterator< typename range_iterator<T>::type >
-
compile time
range_const_reverse_iterator<X>::typeboost::reverse_iterator< typename range_const_iterator<T>::type > -
-
compile time
range_reverse_result_iterator<X>::typeboost::reverse_iterator< typename range_result_iterator<T>::type - > - compile time
-

-

- The special metafunctions range_result_iterator and range_reverse_result_iterator - are not part of any Range concept, but they are very useful when implementing - certain Range classes like sub_range because of their - ability to select iterators based on constness. -

- -

Functions

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionReturn typeReturnsComplexity
begin(x)range_result_iterator<X>::typet.begin()
- p.first
- a
- s -
constant time
end(x)range_result_iterator<X>::typet.end()
- p.second
- a + sz
- s + std::char_traits<X>::length( s ) if X is Char* -
- s + sz - 1 if X is Char[sz]
- - -
linear if X is Char*
- constant time otherwise
empty(x)boolbegin(x) == end( x )
-
linear if X is Char*
- constant time otherwise
-
size(x)range_size<X>::typet.size()
- std::distance(p.first,p.second)
- sz
- end(s) - s - -
linear if X is Char*
- or if std::distance() is linear
- constant time otherwise
rbegin(x)range_reverse_result_iterator<X>::typerange_reverse_result_iterator<X>::type( end(x) )
-
same as end(x)
rend(x)range_reverse_result_iterator<X>::typerange_reverse_result_iterator<X>::type( begin(x) ) - same as begin(x)
const_begin(x)range_const_iterator<X>::typerange_const_iterator<X>::type( begin(x) ) -
same as begin(x)
const_end(x)range_const_iterator<X>::typerange_const_iterator<X>::type( end(x) ) - same as end(x)
const_rbegin(x)range_const_reverse_iterator<X>::typerange_const_reverse_iterator<X>::type( rbegin(x) ) -
same as rbegin(x)
const_rend(x)range_const_reverse_iterator<X>::typerange_const_reverse_iterator<X>::type( rend(x) ) - same as rend(x)
-

- -

- The special const functions are not part of any Range concept, - but are very useful when you want to document clearly that your code is - read-only. -

- -
-

Extending the library

-

- 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 functionRelated concept
begin()Single Pass Range
end() Single Pass Range
size()Forward 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 typeRelated concept
value_typeSingle Pass Range
iteratorSingle Pass Range
const_iteratorSingle Pass Range
difference_typeForward Range
size_typeForward Range
-

-

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

- -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - diff --git a/doc/examples.html b/doc/examples.html deleted file mode 100755 index 6db7253..0000000 --- a/doc/examples.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Boost.Range Examples - - - - - - - - - - -

Boost.Range

- -

Examples

-

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

- - -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/faq.html b/doc/faq.html deleted file mode 100755 index 34304ef..0000000 --- a/doc/faq.html +++ /dev/null @@ -1,138 +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>. -
  2. -

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

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

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/headers.html b/doc/headers.html deleted file mode 100755 index 6e3b77e..0000000 --- a/doc/headers.html +++ /dev/null @@ -1,171 +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/const_iterator.hpp>range_const_iteratorSingle Pass Range
<boost/range/difference_type.hpp>range_differenceForward Range
<boost/range/size_type.hpp>range_sizeForward Range
<boost/range/result_iterator.hpp>range_result_iterator-
<boost/range/reverse_iterator.hpp>range_reverse_iteratorBidirectional Range
<boost/range/const_reverse_iterator.hpp>range_const_reverse_iteratorBidirectional Range
<boost/range/reverse_result_iterator.hpp>range_reverse_result_iterator-
<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/size.hpp>sizeForward Range
<boost/range/rbegin.hpp> - rbegin and - const_rbegin - Bidirectional Range
<boost/range/rend.hpp> - rend and - const_rend - Bidirectional Range
<boost/range/iterator_range.hpp>iterator_range-
<boost/range/sub_range.hpp>sub_range-
-
- - -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

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

Boost.Range

- -

History and Acknowledgement

-

- The library have been 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. -

- -

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

-

-
-

- (C) Copyright Thorsten Ottosen 2003-2005 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/intro.html b/doc/intro.html deleted file mode 100755 index 0161f42..0000000 --- a/doc/intro.html +++ /dev/null @@ -1,168 +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. Likewise, null - terminated strings can be treated as containers of characters, if suitably - adapted. -

- -

- This library therefore provides the means to adapt standard-like - containers, - null terminated strings, 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 are 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_const_iterator< 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_size< 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 )
-              << my_generic_replace( my_view, 4, 2 )
-              << 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 ). - -

- - -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/portability.html b/doc/portability.html deleted file mode 100755 index ae3a264..0000000 --- a/doc/portability.html +++ /dev/null @@ -1,97 +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 of range_result_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: -
      -
    • - if you overload functions, include that header before the headers in this - library, -
    • - put all overloads in namespace boost. -
    - -
-

- -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/range.html b/doc/range.html deleted file mode 100755 index b2f907c..0000000 --- a/doc/range.html +++ /dev/null @@ -1,493 +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 - 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 its - 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

- - - - - - - - - - - - - - - - -
Value typeboost::range_value<X>::typeThe type of the object stored in a Range. -
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_const_iterator<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_const_iterator<X>::type -otherwise
End of rangeboost::end(a)boost::range_iterator<X>::type if -a is mutable, boost::range_const_iterator<X>::type -otherwise
Is range empty?boost::empty(a)Convertible to bool
-

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::size(a) == 0.
boost::end(a)Returns an iterator pointing one past the last element in the - Range.boost::end(a) is past-the-end.
boost::empty(a)Equivalent to boost::begin(a) == boost::end(a). (But possibly - faster.) - 
- -

Complexity guarantees

- - All three functions are at most amortized linear time. For most practical - purposes, one can expect boost::begin(a), boost::end(a) and boost::empty(a) - 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

-

- Container -

-

implementation of - metafunctions

- -

implementation of - functions

- -
-

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

Associated types

- - - - - - - - - - - - -
Distance typeboost::range_difference<X>::typeA signed integral type used to represent the distance between - two of the Range's iterators. This type must be the same as the iterator's - distance type.
Size typeboost::range_size<X>::typeAn unsigned integral type that can represent any nonnegative - value of the Range's distance type.
- -

Valid expressions

- - - - - - - - - - - - -
NameExpressionReturn type
Size of rangeboost::size(a)boost::range_size<X>::type
- -

Expression semantics

- - - - - - - - - - - - -
ExpressionSemanticsPostcondition
boost::size(a)Returns the size of the Range, that is, its number -of elements. Note boost::size(a) == 0u is equivalent to -boost::empty(a).boost::size(a) >= 0
- -

Complexity guarantees

- -

boost::size(a) is at most amortized linear time.

- -

Invariants

-

- - - -
Range sizeboost::size(a) is equal to the distance from boost::begin(a) - to boost::end(a).
-

- -

See also

-

implementation of - metafunctions

- -

implementation of - functions

- -
- -

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

Associated types

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

Valid expressions

- - - - - - - - - - - - - - - - - - - -
NameExpressionReturn typeSemantics
Beginning of rangerboost::begin(a)boost::range_reverse_iterator<X>::type if -a is mutable, boost::range_const_reverse_iterator<X>::type -otherwise.Equivalent to -boost::range_reverse_iterator<X>::type(boost::end(a)).
End of rangerboost::end(a)boost::range_reverse_iterator<X>::type if -a is mutable, boost::range_const_reverse_iterator<X>::type -otherwise.Equivalent to -boost::range_reverse_iterator<X>::type(boost::begin(a)).
- -

Complexity guarantees

- - rboost::begin(a) has the same complexity as boost::end(a) and rboost::end(a) - has the same complexity as boost::begin(a) from Forward Range. - -

Invariants

-

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

- -

See also

-

implementation of metafunctions

- -

implementation of - functions

- -
- -

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 -

- -
- - - - - - - - - - -
Copyright © 2000Jeremy Siek -
Copyright © 2004Thorsten Ottosen. -
- -
-
-
-
-
-
-
-
-
-
- - - diff --git a/doc/style.css b/doc/style.css deleted file mode 100755 index 1890b52..0000000 --- a/doc/style.css +++ /dev/null @@ -1,31 +0,0 @@ -pre{ - BORDER-RIGHT: gray 1pt solid; - PADDING-RIGHT: 2pt; - BORDER-TOP: gray 1pt solid; - DISPLAY: block; - PADDING-LEFT: 2pt; - PADDING-BOTTOM: 2pt; - BORDER-LEFT: gray 1pt solid; - MARGIN-RIGHT: 32pt; - PADDING-TOP: 2pt; - BORDER-BOTTOM: gray 1pt solid; - FONT-FAMILY: "Courier New", Courier, mono; - background-color: #EEEEEE; -} - - -.keyword{color: #0000FF;} -.identifier{} -.comment{font-style: italic; color: #008000;} -.special{color: #800040;} -.preprocessor{color: #3F007F;} -.string{font-style: italic; color: #666666;} -.literal{font-style: italic; color: #666666;} - -table -{ - cellpadding: 5px; - border: 2px; -} - - diff --git a/doc/style.html b/doc/style.html deleted file mode 100755 index 9a5617e..0000000 --- a/doc/style.html +++ /dev/null @@ -1,126 +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 );
-   
-

-

- -

- -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/doc/utility_class.html b/doc/utility_class.html deleted file mode 100644 index 33c95ae..0000000 --- a/doc/utility_class.html +++ /dev/null @@ -1,374 +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 an - Forward - Traversal Iterator and should be used whenever fairly general code is needed. - The sub_range class is templated on an 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 - Forward 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 means that the - iterator_range will still be usable in many contexts even - though the iterators underneath are not. -

- -

Synopsis

- -
-namespace boost
-{
-    template< class ForwardTraversalIterator >
-    class iterator_range
-    {
-    public: // Forward Range types
-        typedef ...                        value_type;
-        typedef ...                        difference_type;
-        typedef ...                        size_type;
-        typedef ForwardTraversalIterator   iterator;
-        typedef ForwardTraversalIterator   const_iterator;
-
-    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;
-        size_type size() const;
-        bool      empty() const;
-        
-    public: // convenience
-        operator    unspecified_bool_type() const;
-        bool        equal( const iterator_range& ) const;
-        value_type& front() const;
-        value_type& back() const;
-        // for Random Access Range only: 
-        value_type& operator[]( size_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 iterator_of<ForwardRange>::type >
-    make_iterator_range( ForwardRange& r );
-
-    template< class ForwardRange >
-    iterator_range< typename const_iterator_of<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_const_iterator<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_result_iterator<ForwardRange>::type >
-    {
-    public: 
-        typedef typename range_result_iterator<ForwardRange>::type iterator;
-        typedef typename range_const_iterator<ForwardRange>::type  const_iterator;
-    
-    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" );
-
-

- -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - diff --git a/index.html b/index.html deleted file mode 100755 index 05a90d3..0000000 --- a/index.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - -Boost.Range Documentation - - - - - - - - - -
-

Range Library

-
- -

- Copyright © 2003-2004 Thorsten Ottosen -

-

- Use, modification and distribution is subject to the Boost Software License, Version 1.0 - (see - http://www.boost.org/LICENSE_1_0.txt). -

- -

Overview

-

- Boost.Range is a collection of concepts and utilities that are particularly - useful for specifying and implementing generic algorithms. The documentation - consists of the following sections: -

- - - -
-

- (C) Copyright Thorsten Ottosen 2003-2004 -

- -
-
-
-
-
-
-
-
-
-
-
-
- - - - - - - diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100755 index c80a535..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,40 +0,0 @@ -# Boost.Range library -# -# Copyright Thorsten Ottosen 2003-2004. Use, modification and -# distribution is subject to the Boost Software License, Version -# 1.0. (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) -# -# For more information, see http://www.boost.org/libs/range/ -# - -subproject libs/range/test ; - -import testing ; - -rule range-test ( name : includes * ) -{ - return [ - run $(name).cpp - ../../test/build/boost_unit_test_framework - : - : - : $(BOOST_ROOT) - $(includes) - ] ; -} - -test-suite range : - [ range-test array ] - [ range-test iterator_pair ] - [ range-test std_container ] - [ range-test string ] - [ range-test iterator_range ] - [ range-test sub_range ] - [ range-test partial_workaround ] - [ range-test algorithm_example ] - [ range-test reversible_range ] - [ range-test const_ranges ] -# [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] - ; - diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 1e005ce..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,34 +0,0 @@ -# Boost.Range library -# -# Copyright Thorsten Ottosen 2003-2004. Use, modification and -# distribution is subject to the Boost Software License, Version -# 1.0. (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) -# -# For more information, see http://www.boost.org/libs/range/ -# - -rule range-test ( name : includes * ) -{ - return [ - run $(name).cpp /boost/test//boost_unit_test_framework - : - : - : $(includes) - ] ; -} - -test-suite range : - [ range-test array ] - [ range-test iterator_pair ] - [ range-test std_container ] - [ range-test string ] - [ range-test iterator_range ] - [ range-test sub_range ] - [ range-test partial_workaround ] - [ range-test algorithm_example ] - [ range-test reversible_range ] - [ range-test const_ranges ] - [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] - ; - diff --git a/test/TODO b/test/TODO deleted file mode 100644 index 8b13789..0000000 --- a/test/TODO +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/adl_conformance.cpp b/test/adl_conformance.cpp deleted file mode 100755 index b44b7c4..0000000 --- a/test/adl_conformance.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include - -enum adl_types -{ - unused, - boost_namespace, - templated_namespace, - non_templated_namespace, - global_namespace -}; - -namespace boost -{ - namespace range_detail - { - template< class Range > - inline typename Range::iterator begin( Range& r ) - { - return boost_namespace; - } - - template< class Range > - inline typename Range::iterator begin( const Range& r ) - { - return boost_namespace; - } - - } - - template< class Range > - inline typename Range::iterator begin( Range& r ) - { - using range_detail::begin; // create ADL hook - return begin( r ); - } - - template< class Range > - inline typename Range::iterator begin( const Range& r ) - { - using range_detail::begin; // create ADL hook - return begin( r ); - } -} - - -namespace find_templated -{ - template< class T > - struct range - { - typedef adl_types iterator; - - range() { /* allow const objects */ } - iterator begin() { return unused; } - iterator begin() const { return unused; } - iterator end() { return unused; } - iterator end() const { return unused; } - }; - - // - // A fully generic version here will create - // ambiguity. - // - template< class T > - inline typename range::iterator begin( range& r ) - { - return templated_namespace; - } - - template< class T > - inline typename range::iterator begin( const range& r ) - { - return templated_namespace; - } - -} - -namespace find_non_templated -{ - struct range - { - typedef adl_types iterator; - - range() { /* allow const objects */ } - iterator begin() { return unused; } - iterator begin() const { return unused; } - iterator end() { return unused; } - iterator end() const { return unused; } - }; - - inline range::iterator begin( range& r ) - { - return non_templated_namespace; - } - - - inline range::iterator begin( const range& r ) - { - return non_templated_namespace; - } -} - -struct range -{ - typedef adl_types iterator; - - range() { /* allow const objects */ } - iterator begin() { return unused; } - iterator begin() const { return unused; } - iterator end() { return unused; } - iterator end() const { return unused; } -}; - -inline range::iterator begin( range& r ) -{ - return global_namespace; -} - -inline range::iterator begin( const range& r ) -{ - return global_namespace; -} - -void check_adl_conformance() -{ - find_templated::range r; - const find_templated::range r2; - find_non_templated::range r3; - const find_non_templated::range r4; - range r5; - const range r6; - - // - // Notice how ADL kicks in even when we have qualified - // notation! - // - - - BOOST_CHECK( boost::begin( r ) != boost_namespace ); - BOOST_CHECK( boost::begin( r2 ) != boost_namespace ); - BOOST_CHECK( boost::begin( r3 ) != boost_namespace ); - BOOST_CHECK( boost::begin( r4 ) != boost_namespace ); - BOOST_CHECK( boost::begin( r5 ) != boost_namespace ); - BOOST_CHECK( boost::begin( r6 ) != boost_namespace ); - - BOOST_CHECK_EQUAL( boost::begin( r ), templated_namespace ) ; - BOOST_CHECK_EQUAL( boost::begin( r2 ), templated_namespace ); - BOOST_CHECK_EQUAL( boost::begin( r3 ), non_templated_namespace ); - BOOST_CHECK_EQUAL( boost::begin( r4 ), non_templated_namespace ); - BOOST_CHECK_EQUAL( boost::begin( r5 ), global_namespace ); - BOOST_CHECK_EQUAL( boost::begin( r6 ), global_namespace ); -} - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_adl_conformance ) ); - - return test; -} - - diff --git a/test/adl_conformance_no_using.cpp b/test/adl_conformance_no_using.cpp deleted file mode 100755 index 82c1cd2..0000000 --- a/test/adl_conformance_no_using.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include - -namespace A -{ - namespace detail - { - template< typename T > - int f( const T& x ) - { - // Default: - std::cout << 1 << std::endl; - return 1; - } - - template< typename T > - int adl_f2( const T& x, int* ) - { - return f( x ); - } - - template< typename T > - int adl_f( const T& x ) - { - return adl_f2( x, 0 ); - } - } - - template< typename T > - int f( const T& x ) - { - return detail::adl_f( x ); - } - - template< typename T > - int adl_f2( const T& x, int ) - { - return detail::f( x ); - } - - //-------------------------------- - - class C {}; -/* - // Optional: - int f( const C& x ) - { - std::cout << 2 << std::endl; - } -*/ - template< typename T > - class D {}; -/* - // Optional: - template< typename T > - int f( const D< T >& x ) - { - std::cout << 3 << std::endl; - } - */ -} - - -namespace B -{ - class C {}; - - // Optional: -/* int f( const C& ) - { - std::cout << 4 << std::endl; - } -*/ - template< typename T > - class D {}; -/* - // Optional: - template< typename T > - int f( const D< T >& x ) - { - std::cout << 5 << std::endl; - } - */ -} - -int main() -{ - A::f( 42 ); - - A::C ac; - A::f( ac ); - - A::D< int > ad; - A::f( ad ); - - B::C bc; - A::f( bc ); - - B::D< int > bd; - A::f( bd ); -} diff --git a/test/algorithm_example.cpp b/test/algorithm_example.cpp deleted file mode 100755 index cd6e0e0..0000000 --- a/test/algorithm_example.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include -#include -#include - -namespace -{ - // - // example: extrating bounds in a generic algorithm - // - template< typename Range, typename T > - inline typename boost::range_iterator::type - find( Range& c, const T& value ) - { - return std::find( boost::begin( c ), boost::end( c ), value ); - } - - template< typename Range, typename T > - inline typename boost::range_const_iterator::type - find( const Range& c, const T& value ) - { - return std::find( boost::begin( c ), boost::end( c ), value ); - } - - // - // replace first value and return its index - // - template< class Range, class T > - inline typename boost::range_size::type - my_generic_replace( Range& c, const T& value, const T& replacement ) - { - typename boost::range_iterator::type found = find( c, value ); - - if( found != boost::end( c ) ) - *found = replacement; - return std::distance( boost::begin( c ), found ); - } -} - - -void check_algorithm() -{ - // - // usage - // - const unsigned N = 5; - std::vector my_vector; - int values[] = { 1,2,3,4,5,6,7,8,9 }; - my_vector.assign( values, values + 9 ); - typedef std::vector::iterator iterator; - std::pair my_view( boost::begin( my_vector ), - boost::begin( my_vector ) + N ); - char str_val[] = "a string"; - char* str = str_val; - - BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3u ); - BOOST_CHECK_EQUAL( my_generic_replace( my_view, 4, 2 ), N ); - BOOST_CHECK_EQUAL( my_generic_replace( str, 'a', 'b' ), 0u ); - -} - -#include -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_algorithm ) ); - - return test; -} - - - diff --git a/test/array.cpp b/test/array.cpp deleted file mode 100755 index d2f00b0..0000000 --- a/test/array.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_array() -{ - const int sz = 9; - typedef int array_t[sz]; - int my_array[sz] = { 1,2,3,4,5,6,7,8,9 }; - const array_t ca = { 1,2,3,4,5,6,7,8,10 }; - - -// BOOST_RANGE_NO_STATIC_ASSERT -#if !defined( __BORLANDC__ ) -#else - BOOST_STATIC_ASSERT(( is_same< range_value::type, int >::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, int* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, int* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const int* >::value )); - - BOOST_STATIC_ASSERT(( is_same< range_value::type, const int >::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const int* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const int* >::value )); -#endif - - BOOST_CHECK_EQUAL( begin( my_array ), my_array ); - BOOST_CHECK_EQUAL( end( my_array ), my_array + size( my_array ) ); - BOOST_CHECK_EQUAL( empty( my_array ), false ); - - BOOST_CHECK_EQUAL( begin( ca ), ca ); - BOOST_CHECK_EQUAL( end( ca ), ca + size( ca ) ); - BOOST_CHECK_EQUAL( empty( ca ),false ); - -} - -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_array ) ); - - return test; -} - - - - - diff --git a/test/compat1.cpp b/test/compat1.cpp deleted file mode 100755 index e69de29..0000000 diff --git a/test/compat2.cpp b/test/compat2.cpp deleted file mode 100755 index 412fb7e..0000000 --- a/test/compat2.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include - -enum Container {}; -enum String {}; - -template< typename T > -struct range_iterator; - -template<> -struct range_iterator -{ - template< typename C > - struct pts - { - typedef BOOST_DEDUCED_TYPENAME C::iterator type; - }; -}; - -template<> -struct range_iterator -{ - template< typename C > - struct pts - { - typedef C type; - }; -}; - -template< typename C > -class iterator_of -{ -public: - typedef range_iterator::BOOST_NESTED_TEMPLATE pts::type type; -}; - -#include - -void compat1() -{ - std::vector v; - iterator_of< std::vector >::type i = v.begin(); -} - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &compat1 ) ); - - return test; -} - - - - - - diff --git a/test/compat3.cpp b/test/compat3.cpp deleted file mode 100755 index 00987e4..0000000 --- a/test/compat3.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include -#include - -enum Container {}; -enum String {}; - -template< typename T > -struct range_iterator; - -template<> -struct range_iterator -{ - template< typename C > - struct pts - { - typedef BOOST_DEDUCED_TYPENAME C::iterator type; - }; -}; - -template<> -struct range_iterator -{ - template< typename C > - struct pts - { - typedef C type; - }; -}; - -template< typename C > -class iterator_of -{ -public: - typedef BOOST_DEDUCED_TYPENAME range_iterator:: template pts::type type; -}; - -#include - -void compat1() -{ - std::vector v; - iterator_of< std::vector >::type i = v.begin(); -} - -#include - -using boost::unit_test_framework::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &compat1 ) ); - - return test; -} - - - - - - diff --git a/test/const_ranges.cpp b/test/const_ranges.cpp deleted file mode 100755 index 6360317..0000000 --- a/test/const_ranges.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -template< class T > -const T& as_const( const T& r ) -{ - return r; -} - -void check_const_ranges() -{ - std::string foo( "foo" ); - const std::string bar( "bar" ); - - BOOST_CHECK( const_begin( foo ) == begin( as_const( foo ) ) ); - BOOST_CHECK( const_end( foo ) == end( as_const( foo ) ) ); - BOOST_CHECK( const_rbegin( foo ) == rbegin( as_const( foo ) ) ); - BOOST_CHECK( const_rend( foo ) == rend( as_const( foo ) ) ); - - BOOST_CHECK( const_begin( bar ) == begin( as_const( bar ) ) ); - BOOST_CHECK( const_end( bar ) == end( as_const( bar ) ) ); - BOOST_CHECK( const_rbegin( bar ) == rbegin( as_const( bar ) ) ); - BOOST_CHECK( const_rend( bar ) == rend( as_const( bar ) ) ); - -} - - - -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_const_ranges ) ); - - return test; -} - - - - - diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp deleted file mode 100755 index 74358ef..0000000 --- a/test/iterator_pair.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include -#include - -using namespace boost; - -void check_iterator_pair() -{ - typedef std::vector vec_t; - vec_t vec; - vec.push_back( 4 ); - typedef std::pair - pair_t; - typedef std::pair - const_pair_t; - typedef const pair_t const_pair_tt; - pair_t pair = std::make_pair( begin( vec ), end( vec ) ); - const_pair_t const_pair = std::make_pair( begin( vec ), end( vec ) ); - const_pair_tt constness_pair( pair ); - - - BOOST_STATIC_ASSERT(( is_same< range_value::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, - detail::iterator_traits::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const_pair_t::first_type >::value )); - - BOOST_STATIC_ASSERT(( is_same< range_value::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, - detail::iterator_traits::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const_pair_tt::first_type >::value )); - - BOOST_CHECK( begin( pair ) == pair.first ); - BOOST_CHECK( end( pair ) == pair.second ); - BOOST_CHECK( empty( pair ) == (pair.first == pair.second) ); - BOOST_CHECK( size( pair ) == std::size_t( std::distance( pair.first, pair.second ) ) ); - - BOOST_CHECK( begin( const_pair ) == const_pair.first ); - BOOST_CHECK( end( const_pair ) == const_pair.second ); - BOOST_CHECK( empty( const_pair ) == (const_pair.first == const_pair.second) ); - BOOST_CHECK( size( const_pair ) == std::size_t( std::distance( const_pair.first, const_pair.second ) ) ); - - BOOST_CHECK( begin( constness_pair ) == constness_pair.first ); - BOOST_CHECK( end( constness_pair ) == constness_pair.second ); - BOOST_CHECK( empty( constness_pair ) == (constness_pair.first == const_pair.second) ); - BOOST_CHECK( size( constness_pair ) == std::size_t( std::distance( constness_pair.first, constness_pair.second ) ) ); - -} - - -#include -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_iterator_pair ) ); - - return test; -} - - - - - - diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp deleted file mode 100755 index fbf168c..0000000 --- a/test/iterator_range.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - - -#include -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_iterator_range() -{ - - typedef string::iterator iterator; - typedef string::const_iterator const_iterator; - typedef iterator_range irange; - typedef iterator_range cirange; - string str = "hello world"; - const string cstr = "const world"; - irange r = make_iterator_range( str ); - r = make_iterator_range( str.begin(), str.end() ); - cirange r2 = make_iterator_range( cstr ); - r2 = make_iterator_range( cstr.begin(), cstr.end() ); - r2 = make_iterator_range( str ); - - BOOST_CHECK( !r.empty() ); - BOOST_CHECK( !r2.empty() ); - -//#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// if( !(bool)r ) -// BOOST_CHECK( false ); -// if( !(bool)r2 ) -// BOOST_CHECK( false ); -//#else - if( !r ) - BOOST_CHECK( false ); - if( !r2 ) - BOOST_CHECK( false ); -//#endif - - BOOST_CHECK_EQUAL( r.size(), size( r ) ); - BOOST_CHECK_EQUAL( r2.size(), size( r2 ) ); - - BOOST_CHECK_EQUAL( distance( r.begin(), r.end() ), - distance( begin( r2 ), end( r2 ) ) ); - cout << r << r2; - - string res = copy_range( r ); - BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) ); - - irange rr = make_iterator_range( str ); - BOOST_CHECK( rr.equal( r ) ); - - rr = make_iterator_range( str.begin(), str.begin() + 5 ); - BOOST_CHECK( rr == "hello" ); - BOOST_CHECK( rr != "hell" ); - BOOST_CHECK( rr < "hello dude" ); - BOOST_CHECK( "hello" == rr ); - BOOST_CHECK( "hell" != rr ); - BOOST_CHECK( ! ("hello dude" < rr ) ); - irange rrr = rr; - BOOST_CHECK( rrr == rr ); - BOOST_CHECK( !( rrr != rr ) ); - BOOST_CHECK( !( rrr < rr ) ); - - const irange cr = make_iterator_range( str ); - BOOST_CHECK_EQUAL( cr.front(), 'h' ); - BOOST_CHECK_EQUAL( cr.back(), 'd' ); - BOOST_CHECK_EQUAL( cr[1], 'e' ); - - rrr = make_iterator_range( str, 1, -1 ); - BOOST_CHECK( rrr == "ello worl" ); - rrr = make_iterator_range( rrr, -1, 1 ); - BOOST_CHECK( rrr == str ); -} - - -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_iterator_range ) ); - - return test; -} - diff --git a/test/mfc.cpp b/test/mfc.cpp deleted file mode 100755 index c429993..0000000 --- a/test/mfc.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#define _MSL_USING_NAMESPACE 1 - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#define BOOST_RANGE_ENABLE_MFC -#define BOOST_RANGE_ENABLE_MCF_CARRAY - -/* -#define WIN32 -#define _WINDOWS -#define _MBCS -#define _AFXDLL -#define _ATL_DLL -*/ - -///Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_MBCS" /D "_AFXDLL" /D "_ATL_DLL" /Gm /EHsc /RTC1 -// /MDd /Zc:wchar_t /Yu"stdafx.h" /Fp"Debug/Foo.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP - -#include -#include -#include - -#include -#include - - -void check_mfc() -{ - CString s = "hello world"; - BOOST_CHECK( boost::begin( s ) + boost::size( s ) == boost::end( s ) ); - BOOST_CHECK( boost::size( s ) == boost::size( "hello world" ) ); - BOOST_CHECK( !boost::empty( s ) ); - const CString cs( s ); - BOOST_CHECK( boost::begin( cs ) + boost::size( cs ) == boost::end( cs ) ); - BOOST_CHECK( boost::size( cs ) == boost::size( "hello world" ) ); - BOOST_CHECK( !boost::empty( cs ) ); - - CArray a; - BOOST_CHECK( boost::empty( a ) ); - a.Add( 5 ); - a.Add( 10 ); - BOOST_CHECK( boost::begin( a ) + boost::size( a ) == boost::end( a ) ); - BOOST_CHECK( boost::size( a ) == 2 ); - BOOST_CHECK( !boost::empty( a ) ); - const CArray& ca = a; - BOOST_CHECK( boost::begin( ca ) + boost::size( ca ) == boost::end( ca ) ); - BOOST_CHECK( boost::size( ca ) == 2 ); - BOOST_CHECK( !boost::empty( ca ) ); - -} - - - -#include -using boost::unit_test::test_suite; - - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_mfc ) ); - - return test; -} - - - - - - diff --git a/test/partial_workaround.cpp b/test/partial_workaround.cpp deleted file mode 100755 index 36cd213..0000000 --- a/test/partial_workaround.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -#include -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_partial_workaround() -{ - using namespace range_detail; - using type_traits::yes_type; - using type_traits::no_type; - - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - char* c_ptr; - const char* cc_ptr; - wchar_t* w_ptr; - const wchar_t* cw_ptr; - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( c_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cc_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( w_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cw_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_char_ptr_impl( c_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_char_ptr_impl( cc_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_wchar_t_ptr_impl( w_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_wchar_t_ptr_impl( cw_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( c_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( cc_ptr ) ) ); - - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( w_ptr ) ) ); - BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( cw_ptr ) ) ); - - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_, - boost::range_detail::range< vector >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_pair_, - boost::range_detail::range< pair >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::array_, - boost::range_detail::range< int[42] >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::char_ptr_, - boost::range_detail::range< char* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_char_ptr_, - boost::range_detail::range< const char* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::wchar_t_ptr_, - boost::range_detail::range< wchar_t* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_wchar_t_ptr_, - boost::range_detail::range< const wchar_t* >::type >::value )); - BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_, - boost::range_detail::range< vector >::type >::value )); - -} - - -#include -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_partial_workaround ) ); - - return test; -} - -#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - -#include -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int, char** ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - return test; -} - -#endif - diff --git a/test/reversible_range.cpp b/test/reversible_range.cpp deleted file mode 100755 index 26d953a..0000000 --- a/test/reversible_range.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_iterator() -{ - typedef vector vec_t; - typedef vec_t::iterator iterator; - typedef pair pair_t; - typedef range_reverse_iterator::type rev_iterator; - typedef pair rev_pair_t; - - vec_t vec; - pair_t p = make_pair( vec.begin(), vec.end() ); - rev_pair_t rp = make_pair( rbegin( p ), rend( p ) ); - char* str = "mutable"; - const char* cstr = "not mutable"; - char a[] = "mutable"; - const char ca[] = "not mutable"; - wchar_t* wstr = L"mutable"; - const wchar_t* cwstr= L"not mutable"; - wchar_t wa[] = L"mutable"; - const wchar_t cwa[]= L"not mutable"; - - BOOST_CHECK( rbegin( vec ) == range_reverse_iterator::type( vec.end() ) ); - BOOST_CHECK( rend( vec ) == range_reverse_iterator::type( vec.begin() ) ); - BOOST_CHECK( std::distance( rbegin( vec ), rend( vec ) ) == std::distance( begin( vec ), end( vec ) ) ); - - BOOST_CHECK( rbegin( p ) == begin( rp ) ); - BOOST_CHECK( rend( p ) == end( rp ) ); - BOOST_CHECK( std::distance( rbegin( p ), rend( p ) ) == std::distance( begin( rp ), end( rp ) ) ); - BOOST_CHECK( std::distance( begin( p ), end( p ) ) == std::distance( rbegin( rp ), rend( rp ) ) ); - - BOOST_CHECK_EQUAL( &*begin( str ), &*( rend( str ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( str ) - 1 ), &*rbegin( str ) ); - BOOST_CHECK_EQUAL( &*begin( cstr ), &*( rend( cstr ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( cstr ) - 1 ), &*rbegin( cstr ) ); - - BOOST_CHECK_EQUAL( &*begin( a ), &*( rend( a ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( a ) - 1 ), &*rbegin( a ) ); - BOOST_CHECK_EQUAL( &*begin( ca ), &*( rend( ca ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( ca ) - 1 ), &*rbegin( ca ) ); - - BOOST_CHECK_EQUAL( &*begin( wstr ), &*( rend( wstr ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( wstr ) - 1 ), &*rbegin( wstr ) ); - BOOST_CHECK_EQUAL( &*begin( cwstr ), &*( rend( cwstr ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( cwstr ) - 1 ), &*rbegin( cwstr ) ); - - BOOST_CHECK_EQUAL( &*begin( wa ), &*( rend( wa ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( wa ) - 1 ), &*rbegin( wa ) ); - BOOST_CHECK_EQUAL( &*begin( cwa ), &*( rend( cwa ) - 1 ) ); - BOOST_CHECK_EQUAL( &*( end( cwa ) - 1 ), &*rbegin( cwa ) ); - -} - - -#include -using boost::unit_test::test_suite; - - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_iterator ) ); - - return test; -} - - - - - - - diff --git a/test/std_container.cpp b/test/std_container.cpp deleted file mode 100755 index a61e8d1..0000000 --- a/test/std_container.cpp +++ /dev/null @@ -1,79 +0,0 @@ - // Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include -#include -#include - -using namespace boost; - -void check_std_container() -{ - typedef std::vector vec_t; - vec_t vec; - vec.push_back( 3 ); vec.push_back( 4 ); - const vec_t cvec( vec ); - - BOOST_STATIC_ASSERT(( is_same< range_value::type, vec_t::value_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, vec_t::const_iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, vec_t::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, vec_t::size_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, vec_t::const_iterator >::value )); - - BOOST_STATIC_ASSERT(( is_same< range_value::type, vec_t::value_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, vec_t::const_iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, vec_t::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, vec_t::size_type >::value )); - - BOOST_CHECK( begin( vec ) == vec.begin() ); - BOOST_CHECK( end( vec ) == vec.end() ); - BOOST_CHECK( empty( vec ) == vec.empty() ); - BOOST_CHECK( size( vec ) == vec.size() ); - - BOOST_CHECK( begin( cvec ) == cvec.begin() ); - BOOST_CHECK( end( cvec ) == cvec.end() ); - BOOST_CHECK( empty( cvec ) == cvec.empty() ); - BOOST_CHECK( size( cvec ) == cvec.size() ); - -} - - -#include -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_std_container ) ); - - return test; -} - - - - - - diff --git a/test/string.cpp b/test/string.cpp deleted file mode 100755 index 36f103b..0000000 --- a/test/string.cpp +++ /dev/null @@ -1,202 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - -//#define _MSL_USING_NAMESPACE 1 - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::range_iterator::type -find( Container& c, T value ) -{ - return std::find( boost::begin( c ), boost::end( c ), value ); -} - -template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::range_const_iterator::type -find( const Container& c, T value ) -{ - return std::find( boost::begin( c ), boost::end( c ), value ); -} - -template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::range_iterator::type -find_mutable( Container& c, T value ) -{ - boost::size( c ); - boost::end( c ); - return std::find( boost::begin( c ), boost::end( c ), value ); -} - -template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::range_const_iterator::type -find_const( const Container& c, T value ) -{ - boost::size( c ); - boost::end( c ); - return std::find( boost::begin( c ), boost::end( c ), value ); -} - - -std::vector -check_rvalue_return() -{ - return std::vector( 10, 'm' ); -} - -using namespace boost; - - -void check_char() -{ - typedef char* char_iterator_t; - typedef char char_array_t[10]; - const char* char_s = "a string"; - char my_string[] = "another string"; - const unsigned my_string_length = 14; - char* char_s2 = "a string"; - - BOOST_STATIC_ASSERT(( is_same< range_value::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, char_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const char* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, - ::std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, char_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const char* >::value )); - - BOOST_STATIC_ASSERT(( is_same< range_value::type, - char>::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, char* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const char* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, - ::std::ptrdiff_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, char* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const char* >::value )); - - BOOST_CHECK_EQUAL( begin( char_s ), char_s ); - std::size_t sz = size( char_s ); - const char* end1 = begin( char_s ) + sz; - BOOST_CHECK_EQUAL( end( char_s ), end1 ); - BOOST_CHECK_EQUAL( empty( char_s ), (char_s == 0 || char_s[0] == char()) ); - BOOST_CHECK_EQUAL( sz, std::char_traits::length( char_s ) ); -/* - BOOST_CHECK_EQUAL( begin( char_s2 ), char_s2 ); - std::size_t sz2 = size( char_s2 ); - const char* end12 = begin( char_s2 ) + sz; - BOOST_CHECK_EQUAL( end( char_s2 ), end12 ); - BOOST_CHECK_EQUAL( empty( char_s2 ), (char_s2 == 0 || char_s2[0] == char()) ); - BOOST_CHECK_EQUAL( sz2, std::char_traits::length( char_s2 ) ); -*/ - BOOST_CHECK_EQUAL( begin( my_string ), my_string ); - range_iterator::type end2 = begin( my_string ) + size( my_string ); - range_iterator::type end3 = end( my_string ); - BOOST_CHECK_EQUAL( end3, end2 ); - BOOST_CHECK_EQUAL( empty( my_string ), (my_string == 0 || my_string[0] == char()) ); - BOOST_CHECK_EQUAL( size( my_string ), my_string_length ); - BOOST_CHECK_EQUAL( size( my_string ), std::char_traits::length( my_string ) ); - - char to_search = 'n'; - BOOST_CHECK( find_mutable( char_s, to_search ) != end( char_s ) ); - BOOST_CHECK( find_const( char_s, to_search ) != end( char_s ) ); - - BOOST_CHECK( find_mutable( my_string, to_search ) != end( my_string ) ); - BOOST_CHECK( find_const( my_string, to_search ) != end( my_string ) ); - - BOOST_CHECK( find_mutable( char_s2, to_search ) != end( char_s2 ) ); - BOOST_CHECK( find_const( char_s2, to_search ) != end( char_s2 ) ); -} - - - -void check_string() -{ - check_char(); -// check_char(); -// check_char(); -// check_char(); - -#ifndef BOOST_NO_STD_WSTRING - typedef wchar_t* wchar_iterator_t; - const wchar_t* char_ws = L"a wide string"; - wchar_t my_wstring[] = L"another wide string"; - wchar_t* char_ws2 = L"a wide string"; - - BOOST_STATIC_ASSERT(( is_same< range_value::type, - detail::iterator_traits::value_type>::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, wchar_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const wchar_t* >::value )); - BOOST_STATIC_ASSERT(( is_same< range_difference::type, - detail::iterator_traits::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, std::size_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, wchar_iterator_t >::value )); - BOOST_STATIC_ASSERT(( is_same< range_result_iterator::type, const wchar_t* >::value )); - - std::size_t sz = size( char_ws ); - BOOST_CHECK_EQUAL( begin( char_ws ), char_ws ); - BOOST_CHECK_EQUAL( end( char_ws ), (begin( char_ws ) + sz) ); - BOOST_CHECK_EQUAL( empty( char_ws ), (char_ws == 0 || char_ws[0] == wchar_t()) ); - BOOST_CHECK_EQUAL( sz, std::char_traits::length( char_ws ) ); - /* - std::size_t sz2 = size( char_ws2 ); - BOOST_CHECK_EQUAL( begin( char_ws2 ), char_ws2 ); - BOOST_CHECK_EQUAL( end( char_ws2 ), (begin( char_ws2 ) + sz2) ); - BOOST_CHECK_EQUAL( empty( char_ws2 ), (char_ws2 == 0 || char_ws2[0] == wchar_t()) ); - BOOST_CHECK_EQUAL( sz2, std::char_traits::length( char_ws2 ) ); - */ - wchar_t to_search = L'n'; - BOOST_CHECK( find( char_ws, to_search ) != end( char_ws ) ); - -#if BOOST_WORKAROUND(_MSC_VER, BOOST_TESTED_AT(1300)) - - BOOST_CHECK( find( my_wstring, to_search ) != end( my_wstring ) ); - -#endif -#endif - - find( check_rvalue_return(), 'n' ); - -} - - -#include -using boost::unit_test::test_suite; - - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_string ) ); - - return test; -} - - - - - - diff --git a/test/sub_range.cpp b/test/sub_range.cpp deleted file mode 100755 index 0b28fc1..0000000 --- a/test/sub_range.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// Boost.Range library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is subject to the Boost Software License, Version -// 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see http://www.boost.org/libs/range/ -// - - -#include - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# pragma warn -8091 // supress warning in Boost.Test -# pragma warn -8057 // unused argument argc/argv in Boost.Test -#endif - -#include -#include -#include -#include -#include - -using namespace boost; -using namespace std; - -void check_sub_range() -{ - - typedef string::iterator iterator; - typedef string::const_iterator const_iterator; - typedef iterator_range irange; - typedef iterator_range cirange; - string str = "hello world"; - const string cstr = "const world"; - irange r = make_iterator_range( str ); - r = make_iterator_range( str.begin(), str.end() ); - cirange r2 = make_iterator_range( cstr ); - r2 = make_iterator_range( cstr.begin(), cstr.end() ); - r2 = make_iterator_range( str ); - - typedef sub_range srange; - typedef sub_range csrange; - srange s = r; - BOOST_CHECK( r == r ); - BOOST_CHECK( s == r ); - s = make_iterator_range( str ); - csrange s2 = r; - s2 = r2; - s2 = make_iterator_range( cstr ); - BOOST_CHECK( r2 == r2 ); - BOOST_CHECK( s2 != r2 ); - s2 = make_iterator_range( str ); - BOOST_CHECK( !(s != s) ); - - BOOST_CHECK( r.begin() == s.begin() ); - BOOST_CHECK( r2.begin()== s2.begin() ); - BOOST_CHECK( r.end() == s.end() ); - BOOST_CHECK( r2.end() == s2.end() ); - BOOST_CHECK_EQUAL( r.size(), s.size() ); - BOOST_CHECK_EQUAL( r2.size(), s2.size() ); - -//#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// if( !(bool)r ) -// BOOST_CHECK( false ); -// if( !(bool)r2 ) -// BOOST_CHECK( false ); -// if( !(bool)s ) -// BOOST_CHECK( false ); -// if( !(bool)s2 ) -// BOOST_CHECK( false ); -//#else - if( !r ) - BOOST_CHECK( false ); - if( !r2 ) - BOOST_CHECK( false ); - if( !s ) - BOOST_CHECK( false ); - if( !s2 ) - BOOST_CHECK( false ); -//#endif - - cout << r << r2 << s << s2; - - string res = copy_range( r ); - BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) ); - - r.empty(); - s.empty(); - r.size(); - s.size(); - - irange singular_irange; - BOOST_CHECK( singular_irange.empty() ); - BOOST_CHECK( singular_irange.size() == 0 ); - - srange singular_srange; - BOOST_CHECK( singular_srange.empty() ); - BOOST_CHECK( singular_srange.size() == 0 ); - - BOOST_CHECK( empty( singular_irange ) ); - BOOST_CHECK( empty( singular_srange ) ); - - srange rr = make_iterator_range( str ); - BOOST_CHECK( rr.equal( r ) ); - - rr = make_iterator_range( str.begin(), str.begin() + 5 ); - BOOST_CHECK( rr == "hello" ); - BOOST_CHECK( rr != "hell" ); - BOOST_CHECK( rr < "hello dude" ); - BOOST_CHECK( "hello" == rr ); - BOOST_CHECK( "hell" != rr ); - BOOST_CHECK( ! ("hello dude" < rr ) ); - - irange rrr = rr; - BOOST_CHECK( rrr == rr ); - BOOST_CHECK( !( rrr != rr ) ); - BOOST_CHECK( !( rrr < rr ) ); - - const irange cr = make_iterator_range( str ); - BOOST_CHECK_EQUAL( cr.front(), 'h' ); - BOOST_CHECK_EQUAL( cr.back(), 'd' ); - BOOST_CHECK_EQUAL( cr[1], 'e' ); - - rrr = make_iterator_range( str, 1, -1 ); - BOOST_CHECK( rrr == "ello worl" ); - rrr = make_iterator_range( rrr, -1, 1 ); - BOOST_CHECK( rrr == str ); - rrr.front() = 'H'; - rrr.back() = 'D'; - rrr[1] = 'E'; - BOOST_CHECK( rrr == "HEllo worlD" ); -} - -#include -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); - - test->add( BOOST_TEST_CASE( &check_sub_range ) ); - - return test; -} - - - - -