diff --git a/doc/boost_range.html b/doc/boost_range.html index 7ee54ee..41f4e81 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -1,112 +1,128 @@ - Boost.Range External Range Implementation


Boost.Range External Range Implementation


Introduction

This library makes it possible to treat different types as if they have - implemented a subset of the container requirements - (see §23.1of the C++ standard). Formally, that subset is defined by - the CollectionConcept. - The subset deals mostly with - iterator returning functions and nested typedefs. - The main goal is to treat built-in arrays, standard containers, - pairs of iterators and some iterators uniformly. Formally, this library is an implementation - of the ExternalCollectionConcept (see also this explanation of External Concepts ).

The main advantages are

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

-       //
-       // Example: extracting bounds in generic algorithms
-       //                
-                       
-       template< typename ExternalCollection, typename T >
-       inline typename boost::iterator_of<ExternalCollection>::type
-       find( ExternalCollection& c, const T& value )
-       {
-           return std::find( boost::begin( c ), boost::end( c ), value );
-       }
+
+
+
+    Boost.Range Range Implementation 
+    
+
 
-       template< typename ExternalCollection, typename T >
-       inline typename boost::const_iterator_of<ExternalCollection>::type 
-       find( const ExternalCollection& c, const T& value )
-       {
-           return std::find( boost::begin( c ), boost::end( c ), value );
-       }
-                       
-       // 
-       // replace first value and return its index
-       //                                
-       template< typename EC, typename T >
-       inline typename boost::size_type_of< EC >::type
-       my_generic_replace( EC& c, const T& value, const T& replacement )
-       {
-           typename boost::const_iterator_of<EC>::type found = find( c, value );
-           *found = replacement;
-           return std::distance( boost::begin( c ), found );
-       }                  
-                       
-       // 
-       // usage
-       //                                
-       std::vector<int>              my_vector;
-       typedef vector<int>::iterator iterator;
-       std::pair<iterator,iterator>  my_view( my_vector.begin(), my_vector.begin() + N );
-       char str[] = "a string";
-       // ...
-       std::cout << my_generic_replace( my_vector, 4, 2 )
-                 << my_generic_replace( my_view, 4, 2 )
-                 << my_generic_replace( str, 'a', 'b' );
-       
By using the free-standing functions and type-generators, the code automatically - works for all the types supported by this library. 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 ).


Reference

#include <boost/collection_traits.hpp>

Five types of objects are currently supported by the library:

It is worth noticing that some functionality requires partial template specialization, in particular, - full array support does (remark: this is a very small problem since one would use boost::array<> - anyway). Also note that arrays and pointers of char or whar_t are treated special because of their use in string algorithms.

ExternalCollectionConcept

The concept is defined by the type-generators and the - functions below. Even though these functions are defined in - namespace boost, there is no such general requirement, that is, - if one wants to extend the list of supported types, it can be done in any - namespace.

Synopsis

-    namespace boost 
+
+
+
+
+
+    
+        
+        
+    
+


+ Boost.Range

+ +

Range and ReversibleRange Implementation

+ + +
+ +

Overview

+

+Five types of objects are currently supported by the library: +

+It is worth noticing that some functionality requires partial template +specialization, in particular, full array support does (remark: this is a very +small problem since one would use boost::array<> anyway). Also note +that arrays and pointers of char or whar_t are +treated special because of their use in string algorithms. +

+

ExternalCollectionConcept

+

+The concept is defined by the type-generators and the functions below. Even +though these functions are defined in namespace boost, there is no +such general requirement, that is, if one wants to extend the list of supported +types, it can be done in any namespace. +

+

Synopsis

+

+

+    namespace boost
     {
-        //             
+        //
         // type generators
-        //              
+        //
         
-        template< typename EC >                                     
+        template< typename EC >
         struct value_type_of
         {
-            typedef ... type; // type of stored objects 
+            typedef ... type; // type of stored objects
         };
                      
-        template< typename EC >                                     
-        struct iterator_of 
+        template< typename EC >
+        struct iterator_of
         {
             typedef ... type; // iterator over stored objects
         };
         
-        template< typename EC >                                     
-        struct const_iterator_of      
+        template< typename EC >
+        struct const_iterator_of
         {
-            typedef ... type; // iterator over immutable stored objects 
+            typedef ... type; // iterator over immutable stored objects
         };
 
-        template< typename EC >                                     
+        template< typename EC >
         struct difference_type_of
         {
-            typedef ... type; 
+            typedef ... type;
             BOOST_STATIC_ASSERT( boost::is_signed< type >::value );
             //
-            // remark: if std::iterator_traits<> works for the type, this assertion must hold
+            // remark: if std::iterator_traits<> works for the type, this assertion must
+            hold
             //
-            BOOST_STATIC_ASSERT( boost::is_same< type, std::iterator_traits< typename 
-                                                       iterator_of< EC >::type >::difference_type>::value );         
+            BOOST_STATIC_ASSERT( boost::is_same< type, std::iterator_traits< typename
+                                                       iterator_of< EC >::type >::difference_type>::value );
         };
 
-        template< typename EC >                                     
+        template< typename EC >
         struct size_type_of
         {
             typedef ... type;
             BOOST_STATIC_ASSERT( boost::is_unsigned< type >::value );
-            BOOST_STATIC_ASSERT( sizeof( type ) >= sizeof( difference_type_of< EC >::type ) );                   
+            BOOST_STATIC_ASSERT( sizeof( type ) >= sizeof( 
+            difference_type_of< EC >::type ) );
         };
 
-        template< typename EC >                                     
-        struct result_iterator_of     
+        template< typename EC >
+        struct result_iterator_of
         {
-            typedef ... type; 
-            // iterator_of< EC >::type if EC is non-const, const_iterator_of< EC >::type otherwise         
+            typedef ... type;
+            // iterator_of< EC >::type if EC is non-const, 
+            const_iterator_of< EC >::type otherwise
         };
                      
         //
@@ -115,15 +131,15 @@
         
         template< typename EC >
         inline typename iterator_of::type
-        begin( EC& c );               
+        begin( EC& c );
     
         template< typename EC >
         inline typename const_iterator_of< EC >::type
-        begin( const EC& c );                       
+        begin( const EC& c );
             
         template< typename EC >
         inline typename iterator_of< EC >::type
-        end( EC& c );  
+        end( EC& c );
                           
         template< typename EC >
         inline typename const_iterator_of< EC >::type
@@ -131,38 +147,230 @@
         
         template< typename EC >
         inline bool
-        empty( const EC& c );         
+        empty( const EC& c );
                    
         template< typename EC >
         inline typename size_type_of< EC >::type
         size( const EC& c );
                      
-     } // namespace 'boost' 

Library headers

HeaderIncludes
<boost/collection_traits.hpp>everything
<boost/collection_traits/types.hpp>every type-generator
<boost/collection_traits/functions.hpp>every function
<boost/collection_traits/value_type.hpp>value_type_of
<boost/collection_traits/iterator.hpp>iterator_of
<boost/collection_traits/const_iterator.hpp>const_iterator_of
<boost/collection_traits/difference_type.hpp>difference_type_of
<boost/collection_traits/size_type.hpp>size_type_of
<boost/collection_traits/result_iterator.hpp>result_iterator_of
<boost/collection_traits/begin.hpp>begin
<boost/collection_traits/end.hpp>end
<boost/collection_traits/empty.hpp>empty
<boost/collection_traits/size.hpp>size

Semantics

In the table C is a type that conforms to the ExternalCollectionConcept and c is an object of that type. SC will denote a standard - container, T[sz] will denote an array of type T of size sz, P will denote std::pair<>, I means an iterator which default construction - denotes the end of the range and sc,t,p,i are objects of these types, - respectively. Special cases for char* and wchar_t* are described explicitly.

ExpressionReturn typeComplexity
value_type_of<C>::typeSC::value_type
T
std::iterator_traits<P::first_type>::value_type
std::iterator_traits<I>::value_type
compile time
iterator_of<C>::typeSC::iterator
T*
P::first_type
I
compile time
const_iterator_of<C>::typeSC::const_iterator
const T*
P::first_type
I
compile time
difference_type_of<C>::typeSC::difference_type
std::ptrdiff_t
std::iterator_traits<P::first_type>::difference_type
std::iterator_traits<I>::difference_type
compile time
size_type_of<C>::typeSC::size_type
std::size_t
std::size_t
std::size_t
compile time
result_iterator_of<C>::typeconst_iterator_of<C>::type if C is const
iterator_of<C>::type otherwise
compile time

ExpressionReturn typeEffectsComplexity
begin( c )result_iterator_of<C>::typesc.begin()
t
p.first
i
constant time
end( c )result_iterator_of<C>::typesc.end()
t + std::char_traits<C>::length( t ) if C is char* or wchar_t*
t + sz - 1 if C is char[sz] or wchar_t[sz]
t + sz otherwise
p.second
I()
linear if C is char* or wchar_t*
constant time otherwise
empty( c )Convertible to boolsc.empty()
size( t ) == 0
p.first == p.second
begin( i ) == end( i )
linear if C is char* or wchar_t*
constant time otherwise
size( c )size_type_of<C>::typesc.size()
end( t ) - begin( t )
distance( p.first, p.second )
not available for iterators
linear if C is char* or wchar_t*
or if std::distance() is linear
constant time otherwise

Please note that char*,whar_t*,char[], and wchar_t[] behaves differently from - normal arrays only for size() and end(). - Note that the null pointer is allowed as an argument in these cases.



Examples

Some examples are given in the accompanying test - files:


Portability

Full support for built-in arrays require that the - compiler supports class template partial specialization.

Notice that some compilers cannot do function template ordering - properly. In that case one cannot rely of result_iterator_of<> and a single function definition; instead one needs to supply - a function overloaded for const and non-const arguments if it is required.

Full support for iterators like std::istream_iterator<> depends very - much on a conforming standard library.

Most of the tests have been run successfully on these compilers


FAQ

  1. Why is there no difference between iterator_of<C>::type and const_iterator_of<C>::type for std::pair<iterator,iterator> or iterators which default construction denotes the end of the range?
  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.

  3. Why does the traits not supply more types or more functions?

    The traits class have 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. How should I implement generic algorithms for external collections?

    One should always start with a generic algorithm that takes two iterators as input. Then use the - collection traits to build handier versions on top of the base algorithm.


History

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 container algorithms - in various context showed the need for handling pairs of iterators, and - string libraries needed special treatment of character arrays. - Thorsten Ottosen wrote everything from the ground up including the first - work-around for missing partial template specialization. Pavol Droba helped to - improve the work-around for handicapped compilers and the special character support. - The naming scheme of type-generators was suggested by Peter Dimov.


© Thorsten Ottosen 2003-2004 (nesotto_AT_cs.auc.dk). - Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears - in all copies. This software is provided "as is" without express or implied warranty, and with no - claim as to its suitability for any purpose.































- \ No newline at end of file + } // namespace 'boost'
+

+ + +

Semantics

+

+In the table C is a type that conforms to the +ExternalCollectionConcept and c is an object of that type. +SC +will denote a standard container, T[sz] will denote an array of +type T of size sz, P will denote +std::pair<>, +I means an iterator which default construction denotes the end of +the range and sc,t,p,i are objects of these types, respectively. +Special cases for char* and wchar_t* are described +explicitly. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeComplexity
value_type_of<C>::typeSC::value_type
+ T
+ std::iterator_traits<P::first_type>::value_type
+
compile time
iterator_of<C>::typeSC::iterator
+ T*
+ P::first_type
+
compile time
const_iterator_of<C>::typeSC::const_iterator
+ const T*
+ P::first_type
+
compile time
difference_type_of<C>::typeSC::difference_type
+ std::ptrdiff_t
+ std::iterator_traits<P::first_type>:: difference_type
+
compile time
size_type_of<C>::typeSC::size_type
+ std::size_t
+ std::size_t
+
compile time
result_iterator_of<C>::typeconst_iterator_of< C>::type if C is + const +
+ iterator_of<C>::type otherwise
compile time
reverse_iterator_of<C>::typeboost::reverse_iterator< typename iterator_of<T>::type +>
compile time
const_reverse_iterator_of<C>::typeboost::reverse_iterator< typename const_iterator_of<T>::type >
+
compile time
reverse_result_iterator_of<C>::typeboost::reverse_iterator< typename result_iterator_of<T>:: + type > + compile time
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ExpressionReturn typeReturnsComplexity
begin( c )result_iterator_of<C>::typesc.begin()
+ t
+ p.first
+
constant time
end( c )result_iterator_of<C>::typesc.end()
+ t + std::char_traits<C>::length( t ) if C is + char* + or wchar_t*
+ t + sz - 1 if C is char[sz] or + wchar_t[sz] +
+ t + sz otherwise
+ p.second
+
linear if C is char* or wchar_t* +
+ constant time otherwise
empty( c )Convertible to boolsc.empty()
+ size( t ) == 0
+ p.first == p.second
+
linear if C is char* or wchar_t* +
+ constant time otherwise
+
size( c )size_type_of<C>::typesc.size()
+ end( t ) - begin( t )
+ distance( p. first, p.second )
+
linear if C is char* or wchar_t* +
+ or if std::distance() is linear
+ constant time otherwise
rbegin( c )reverse_result_iterator_of<C>::typereverse_result_iterator_of<C>::type( end( c ) ) +
+
same as end()
rend( c )reverse_result_iterator_of<C>::typereverse_result_iterator_of<C>::type( begin( c ) ) + same as begin()
+ +

+Please note that char*,whar_t*,char[], +and wchar_t[] behaves differently from normal arrays only for +size() +and end(). Note that the null pointer is allowed as an argument +in these cases. +

+ + +

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 new file mode 100755 index 0000000..91b1587 --- /dev/null +++ b/doc/faq.html @@ -0,0 +1,75 @@ + + + + + + Boost.Range FAQ + + + + + + + + + + +

Boost.Range

+ +

+

FAQ

+ +
    +
  1. + Why is there no difference between iterator_of<C>::type and const_iterator_of<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. +

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

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

+ (C) Copyright Thorsten Ottosen 2003-2004 +

+ +
+
+
+
+
+
+
+
+
+
+
+
+ + + + + diff --git a/doc/headers.html b/doc/headers.html new file mode 100755 index 0000000..47b6b48 --- /dev/null +++ b/doc/headers.html @@ -0,0 +1,134 @@ + + + + + + Boost.Range Headers + + + + + + + + + + +

Boost.Range

+ +

+

Library headers

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HeaderIncludes
<boost/range.hpp>everything
<boost/range/types.hpp>every meta-function
<boost/range/functions.hpp>every function
<boost/range/value_type.hpp>value_type_of
<boost/range/iterator.hpp>iterator_of
<boost/range/const_iterator.hpp>const_iterator_of
<boost/range/difference_type.hpp>difference_type_of
<boost/range/size_type.hpp>size_type_of
<boost/range/result_iterator.hpp>result_iterator_of
<boost/range/reverse_iterator.hpp>reverse_iterator_of
<boost/range/const_reverse_iterator.hpp>const_reverse_iterator_of
<boost/range/reverse_result_iterator.hpp>reverse_result_iterator_of
<boost/range/begin.hpp>begin
<boost/range/end.hpp>end
<boost/range/empty.hpp>empty
<boost/range/size.hpp>size
<boost/range/rbegin.hpp>rbegin
<boost/range/rend.hpp>rend
<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 new file mode 100755 index 0000000..d201580 --- /dev/null +++ b/doc/history_ack.html @@ -0,0 +1,62 @@ + + + + + + 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 container algorithms in various context showed the + need for handling pairs of iterators, and string libraries needed special + treatment of character arrays. +

+ +

+ Special thanks goes to +

+

+
+

+ (C) Copyright Thorsten Ottosen 2003-2004 +

+ +
+
+
+
+
+
+
+
+
+
+
+
+ + + + + diff --git a/doc/intro.html b/doc/intro.html new file mode 100755 index 0000000..eadca07 --- /dev/null +++ b/doc/intro.html @@ -0,0 +1,125 @@ + + + + + + Boost.Range Introduction + + + + + + + + + + +

Boost.Range

+ +

Introduction

+

+ This library makes it possible to treat different types as if they have + implemented a subset of the container requirements (see §23.1of the C++ + standard). Formally, that subset is defined by the Range concept. The subset deals mostly with iterator + returning functions and nested typedefs. The main goal is to treat + built-in arrays, standard containers, pairs of iterators and some iterators + uniformly. +

+

+ The main advantages are +

+

+

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

+       
+       //
+       // Example: extracting bounds in generic algorithms
+       //
+                       
+       template< typename XRange, typename T >
+       inline typename boost::iterator_of<XRange>::type
+       find( XRange& c, const T& value )
+       {
+           return std::find( boost::begin( c ), boost::end( c ), value );
+       }
+
+       template< typename XRange, typename T >
+       inline typename boost::const_iterator_of<XRange>::type
+       find( const XRange& c, const T& value )
+       {
+           return std::find( boost::begin( c ), boost::end( c ), value );
+       }
+                       
+       //
+       // replace first value and return its index
+       //
+       template< typename EC, typename T >
+       inline typename boost::size_type_of< EC >::type
+       my_generic_replace( EC& c, const T& value, const T& replacement )
+       {
+           typename boost::const_iterator_of<EC>::type found = find( c, value );
+           *found = replacement;
+           return std::distance( boost::begin( c ), found );
+       }
+                       
+       //
+       // usage
+       //
+       std::vector<int>              my_vector;
+       typedef vector<int>::iterator iterator;
+       std::pair<iterator,iterator>  my_view( my_vector.begin(), my_vector.begin(
+       ) + N );
+       char str[] = "a string";
+       // ...
+       std::cout << my_generic_replace( my_vector, 4, 2 )
+                 << my_generic_replace( my_view, 4, 2 )
+                 << my_generic_replace( str, 'a', 'b' );
+       
+ + By using the free-standing functions and type-generators, the code automatically + works for all the types supported by this library. 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 new file mode 100755 index 0000000..92ee98a --- /dev/null +++ b/doc/portability.html @@ -0,0 +1,63 @@ + + + + + + Boost.Range Portability + + + + + + + + + + +

Boost.Range

+ +

Portability

+

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

+

+ Notice that some compilers cannot do function template ordering properly. In + that case one must rely of result_iterator_of<> 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. +

+ +

+ A huge effort has been made to port the library to as many compilers as + possible. The results of the test-suites can be found + here. +

+ +
+

+ (C) Copyright Thorsten Ottosen 2003-2004 +

+ +
+
+
+
+
+
+
+
+
+
+
+
+ + + + + diff --git a/doc/range.htm b/doc/range.htm index 2119e7a..c4308ed 100755 --- a/doc/range.htm +++ b/doc/range.htm @@ -11,181 +11,112 @@ -- purpose. It is provided "as is" without express or implied warranty. --> -Range Concepts + + Range Concepts + - -C++ Boost - -
- -

Range

+ + + + + +

Boost.Range

+ +

Range concepts

+ +
+
+ +

Range

Description

A Range is a concept similar to the STL
Container -concept. A Range provides iterators for accessing a range 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 +href="http://www.sgi.com/Technology/STL/Container.html">Container concept. A +Range provides iterators for accessing a range 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 reference in generic code. +Because of the second requirement, a Range object must be passed by reference in +generic code.

Notation

- - - - - - - - - - - - + + + + + + + + + + + +
-X - -A type that is a model of Range. -
-a, b - -Object of type X. -
-T - -The value type of X. -
XA type that is a model of Range.
a, bObject of type X.
TThe value type of X.

Associated types

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
-Value type - -X::value_type - -The type of the object stored in a Range. - -
-Iterator type - -X::iterator - -The 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. - The iterator type must at least be an InputIterator. -
-Const iterator type - -X::const_iterator - -A type of iterator that may be used to examine, but not to modify, - a Range's elements. -
-Reference type - -X::reference - -A type that behaves like a reference to the Range's value type. -[1] -
-Distance type - -X::difference_type - -A 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 type - -X::size_type - -An unsigned integral type that can represent any nonnegative value - of the Range's distance type. -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Value typevalue_type_of<X>::typeThe type of the object stored in a Range. +
Iterator typeiterator_of<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. The + iterator type must at least be an InputIterator.
Const iterator typeconst_iterator_of<X>::typeA type of iterator that may be used to examine, but not to + modify, a Range's elements.
Reference typereference_of<X>::typeA type that behaves like a reference to the Range's value type. [1]
Distance typedifference_type_of<>::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 typesize_type_of<X>::typeAn unsigned integral type that can represent any nonnegative + value of the Range's distance type.
@@ -194,395 +125,209 @@ An unsigned integral type that can represent any nonnegative value The following expressions must be valid.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
-Name - -Expression - -Return type -
-Beginning of range - -a.begin() - -iterator if a is mutable, const_iterator otherwise -
-End of range - -a.end() - -iterator if a is mutable, const_iterator otherwise -
-Size - -a.size() - -size_type -
-Empty range - -a.empty() - -Convertible to bool -
+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameExpressionReturn type
Beginning of rangebegin(a)iterator if a is mutable, const_iterator + otherwise
End of rangeend(a)iterator if a is mutable, const_iterator + otherwise
Size of rangesize(a)size_type
Is range empty?empty(a)Convertible to bool

Expression semantics

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +
-Name - -Expression - -Semantics - -Postcondition -
-
-Beginning of range - -a.begin() - -Returns an iterator pointing to the first element in the Range. - -a.begin() is either dereferenceable or past-the-end. It is - past-the-end if and only if a.size() == 0. -
-End of range - -a.end() - -Returns an iterator pointing one past the last element in the - Range. - -a.end() is past-the-end. -
-Size - -a.size() - -Returns the size of the Collection, that is, its number of elements. - -a.size() >= 0 -
-Empty Collection - -a.empty() - -Equivalent to a.size() == 0. (But possibly faster.) - -  -
ExpressionSemanticsPostcondition
+
begin(a)Returns an iterator pointing to the first element in the Range.begin(a) is either dereferenceable or +past-the-end. It is past-the-end if and only if size(a) == 0.
end(a)Returns an iterator pointing one past the last element in the + Range.end(a) is past-the-end.
size(a)Returns the size of the Collection, that is, its number of + elements.size(a) >= 0
empty(a)Equivalent to size(a) == 0. (But +possibly faster.)  - 
+

Complexity guarantees

-All four functions are at most amortized linear time. For -most practical purposes, one can expect -begin(), end() and empty() to be amortized constant -time. +All four functions are at most amortized linear time. For most practical +purposes, one can expect begin(a), end(a) and +empty(a) to be amortized constant time.

Invariants

- - - - - - - - - - - - + + + + + + + + + + + +
-Valid range - -For any Range a, [a.begin(), a.end()) is a valid - range. -
-Range size - -a.size() is equal to the distance from a.begin() to a.end(). -
-Completeness - -An algorithm that iterates through the range [a.begin(), a.end()) - will pass through every element of a. -
Valid rangeFor any Range a, [begin(a),end(a)) is a + valid range, that is, end(a) is reachable from begin(a) + in a finite number of increments.
Range sizesize(a) is equal to the distance from +begin(a) to end(a).
CompletenessAn algorithm that iterates through the range +[begin(a),end(a)) will pass through every element of a.

Models

-

See also

-Container +

See also

Container -

+
+


- -

ReversibleRange

+

ReversibleRange

-

Description

-This concept provides access to iterators that traverse in both -directions (forward and reverse). The iterator type must meet all of -the requirements of
BidirectionalIterator -except that the reference type does not have to be a real C++ -reference. +

Description

This concept provides access to iterators that traverse in +both directions (forward and reverse). The iterator type must meet all of the +requirements of BidirectionalIterator +except that the reference type does not have to be a real C++ reference. -

Refinement of

-Range +

Refinement of

Range

Associated types

- - - - - - - - - - + + + + + + + + + +
-Reverse Iterator type - -X::reverse_iterator - -The 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. - The iterator type must at least be a BidirectionalIterator. -
-Const reverse iterator type - -X::const_reverse_iterator - -A type of reverse iterator that may be used to examine, but not to modify, - a Range's elements. -
Reverse Iterator typeX::reverse_iteratorThe 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. The iterator type must at least be a BidirectionalIterator.
Const reverse iterator typeX::const_reverse_iteratorA type of reverse iterator that may be used to examine, but not + to modify, a Range's elements.

Valid expressions

- + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
-Name - -Expression - -Return type - -Semantics -
-Beginning of range - -a.rbegin() - -reverse_iterator if a is mutable, -const_reverse_iterator otherwise. - -Equivalent to X::reverse_iterator(a.end()). -
-End of range - -a.rend() - -reverse_iterator if a is mutable, -const_reverse_iterator otherwise. - -Equivalent to X::reverse_iterator(a.begin()). -
NameExpressionReturn typeSemantics
Beginning of rangerbegin(a)reverse_iterator if a is mutable, const_reverse_iterator + otherwise.Equivalent to X::reverse_iterator(end(a)).
End of rangerend(a)reverse_iterator if a is mutable, const_reverse_iterator + otherwise.Equivalent to +X::reverse_iterator(begin(a)).

Complexity guarantees

-rbegin() has the same complexity as end() and -rend() has the same complexity as begin() from Range. +rbegin(a) has the same complexity as end(a) and +rend(a) has the same complexity as begin(a) from Range.

Models


Notes

-

[1] +

+[1] -The reference type does not have to be a real C++ reference. The -requirements of the reference type depend on the context within which -the Range is being used. Specifically it depends on the -requirements the context places on the value type of the Range. -The reference type of the Range must meet the same requirements -as the value type. In addition, the reference objects must be -equivalent to the value type objects in the Range (which is -trivially true if they are the same). Also, in a mutable Range, -an assignment to the reference object must result in an assignment to -the object in the Range (again, which is trivially true if they -are the same object, but non-trivial if the reference type is a proxy -class). +The reference type does not have to be a real C++ reference. The requirements of +the reference type is that it behaves like a real reference. Hence the +reference type must be convertible to the value_type and assignment through - -

+
+



- - - - + + + + +
Copyright © 2000 -Jeremy Siek, Univ.of Notre Dame and C++ Library & Compiler Group/SGI (jsiek@engr.sgi.com) -
Copyright © 2004 -Thorsten Ottosen. +
Copyright © 2000Jeremy Siek +
Copyright © 2004Thorsten Ottosen.
- + diff --git a/doc/style.css b/doc/style.css index 52f82f1..1890b52 100755 --- a/doc/style.css +++ b/doc/style.css @@ -21,3 +21,11 @@ pre{ .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 index 5dbace7..673a474 100755 --- a/doc/style.html +++ b/doc/style.html @@ -2,145 +2,122 @@ - -Boost.Range Terminology and Style Guidelines - + + Boost.Range Terminology and Style Guidelines + - + - - - - - -
-

Boost.Range terminology and style guidelines

-
- -

- The use of a consistent terminologi is as important for - iterator Ranges and - ExternalRange-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 iterator ranges are characterized by a specific underlying - iterator type, we get a type of iterator range for each type of - iterator. Hence we can speak of the following types of iterator - ranges: -

- Notice how we have used the categories from the - new style iterators. - Similarly, for ExternalRange - we have - - The convention of using an X to mean "External" save us from -rediculously long parameter names and is easy to associate with an - external concept. - -

- Notice that an interator (and therefore an iterator 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 travelsal property first - as done above. This seems resonable since there will only be one - traversal property, but perhaps many value acccess properties. -

- -

- As an example, consider how we specify the interface of - std::sort(). The iterator-based version looks like - this: - -

+    
+        
+            
+            
+    

Boost.Range

+ +

Terminology and style guidelines

+ +

+ The use of a consistent terminologi is as important for iterator Ranges + and ExternalRange-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 iterator ranges are characterized by a specific underlying iterator type, + we get a type of iterator range for each type of iterator. Hence we can speak of + the following types of iterator ranges: +

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

+ Notice that an interator (and therefore an iterator 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 travelsal property first as + done above. This seems resonable since there will only be one traversal + property, but perhaps many value acccess properties. +

+ +

+ As an example, consider how we specify the interface of std::sort(). + The iterator-based version looks like this: + +

    template< class RandomAccessTraversalReadableWritableIterator >
    void sort( RandomAccessTraversalReadableWritableIterator first,
               RandomAccessTraversalReadableWritableIterator last );
    
- For external iterator ranges the interface becomes - -
-   template< class XRandomAccessReadableWritableRange >
-   void sort( XRandomAccessReadableWritableRange& r );
-   
- Had the function been specified like - -
+    For iterator ranges the interface becomes
+
+    
    template< class RandomAccessReadableWritableRange >
    void sort( RandomAccessReadableWritableRange& r );
    
- - we should expect the underlying code to call r.begin() - and r.end() to extract the iterators instead of - begin( r ) and end( r ). In general - it is much more flexible to rely on external iterator ranges - than iterator ranges. -

-

- - -
-

+ + +

+ + +
+

(C) Copyright Thorsten Ottosen 2003-2004 -

+

-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
- + diff --git a/index.html b/index.html index a54591b..e2d1dd2 100755 --- a/index.html +++ b/index.html @@ -34,18 +34,15 @@