From e9a4a0d7aa2bf498df9f0f94998db68dfeee5691 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 9 Nov 2007 17:28:34 +0000 Subject: [PATCH] Merged revisions 40922-40969 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r40923 | eric_niebler | 2007-11-07 22:48:08 -0800 (Wed, 07 Nov 2007) | 1 line fix errors and warnings on msvc-9 ........ r40924 | chris_kohlhoff | 2007-11-07 23:52:49 -0800 (Wed, 07 Nov 2007) | 2 lines Fix timer stalls. ........ r40925 | johnmaddock | 2007-11-08 01:38:22 -0800 (Thu, 08 Nov 2007) | 1 line Fixed license text. ........ r40926 | bemandawes | 2007-11-08 04:35:50 -0800 (Thu, 08 Nov 2007) | 1 line Borland appends newline, so just check text ........ r40927 | johnmaddock | 2007-11-08 04:39:58 -0800 (Thu, 08 Nov 2007) | 1 line Removed non-BSL files, updated and regenerated docs accordingly. ........ r40928 | bemandawes | 2007-11-08 05:01:23 -0800 (Thu, 08 Nov 2007) | 1 line Markup older Borland compilers that don't support enable_if ........ r40932 | bemandawes | 2007-11-08 06:25:09 -0800 (Thu, 08 Nov 2007) | 1 line Clarify comment ........ r40934 | joaquin | 2007-11-08 07:46:57 -0800 (Thu, 08 Nov 2007) | 1 line removed markup for a fixed failure of multi_index on vacpp ........ r40935 | nikiml | 2007-11-08 08:28:44 -0800 (Thu, 08 Nov 2007) | 1 line changed handle cast to downcast ........ r40936 | hljin | 2007-11-08 09:31:56 -0800 (Thu, 08 Nov 2007) | 1 line GIL: added missing standard C++ header files ........ r40937 | hljin | 2007-11-08 09:35:37 -0800 (Thu, 08 Nov 2007) | 1 line GIL: added namespace prefix to avoid confusion ........ r40938 | danieljames | 2007-11-08 10:04:12 -0800 (Thu, 08 Nov 2007) | 3 lines Remove the from the copyright footer, because it was causing the markup to be invalid. ........ r40939 | johnmaddock | 2007-11-08 10:05:28 -0800 (Thu, 08 Nov 2007) | 1 line Applied fix from http://svn.boost.org/trac/boost/ticket/1023. ........ r40956 | vladimir_prus | 2007-11-09 00:26:47 -0800 (Fri, 09 Nov 2007) | 1 line Don't use toolset.register ........ r40957 | vladimir_prus | 2007-11-09 00:30:27 -0800 (Fri, 09 Nov 2007) | 2 lines Remove toolset.register. ........ r40958 | speedsnail | 2007-11-09 00:31:45 -0800 (Fri, 09 Nov 2007) | 2 lines Force static linking for toolsets mingw and boorland. ........ r40959 | speedsnail | 2007-11-09 01:28:29 -0800 (Fri, 09 Nov 2007) | 1 line Reverted the previous commit, until I find a better solution... ........ r40960 | johnmaddock | 2007-11-09 01:54:43 -0800 (Fri, 09 Nov 2007) | 1 line Still trying to get the Solaris error rates correct.... ........ r40961 | johnmaddock | 2007-11-09 01:59:37 -0800 (Fri, 09 Nov 2007) | 1 line Trivial fix for issue #647. ........ r40962 | nesotto | 2007-11-09 02:27:42 -0800 (Fri, 09 Nov 2007) | 1 line major update wrt. new range concepts ........ r40963 | johnmaddock | 2007-11-09 03:01:45 -0800 (Fri, 09 Nov 2007) | 1 line Improved error messages and added tentative fixes for HP Tru64: the compiler appears to store constants that should underflow to zero as a small non-zero values which messes up the logic used in the test cases. ........ r40964 | nesotto | 2007-11-09 05:13:06 -0800 (Fri, 09 Nov 2007) | 1 line minor editorial issue ........ r40965 | nesotto | 2007-11-09 05:30:57 -0800 (Fri, 09 Nov 2007) | 1 line update of new concepts, and replacement of range_size::type with range_difference::type throughut the library ........ r40966 | nesotto | 2007-11-09 05:31:43 -0800 (Fri, 09 Nov 2007) | 1 line minor tweaks to avoid warnings ... extension mechanism updated to follow new protocol ........ r40967 | schoepflin | 2007-11-09 06:25:44 -0800 (Fri, 09 Nov 2007) | 1 line Added memory barriers to Tru64 atomic ops. ........ r40968 | nesotto | 2007-11-09 07:15:28 -0800 (Fri, 09 Nov 2007) | 1 line improved reference ........ r40969 | johnmaddock | 2007-11-09 08:57:42 -0800 (Fri, 09 Nov 2007) | 1 line Added needed macro suppression to use of isfinite. ........ [SVN r40970] --- doc/boost_range.html | 338 +++++++++++++------------ doc/examples.html | 4 - doc/intro.html | 10 +- doc/mfc_atl.html | 300 ++++++++++++++++++++-- doc/mfc_atl.rst | 8 +- doc/portability.html | 2 +- doc/range.html | 209 ++------------- doc/utility_class.html | 19 +- include/boost/range/concepts.hpp | 47 ++-- include/boost/range/iterator_range.hpp | 27 +- include/boost/range/size.hpp | 7 +- include/boost/range/sub_range.hpp | 11 +- index.html | 10 +- test/algorithm_example.cpp | 4 +- test/array.cpp | 2 +- test/extension_mechanism.cpp | 1 - 16 files changed, 539 insertions(+), 460 deletions(-) diff --git a/doc/boost_range.html b/doc/boost_range.html index e652436..65284fa 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -70,6 +70,10 @@ class=identifier>range_iterator; struct range_value; + template< class T > + struct range_reference; + template< class T > struct range_pointer; @@ -94,14 +98,6 @@ class=identifier>range_difference; struct range_reverse_iterator; - - // - // Random Access Range metafunctions - // - - template< class T > - struct range_size; // // Single Pass Range functions @@ -109,23 +105,23 @@ class=identifier>range_size; template< class T > typename range_iterator<T>::type - begin( T& c ); + begin( T& r ); template< class T > - typename range_iterator<T>::type - begin( const T& c ); + typename range_iterator<const T>::type + begin( const T& r ); template< class T > typename range_iterator<T>::type - end( T& c ); + end( T& r ); template< class T > - typename range_iterator<T>::type - end( const T& c ); + typename range_iterator<const T>::type + end( const T& r ); template< class T > bool - empty( const T& c ); + empty( const T& r ); // // Forward Range functions @@ -133,7 +129,7 @@ class=identifier>range_size; template< class T > typename range_difference<T>::type - distance( const T& c ); + distance( const T& r ); // // Bidirectional Range functions @@ -141,30 +137,29 @@ class=identifier>range_size; template< class T > typename range_reverse_iterator<T>::type - rbegin( T& c ); + rbegin( T& r ); template< class T > - typename range_reverse_iterator<T>::type - rbegin( const T& c ); + typename range_reverse_iterator<const T>::type + rbegin( const T& r ); template< class T > typename range_reverse_iterator<T>::type - rend( T& c ); + rend( T& r ); template< class T > - typename range_reverse_iterator<T>::type + typename range_reverse_iterator<const T>::type rend( const T& c ); +class=identifier>T& r ); - // // Random Access Range functions // template< class T > typename range_size<T>::type - size( const T& c ); - + size( const T& r ); + // // Special const Range functions // @@ -185,6 +180,26 @@ class=identifier>T& typename range_reverse_iterator<const T>::type const_rend( const T& r ); + // + // String utilities + // + + template< class T > + iterator_range<...see below...> + as_literal( T& r ); + + template< class T > + iterator_range<...see below...> + as_literal( const T& r ); + + template< class T > + iterator_range< typename range_iterator<T>::type > + as_array( T& r ); + + template< class T > + iterator_range< typename range_iterator<const T>::type > + as_array( const T& r ); + } // namespace 'boost' @@ -244,88 +259,79 @@ class=identifier>T& Complexity - - - range_value<X>::type - T::value_type
- boost::iterator_value<P::first_type>::type
- A
- Char - compile time - range_iterator<X>::type T::iterator
P::first_type
A*
- Char* + compile time - range_const_iterator<X>::type + range_iterator<const X>::type T::const_iterator
P::first_type
const A*
- const Char* + + compile time + + + + range_value<X>::type + boost::iterator_value<range_iterator<X>::type>::type + + compile time + + + + range_reference<X>::type + boost::iterator_reference<range_iterator<X>::type>::type + + compile time + + + + + range_pointer<X>::type + boost::iterator_pointer<range_iterator<X>::type>::type + + compile time + + + + + range_category<X>::type + boost::iterator_category<range_iterator<X>::type>::type + compile time range_difference<X>::type - T::difference_type
- boost::iterator_difference<P::first_type>::type
- std::ptrdiff_t
- std::ptrdiff_t
+ + boost::iterator_difference<range_iterator<X>::type>::type + compile time - - - range_size<X>::type - T::size_type
- std::size_t
- std::size_t
- std::size_t
- compile time - - - - range_result_iterator<X>::type - range_const_iterator<X>::type if X is const -
- range_iterator<X>::type otherwise - - compile time + range_reverse_iterator<X>::type - boost::reverse_iterator< typename range_iterator<T>::type >
+ boost::reverse_iterator<range_iterator<X>::type>
compile time - range_const_reverse_iterator<X>::type - boost::reverse_iterator< typename range_const_iterator<T>::type > + range_reverse_iterator<const X>::type + boost::reverse_iterator<range_iterator<const X>::type>
compile time - - - range_reverse_result_iterator<X>::type - boost::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

@@ -342,12 +348,11 @@ class=identifier>T& - + @@ -355,106 +360,133 @@ class=identifier>T& - + + - + + + + + + + + + - - + + - - + - - + + - - + - - + + - - + - - + + + + + + + + +
begin(x)range_result_iterator<X>::typerange_iterator<X>::type p.first if p is of type std::pair<T>
a if a is an array
- s if s is a string literal
- boost_range_begin(x) if that expression would invoke a function found by ADL
+ range_begin(x) if that expression would invoke a function found by ADL
t.begin() otherwise
constant timeend(x)range_result_iterator<X>::typerange_iterator<X>::type p.second if p is of type std::pair<T>
- a + sz if a is an array of size sz
- s + std::char_traits<X>::length( s ) if s is a Char* + a + sz if a is an array of size sz +
- s + sz - 1 if s is a string literal of size sz -
- boost_range_end(x) if that expression would invoke a function found by ADL
+ range_end(x) if that expression would invoke a function found by ADL
t.end() otherwise -
linear if X is Char* -
- constant time otherwise
+ constant time
empty(x) boolbegin(x) == end( x )
-
linear if X is Char* -
- constant time otherwise
+
boost::begin(x) == boost::end(x)
+
constant time
distance(x)range_difference<X>::type + + std::distance(boost::begin(x),boost::end(x)) + + -
size(x)range_size<X>::type - std::distance(p.first,p.second) if p is of type std::pair<T>
- sz if a is an array of size sz
- end(s) - s if s is a string literal or a Char*
- boost_range_size(x) if that expression would invoke a function found by ADL
- t.size() otherwise -
linear if X is Char* -
- or if std::distance() is linear -
- constant time otherwise
range_difference<X>::type boost::end(x) - boost::begin(x) + + constant time
rbegin(x)range_reverse_result_iterator<X>::typerange_reverse_result_iterator<X>::type( end(x) ) + range_reverse_iterator<X>::typerange_reverse_iterator<X>::type( boost::end(x) )
-
same as end(x) + constant time
rend(x)range_reverse_result_iterator<X>::typerange_reverse_result_iterator<X>::type( begin(x) ) - same as begin(x)range_reverse_iterator<X>::typerange_reverse_iterator<X>::type( boost::begin(x) ) + constant time
const_begin(x)range_const_iterator<X>::typerange_const_iterator<X>::type( begin(x) ) + range_iterator<const X>::typerange_iterator<const X>::type( boost::begin(x) )
-
same as begin(x) + constant time
const_end(x)range_const_iterator<X>::typerange_const_iterator<X>::type( end(x) ) - same as end(x)range_iterator<const X>::typerange_iterator<const X>::type( boost::end(x) ) + constant time
const_rbegin(x)range_const_reverse_iterator<X>::typerange_const_reverse_iterator<X>::type( rbegin(x) ) + range_reverse_iterator<const X>::typerange_reverse_iterator<const X>::type( boost::rbegin(x) )
-
same as rbegin(x) + constant time
const_rend(x)range_const_reverse_iterator<X>::typerange_const_reverse_iterator<X>::type( rend(x) ) - same as rend(x)range_reverse_iterator<const X>::typerange_reverse_iterator<const X>::type( boost::rend(x) ) + + constant time
as_literal(x)iterator_range<U> where U is + Char* if x is a pointer to a + string and U is + range_iterator<X>::type otherwise + + + [a,a+sz-1) if a is an array of size sz
+ [s,s + std::char_traits<X>::length(s)) if s is a Char* +
+ [boost::begin(x),boost::end(x)) otherwise + + + +
linear time for pointers to a string, constant time + otherwise

- 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. + The special const_-named functions are useful when you + want to document clearly that your code is read-only.

+

Notice that the above functions should always be called with + qualification (boost::) to prevent unintended + Argument Dependent Lookup (ADL). +


Extending the library

@@ -491,10 +523,6 @@ class=identifier>T
& Single Pass Range - - size() - Forward Range -

@@ -520,10 +548,6 @@ class=identifier>T& const_iterator Single Pass Range - - size_type - Forward Range -

@@ -554,26 +578,23 @@ class=identifier>T& Related concept - boost_range_begin(x) + range_begin(x) Single Pass Range - boost_range_end(x) + range_end(x) Single Pass Range - - boost_range_size(x) - Forward Range - +

-

boost_range_begin() and boost_range_end() must be +

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

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

@@ -583,17 +604,14 @@ class=identifier>T& Related concept - + - - - - +
boost::range_iteratorboost::range_mutable_iterator Single Pass Range
boost::range_const_iterator Single Pass Range
boost::range_sizeForward Range

@@ -627,7 +645,7 @@ class=identifier>T& template< class T > - struct range_iterator< Foo::Pair<T> > + struct range_mutable_iterator< Foo::Pair<T> > { typedef T type; }; @@ -636,20 +654,13 @@ class=identifier>T& struct range_const_iterator< Foo::Pair<T> > { // - // Remark: this is defined similar to 'range_iterator' + // Remark: this is defined similar to 'range_mutable_iterator' // because the 'Pair' type does not distinguish // between an iterator and a const_iterator. // typedef T type; }; - template< class T > - struct range_size< Foo::Pair<T> > - { - - typedef std::size_t type; - }; - } // namespace 'boost' namespace Foo @@ -661,36 +672,29 @@ class=identifier>T& template< class T > - inline T boost_range_begin( Pair<T>& x ) + inline T range_begin( Pair<T>& x ) { return x.first; } template< class T > - inline T boost_range_begin( const Pair<T>& x ) + inline T range_begin( const Pair<T>& x ) { return x.first; } template< class T > - inline T boost_range_end( Pair<T>& x ) + inline T range_end( Pair<T>& x ) { return x.last; } template< class T > - inline T boost_range_end( const Pair<T>& x ) + inline T range_end( const Pair<T>& x ) { return x.last; } - template< class T > - inline typename boost::range_size< Pair<T> >::type - boost_range_size( const Pair<T>& x ) - { - return std::distance(x.first,x.last); - } - } // namespace 'Foo' #include <vector> @@ -699,7 +703,7 @@ class=identifier>T& { typedef std::vector<int>::iterator iter; std::vector<int> vec; - Foo::Pair<iter> pair = { vec.begin(), vec.end() }; + Foo::Pair<iter> pair = { vec.begin(), vec.end() }; const Foo::Pair<iter>& cpair = pair; // // Notice that we call 'begin' etc with qualification. @@ -708,9 +712,9 @@ class=identifier>T& iter e = boost::end( pair ); i = boost::begin( cpair ); e = boost::end( cpair ); - boost::range_size< Foo::Pair<iter> >::type s = boost::size( pair ); + boost::range_difference< Foo::Pair<iter> >::type s = boost::size( pair ); s = boost::size( cpair ); - boost::range_const_reverse_iterator< Foo::Pair<iter> >::type + boost::range_reverse_iterator< const Foo::Pair<iter> >::type ri = boost::rbegin( cpair ), re = boost::rend( cpair ); } @@ -719,7 +723,7 @@ class=identifier>T&

- (C) Copyright Thorsten Ottosen 2003-2004 + (C) Copyright Thorsten Ottosen 2003-2007



diff --git a/doc/examples.html b/doc/examples.html index 6db7253..0ea235d 100755 --- a/doc/examples.html +++ b/doc/examples.html @@ -26,10 +26,6 @@ shows how to implement a container version of std::find() that works with char[],wchar_t[],char*,wchar_t*. -

- Warning: support for null-terminated strings is deprecated and will - disappear in the next Boost release (1.34). -

  • algorithm_example.cpp diff --git a/doc/intro.html b/doc/intro.html index b0542b2..8478d3e 100755 --- a/doc/intro.html +++ b/doc/intro.html @@ -35,16 +35,14 @@ 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. + works with containers, provided a suitable adapter is used.

    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. + containers, std::pairs of iterators, and raw arrays (and + more), such that + the same generic code can work with them all. The basic idea is to add another layer of indirection using metafunctions and free-standing functions so syntactic and/or semantic differences can be removed. diff --git a/doc/mfc_atl.html b/doc/mfc_atl.html index 5717cc8..a022fe3 100644 --- a/doc/mfc_atl.html +++ b/doc/mfc_atl.html @@ -3,14 +3,289 @@ - + Boost Range MFC/ATL Extension @@ -33,7 +308,7 @@

    Overview

    -

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

    +

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

     CTypedPtrArray<CPtrArray, CList<CString> *> myArray;
     ...
    @@ -64,7 +339,7 @@ BOOST_FOREACH (CList<CString> *theList, myArray)
     

    MFC Ranges

    -

    If the <boost/range/mfc.hpp> is included before or after Boost.Range headers, +

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

    @@ -170,7 +445,7 @@ The table below lists the Traversal Category and
    -

    Other Boost.Range metafunctions are defined by the following. +

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

    ATL Ranges

    -

    If the <boost/range/atl.hpp> is included before or after Boost.Range headers, +

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

    @@ -265,7 +540,7 @@ The table below lists the Traversal Category and
    -

    Other Boost.Range metafunctions are defined by the following. +

    Other Boost.Range metafunctions are defined by the following. Let Range be any type listed above and ReF be the same as range_reference<Range>::type. range_value<Range>::type is the same as remove_reference<Ref>::type, range_difference<Range>::type is the same as std::ptrdiff_t, and @@ -288,7 +563,7 @@ else if (there is a type X such that X* const is the same as ReF) else return ReF -

    Other Boost.Range metafunctions are defined by the following. +

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

    @@ -296,18 +571,11 @@ else -
    - diff --git a/doc/mfc_atl.rst b/doc/mfc_atl.rst index 3dcd8fe..67498fb 100644 --- a/doc/mfc_atl.rst +++ b/doc/mfc_atl.rst @@ -225,8 +225,8 @@ __ http://msdn2.microsoft.com/en-US/library/15e672bd.aspx .. _Boost C++ Libraries: http://www.boost.org/ .. _Boost: `Boost C++ Libraries`_ -.. _Boost.Range: http://www.boost.org/libs/range/ -.. _forward: http://www.boost.org/libs/range/doc/range.html#forward_range -.. _bidirectional: http://www.boost.org/libs/range/doc/range.html#forward_range -.. _random access: http://www.boost.org/libs/range/doc/range.html#random_access_range +.. _Boost.Range: ../index.html +.. _forward: range.html#forward_range +.. _bidirectional: range.html#forward_range +.. _random access: range.html#random_access_range diff --git a/doc/portability.html b/doc/portability.html index ae3a264..20b1355 100755 --- a/doc/portability.html +++ b/doc/portability.html @@ -36,7 +36,7 @@ href="http://boost.sourceforge.net/regression-logs/developer/range.html">here Notice also that some compilers cannot do function template ordering properly. In that case one must rely of range_result_iterator + href="boost_range.html#range_iterator">range_iterator and a single function definition instead of overloaded versions for const and non-const arguments. diff --git a/doc/range.html b/doc/range.html index 03a773d..dfe9345 100755 --- a/doc/range.html +++ b/doc/range.html @@ -50,7 +50,7 @@ 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. + much fewer requirements than a Container.

    The motivation for the Range concept is @@ -78,9 +78,9 @@ 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 range concepts are named to reflect which traversal category their + iterators support. See also terminology and style + guidelines. for more information about naming of ranges.

    The concepts described below specifies associated types as metafunctions and all @@ -118,11 +118,7 @@ Single Pass Iterator

    Associated types

    - - - - + @@ -132,7 +128,7 @@ Single Pass Iterator - + @@ -161,20 +157,16 @@ Single Pass Iterator - - - - - +
    Value typeboost::range_value<X>::typeThe type of the object stored in a Range. -
    Iterator type boost::range_iterator<X>::type
    Const iterator typeboost::range_const_iterator<X>::typeboost::range_iterator<const X>::type A type of iterator that may be used to examine, but not to modify, a Range's elements.
    Beginning of range boost::begin(a) boost::range_iterator<X>::type if -a is mutable, boost::range_const_iterator<X>::type +a is mutable, boost::range_iterator<const X>::type otherwise
    End of range boost::end(a) boost::range_iterator<X>::type if -a is mutable, boost::range_const_iterator<X>::type +a is mutable, boost::range_iterator<const X>::type otherwise
    Is range empty?boost::empty(a)Convertible to bool

    Expression semantics

    @@ -188,7 +180,7 @@ otherwise 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. + It is past-the-end if and only if boost::distance(a) == 0. boost::end(a) @@ -196,19 +188,14 @@ otherwise 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. + boost::end(a) is at most amortized linear time, boost::begin(a) is + amortized constant time. For most practical + purposes, one can expect both to be amortized constant time.

    Invariants

    @@ -227,14 +214,17 @@ otherwise

    See also

    -

    - Container -

    -

    implementation of +

    Extending the library for UDTs

    +

    Implementation of metafunctions

    -

    implementation of +

    Implementation of functions

    +

    + Container +

    +

    Forward Range

    @@ -261,76 +251,8 @@ href="../../iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-

    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

    @@ -356,83 +278,8 @@ s-lib-bidirectional-traversal-iterators">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 rangeboost::rbegin(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 rangeboost::rend(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

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

    Invariants

    -

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

    - -

    See also

    -

    implementation of metafunctions

    - -

    implementation of - functions

    + +


    @@ -455,7 +302,7 @@ href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterator

    Concept Checking

    Each of the range concepts has a corresponding concept checking - class in the file boost/range/concepts.hpp. These classes may be + class in the file . These classes may be used in conjunction with the
    Boost Concept Check library to insure that the type of a template parameter @@ -529,7 +376,7 @@ href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterator Jeremy Siek - Copyright © 2004 + Copyright © 2004-2007 Thorsten Ottosen. diff --git a/doc/utility_class.html b/doc/utility_class.html index 57bf5dc..16df096 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -59,19 +59,16 @@ corresponding const_iterator is.

    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 + Random Access Iterators whereas empty() only requires Single Pass Iterators.

    Recall that many default constructed iterators are singular and hence can only be assigned, but not compared or - incremented or anything. 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. -

    + incremented or anything. Likewise, if one creates a default constructed + iterator_range, then one have to be careful about not doing + anything besides copying.

    Synopsis

    @@ -82,9 +79,6 @@ corresponding const_iterator is.

    class iterator_range { public: // Forward Range types - typedef ... value_type; - typedef ... difference_type; - typedef ... size_type; typedef ForwardTraversalIterator iterator; typedef ForwardTraversalIterator const_iterator; @@ -117,10 +111,11 @@ class=identifier>equal( const iterator_range& ) const; - value_type& front() const; - value_type& back() const; + referencefront() const; + reference back() const; // for Random Access Range only: value_type& operator[]( size_type at ) const; + value_typecial>& operator()( size_type at ) const; }; // stream output diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index 5faf2de..d9c122f 100755 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -13,8 +13,8 @@ #include #include -#include -#include +#include +#include /*! * \file @@ -57,10 +57,10 @@ namespace boost { //! Check if a type T models the SinglePassRange range concept. template - struct SinglePassRangeConcept { - typedef typename range_value::type range_value; - typedef typename range_iterator::type range_iterator; - //typedef typename range_iterator::type range_const_iterator; + struct SinglePassRangeConcept + { + typedef typename range_iterator::type range_const_iterator; + typedef typename range_iterator::type range_iterator; void constraints() { @@ -71,23 +71,24 @@ namespace boost { >(); i = boost::begin(a); i = boost::end(a); - b = boost::empty(a); const_constraints(a); } + void const_constraints(const T& a) { - //ci = boost::begin(a); - //ci = boost::end(a); + ci = boost::begin(a); + ci = boost::end(a); } T a; range_iterator i; + range_const_iterator ci; bool b; }; //! Check if a type T models the ForwardRange range concept. template - struct ForwardRangeConcept { - typedef typename range_difference::type range_difference; + struct ForwardRangeConcept + { void constraints() { function_requires< @@ -103,8 +104,8 @@ namespace boost { //! Check if a type T models the BidirectionalRange range concept. template - struct BidirectionalRangeConcept { - typedef typename range_reverse_iterator::type range_reverse_iterator; + struct BidirectionalRangeConcept + { void constraints() { function_requires< @@ -115,24 +116,13 @@ namespace boost { typename range_iterator::type > >(); - i = boost::rbegin(a); - i = boost::rend(a); - const_constraints(a); - } - void const_constraints(const T& a) - { - //ci = boost::rbegin(a); - //ci = boost::rend(a); } - T a; - range_reverse_iterator i; }; //! Check if a type T models the RandomAccessRange range concept. template - struct RandomAccessRangeConcept { - typedef typename range_size::type range_size; - + struct RandomAccessRangeConcept + { void constraints() { function_requires< @@ -143,12 +133,7 @@ namespace boost { typename range_iterator::type > >(); - - s = boost::size(a); } - - T a; - range_size s; }; } // namespace boost diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index bcead14..9df24c0 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -73,7 +73,7 @@ namespace boost template< class Left, class Right > inline bool equal( const Left& l, const Right& r ) { - typedef BOOST_DEDUCED_TYPENAME boost::range_size::type sz_type; + typedef BOOST_DEDUCED_TYPENAME boost::range_difference::type sz_type; sz_type l_size = boost::size( l ), r_size = boost::size( r ); @@ -166,20 +166,7 @@ namespace boost , singular( true ) #endif { } -/* -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - iterator_range( this_type r ) : - : m_Begin(r.begin()), m_End(r.end()) - { } - - this_type& operator=( this_type r ) - { - m_Begin = r.begin(); - m_End = r.end(); - return *this; - } -#endif -*/ + //! Constructor from a pair of iterators template< class Iterator > iterator_range( Iterator Begin, Iterator End ) : @@ -283,7 +270,7 @@ namespace boost return m_End; } - size_type size() const + difference_type size() const { BOOST_ASSERT( !is_singular() ); return m_End - m_Begin; @@ -351,9 +338,9 @@ namespace boost return *--last; } - reference operator[]( size_type at ) const + reference operator[]( difference_type at ) const { - BOOST_ASSERT( at < size() ); + BOOST_ASSERT( at >= 0 && at < size() ); return m_Begin[at]; } @@ -362,9 +349,9 @@ namespace boost // fails because it returns by reference. Therefore // operator()() is provided for these cases. // - value_type operator()( size_type at ) const + value_type operator()( difference_type at ) const { - BOOST_ASSERT( at < size() ); + BOOST_ASSERT( at >= 0 && at < size() ); return m_Begin[at]; } diff --git a/include/boost/range/size.hpp b/include/boost/range/size.hpp index eb021a5..311a692 100755 --- a/include/boost/range/size.hpp +++ b/include/boost/range/size.hpp @@ -17,14 +17,17 @@ #include #include -#include +#include +#include namespace boost { template< class T > - inline BOOST_DEDUCED_TYPENAME range_size::type size( const T& r ) + inline BOOST_DEDUCED_TYPENAME range_difference::type size( const T& r ) { + BOOST_ASSERT( (boost::end( r ) - boost::begin( r )) >= 0 && + "reachability invariant broken!" ); return boost::end( r ) - boost::begin( r ); } diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index 30daaea..802454b 100755 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -38,6 +38,7 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME range_iterator::type const_iterator; typedef BOOST_DEDUCED_TYPENAME range_difference::type difference_type; typedef BOOST_DEDUCED_TYPENAME range_size::type size_type; + typedef BOOST_DEDUCED_TYPENAME base::reference reference; public: sub_range() : base() @@ -100,11 +101,11 @@ namespace boost const_iterator begin() const { return base::begin(); } iterator end() { return base::end(); } const_iterator end() const { return base::end(); } - size_type size() const { return base::size(); } + difference_type size() const { return base::size(); } public: // convenience - value_type& front() + reference front() { return base::front(); } @@ -114,7 +115,7 @@ namespace boost return base::front(); } - value_type& back() + reference back() { return base::back(); } @@ -124,12 +125,12 @@ namespace boost return base::back(); } - value_type& operator[]( size_type sz ) + reference operator[]( difference_type sz ) { return base::operator[](sz); } - const value_type& operator[]( size_type sz ) const + const value_type& operator[]( difference_type sz ) const { return base::operator[](sz); } diff --git a/index.html b/index.html index 29af65a..5313690 100755 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@

    - Copyright © 2003-2004 Thorsten Ottosen + Copyright © 2003-2007 Thorsten Ottosen

    Use, modification and distribution is subject to the Boost Software License, Version 1.0 @@ -52,18 +52,14 @@

  • Terminology and style guidelines
  • Headers
  • Examples -
  • MFC/ATL mapping (courtesy of Shunsuke - Sogame)
  • +
  • MFC/ATL mapping (courtesy of Shunsuke + Sogame)
  • Portability
  • FAQ
  • History and acknowledgment -
    -

    - (C) Copyright Thorsten Ottosen 2003-2004 -



    diff --git a/test/algorithm_example.cpp b/test/algorithm_example.cpp index d14a597..85e2b22 100755 --- a/test/algorithm_example.cpp +++ b/test/algorithm_example.cpp @@ -64,14 +64,14 @@ void check_algorithm() // // usage // - const unsigned N = 5; + const int 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 ); - BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3u ); + BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3 ); BOOST_CHECK_EQUAL( my_generic_replace( my_view, 4, 2 ), N ); } diff --git a/test/array.cpp b/test/array.cpp index a83151c..b438dce 100755 --- a/test/array.cpp +++ b/test/array.cpp @@ -63,7 +63,7 @@ void check_array() BOOST_CHECK_EQUAL( empty( ca ),false ); const char A[] = "\0A"; - BOOST_CHECK_EQUAL( boost::size(A), 3u ); + BOOST_CHECK_EQUAL( boost::size(A), 3 ); } using boost::unit_test::test_suite; diff --git a/test/extension_mechanism.cpp b/test/extension_mechanism.cpp index 2fd7929..a206afb 100755 --- a/test/extension_mechanism.cpp +++ b/test/extension_mechanism.cpp @@ -44,7 +44,6 @@ namespace Foo typedef std::vector data_t; typedef data_t::iterator iterator; typedef data_t::const_iterator const_iterator; - typedef data_t::size_type size_type; data_t vec;