diff --git a/doc/boost_range.html b/doc/boost_range.html index 65284fa..ace1901 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -157,7 +157,7 @@ class=identifier>T& template< class T > - typename range_size<T>::type + typename range_difference<T>::type size( const T& r ); // @@ -471,12 +471,34 @@ class=identifier>T& linear time for pointers to a string, constant time otherwise + + + as_array(x) + iterator_range<X> + + [boost::begin(x),boost::end(x)) + + + + + + constant time otherwise + +

The special const_-named functions are useful when you want to document clearly that your code is read-only.

+

+ as_literal() can be used internally in string + algorithm librararies to such that arrays of characters are + handled correctly. +

+

+ as_array() can be used with string algorithm libraries to make it clear that arrays of characters are handled like an array and not like a string. +

Notice that the above functions should always be called with qualification (boost::) to prevent unintended Argument Dependent Lookup (ADL). diff --git a/doc/headers.html b/doc/headers.html index 1539ae8..69987ce 100755 --- a/doc/headers.html +++ b/doc/headers.html @@ -50,7 +50,7 @@ >range_iterator Single Pass Range - + <boost/range/mutable_iterator.hpp> range_mutable_iterator @@ -69,20 +69,15 @@ Forward Range - <boost/range/size_type.hpp> - range_size - Forward Range - - <boost/range/pointer.hpp> range_pointer + >range_pointer - - + <boost/range/category.hpp> range_category + >range_category - @@ -112,7 +107,7 @@ empty Single Pass Range - + <boost/range/distance.hpp> distance Forward Range @@ -121,7 +116,7 @@ <boost/range/size.hpp> size Random Access Range - + <boost/range/rbegin.hpp> @@ -139,14 +134,14 @@ Bidirectional Range - + <boost/range/as_array.hpp> as_array - - + <boost/range/as_literal.hpp> as_literal @@ -178,7 +173,7 @@


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


diff --git a/doc/utility_class.html b/doc/utility_class.html index 16df096..f7b5535 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -79,9 +79,10 @@ corresponding const_iterator is.

class iterator_range { public: // Forward Range types - typedef ForwardTraversalIterator iterator; - typedef ForwardTraversalIterator const_iterator; - + typedef ForwardTraversalIterator iterator; + typedef ForwardTraversalIterator const_iterator; + typedef iterator_difference<iterator>::type difference_type; +
public: // construction, assignment template< class ForwardTraversalIterator2 > iterator_range( ForwardTraversalIterator2 Begin, ForwardTraversalIterator2 End ); @@ -99,23 +100,24 @@ corresponding const_iterator is.

iterator_range& operator=( const ForwardRange& r ); public: // Forward Range functions - iterator begin() const; - iterator end() const; - size_type size() const; - bool empty() const; + iterator begin() const; + iterator end() const; + difference_type size() const; + bool empty() const; public: // convenience - operator unspecified_bool_type() const; - bool operator unspecified_bool_type() const; + bool equal( const iterator_range& ) ( const iterator_range& ) const; - referencefront() const; - reference back() const; + reference front() const; + reference back() const; + iterator_range& advance_begin( difference_type n ); + iterator_range& advance_end( difference_type n ); // for Random Access Range only: - value_type& operator[]( size_type at ) const; - value_typecial>& operator()( size_type at ) const; + reference operator[]( difference_type at ) const; + value_type operator()( difference_type at ) const; }; // stream output @@ -168,11 +170,11 @@ class=keyword>const; ForwardTraversalIterator End ); template< class ForwardRange > - iterator_range< typename iterator<ForwardRange>::type > + iterator_range< typename range_iterator<ForwardRange>::type > make_iterator_range( ForwardRange& r ); template< class ForwardRange > - iterator_range< typename const_iterator<ForwardRange>::type > + iterator_range< typename range_iterator<const ForwardRange>::type > make_iterator_range( const ForwardRange& r ); template< class Range > @@ -182,7 +184,7 @@ class=keyword>const; typename range_difference<Range>::type advance_end ); template< class Range > - iterator_range< typename range_const_iterator<Range>::type > + iterator_range< typename range_iterator<const Range>::type > make_iterator_range( const Range& r, typename range_difference<Range>::type advance_begin, typename range_difference<Range>::type advance_end ); @@ -286,12 +288,14 @@ class can propagate constness since it knows what a corresponding namespace boost { template< class ForwardRange > - class sub_range : public iterator_range< typename range_result_iterator<ForwardRange>::type > + class sub_range : public iterator_range< typename range_iterator<ForwardRange>::type > { public: - typedef typename range_result_iterator<ForwardRange>::type iterator; - typedef typename range_const_iterator<ForwardRange>::type const_iterator; + typedef typename range_iterator<ForwardRange>::type iterator; + typedef typename range_iterator<const ForwardRange>::type const_iterator; + typedef typename iterator_difference<iterator>::type difference_type; + public: // construction, assignment template< class ForwardTraversalIterator > sub_range( ForwardTraversalIterator Begin, ForwardTraversalIterator End ); @@ -320,8 +324,8 @@ class can propagate constness since it knows what a corresponding 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; + value_type& operator[]( difference_type at ); + const value_type& operator[]( difference_type at ) const; public: // rest of interface inherited from iterator_range @@ -339,15 +343,15 @@ 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" );
+    std::string str("hello");
+    iterator_range<std::string::iterator> ir = find_first( str, as_literal("ll") );
+    sub_range<std::string>               sub = find_first( str, as_literal("ll") );
 


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


diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp index e8251c9..9abf313 100755 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -41,6 +41,11 @@ namespace range_detail inline BOOST_DEDUCED_TYPENAME range_iterator::type range_begin( C& c ) { + // + // If you get a compile-error here, it is most likely because + // you have not implemented range_begin() properly in + // the namespace of C + // return c.begin(); } diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index d9c122f..53a88dc 100755 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -82,7 +82,6 @@ namespace boost { T a; range_iterator i; range_const_iterator ci; - bool b; }; //! Check if a type T models the ForwardRange range concept. diff --git a/include/boost/range/config.hpp b/include/boost/range/config.hpp index 5f856bb..4e7fb24 100755 --- a/include/boost/range/config.hpp +++ b/include/boost/range/config.hpp @@ -37,8 +37,7 @@ #error "macro already defined!" #endif -//#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || __MWERKS__ <= 0x3003 -#if _MSC_VER <= 1300 && !defined( __COMO__ ) && !defined( __GNUC__ ) && __MWERKS__ <= 0x3003 +#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || BOOST_WORKAROUND( __MWERKS__, <= 0x3003 ) #define BOOST_RANGE_NO_ARRAY_SUPPORT 1 #endif diff --git a/include/boost/range/detail/microsoft.hpp b/include/boost/range/detail/microsoft.hpp index 2c4b1ed..7b672c9 100644 --- a/include/boost/range/detail/microsoft.hpp +++ b/include/boost/range/detail/microsoft.hpp @@ -1,9 +1,6 @@ #ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP #define BOOST_RANGE_DETAIL_MICROSOFT_HPP - - - // Boost.Range MFC/ATL Extension // // Copyright Shunsuke Sogame 2005-2006. @@ -931,5 +928,4 @@ namespace boost { namespace range_detail_microsoft { - #endif diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp index be2f495..b777a55 100755 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -42,6 +42,11 @@ namespace range_detail inline BOOST_DEDUCED_TYPENAME range_iterator::type range_end( C& c ) { + // + // If you get a compile-error here, it is most likely because + // you have not implemented range_begin() properly in + // the namespace of C + // return c.end(); } diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 9df24c0..4304ecc 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -29,11 +29,13 @@ #include #include #include -#ifndef BOOST_OLD_IOSTREAMS -# include -#else -# include -#endif +#ifndef _STLP_NO_IOSTREAMS +# ifndef BOOST_OLD_IOSTREAMS +# include +# else +# include +# endif +#endif // _STLP_NO_IOSTREAMS #include #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) @@ -396,7 +398,8 @@ namespace boost // iterator range free-standing operators ---------------------------// -#ifndef BOOST_OLD_IOSTREAMS +#ifndef _STLP_NO_IOSTREAMS +# ifndef BOOST_OLD_IOSTREAMS //! iterator_range output operator /*! @@ -415,7 +418,7 @@ namespace boost return Os; } -#else +# else //! iterator_range output operator /*! @@ -431,7 +434,8 @@ namespace boost return Os; } -#endif +# endif +#endif // _STLP_NO_IOSTREAMS ///////////////////////////////////////////////////////////////////// // comparison operators diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp index d50a1f7..2546817 100755 --- a/test/iterator_pair.cpp +++ b/test/iterator_pair.cpp @@ -65,17 +65,17 @@ void check_iterator_pair() 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( size( pair ) == 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( size( const_pair ) == 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 ) ) ); + BOOST_CHECK( size( constness_pair ) == std::distance( constness_pair.first, constness_pair.second ) ); } diff --git a/test/std_container.cpp b/test/std_container.cpp index e26d2a3..e2ee692 100755 --- a/test/std_container.cpp +++ b/test/std_container.cpp @@ -48,12 +48,12 @@ void check_std_container() 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( (std::size_t)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() ); + BOOST_CHECK( (std::size_t)size( cvec ) == cvec.size() ); }