From dc96b440beebc363e90222a7ba65ec09ae208f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 18 May 2006 19:17:04 +0000 Subject: [PATCH 01/92] v2 upgrade [SVN r34011] --- test/Jamfile | 4 + test/algorithm_example.cpp | 5 +- test/array.cpp | 8 +- test/extension_mechanism.cpp | 14 ++-- test/iterator_pair.cpp | 8 +- test/iterator_range.cpp | 22 ++++-- test/partial_workaround.cpp | 7 +- test/reversible_range.cpp | 39 ++-------- test/std_container.cpp | 8 +- test/string.cpp | 146 ++++++++++++++++++++++------------- 10 files changed, 136 insertions(+), 125 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index 4a8ef6d..b00b99d 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -17,6 +17,7 @@ rule range-test ( name : includes * ) return [ run $(name).cpp ../../test/build/boost_unit_test_framework + ../../regex/build/boost_regex : : : $(BOOST_ROOT) @@ -36,6 +37,9 @@ test-suite range : [ range-test reversible_range ] [ range-test const_ranges ] [ range-test extension_mechanism ] +# [ range-test test ] +# [ range-test algorithm ] +# [ range-test adaptors ] # [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] ; diff --git a/test/algorithm_example.cpp b/test/algorithm_example.cpp index cd6e0e0..3bfb71f 100755 --- a/test/algorithm_example.cpp +++ b/test/algorithm_example.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -70,12 +71,8 @@ void check_algorithm() 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 ); } diff --git a/test/array.cpp b/test/array.cpp index d2f00b0..db7054d 100755 --- a/test/array.cpp +++ b/test/array.cpp @@ -42,16 +42,16 @@ void check_array() 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_iterator::type, int* >::value )); + BOOST_STATIC_ASSERT(( is_same< range_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 )); + BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const int* >::value )); + BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const int* >::value )); #endif BOOST_CHECK_EQUAL( begin( my_array ), my_array ); diff --git a/test/extension_mechanism.cpp b/test/extension_mechanism.cpp index 0a272c3..2fd7929 100755 --- a/test/extension_mechanism.cpp +++ b/test/extension_mechanism.cpp @@ -25,7 +25,7 @@ // Generic range algorithm // template< class Rng > -typename boost::range_result_iterator::type foo_algo( Rng& r ) +typename boost::range_iterator::type foo_algo( Rng& r ) { // // This will only compile for Rng = UDT if the qualified calls @@ -57,32 +57,28 @@ namespace Foo // to be defined because X defines the proper set of // nested types. // - inline X::iterator boost_range_begin( X& x ) + inline X::iterator range_begin( X& x ) { return x.vec.begin(); } - inline X::const_iterator boost_range_begin( const X& x ) + inline X::const_iterator range_begin( const X& x ) { return x.vec.begin(); } - inline X::iterator boost_range_end( X& x ) + inline X::iterator range_end( X& x ) { return x.vec.end(); } - inline X::const_iterator boost_range_end( const X& x ) + inline X::const_iterator range_end( const X& x ) { return x.vec.end(); } - inline X::size_type boost_range_size( const X& x ) - { - return x.vec.size(); - } } void check_extension() diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp index 74358ef..db82f64 100755 --- a/test/iterator_pair.cpp +++ b/test/iterator_pair.cpp @@ -46,8 +46,8 @@ void check_iterator_pair() 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_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const_pair_t::first_type >::value )); BOOST_STATIC_ASSERT(( is_same< range_value::type, detail::iterator_traits::value_type>::value )); @@ -56,8 +56,8 @@ void check_iterator_pair() 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_STATIC_ASSERT(( is_same< range_iterator::type, const_pair_tt::first_type >::value )); + BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const_pair_tt::first_type >::value )); BOOST_CHECK( begin( pair ) == pair.first ); BOOST_CHECK( end( pair ) == pair.second ); diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 20696aa..152ac76 100755 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -8,6 +8,7 @@ // For more information, see http://www.boost.org/libs/range/ // +//#include #include @@ -16,7 +17,6 @@ # pragma warn -8057 // unused argument argc/argv in Boost.Test #endif - #include #include #include @@ -26,7 +26,7 @@ using namespace boost; using namespace std; - + void check_reference_type(); void check_iterator_range() @@ -65,6 +65,12 @@ void check_iterator_range() BOOST_CHECK_EQUAL( distance( r.begin(), r.end() ), distance( begin( r2 ), end( r2 ) ) ); cout << r << r2; + + +#ifndef BOOST_NO_STD_WSTRING + wcout << make_iterator_range( wstring( L"a wide string" ) ) + << make_iterator_range( L"another wide string" ); +#endif string res = copy_range( r ); BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) ); @@ -94,7 +100,7 @@ void check_iterator_range() rrr = make_iterator_range( rrr, -1, 1 ); BOOST_CHECK( rrr == str ); - check_reference_type(); + check_reference_type(); } @@ -121,13 +127,13 @@ test_suite* init_unit_test_suite( int argc, char* argv[] ) template< class Container > int test_iter_range( Container& a_cont ) { - typedef BOOST_DEDUCED_TYPENAME range_result_iterator::type citer_type; + typedef BOOST_DEDUCED_TYPENAME range_iterator::type citer_type; typedef iterator_range riter_type; riter_type a_riter( make_iterator_range( a_cont ) ); - a_riter.front(); - a_riter.back(); - int i = a_riter[0]; - return i; + a_riter.front(); + a_riter.back(); + int i = a_riter[0]; + return i; } diff --git a/test/partial_workaround.cpp b/test/partial_workaround.cpp index ba014ae..8ac6f66 100755 --- a/test/partial_workaround.cpp +++ b/test/partial_workaround.cpp @@ -17,18 +17,15 @@ #endif #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +//#define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 1 #include #include #include #include #include -#include -#include -#include -#include -#include +#include #include #include diff --git a/test/reversible_range.cpp b/test/reversible_range.cpp index 26d953a..c3d943e 100755 --- a/test/reversible_range.cpp +++ b/test/reversible_range.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -31,7 +32,7 @@ using namespace std; void check_iterator() { - typedef vector vec_t; + typedef vector vec_t; typedef vec_t::iterator iterator; typedef pair pair_t; typedef range_reverse_iterator::type rev_iterator; @@ -40,15 +41,8 @@ void check_iterator() 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"; - + int a[] = {1,2,3,4,5,6,7,8,9,10}; + const int ca[] = {1,2,3,4,5,6,7,8,9,10,11,12}; 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 ) ) ); @@ -58,33 +52,16 @@ void check_iterator() 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 ) ); + BOOST_CHECK_EQUAL( &*begin( a ), &*( rend( a ) ) ); + BOOST_CHECK_EQUAL( &*( end( a ) ), &*rbegin( a ) ); + BOOST_CHECK_EQUAL( &*begin( ca ), &*( rend( ca ) ) ); + BOOST_CHECK_EQUAL( &*( end( ca ) ), &*rbegin( 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" ); diff --git a/test/std_container.cpp b/test/std_container.cpp index a61e8d1..e26d2a3 100755 --- a/test/std_container.cpp +++ b/test/std_container.cpp @@ -35,15 +35,13 @@ void check_std_container() 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_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_iterator::type, vec_t::iterator >::value )); + BOOST_STATIC_ASSERT(( is_same< range_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 )); diff --git a/test/string.cpp b/test/string.cpp index 36f103b..9d4b252 100755 --- a/test/string.cpp +++ b/test/string.cpp @@ -17,7 +17,10 @@ # pragma warn -8057 // unused argument argc/argv in Boost.Test #endif -#include +#include +#include +#include +#include #include #include #include @@ -26,36 +29,66 @@ #include #include +template< class T > +inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type +str_begin( T& r ) +{ + return boost::begin( as_literal(r) ); +} + +template< class T > +inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type +str_end( T& r ) +{ + return boost::end( as_literal(r) ); +} + +template< class T > +inline BOOST_DEDUCED_TYPENAME boost::range_size::type +str_size( const T& r ) +{ + return boost::size( as_literal(r) ); +} + +template< class T > +inline bool +str_empty( T& r ) +{ + return boost::empty( as_literal(r) ); +} + 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 ); + return std::find( str_begin(c), str_end(c), + value ); } template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::range_const_iterator::type +BOOST_DEDUCED_TYPENAME boost::range_iterator::type find( const Container& c, T value ) { - return std::find( boost::begin( c ), boost::end( c ), value ); + return std::find( str_begin(c), str_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 ); +{ + str_size( c ); + return std::find( str_begin(c), str_end(c), + value ); } template< typename Container, typename T > -BOOST_DEDUCED_TYPENAME boost::range_const_iterator::type +BOOST_DEDUCED_TYPENAME boost::range_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 ); + str_size( c ); + return std::find( str_begin(c), str_end(c), + value ); } @@ -72,62 +105,66 @@ 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"; + const char* char_s = "a string"; + char my_string[] = "another string"; + const char my_const_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_iterator::type, char_iterator_t >::value )); + BOOST_STATIC_ASSERT(( is_same< range_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_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_STATIC_ASSERT(( is_same< range_iterator::type, char* >::value )); + BOOST_STATIC_ASSERT(( is_same< range_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( str_begin( char_s ), char_s ); + std::size_t sz = str_size(char_s); + const char* str_end1 = str_begin( char_s ) + sz; + BOOST_CHECK_EQUAL( str_end( char_s ), str_end1 ); + BOOST_CHECK_EQUAL( str_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 ); + BOOST_CHECK_EQUAL( str_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 ); + const char* str_end12 = str_begin( char_s2 ) + sz; + BOOST_CHECK_EQUAL( str_end( char_s2 ), str_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 ) ); + BOOST_CHECK_EQUAL( str_begin( my_string ), my_string ); + range_iterator::type str_end2 = str_begin( my_string ) + str_size(my_string); + range_iterator::type str_end3 = str_end(my_string); + BOOST_CHECK_EQUAL( str_end3, str_end2 ); + BOOST_CHECK_EQUAL( str_empty( my_string ), (my_string == 0 || my_string[0] == char()) ); + BOOST_CHECK_EQUAL( str_size( my_string ), my_string_length ); + BOOST_CHECK_EQUAL( str_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( char_s, to_search ) != str_end( char_s ) ); + BOOST_CHECK( find_const( char_s, to_search ) != str_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( my_string, to_search ) != str_end(my_string) ); + BOOST_CHECK( find_const( my_string, to_search ) != str_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 ) ); + BOOST_CHECK( find_mutable( char_s2, to_search ) != str_end(char_s) ); + BOOST_CHECK( find_const( char_s2, to_search ) != str_end(char_s2) ); + + BOOST_CHECK( find_const( as_array( my_string ), to_search ) != str_end(my_string) ); + BOOST_CHECK( find_const( as_array( my_const_string ), to_search ) != str_end(my_string) ); } @@ -148,31 +185,31 @@ void check_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_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 )); + BOOST_STATIC_ASSERT(( is_same< range_iterator::type, wchar_iterator_t >::value )); + BOOST_STATIC_ASSERT(( is_same< range_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()) ); + std::size_t sz = str_size( char_ws ); + BOOST_CHECK_EQUAL( str_begin( char_ws ), char_ws ); + BOOST_CHECK_EQUAL( str_end(char_ws), (str_begin( char_ws ) + sz) ); + BOOST_CHECK_EQUAL( str_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( str_begin( char_ws2 ), char_ws2 ); + BOOST_CHECK_EQUAL( str_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 ) ); + BOOST_CHECK( find( char_ws, to_search ) != str_end(char_ws) ); #if BOOST_WORKAROUND(_MSC_VER, BOOST_TESTED_AT(1300)) - BOOST_CHECK( find( my_wstring, to_search ) != end( my_wstring ) ); + BOOST_CHECK( find( my_wstring, to_search ) != str_end(my_wstring) ); #endif #endif @@ -181,7 +218,6 @@ void check_string() } - #include using boost::unit_test::test_suite; From 554f832234566a3253c71c043c50d71a4130c784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 18 May 2006 20:52:17 +0000 Subject: [PATCH 02/92] upgrade to v2 [SVN r34012] --- include/boost/range/begin.hpp | 100 ++-------- include/boost/range/const_iterator.hpp | 65 +------ .../boost/range/const_reverse_iterator.hpp | 17 +- include/boost/range/detail/begin.hpp | 49 +---- include/boost/range/detail/common.hpp | 1 + include/boost/range/detail/const_iterator.hpp | 52 ----- include/boost/range/detail/end.hpp | 71 +------ include/boost/range/detail/iterator.hpp | 52 +---- include/boost/range/detail/size_type.hpp | 50 +---- include/boost/range/detail/value_type.hpp | 50 ----- include/boost/range/difference_type.hpp | 124 +----------- include/boost/range/empty.hpp | 43 +---- include/boost/range/end.hpp | 99 ++-------- include/boost/range/functions.hpp | 4 +- include/boost/range/iterator.hpp | 110 ++--------- include/boost/range/iterator_range.hpp | 137 ++++++++------ include/boost/range/metafunctions.hpp | 10 +- include/boost/range/rbegin.hpp | 19 +- include/boost/range/rend.hpp | 19 +- include/boost/range/result_iterator.hpp | 20 +- .../boost/range/reverse_result_iterator.hpp | 17 +- include/boost/range/size.hpp | 104 +--------- include/boost/range/size_type.hpp | 178 ++++-------------- include/boost/range/sub_range.hpp | 24 ++- include/boost/range/value_type.hpp | 124 +----------- 25 files changed, 248 insertions(+), 1291 deletions(-) diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp index d16ce1e..e8251c9 100755 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -15,7 +15,6 @@ # pragma once #endif -#include #include #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING @@ -23,7 +22,6 @@ #else #include -#include namespace boost { @@ -40,16 +38,8 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename C > - inline BOOST_DEDUCED_TYPENAME range_const_iterator::type - boost_range_begin( const C& c ) - { - return c.begin(); - } - - template< typename C > - inline BOOST_DEDUCED_TYPENAME range_iterator< - typename remove_const::type >::type - boost_range_begin( C& c ) + inline BOOST_DEDUCED_TYPENAME range_iterator::type + range_begin( C& c ) { return c.begin(); } @@ -59,13 +49,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator boost_range_begin( const std::pair& p ) + inline Iterator range_begin( const std::pair& p ) { return p.first; } template< typename Iterator > - inline Iterator boost_range_begin( std::pair& p ) + inline Iterator range_begin( std::pair& p ) { return p.first; } @@ -74,66 +64,22 @@ namespace range_detail // array ////////////////////////////////////////////////////////////////////// + // + // May this be discarded? Or is it needed for bad compilers? + // template< typename T, std::size_t sz > - inline const T* boost_range_begin( const T (&array)[sz] ) + inline const T* range_begin( const T (&array)[sz] ) { return array; } template< typename T, std::size_t sz > - inline T* boost_range_begin( T (&array)[sz] ) + inline T* range_begin( T (&array)[sz] ) { return array; } - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - -#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// CW up to 9.3 and borland have troubles with function ordering - inline const char* boost_range_begin( const char* s ) - { - return s; - } - - inline char* boost_range_begin( char* s ) - { - return s; - } - - inline const wchar_t* boost_range_begin( const wchar_t* s ) - { - return s; - } - - inline wchar_t* boost_range_begin( wchar_t* s ) - { - return s; - } -#else - inline const char* boost_range_begin( const char*& s ) - { - return s; - } - - inline char* boost_range_begin( char*& s ) - { - return s; - } - - inline const wchar_t* boost_range_begin( const wchar_t*& s ) - { - return s; - } - - inline wchar_t* boost_range_begin( wchar_t*& s ) - { - return s; - } -#endif - #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ @@ -142,44 +88,27 @@ namespace range_detail template< class T > -inline BOOST_DEDUCED_TYPENAME range_iterator< - typename remove_const::type >::type begin( T& r ) +inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ using namespace range_detail; #endif - return boost_range_begin( r ); + return range_begin( r ); } template< class T > -inline BOOST_DEDUCED_TYPENAME range_const_iterator::type begin( const T& r ) +inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( const T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ using namespace range_detail; #endif - return boost_range_begin( r ); + return range_begin( r ); } -#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// BCB and CW are not able to overload pointer when class overloads are also available. -template<> -inline range_const_iterator::type begin( const char*& r ) -{ - return r; -} - -template<> -inline range_const_iterator::type begin( const wchar_t*& r ) -{ - return r; -} - -#endif - } // namespace boost #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING @@ -187,7 +116,7 @@ inline range_const_iterator::type begin( const w namespace boost { template< class T > - inline BOOST_DEDUCED_TYPENAME range_const_iterator::type + inline BOOST_DEDUCED_TYPENAME range_iterator::type const_begin( const T& r ) { return boost::begin( r ); @@ -195,3 +124,4 @@ namespace boost } #endif + diff --git a/include/boost/range/const_iterator.hpp b/include/boost/range/const_iterator.hpp index 4ba41b2..195f9d4 100755 --- a/include/boost/range/const_iterator.hpp +++ b/include/boost/range/const_iterator.hpp @@ -21,6 +21,7 @@ #include #else +#include #include #include @@ -46,12 +47,6 @@ namespace boost typedef Iterator type; }; - template< typename Iterator > - struct range_const_iterator< const std::pair > - { - typedef Iterator type; - }; - ////////////////////////////////////////////////////////////////////////// // array ////////////////////////////////////////////////////////////////////////// @@ -62,64 +57,6 @@ namespace boost typedef const T* type; }; - template< typename T, std::size_t sz > - struct range_const_iterator< const T[sz] > - { - typedef const T* type; - }; - - ////////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////////// - - template<> - struct range_const_iterator< char* > - { - typedef const char* type; - }; - - template<> - struct range_const_iterator< wchar_t* > - { - typedef const wchar_t* type; - }; - - template<> - struct range_const_iterator< const char* > - { - typedef const char* type; - }; - - template<> - struct range_const_iterator< const wchar_t* > - { - typedef const wchar_t* type; - }; - - template<> - struct range_const_iterator< char* const > - { - typedef const char* type; - }; - - template<> - struct range_const_iterator< wchar_t* const > - { - typedef const wchar_t* type; - }; - - template<> - struct range_const_iterator< const char* const > - { - typedef const char* type; - }; - - template<> - struct range_const_iterator< const wchar_t* const > - { - typedef const wchar_t* type; - }; - } // namespace boost #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION diff --git a/include/boost/range/const_reverse_iterator.hpp b/include/boost/range/const_reverse_iterator.hpp index f33f63d..215bcc7 100755 --- a/include/boost/range/const_reverse_iterator.hpp +++ b/include/boost/range/const_reverse_iterator.hpp @@ -15,22 +15,17 @@ # pragma once #endif -#include -#include -#include +#include namespace boost { - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// + // + // This interface is deprecated, use range_reverse_iterator + // template< typename C > - struct range_const_reverse_iterator - { - typedef reverse_iterator< - BOOST_DEDUCED_TYPENAME range_const_iterator::type > type; - }; + struct range_const_reverse_iterator : range_reverse_iterator + { }; } // namespace boost diff --git a/include/boost/range/detail/begin.hpp b/include/boost/range/detail/begin.hpp index f516a14..06c2561 100755 --- a/include/boost/range/detail/begin.hpp +++ b/include/boost/range/detail/begin.hpp @@ -13,7 +13,7 @@ #include // BOOST_MSVC #include -#include +#include #include #if BOOST_WORKAROUND(BOOST_MSVC, < 1310) # include @@ -35,7 +35,7 @@ namespace boost struct range_begin { template< typename C > - static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator::type fun( C& c ) + static BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type fun( C& c ) { return c.begin(); }; @@ -49,7 +49,7 @@ namespace boost struct range_begin { template< typename P > - static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator

::type fun( const P& p ) + static BOOST_RANGE_DEDUCED_TYPENAME range_iterator

::type fun( const P& p ) { return p.first; } @@ -77,51 +77,10 @@ namespace boost #endif }; - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - - template<> - struct range_begin - { - static char* fun( char* s ) - { - return s; - } - }; - - template<> - struct range_begin - { - static const char* fun( const char* s ) - { - return s; - } - }; - - template<> - struct range_begin - { - - static wchar_t* fun( wchar_t* s ) - { - return s; - } - }; - - template<> - struct range_begin - { - static const wchar_t* fun( const wchar_t* s ) - { - return s; - } - }; - } // namespace 'range_detail' template< typename C > - inline BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator::type + inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type begin( C& c ) { return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range::type >::fun( c ); diff --git a/include/boost/range/detail/common.hpp b/include/boost/range/detail/common.hpp index 36fada1..f7539f5 100755 --- a/include/boost/range/detail/common.hpp +++ b/include/boost/range/detail/common.hpp @@ -114,3 +114,4 @@ namespace boost } #endif + diff --git a/include/boost/range/detail/const_iterator.hpp b/include/boost/range/detail/const_iterator.hpp index 3aef82a..e5cb34a 100755 --- a/include/boost/range/detail/const_iterator.hpp +++ b/include/boost/range/detail/const_iterator.hpp @@ -56,58 +56,6 @@ namespace boost remove_extent::type* type; }; }; - - template<> - struct range_const_iterator_ - { - template< typename T > - struct pts - { - typedef const BOOST_RANGE_DEDUCED_TYPENAME - remove_extent::type* type; - }; - }; - - template<> - struct range_const_iterator_ - { - template< typename S > - struct pts - { - typedef const char* type; - }; - }; - - template<> - struct range_const_iterator_ - { - template< typename S > - struct pts - { - typedef const char* type; - }; - }; - - template<> - struct range_const_iterator_ - { - template< typename S > - struct pts - { - typedef const wchar_t* type; - }; - }; - - template<> - struct range_const_iterator_ - { - template< typename S > - struct pts - { - typedef const wchar_t* type; - }; - }; - } template< typename C > diff --git a/include/boost/range/detail/end.hpp b/include/boost/range/detail/end.hpp index 410ae60..d6a7368 100755 --- a/include/boost/range/detail/end.hpp +++ b/include/boost/range/detail/end.hpp @@ -18,8 +18,7 @@ # include #else # include -# include -# include +# include # include # if BOOST_WORKAROUND(BOOST_MSVC, < 1310) # include @@ -40,7 +39,7 @@ namespace boost struct range_end { template< typename C > - static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator::type + static BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type fun( C& c ) { return c.end(); @@ -55,7 +54,7 @@ namespace boost struct range_end { template< typename P > - static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator

::type + static BOOST_RANGE_DEDUCED_TYPENAME range_iterator

::type fun( const P& p ) { return p.second; @@ -83,73 +82,11 @@ namespace boost } #endif }; - - - template<> - struct range_end - { - template< typename T, std::size_t sz > - static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) - { - return boost::range_detail::array_end( boost_range_array ); - } - }; - - template<> - struct range_end - { - template< typename T, std::size_t sz > - static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) - { - return boost::range_detail::array_end( boost_range_array ); - } - }; - - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - - template<> - struct range_end - { - static char* fun( char* s ) - { - return boost::range_detail::str_end( s ); - } - }; - - template<> - struct range_end - { - static const char* fun( const char* s ) - { - return boost::range_detail::str_end( s ); - } - }; - - template<> - struct range_end - { - static wchar_t* fun( wchar_t* s ) - { - return boost::range_detail::str_end( s ); - } - }; - - - template<> - struct range_end - { - static const wchar_t* fun( const wchar_t* s ) - { - return boost::range_detail::str_end( s ); - } - }; } // namespace 'range_detail' template< typename C > - inline BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator::type + inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type end( C& c ) { return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range::type >::fun( c ); diff --git a/include/boost/range/detail/iterator.hpp b/include/boost/range/detail/iterator.hpp index b9098e6..58346d4 100755 --- a/include/boost/range/detail/iterator.hpp +++ b/include/boost/range/detail/iterator.hpp @@ -64,60 +64,10 @@ namespace boost }; }; - template<> - struct range_iterator_ - { - template< typename T > - struct pts - { - typedef BOOST_RANGE_DEDUCED_TYPENAME - remove_extent::type* type; - }; - }; - - template<> - struct range_iterator_ - { - template< typename S > - struct pts - { - typedef char* type; - }; - }; - - template<> - struct range_iterator_ - { - template< typename S > - struct pts - { - typedef const char* type; - }; - }; - - template<> - struct range_iterator_ - { - template< typename S > - struct pts - { - typedef wchar_t* type; - }; - }; - - template<> - struct range_iterator_ - { - template< typename S > - struct pts - { - typedef const wchar_t* type; - }; - }; } template< typename C > - class range_iterator + class range_mutable_iterator { typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range::type c_type; public: diff --git a/include/boost/range/detail/size_type.hpp b/include/boost/range/detail/size_type.hpp index d4f0704..ec49f4d 100755 --- a/include/boost/range/detail/size_type.hpp +++ b/include/boost/range/detail/size_type.hpp @@ -54,55 +54,7 @@ namespace boost }; }; - template<> - struct range_size_type_ - { - template< typename A > - struct pts - { - typedef std::size_t type; - }; - }; - - template<> - struct range_size_type_ - { - template< typename S > - struct pts - { - typedef std::size_t type; - }; - }; - - template<> - struct range_size_type_ - { - template< typename S > - struct pts - { - typedef std::size_t type; - }; - }; - - template<> - struct range_size_type_ - { - template< typename S > - struct pts - { - typedef std::size_t type; - }; - }; - - template<> - struct range_size_type_ - { - template< typename S > - struct pts - { - typedef std::size_t type; - }; - }; + } template< typename C > diff --git a/include/boost/range/detail/value_type.hpp b/include/boost/range/detail/value_type.hpp index c3a4693..2784514 100755 --- a/include/boost/range/detail/value_type.hpp +++ b/include/boost/range/detail/value_type.hpp @@ -56,56 +56,6 @@ namespace boost }; }; - template<> - struct range_value_type_ - { - template< typename T > - struct pts - { - typedef char type; - }; - }; - - template<> - struct range_value_type_ - { - template< typename S > - struct pts - { - typedef char type; - }; - }; - - template<> - struct range_value_type_ - { - template< typename S > - struct pts - { - typedef const char type; - }; - }; - - template<> - struct range_value_type_ - { - template< typename S > - struct pts - { - typedef wchar_t type; - }; - }; - - template<> - struct range_value_type_ - { - template< typename S > - struct pts - { - typedef const wchar_t type; - }; - }; - } template< typename C > diff --git a/include/boost/range/difference_type.hpp b/include/boost/range/difference_type.hpp index 33c56e3..164288f 100755 --- a/include/boost/range/difference_type.hpp +++ b/include/boost/range/difference_type.hpp @@ -16,130 +16,14 @@ #endif #include -#include +#include #include namespace boost { - template< class T > - struct range_difference - { - typedef BOOST_DEDUCED_TYPENAME iterator_difference< - BOOST_DEDUCED_TYPENAME range_const_iterator::type >::type - type; - }; + template< class T > + struct range_difference : iterator_difference< typename range_iterator::type > + { }; } -//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -//#include -//#else - -/* -#include -#include - -namespace boost -{ - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// - - template< typename C > - struct range_difference - { - typedef BOOST_DEDUCED_TYPENAME C::difference_type type; - }; - - ////////////////////////////////////////////////////////////////////////// - // pair - ////////////////////////////////////////////////////////////////////////// - - template< typename Iterator > - struct range_difference< std::pair > - { - typedef BOOST_DEDUCED_TYPENAME - iterator_difference::type type; - }; - - template< typename Iterator > - struct range_difference< const std::pair > - { - typedef BOOST_DEDUCED_TYPENAME - iterator_difference::type type; - }; - - - ////////////////////////////////////////////////////////////////////////// - // array - ////////////////////////////////////////////////////////////////////////// - - template< typename T, std::size_t sz > - struct range_difference< T[sz] > - { - typedef std::ptrdiff_t type; - }; - - template< typename T, std::size_t sz > - struct range_difference< const T[sz] > - { - typedef std::ptrdiff_t type; - }; - - ////////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////////// - - template<> - struct range_difference< char* > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< wchar_t* > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< const char* > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< const wchar_t* > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< char* const > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< wchar_t* const > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< const char* const > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_difference< const wchar_t* const > - { - typedef std::ptrdiff_t type; - }; - -} // namespace boost - -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -*/ - #endif diff --git a/include/boost/range/empty.hpp b/include/boost/range/empty.hpp index 7363262..78c4e85 100755 --- a/include/boost/range/empty.hpp +++ b/include/boost/range/empty.hpp @@ -16,52 +16,19 @@ #endif #include -//#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -//#include -//#else - #include #include namespace boost { -namespace range_detail -{ - ////////////////////////////////////////////////////////////////////// - // primary template - ////////////////////////////////////////////////////////////////////// - - template< typename C > - inline bool empty( const C& c ) - { - return boost::begin( c ) == boost::end( c ); - } - - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - - inline bool empty( const char* const& s ) - { - return s == 0 || s[0] == 0; - } - - inline bool empty( const wchar_t* const& s ) - { - return s == 0 || s[0] == 0; - } - -} // namespace 'range_detail' - -template< class T > -inline bool empty( const T& r ) -{ - return range_detail::empty( r ); -} + template< class T > + inline bool empty( const T& r ) + { + return boost::begin( r ) == boost::end( r ); + } } // namepace 'boost' -//#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING #endif diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp index 493208f..be2f495 100755 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -15,7 +15,6 @@ # pragma once #endif -#include #include #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING @@ -39,18 +38,9 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// // primary template ////////////////////////////////////////////////////////////////////// - template< typename C > - inline BOOST_DEDUCED_TYPENAME range_const_iterator::type - boost_range_end( const C& c ) - { - return c.end(); - } - - template< typename C > - inline BOOST_DEDUCED_TYPENAME range_iterator< - typename remove_const::type >::type - boost_range_end( C& c ) + inline BOOST_DEDUCED_TYPENAME range_iterator::type + range_end( C& c ) { return c.end(); } @@ -60,13 +50,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator boost_range_end( const std::pair& p ) + inline Iterator range_end( const std::pair& p ) { return p.second; } template< typename Iterator > - inline Iterator boost_range_end( std::pair& p ) + inline Iterator range_end( std::pair& p ) { return p.second; } @@ -76,64 +66,17 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename T, std::size_t sz > - inline const T* boost_range_end( const T (&array)[sz] ) + inline const T* range_end( const T (&array)[sz] ) { return range_detail::array_end( array ); } template< typename T, std::size_t sz > - inline T* boost_range_end( T (&array)[sz] ) + inline T* range_end( T (&array)[sz] ) { return range_detail::array_end( array ); } - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - -#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// CW up to 9.3 and borland have troubles with function ordering - inline char* boost_range_end( char* s ) - { - return range_detail::str_end( s ); - } - - inline wchar_t* boost_range_end( wchar_t* s ) - { - return range_detail::str_end( s ); - } - - inline const char* boost_range_end( const char* s ) - { - return range_detail::str_end( s ); - } - - inline const wchar_t* boost_range_end( const wchar_t* s ) - { - return range_detail::str_end( s ); - } -#else - inline char* boost_range_end( char*& s ) - { - return range_detail::str_end( s ); - } - - inline wchar_t* boost_range_end( wchar_t*& s ) - { - return range_detail::str_end( s ); - } - - inline const char* boost_range_end( const char*& s ) - { - return range_detail::str_end( s ); - } - - inline const wchar_t* boost_range_end( const wchar_t*& s ) - { - return range_detail::str_end( s ); - } -#endif - #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ @@ -141,46 +84,27 @@ namespace range_detail #endif template< class T > -inline BOOST_DEDUCED_TYPENAME range_iterator< - typename remove_const::type >::type end( T& r ) +inline BOOST_DEDUCED_TYPENAME range_iterator::type end( T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ using namespace range_detail; #endif - return boost_range_end( r ); + return range_end( r ); } template< class T > -inline BOOST_DEDUCED_TYPENAME range_const_iterator::type end( const T& r ) +inline BOOST_DEDUCED_TYPENAME range_iterator::type end( const T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ using namespace range_detail; #endif - return boost_range_end( r ); + return range_end( r ); } - - -#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// BCB and CW are not able to overload pointer when class overloads are also available. -template<> -inline range_const_iterator::type end( const char*& r ) -{ - return range_detail::str_end( r ); -} - -template<> -inline range_const_iterator::type end( const wchar_t*& r ) -{ - return range_detail::str_end( r ); -} - -#endif - } // namespace 'boost' @@ -191,7 +115,7 @@ inline range_const_iterator::type end( const wch namespace boost { template< class T > - inline BOOST_DEDUCED_TYPENAME range_const_iterator::type + inline BOOST_DEDUCED_TYPENAME range_iterator::type const_end( const T& r ) { return boost::end( r ); @@ -199,3 +123,4 @@ namespace boost } #endif + diff --git a/include/boost/range/functions.hpp b/include/boost/range/functions.hpp index 5b5fb54..b8b8608 100755 --- a/include/boost/range/functions.hpp +++ b/include/boost/range/functions.hpp @@ -1,6 +1,6 @@ // Boost.Range library // -// Copyright Thorsten Ottosen 2003-2004. Use, modification and +// Copyright Thorsten Ottosen 2003-2006. 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) @@ -18,8 +18,10 @@ #include #include #include +#include #include #include #include #endif + diff --git a/include/boost/range/iterator.hpp b/include/boost/range/iterator.hpp index 0225495..3942cbc 100755 --- a/include/boost/range/iterator.hpp +++ b/include/boost/range/iterator.hpp @@ -11,118 +11,30 @@ #ifndef BOOST_RANGE_ITERATOR_HPP #define BOOST_RANGE_ITERATOR_HPP -#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#include -#else - -#include -#include -#include +#include +#include +#include +#include +#include namespace boost { - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// - template< typename C > struct range_iterator { - typedef BOOST_DEDUCED_TYPENAME C::iterator type; + typedef BOOST_RANGE_DEDUCED_TYPENAME + mpl::eval_if_c< is_const::value, + range_const_iterator< typename remove_const::type >, + range_mutable_iterator >::type type; }; - ////////////////////////////////////////////////////////////////////////// - // pair - ////////////////////////////////////////////////////////////////////////// - - template< typename Iterator > - struct range_iterator< std::pair > - { - typedef Iterator type; - }; - - template< typename Iterator > - struct range_iterator< const std::pair > - { - typedef Iterator type; - }; - - ////////////////////////////////////////////////////////////////////////// - // array - ////////////////////////////////////////////////////////////////////////// - - template< typename T, std::size_t sz > - struct range_iterator< T[sz] > - { - typedef T* type; - }; - - template< typename T, std::size_t sz > - struct range_iterator< const T[sz] > - { - typedef const T* type; - }; - - ////////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////////// - - template<> - struct range_iterator< char* > - { - typedef char* type; - }; - - template<> - struct range_iterator< wchar_t* > - { - typedef wchar_t* type; - }; - - template<> - struct range_iterator< const char* > - { - typedef const char* type; - }; - - template<> - struct range_iterator< const wchar_t* > - { - typedef const wchar_t* type; - }; - - template<> - struct range_iterator< char* const > - { - typedef char* type; - }; - - template<> - struct range_iterator< wchar_t* const > - { - typedef wchar_t* type; - }; - - template<> - struct range_iterator< const char* const > - { - typedef const char* type; - }; - - template<> - struct range_iterator< const wchar_t* const > - { - typedef const wchar_t* type; - }; - } // namespace boost -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index b29df15..a09ee30 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -158,8 +158,11 @@ namespace boost //! iterator type typedef IteratorT iterator; - iterator_range() : m_Begin( iterator() ), m_End( iterator() ), - singular( true ) + iterator_range() : m_Begin( iterator() ), m_End( iterator() ) + + #ifndef NDEBUG + , singular( true ) + #endif { } /* #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) @@ -178,41 +181,57 @@ namespace boost //! Constructor from a pair of iterators template< class Iterator > iterator_range( Iterator Begin, Iterator End ) : - m_Begin(Begin), m_End(End), singular(false) {} + m_Begin(Begin), m_End(End) + #ifndef NDEBUG + , singular(false) + #endif + {} //! Constructor from a Range template< class Range > iterator_range( const Range& r ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ), - singular(false) {} - + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + #ifndef NDEBUG + , singular(false) + #endif + {} + //! Constructor from a Range template< class Range > iterator_range( Range& r ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ), - singular(false) {} + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + #ifndef NDEBUG + , singular(false) + #endif + {} //! Constructor from a Range template< class Range > iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ), - singular(false) {} + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + #ifndef NDEBUG + , singular(false) + #endif + {} //! Constructor from a Range template< class Range > iterator_range( Range& r, iterator_range_detail::range_tag ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ), - singular(false) {} + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + #ifndef NDEBUG + , singular(false) + #endif + {} #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) this_type& operator=( const this_type& r ) { m_Begin = r.begin(); m_End = r.end(); - // - // remark: this need not necessarily be true, but it does no harm - // + + #ifndef NDEBUG singular = r.singular; + #endif return *this; } #endif @@ -222,10 +241,9 @@ namespace boost { m_Begin = r.begin(); m_End = r.end(); - // - // remark: this need not necessarily be true, but it does no harm - // - singular = r.empty(); + #ifndef NDEBUG + singular = r.is_singular(); + #endif return *this; } @@ -234,7 +252,9 @@ namespace boost { m_Begin = impl::adl_begin( r ); m_End = impl::adl_end( r ); + #ifndef NDEBUG singular = false; + #endif return *this; } @@ -243,33 +263,33 @@ namespace boost { m_Begin = impl::adl_begin( r ); m_End = impl::adl_end( r ); + #ifndef NDEBUG singular = false; + #endif return *this; } IteratorT begin() const { + BOOST_ASSERT( !is_singular() ); return m_Begin; } IteratorT end() const { + BOOST_ASSERT( !is_singular() ); return m_End; } size_type size() const { - if( singular ) - return 0; - - return std::distance( m_Begin, m_End ); + BOOST_ASSERT( !is_singular() ); + return m_End - m_Begin; } bool empty() const { - if( singular ) - return true; - + BOOST_ASSERT( !is_singular() ); return m_Begin == m_End; } @@ -288,7 +308,8 @@ namespace boost bool equal( const iterator_range& r ) const { - return singular == r.singular && m_Begin == r.m_Begin && m_End == r.m_End; + BOOST_ASSERT( !is_singular() ); + return m_Begin == r.m_Begin && m_End == r.m_End; } @@ -296,17 +317,20 @@ namespace boost bool operator==( const iterator_range& r ) const { + BOOST_ASSERT( !is_singular() ); return iterator_range_detail::equal( *this, r ); } bool operator!=( const iterator_range& r ) const { + BOOST_ASSERT( !is_singular() ); return !operator==(r); } bool operator<( const iterator_range& r ) const { - return iterator_range_detail::less_than( *this, r ); + BOOST_ASSERT( !is_singular() ); + return iterator_range_detail::less_than( *this, r ); } #endif @@ -327,19 +351,20 @@ namespace boost reference operator[]( size_type sz ) const { - //BOOST_STATIC_ASSERT( is_random_access ); BOOST_ASSERT( sz < size() ); return m_Begin[sz]; } iterator_range& advance_begin( difference_type n ) { + BOOST_ASSERT( !is_singular() ); std::advance( m_Begin, n ); return *this; } iterator_range& advance_end( difference_type n ) { + BOOST_ASSERT( !is_singular() ); std::advance( m_End, n ); return *this; } @@ -348,24 +373,23 @@ namespace boost // begin and end iterators IteratorT m_Begin; IteratorT m_End; + + #ifndef NDEBUG bool singular; + #endif + + #ifndef NDEBUG + public: + bool is_singular() const + { + return singular; + } + #endif + }; // iterator range free-standing operators ---------------------------// -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -#else - template< class Iterator > - inline bool empty( const iterator_range& r ) - { - // - // this will preserve the well-defined empty() even - // though 'r' is singular. - // - return r.empty(); - } -#endif - #ifndef BOOST_OLD_IOSTREAMS //! iterator_range output operator @@ -380,7 +404,7 @@ namespace boost { std::copy( r.begin(), r.end(), std::ostream_iterator< BOOST_DEDUCED_TYPENAME - iterator_value::type, + iterator_value::type, Elem, Traits>(Os) ); return Os; } @@ -496,10 +520,10 @@ namespace boost #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< typename Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator::type > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > make_iterator_range( Range& r ) { - return iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator::type > + return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > ( boost::begin( r ), boost::end( r ) ); } @@ -518,10 +542,10 @@ namespace boost } template< class ForwardRange > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator::type > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > make_iterator_range( const ForwardRange& r ) { - return iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator::type > + return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > ( r, iterator_range_detail::const_range_tag() ); } @@ -530,15 +554,19 @@ namespace boost namespace iterator_range_detail { template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator::type > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > make_range_impl( Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) { - if( advance_begin == 0 && advance_end == 0 ) - return make_iterator_range( r ); + // + // Not worth the effort + // + //if( advance_begin == 0 && advance_end == 0 ) + // return make_iterator_range( r ); + // - BOOST_DEDUCED_TYPENAME range_result_iterator::type + BOOST_DEDUCED_TYPENAME range_iterator::type new_begin = boost::begin( r ), new_end = boost::end( r ); std::advance( new_begin, advance_begin ); @@ -550,7 +578,7 @@ namespace boost #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator::type > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > make_iterator_range( Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) @@ -572,7 +600,7 @@ namespace boost } template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator::type > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > make_iterator_range( const Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) @@ -602,3 +630,4 @@ namespace boost #undef BOOST_OLD_IOSTREAMS #endif + diff --git a/include/boost/range/metafunctions.hpp b/include/boost/range/metafunctions.hpp index 3bf899f..5b25a8f 100755 --- a/include/boost/range/metafunctions.hpp +++ b/include/boost/range/metafunctions.hpp @@ -16,13 +16,15 @@ #endif #include -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include +#include #endif diff --git a/include/boost/range/rbegin.hpp b/include/boost/range/rbegin.hpp index 0fcf00c..78e5f61 100755 --- a/include/boost/range/rbegin.hpp +++ b/include/boost/range/rbegin.hpp @@ -16,9 +16,7 @@ #endif #include -#include #include -#include namespace boost { @@ -26,30 +24,28 @@ namespace boost #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< class C > -inline BOOST_DEDUCED_TYPENAME range_reverse_result_iterator::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type rbegin( C& c ) { - return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator::type( end( c ) ); + return BOOST_DEDUCED_TYPENAME range_reverse_iterator::type( boost::end( c ) ); } #else template< class C > -inline BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type rbegin( C& c ) { - typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type + typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator::type iter_type; return iter_type( boost::end( c ) ); } template< class C > -inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type rbegin( const C& c ) { - typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type + typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator::type iter_type; return iter_type( boost::end( c ) ); } @@ -57,7 +53,7 @@ rbegin( const C& c ) #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< class T > -inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type const_rbegin( const T& r ) { return boost::rbegin( r ); @@ -66,3 +62,4 @@ const_rbegin( const T& r ) } // namespace 'boost' #endif + diff --git a/include/boost/range/rend.hpp b/include/boost/range/rend.hpp index 3e91ff7..fd79aa2 100755 --- a/include/boost/range/rend.hpp +++ b/include/boost/range/rend.hpp @@ -16,9 +16,7 @@ #endif #include -#include #include -#include namespace boost { @@ -26,30 +24,28 @@ namespace boost #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< class C > -inline BOOST_DEDUCED_TYPENAME range_reverse_result_iterator::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type rend( C& c ) { - return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator::type( boost::begin( c ) ); + return BOOST_DEDUCED_TYPENAME range_reverse_iterator::type( boost::begin( c ) ); } #else template< class C > -inline BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type rend( C& c ) { - typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type + typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator::type iter_type; return iter_type( boost::begin( c ) ); } template< class C > -inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type rend( const C& c ) { - typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type + typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator::type iter_type; return iter_type( boost::begin( c ) ); } @@ -57,7 +53,7 @@ rend( const C& c ) #endif template< class T > -inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator::type const_rend( const T& r ) { return boost::rend( r ); @@ -66,3 +62,4 @@ const_rend( const T& r ) } // namespace 'boost' #endif + diff --git a/include/boost/range/result_iterator.hpp b/include/boost/range/result_iterator.hpp index 86e71cd..ba09c5f 100755 --- a/include/boost/range/result_iterator.hpp +++ b/include/boost/range/result_iterator.hpp @@ -15,29 +15,19 @@ # pragma once #endif -#include #include -#include -#include -#include namespace boost { - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// + // + // This interface is deprecated, use range_iterator + // template< typename C > - struct range_result_iterator - { - typedef BOOST_RANGE_DEDUCED_TYPENAME - mpl::if_< BOOST_DEDUCED_TYPENAME is_const::type, - BOOST_DEDUCED_TYPENAME range_const_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type >::type type; - }; + struct range_result_iterator : range_iterator + { }; } // namespace boost -//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif diff --git a/include/boost/range/reverse_result_iterator.hpp b/include/boost/range/reverse_result_iterator.hpp index bb17389..62bf135 100755 --- a/include/boost/range/reverse_result_iterator.hpp +++ b/include/boost/range/reverse_result_iterator.hpp @@ -15,22 +15,17 @@ # pragma once #endif -#include -#include -#include +#include namespace boost { - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// + // + // This interface is deprecated, use range_reverse_iterator + // template< typename C > - struct range_reverse_result_iterator - { - typedef reverse_iterator< - BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator::type > type; - }; + struct range_reverse_result_iterator : range_reverse_iterator + { }; } // namespace boost diff --git a/include/boost/range/size.hpp b/include/boost/range/size.hpp index 88201da..eb021a5 100755 --- a/include/boost/range/size.hpp +++ b/include/boost/range/size.hpp @@ -15,109 +15,19 @@ # pragma once #endif -#include - -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -#include -#else - -#include +#include +#include #include -#include -#include -#include namespace boost { -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -namespace range_detail -{ -#endif - ////////////////////////////////////////////////////////////////////// - // primary template - ////////////////////////////////////////////////////////////////////// - - template< typename C > - inline BOOST_DEDUCED_TYPENAME C::size_type - boost_range_size( const C& c ) - { - return c.size(); - } - - ////////////////////////////////////////////////////////////////////// - // pair - ////////////////////////////////////////////////////////////////////// - - template< typename Iterator > - inline std::size_t boost_range_size( const std::pair& p ) - { - return std::distance( p.first, p.second ); - } - - ////////////////////////////////////////////////////////////////////// - // array - ////////////////////////////////////////////////////////////////////// - - template< typename T, std::size_t sz > - inline std::size_t boost_range_size( const T (&array)[sz] ) - { - return range_detail::array_size( array ); - } - - template< typename T, std::size_t sz > - inline std::size_t boost_range_size( T (&array)[sz] ) - { - return boost::range_detail::array_size( array ); - } - - ////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////// - - inline std::size_t boost_range_size( const char* const& s ) - { - return boost::range_detail::str_size( s ); - } - - inline std::size_t boost_range_size( const wchar_t* const& s ) - { - return boost::range_detail::str_size( s ); - } - -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -} // namespace 'range_detail' -#endif - -template< class T > -inline BOOST_DEDUCED_TYPENAME range_size::type size( const T& r ) -{ -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - using namespace range_detail; -#endif - return boost_range_size( r ); -} - - -#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// BCB and CW are not able to overload pointer when class overloads are also available. -inline range_size::type size( const char* r ) { - return range_detail::str_size( r ); -} -inline range_size::type size( char* r ) { - return range_detail::str_size( r ); -} -inline range_size::type size( const wchar_t* r ) { - return range_detail::str_size( r ); -} -inline range_size::type size( wchar_t* r ) { - return range_detail::str_size( r ); -} -#endif - + template< class T > + inline BOOST_DEDUCED_TYPENAME range_size::type size( const T& r ) + { + return boost::end( r ) - boost::begin( r ); + } } // namespace 'boost' -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - #endif diff --git a/include/boost/range/size_type.hpp b/include/boost/range/size_type.hpp index 57f191d..7ed8dfa 100755 --- a/include/boost/range/size_type.hpp +++ b/include/boost/range/size_type.hpp @@ -16,158 +16,60 @@ #endif #include -/* -#include - -namespace boost -{ - namespace range_detail - { - template< class T > - struct add_unsigned; - - template<> - struct add_unsigned - { - typedef unsigned short type; - }; - - template<> - struct add_unsigned - { - typedef unsigned int type; - }; - - template<> - struct add_unsigned - { - typedef unsigned long type; - }; - -#ifdef BOOST_HAS_LONG_LONG - - template<> - struct add_unsigned - { - typedef unsigned long long type; - }; -#endif - - } - - template< class T > - struct range_size - { - typedef BOOST_DEDUCED_TYPENAME range_detail::add_unsigned< - BOOST_DEDUCED_TYPENAME range_difference::type >::type - type; - }; -} -*/ #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #include #else +#include #include #include namespace boost { - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// - - template< typename C > - struct range_size + namespace detail { - typedef BOOST_DEDUCED_TYPENAME C::size_type type; - }; - ////////////////////////////////////////////////////////////////////////// - // pair - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // default + ////////////////////////////////////////////////////////////////////////// + + template< typename C > + struct range_size + { + typedef BOOST_DEDUCED_TYPENAME C::size_type type; + }; + + ////////////////////////////////////////////////////////////////////////// + // pair + ////////////////////////////////////////////////////////////////////////// + + template< typename Iterator > + struct range_size< std::pair > + { + typedef std::size_t type; + }; + + ////////////////////////////////////////////////////////////////////////// + // array + ////////////////////////////////////////////////////////////////////////// + + template< typename T, std::size_t sz > + struct range_size< T[sz] > + { + typedef std::size_t type; + }; + } - template< typename Iterator > - struct range_size< std::pair > - { - typedef std::size_t type; - }; - - template< typename Iterator > - struct range_size< const std::pair > - { - typedef std::size_t type; - }; - - ////////////////////////////////////////////////////////////////////////// - // array - ////////////////////////////////////////////////////////////////////////// - - template< typename T, std::size_t sz > - struct range_size< T[sz] > - { - typedef std::size_t type; - }; - - template< typename T, std::size_t sz > - struct range_size< const T[sz] > - { - typedef std::size_t type; - }; - - ////////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////////// - - template<> - struct range_size< char* > - { - typedef std::size_t type; - }; - - template<> - struct range_size< wchar_t* > - { - typedef std::size_t type; - }; - - template<> - struct range_size< const char* > - { - typedef std::size_t type; - }; - - template<> - struct range_size< const wchar_t* > - { - typedef std::size_t type; - }; - - template<> - struct range_size< char* const > - { - typedef std::size_t type; - }; - - template<> - struct range_size< wchar_t* const > - { - typedef std::size_t type; - }; - - template<> - struct range_size< const char* const > - { - typedef std::size_t type; - }; - - template<> - struct range_size< const wchar_t* const > - { - typedef std::size_t type; - }; + template< class T > + struct range_size : + detail::range_size + { }; + template< class T > + struct range_size : range_size + { }; + } // namespace boost #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index 7781fca..346c0e0 100755 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -23,20 +22,18 @@ namespace boost { template< class ForwardRange > - class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator::type > + class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > { - typedef BOOST_DEDUCED_TYPENAME range_result_iterator::type iterator_t; + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; typedef iterator_range< iterator_t > base; typedef BOOST_DEDUCED_TYPENAME base::impl impl; public: typedef BOOST_DEDUCED_TYPENAME range_value::type value_type; - typedef BOOST_DEDUCED_TYPENAME range_result_iterator::type iterator; - typedef BOOST_DEDUCED_TYPENAME range_const_iterator::type const_iterator; + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator; + 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; - typedef BOOST_DEDUCED_TYPENAME iterator_reference::type const_reference; public: sub_range() : base() @@ -111,32 +108,32 @@ namespace boost public: // convenience - reference front() + value_type& front() { return base::front(); } - const_reference front() const + const value_type& front() const { return base::front(); } - reference back() + value_type& back() { return base::back(); } - const_reference back() const + const value_type& back() const { return base::back(); } - reference operator[]( size_type sz ) + value_type& operator[]( size_type sz ) { return base::operator[](sz); } - const_reference operator[]( size_type sz ) const + const value_type& operator[]( size_type sz ) const { return base::operator[](sz); } @@ -168,3 +165,4 @@ namespace boost } // namespace 'boost' #endif + diff --git a/include/boost/range/value_type.hpp b/include/boost/range/value_type.hpp index 15537b0..95c7580 100755 --- a/include/boost/range/value_type.hpp +++ b/include/boost/range/value_type.hpp @@ -18,129 +18,17 @@ #include #include -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#include -#else +//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +//#include +//#else #include namespace boost { - template< class T > - struct range_value - { - typedef BOOST_DEDUCED_TYPENAME iterator_value< - BOOST_DEDUCED_TYPENAME range_iterator::type >::type - type; - }; + template< class T > + struct range_value : iterator_value< typename range_iterator::type > + { }; } -/* -#include -#include - - -namespace boost -{ - ////////////////////////////////////////////////////////////////////////// - // default - ////////////////////////////////////////////////////////////////////////// - - template< typename C > - struct range_value - { - typedef BOOST_DEDUCED_TYPENAME C::value_type type; - }; - - ////////////////////////////////////////////////////////////////////////// - // pair - ////////////////////////////////////////////////////////////////////////// - - template< typename Iterator > - struct range_value< std::pair > - { - typedef BOOST_DEDUCED_TYPENAME - iterator_value::type type; - }; - - - template< typename Iterator > - struct range_value< const std::pair > - { - typedef BOOST_DEDUCED_TYPENAME - iterator_value::type type; - }; - - ////////////////////////////////////////////////////////////////////////// - // array - ////////////////////////////////////////////////////////////////////////// - - template< typename T, std::size_t sz > - struct range_value< T[sz] > - { - typedef T type; - }; - - template< typename T, std::size_t sz > - struct range_value< const T[sz] > - { - typedef const T type; - }; - - ////////////////////////////////////////////////////////////////////////// - // string - ////////////////////////////////////////////////////////////////////////// - - template<> - struct range_value< char* > - { - typedef char type; - }; - - template<> - struct range_value< wchar_t* > - { - typedef wchar_t type; - }; - - template<> - struct range_value< const char* > - { - typedef const char type; - }; - - template<> - struct range_value< const wchar_t* > - { - typedef const wchar_t type; - }; - - template<> - struct range_value< char* const > - { - typedef char type; - }; - - template<> - struct range_value< wchar_t* const > - { - typedef wchar_t type; - }; - - template<> - struct range_value< const char* const > - { - typedef const char type; - }; - - template<> - struct range_value< const wchar_t* const > - { - typedef const wchar_t type; - }; - -} // namespace boost -*/ -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - #endif From 5850d7ce3e3fd328ec66a898176bc7d57bf28229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 18 May 2006 20:53:21 +0000 Subject: [PATCH 03/92] new traits and functions for v2 [SVN r34013] --- include/boost/range/as_array.hpp | 45 +++++++++++ include/boost/range/as_literal.hpp | 120 +++++++++++++++++++++++++++++ include/boost/range/category.hpp | 29 +++++++ include/boost/range/distance.hpp | 34 ++++++++ include/boost/range/pointer.hpp | 29 +++++++ include/boost/range/reference.hpp | 29 +++++++ 6 files changed, 286 insertions(+) create mode 100755 include/boost/range/as_array.hpp create mode 100755 include/boost/range/as_literal.hpp create mode 100755 include/boost/range/category.hpp create mode 100755 include/boost/range/distance.hpp create mode 100755 include/boost/range/pointer.hpp create mode 100755 include/boost/range/reference.hpp diff --git a/include/boost/range/as_array.hpp b/include/boost/range/as_array.hpp new file mode 100755 index 0000000..0723e60 --- /dev/null +++ b/include/boost/range/as_array.hpp @@ -0,0 +1,45 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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/ +// + +#ifndef BOOST_RANGE_AS_ARRAY_HPP +#define BOOST_RANGE_AS_ARRAY_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include + +namespace boost +{ + + template< class R > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + as_array( R& r ) + { + return boost::make_iterator_range( r ); + } + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + template< class Range > + inline boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + as_array( const Range& r ) + { + return boost::make_iterator_range( r ); + } + +#endif + +} + +#endif + diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp new file mode 100755 index 0000000..069f82d --- /dev/null +++ b/include/boost/range/as_literal.hpp @@ -0,0 +1,120 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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/ +// + +#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP +#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#if BOOST_NO_FUNCTION_TEMPLATE_ORDERING +#include +#else + +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + inline std::size_t length( const char* s ) + { + return strlen( s ); + } + + inline std::size_t length( const wchar_t* s ) + { + return wcslen( s ); + } + + // + // Remark: the compiler cannot choose between T* and T[sz] + // overloads, so we must put the T* internal to the + // unconstrained version. + // + + inline bool is_char_ptr( char* ) + { + return true; + } + + inline bool is_char_ptr( const char* ) + { + return true; + } + + + inline bool is_char_ptr( wchar_t* ) + { + return true; + } + + inline bool is_char_ptr( const wchar_t* ) + { + return true; + } + + template< class T > + inline long is_char_ptr( T r ) + { + return 0L; + } + + template< class T > + inline iterator_range + make_range( T* const r, bool ) + { + return iterator_range( r, r + length(r) ); + } + + template< class T > + inline iterator_range::type> + make_range( T& r, long ) + { + return boost::make_iterator_range( r ); + } + + } + + template< class Range > + inline iterator_range::type> + as_literal( Range& r ) + { + return range_detail::make_range( r, range_detail::is_char_ptr(r) ); + } + + template< class Range > + inline iterator_range::type> + as_literal( const Range& r ) + { + return range_detail::make_range( r, range_detail::is_char_ptr(r) ); + } + + template< class Char, std::size_t sz > + inline iterator_range as_literal( Char (&arr)[sz] ) + { + return boost::make_iterator_range( arr, arr + sz - 1 ); + } + + + template< class Char, std::size_t sz > + inline iterator_range as_literal( const Char (&arr)[sz] ) + { + return boost::make_iterator_range( arr, arr + sz - 1 ); + } +} + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +#endif diff --git a/include/boost/range/category.hpp b/include/boost/range/category.hpp new file mode 100755 index 0000000..1574605 --- /dev/null +++ b/include/boost/range/category.hpp @@ -0,0 +1,29 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2006. 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/ +// + +#ifndef BOOST_RANGE_CATEGORY_HPP +#define BOOST_RANGE_CATEGORY_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include + +namespace boost +{ + template< class T > + struct range_category : iterator_category< typename range_iterator::type > + { }; +} + +#endif diff --git a/include/boost/range/distance.hpp b/include/boost/range/distance.hpp new file mode 100755 index 0000000..42a106d --- /dev/null +++ b/include/boost/range/distance.hpp @@ -0,0 +1,34 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2006. 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/ +// + +#ifndef BOOST_RANGE_DISTANCE_HPP +#define BOOST_RANGE_DISTANCE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include + +namespace boost +{ + + template< class T > + inline BOOST_DEDUCED_TYPENAME range_difference::type + distance( const T& r ) + { + return std::distance( boost::begin( r ), boost::end( r ) ); + } + +} // namespace 'boost' + +#endif diff --git a/include/boost/range/pointer.hpp b/include/boost/range/pointer.hpp new file mode 100755 index 0000000..e7431ff --- /dev/null +++ b/include/boost/range/pointer.hpp @@ -0,0 +1,29 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2006. 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/ +// + +#ifndef BOOST_RANGE_POINTER_TYPE_HPP +#define BOOST_RANGE_POINTER_TYPE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include + +namespace boost +{ + template< class T > + struct range_pointer : iterator_pointer< typename range_iterator::type > + { }; +} + +#endif diff --git a/include/boost/range/reference.hpp b/include/boost/range/reference.hpp new file mode 100755 index 0000000..d308e43 --- /dev/null +++ b/include/boost/range/reference.hpp @@ -0,0 +1,29 @@ +// 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/ +// + +#ifndef BOOST_RANGE_REFERENCE_TYPE_HPP +#define BOOST_RANGE_REFERENCE_TYPE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include +#include + +namespace boost +{ + template< class T > + struct range_reference : iterator_reference< typename range_iterator::type > + { }; +} + +#endif From dc34cd60799b4efffbc57918c10cc5cbfb1d9cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 18 May 2006 21:11:55 +0000 Subject: [PATCH 04/92] *** empty log message *** [SVN r34014] --- include/boost/range/detail/as_literal.hpp | 33 ++ include/boost/range/detail/detail_str.hpp | 376 ++++++++++++++++++++++ include/boost/range/detail/str_types.hpp | 118 +++++++ 3 files changed, 527 insertions(+) create mode 100755 include/boost/range/detail/as_literal.hpp create mode 100755 include/boost/range/detail/detail_str.hpp create mode 100755 include/boost/range/detail/str_types.hpp diff --git a/include/boost/range/detail/as_literal.hpp b/include/boost/range/detail/as_literal.hpp new file mode 100755 index 0000000..b4fd925 --- /dev/null +++ b/include/boost/range/detail/as_literal.hpp @@ -0,0 +1,33 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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/ +// + +#ifndef BOOST_RANGE_AS_LITERAL_HPP +#define BOOST_RANGE_AS_LITERAL_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include +#include + +namespace boost +{ + template< class Range > + inline iterator_range::type> + as_literal( Range& r ) + { + return ::boost::make_iterator_range( ::boost::range_detail::str_begin(r), + ::boost::range_detail::str_end(r) ); + } + +} + +#endif diff --git a/include/boost/range/detail/detail_str.hpp b/include/boost/range/detail/detail_str.hpp new file mode 100755 index 0000000..d5ad5b3 --- /dev/null +++ b/include/boost/range/detail/detail_str.hpp @@ -0,0 +1,376 @@ +// 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/ +// + +#ifndef BOOST_RANGE_DETAIL_DETAIL_STR_HPP +#define BOOST_RANGE_DETAIL_DETAIL_STR_HPP + +#include // BOOST_MSVC +#include + +namespace boost +{ + + namespace range_detail + { + // + // iterator + // + + template<> + struct range_iterator_ + { + template< typename T > + struct pts + { + typedef BOOST_RANGE_DEDUCED_TYPENAME + remove_extent::type* type; + }; + }; + + template<> + struct range_iterator_ + { + template< typename S > + struct pts + { + typedef char* type; + }; + }; + + template<> + struct range_iterator_ + { + template< typename S > + struct pts + { + typedef const char* type; + }; + }; + + template<> + struct range_iterator_ + { + template< typename S > + struct pts + { + typedef wchar_t* type; + }; + }; + + template<> + struct range_iterator_ + { + template< typename S > + struct pts + { + typedef const wchar_t* type; + }; + }; + + + // + // const iterator + // + + template<> + struct range_const_iterator_ + { + template< typename T > + struct pts + { + typedef const BOOST_RANGE_DEDUCED_TYPENAME + remove_extent::type* type; + }; + }; + + template<> + struct range_const_iterator_ + { + template< typename S > + struct pts + { + typedef const char* type; + }; + }; + + template<> + struct range_const_iterator_ + { + template< typename S > + struct pts + { + typedef const char* type; + }; + }; + + template<> + struct range_const_iterator_ + { + template< typename S > + struct pts + { + typedef const wchar_t* type; + }; + }; + + template<> + struct range_const_iterator_ + { + template< typename S > + struct pts + { + typedef const wchar_t* type; + }; + }; + } +} + +#include +#include +#include +#include +#include + +namespace boost +{ + + namespace range_detail + { + // + // str_begin() + // + template<> + struct range_begin + { + static char* fun( char* s ) + { + return s; + } + }; + + template<> + struct range_begin + { + static const char* fun( const char* s ) + { + return s; + } + }; + + template<> + struct range_begin + { + + static wchar_t* fun( wchar_t* s ) + { + return s; + } + }; + + template<> + struct range_begin + { + static const wchar_t* fun( const wchar_t* s ) + { + return s; + } + }; + + template< typename C > + inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type + str_begin( C& c ) + { + return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME + range_detail::range::type >::fun( c ); + } + + // + // str_end() + // + + template<> + struct range_end + { + template< typename T, std::size_t sz > + static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) + { + return boost::range_detail::array_end( boost_range_array ); + } + }; + + template<> + struct range_end + { + template< typename T, std::size_t sz > + static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) + { + return boost::range_detail::array_end( boost_range_array ); + } + }; + + template<> + struct range_end + { + static char* fun( char* s ) + { + return boost::range_detail::str_end( s ); + } + }; + + template<> + struct range_end + { + static const char* fun( const char* s ) + { + return boost::range_detail::str_end( s ); + } + }; + + template<> + struct range_end + { + static wchar_t* fun( wchar_t* s ) + { + return boost::range_detail::str_end( s ); + } + }; + + + template<> + struct range_end + { + static const wchar_t* fun( const wchar_t* s ) + { + return boost::range_detail::str_end( s ); + } + }; + + template< typename C > + inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type + str_end( C& c ) + { + return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME + range_detail::range::type >::fun( c ); + } + + // + // size_type + // + + template<> + struct range_size_type_ + { + template< typename A > + struct pts + { + typedef std::size_t type; + }; + }; + + template<> + struct range_size_type_ + { + template< typename S > + struct pts + { + typedef std::size_t type; + }; + }; + + template<> + struct range_size_type_ + { + template< typename S > + struct pts + { + typedef std::size_t type; + }; + }; + + template<> + struct range_size_type_ + { + template< typename S > + struct pts + { + typedef std::size_t type; + }; + }; + + template<> + struct range_size_type_ + { + template< typename S > + struct pts + { + typedef std::size_t type; + }; + }; + + // + // value_type + // + + template<> + struct range_value_type_ + { + template< typename T > + struct pts + { + typedef char type; + }; + }; + + template<> + struct range_value_type_ + { + template< typename S > + struct pts + { + typedef char type; + }; + }; + + template<> + struct range_value_type_ + { + template< typename S > + struct pts + { + typedef const char type; + }; + }; + + template<> + struct range_value_type_ + { + template< typename S > + struct pts + { + typedef wchar_t type; + }; + }; + + template<> + struct range_value_type_ + { + template< typename S > + struct pts + { + typedef const wchar_t type; + }; + }; + + } // namespace 'range_detail' + +} // namespace 'boost' + + +#endif diff --git a/include/boost/range/detail/str_types.hpp b/include/boost/range/detail/str_types.hpp new file mode 100755 index 0000000..86e7b2e --- /dev/null +++ b/include/boost/range/detail/str_types.hpp @@ -0,0 +1,118 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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/ +// + +#ifndef BOOST_RANGE_DETAIL_STR_TYPES_HPP +#define BOOST_RANGE_DETAIL_STR_TYPES_HPP + +#include +#include + +namespace boost +{ + template<> + struct range_iterator + { + typedef char* type; + }; + + template<> + struct range_iterator + { + typedef char* type; + }; + + template<> + struct range_iterator + { + typedef const char* type; + }; + + template<> + struct range_iterator + { + typedef const char* type; + }; + + template<> + struct range_iterator + { + typedef wchar_t* type; + }; + + template<> + struct range_iterator + { + typedef wchar_t* type; + }; + + template<> + struct range_iterator + { + typedef const wchar_t* type; + }; + + template<> + struct range_iterator + { + typedef const wchar_t* type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + template<> + struct range_size + { + typedef std::size_t type; + }; + + +} + +#endif From f8854955651d25b146541a024e271ed6810b4a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 18 May 2006 21:27:29 +0000 Subject: [PATCH 05/92] *** empty log message *** [SVN r34015] --- include/boost/range/detail/str_types.hpp | 100 +++-------------------- 1 file changed, 10 insertions(+), 90 deletions(-) diff --git a/include/boost/range/detail/str_types.hpp b/include/boost/range/detail/str_types.hpp index 86e7b2e..f8cab19 100755 --- a/include/boost/range/detail/str_types.hpp +++ b/include/boost/range/detail/str_types.hpp @@ -16,103 +16,23 @@ namespace boost { - template<> - struct range_iterator + template< class T > + struct range_mutable_iterator { - typedef char* type; + typedef T* type; }; - template<> - struct range_iterator + template< class T > + struct range_const_iterator { - typedef char* type; - }; - - template<> - struct range_iterator - { - typedef const char* type; + typedef const T* type; }; - template<> - struct range_iterator + template< class T > + struct range_size { - typedef const char* type; - }; - - template<> - struct range_iterator - { - typedef wchar_t* type; - }; - - template<> - struct range_iterator - { - typedef wchar_t* type; - }; - - template<> - struct range_iterator - { - typedef const wchar_t* type; - }; - - template<> - struct range_iterator - { - typedef const wchar_t* type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - template<> - struct range_size - { - typedef std::size_t type; - }; - - + typedef std::size_t type; + }; } #endif From 4a8987865e8e9d55d9d9419f6a9d043a430c9d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 19 May 2006 10:30:02 +0000 Subject: [PATCH 06/92] dos2unix on some files [SVN r34025] --- test/iterator_pair.cpp | 4 +++- test/reversible_range.cpp | 8 ++++---- test/sub_range.cpp | 24 ++++++++++++++---------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp index db82f64..094a7c2 100755 --- a/test/iterator_pair.cpp +++ b/test/iterator_pair.cpp @@ -52,7 +52,9 @@ void check_iterator_pair() 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 )); + // + // This behavior is not supported with v2. + //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 )); diff --git a/test/reversible_range.cpp b/test/reversible_range.cpp index c3d943e..9dfe8d0 100755 --- a/test/reversible_range.cpp +++ b/test/reversible_range.cpp @@ -53,10 +53,10 @@ void check_iterator() BOOST_CHECK( std::distance( begin( p ), end( p ) ) == std::distance( rbegin( rp ), rend( rp ) ) ); - BOOST_CHECK_EQUAL( &*begin( a ), &*( rend( a ) ) ); - BOOST_CHECK_EQUAL( &*( end( a ) ), &*rbegin( a ) ); - BOOST_CHECK_EQUAL( &*begin( ca ), &*( rend( ca ) ) ); - BOOST_CHECK_EQUAL( &*( end( ca ) ), &*rbegin( ca ) ); + 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 ) ); } diff --git a/test/sub_range.cpp b/test/sub_range.cpp index 0b28fc1..ccc2a89 100755 --- a/test/sub_range.cpp +++ b/test/sub_range.cpp @@ -90,17 +90,21 @@ void check_sub_range() 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 ) ); + // + // As of range v2 not legal anymore. + // + //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 ) ); From 73bb3d899a72630a4ff592153c5bfb8ab56fb936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 19 May 2006 18:01:02 +0000 Subject: [PATCH 07/92] *** empty log message *** [SVN r34034] --- include/boost/range/mutable_iterator.hpp | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 include/boost/range/mutable_iterator.hpp diff --git a/include/boost/range/mutable_iterator.hpp b/include/boost/range/mutable_iterator.hpp new file mode 100755 index 0000000..2f45c16 --- /dev/null +++ b/include/boost/range/mutable_iterator.hpp @@ -0,0 +1,64 @@ +// 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/ +// + +#ifndef BOOST_RANGE_MUTABLE_ITERATOR_HPP +#define BOOST_RANGE_MUTABLE_ITERATOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +#include +#else + +#include +#include +#include + +namespace boost +{ + ////////////////////////////////////////////////////////////////////////// + // default + ////////////////////////////////////////////////////////////////////////// + + template< typename C > + struct range_mutable_iterator + { + typedef BOOST_DEDUCED_TYPENAME C::iterator type; + }; + + ////////////////////////////////////////////////////////////////////////// + // pair + ////////////////////////////////////////////////////////////////////////// + + template< typename Iterator > + struct range_mutable_iterator< std::pair > + { + typedef Iterator type; + }; + + ////////////////////////////////////////////////////////////////////////// + // array + ////////////////////////////////////////////////////////////////////////// + + template< typename T, std::size_t sz > + struct range_mutable_iterator< T[sz] > + { + typedef T* type; + }; + +} // namespace boost + +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +#endif From 007117cefb6e30b2d43e9dfa4622693da53e15ab Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 27 Aug 2006 10:40:36 +0000 Subject: [PATCH 08/92] Merge in recent fixes for inspect errors. [SVN r34973] --- test/iterator_range.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 152ac76..9f8d7b6 100755 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -26,7 +26,7 @@ using namespace boost; using namespace std; - + void check_reference_type(); void check_iterator_range() From f49be0b38222768bcf9e388843d0d64f4cca415e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 24 Oct 2006 10:37:46 +0000 Subject: [PATCH 09/92] *** empty log message *** [SVN r35717] --- include/boost/range/detail/implementation_help.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index 77cc8cc..11c6612 100755 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -43,7 +43,7 @@ namespace boost #else inline const wchar_t* str_end( const wchar_t* s, const wchar_t* ) { - if( s == 0 && s[0] == 0 ) + if( s == 0 || s[0] == 0 ) return s; while( *++s != 0 ) ; From a933622ae197757d7b240a3e65f9e8de13e552fe Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 10 Nov 2006 19:09:56 +0000 Subject: [PATCH 10/92] Allow building of shared versions of some Boost.Test libraries. Adjust tests to use always use static linking to Boost.Test, since linking to the shared version requires test changes. Patch from Juergen Hunold. [SVN r35989] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fcc67f2..b6942ca 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,7 +11,7 @@ rule range-test ( name : includes * ) { return [ - run $(name).cpp /boost/test//boost_unit_test_framework + run $(name).cpp /boost/test//boost_unit_test_framework/static : : : $(includes) From 22b7b4ec8e8cca9f62b256a30538739f7f8a3b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 10 Jan 2007 18:50:13 +0000 Subject: [PATCH 11/92] commented out old array code [SVN r36683] --- .../range/detail/implementation_help.hpp | 20 +++++++++++++++++-- include/boost/range/iterator_range.hpp | 9 +++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index 11c6612..6890d53 100755 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -57,6 +57,7 @@ namespace boost return const_cast( str_end( s, s ) ); } + /* template< class T, std::size_t sz > inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], int ) { @@ -80,25 +81,32 @@ namespace boost { return boost_range_array + sz - 1; } + */ template< class T, std::size_t sz > inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] ) { + /* typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value, char_or_wchar_t_array_tag, int >::type tag; return array_end( boost_range_array, tag() ); + */ + return boost_range_end + sz; } template< class T, std::size_t sz > inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] ) { + /* typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value, char_or_wchar_t_array_tag, int >::type tag; return array_end( boost_range_array, tag() ); + */ + return boost_range_end + sz; } ///////////////////////////////////////////////////////////////////// @@ -110,7 +118,8 @@ namespace boost { return str_end( s ) - s; } - + + /* template< class T, std::size_t sz > inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], int ) { @@ -134,24 +143,31 @@ namespace boost { return sz - 1; } - + */ + template< class T, std::size_t sz > inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] ) { + /* typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value || is_same::value || is_same::value, char_or_wchar_t_array_tag, int >::type tag; return array_size( boost_range_array, tag() ); + */ + return sz; } template< class T, std::size_t sz > inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] ) { + /* typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value, char_or_wchar_t_array_tag, int >::type tag; return array_size( boost_range_array, tag() ); + */ + return sz; } } // namespace 'range_detail' diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index a09ee30..ebdbc3e 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -159,8 +159,7 @@ namespace boost typedef IteratorT iterator; iterator_range() : m_Begin( iterator() ), m_End( iterator() ) - - #ifndef NDEBUG + #ifndef NDEBUG , singular( true ) #endif { } @@ -386,6 +385,12 @@ namespace boost } #endif + protected: + // + // Allow subclasses an easy way to access the + // base type + // + typedef iterator_range iterator_range_; }; // iterator range free-standing operators ---------------------------// From aeb47120e3d958fabee831244ed77e101bdc5be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 10 Jan 2007 18:57:20 +0000 Subject: [PATCH 12/92] fixed typo [SVN r36684] --- include/boost/range/detail/implementation_help.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index 6890d53..31b7aea 100755 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -93,7 +93,7 @@ namespace boost return array_end( boost_range_array, tag() ); */ - return boost_range_end + sz; + return boost_range_array + sz; } template< class T, std::size_t sz > @@ -106,7 +106,7 @@ namespace boost return array_end( boost_range_array, tag() ); */ - return boost_range_end + sz; + return boost_range_array + sz; } ///////////////////////////////////////////////////////////////////// From 51650f1aa2200c4b9e6c440e9632e7ee345bb06e Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 8 Aug 2007 19:02:26 +0000 Subject: [PATCH 13/92] Remove V1 Jamfiles [SVN r38516] --- test/Jamfile | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100755 test/Jamfile diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100755 index b00b99d..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,45 +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 - ../../regex/build/boost_regex - : - : - : $(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 extension_mechanism ] -# [ range-test test ] -# [ range-test algorithm ] -# [ range-test adaptors ] -# [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] - ; - From e0a76af0f9e0d5fefe1f7b6c7654ea6128f840c7 Mon Sep 17 00:00:00 2001 From: Caleb Epstein Date: Fri, 14 Sep 2007 17:18:02 +0000 Subject: [PATCH 14/92] Quiet unused argument warnings from gcc. [SVN r39274] --- include/boost/range/as_literal.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 069f82d..0d6b946 100755 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -66,7 +66,7 @@ namespace boost } template< class T > - inline long is_char_ptr( T r ) + inline long is_char_ptr( T /* r */ ) { return 0L; } From 0b0dfc0e06cb98efb2b8726fca80479b7ba9a68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Thu, 4 Oct 2007 11:51:51 +0000 Subject: [PATCH 15/92] Added missing boost namespace reference to as_literal. [SVN r39683] --- test/string.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/string.cpp b/test/string.cpp index 9d4b252..9a2e5a8 100755 --- a/test/string.cpp +++ b/test/string.cpp @@ -33,28 +33,28 @@ template< class T > inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type str_begin( T& r ) { - return boost::begin( as_literal(r) ); + return boost::begin( boost::as_literal(r) ); } template< class T > inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type str_end( T& r ) { - return boost::end( as_literal(r) ); + return boost::end( boost::as_literal(r) ); } template< class T > inline BOOST_DEDUCED_TYPENAME boost::range_size::type str_size( const T& r ) { - return boost::size( as_literal(r) ); + return boost::size( boost::as_literal(r) ); } template< class T > inline bool str_empty( T& r ) { - return boost::empty( as_literal(r) ); + return boost::empty( boost::as_literal(r) ); } template< typename Container, typename T > From a862a573dfc2a15705f21af431253db4a2dd28b5 Mon Sep 17 00:00:00 2001 From: Nicola Musatti Date: Sun, 14 Oct 2007 17:53:15 +0000 Subject: [PATCH 16/92] Applied patch from Ticket #1320 [SVN r40020] --- include/boost/range/as_literal.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 0d6b946..72f0eb5 100755 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -21,6 +21,9 @@ #include #include + +#include + #include #include @@ -104,15 +107,23 @@ namespace boost template< class Char, std::size_t sz > inline iterator_range as_literal( Char (&arr)[sz] ) { +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 + return boost::make_iterator_range( arr, arr + sz - 1 ); +#else return boost::make_iterator_range( arr, arr + sz - 1 ); +#endif } template< class Char, std::size_t sz > - inline iterator_range as_literal( const Char (&arr)[sz] ) + inline iterator_range as_literal( const Char (&arr)[sz] ) { +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 + return boost::make_iterator_range( arr, arr + sz - 1 ); +#else return boost::make_iterator_range( arr, arr + sz - 1 ); - } +#endif + } } #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING From c8ffe55ae507e6558d9dfef2bd69ca1b2bac2093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 18:36:03 +0000 Subject: [PATCH 17/92] added test for char array with nested null in response to Ticket #471 [SVN r40367] --- test/array.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/array.cpp b/test/array.cpp index db7054d..a83151c 100755 --- a/test/array.cpp +++ b/test/array.cpp @@ -62,6 +62,8 @@ void check_array() BOOST_CHECK_EQUAL( end( ca ), ca + size( ca ) ); BOOST_CHECK_EQUAL( empty( ca ),false ); + const char A[] = "\0A"; + BOOST_CHECK_EQUAL( boost::size(A), 3u ); } using boost::unit_test::test_suite; From 24466ae189cb2f2dcdad10e0d62ac8df52fbc2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 18:59:11 +0000 Subject: [PATCH 18/92] applied patch from Ticket #1302 (new Patches) to handle char arrays correctly [SVN r40370] --- test/iterator_range.cpp | 15 ++++++++------- test/sub_range.cpp | 17 +++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 9f8d7b6..7854a92 100755 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -79,12 +80,12 @@ void check_iterator_range() 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 ) ); + BOOST_CHECK( rr == as_literal("hello") ); + BOOST_CHECK( rr != as_literal("hell") ); + BOOST_CHECK( rr < as_literal("hello dude") ); + BOOST_CHECK( as_literal("hello") == rr ); + BOOST_CHECK( as_literal("hell") != rr ); + BOOST_CHECK( ! (as_literal("hello dude") < rr ) ); irange rrr = rr; BOOST_CHECK( rrr == rr ); BOOST_CHECK( !( rrr != rr ) ); @@ -96,7 +97,7 @@ void check_iterator_range() BOOST_CHECK_EQUAL( cr[1], 'e' ); rrr = make_iterator_range( str, 1, -1 ); - BOOST_CHECK( rrr == "ello worl" ); + BOOST_CHECK( rrr == as_literal("ello worl") ); rrr = make_iterator_range( rrr, -1, 1 ); BOOST_CHECK( rrr == str ); diff --git a/test/sub_range.cpp b/test/sub_range.cpp index ccc2a89..3694105 100755 --- a/test/sub_range.cpp +++ b/test/sub_range.cpp @@ -17,6 +17,7 @@ #endif #include +#include #include #include #include @@ -110,12 +111,12 @@ void check_sub_range() 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 ) ); + BOOST_CHECK( rr == as_literal("hello") ); + BOOST_CHECK( rr != as_literal("hell") ); + BOOST_CHECK( rr < as_literal("hello dude") ); + BOOST_CHECK( as_literal("hello") == rr ); + BOOST_CHECK( as_literal("hell") != rr ); + BOOST_CHECK( ! (as_literal("hello dude") < rr ) ); irange rrr = rr; BOOST_CHECK( rrr == rr ); @@ -128,13 +129,13 @@ void check_sub_range() BOOST_CHECK_EQUAL( cr[1], 'e' ); rrr = make_iterator_range( str, 1, -1 ); - BOOST_CHECK( rrr == "ello worl" ); + BOOST_CHECK( rrr == as_literal("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" ); + BOOST_CHECK( rrr == as_literal("HEllo worlD") ); } #include From 33a8016af3627afcb166c8389b24e182f4e80ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:06:39 +0000 Subject: [PATCH 19/92] change names of ADL functions back to 1.34 names ... the old names have been in use for too long so let's not break code that depends on them [SVN r40371] --- test/extension_mechanism.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/extension_mechanism.cpp b/test/extension_mechanism.cpp index 2fd7929..828b5cd 100755 --- a/test/extension_mechanism.cpp +++ b/test/extension_mechanism.cpp @@ -57,24 +57,24 @@ namespace Foo // to be defined because X defines the proper set of // nested types. // - inline X::iterator range_begin( X& x ) + inline X::iterator boost_range_begin( X& x ) { return x.vec.begin(); } - inline X::const_iterator range_begin( const X& x ) + inline X::const_iterator boost_range_begin( const X& x ) { return x.vec.begin(); } - inline X::iterator range_end( X& x ) + inline X::iterator boost_range_end( X& x ) { return x.vec.end(); } - inline X::const_iterator range_end( const X& x ) + inline X::const_iterator boost_range_end( const X& x ) { return x.vec.end(); } From 028bff0c22a7b67c3d0fbc4e1e8afeaa310649b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:07:38 +0000 Subject: [PATCH 20/92] changed ADL functions back the names of 1.34 ... these names have been in use for too long ... let's not break code that depends on them [SVN r40372] --- include/boost/range/begin.hpp | 14 +++++++------- include/boost/range/end.hpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp index e8251c9..2f2cb3b 100755 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -39,7 +39,7 @@ namespace range_detail template< typename C > inline BOOST_DEDUCED_TYPENAME range_iterator::type - range_begin( C& c ) + boost_range_begin( C& c ) { return c.begin(); } @@ -49,13 +49,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator range_begin( const std::pair& p ) + inline Iterator boost_range_begin( const std::pair& p ) { return p.first; } template< typename Iterator > - inline Iterator range_begin( std::pair& p ) + inline Iterator boost_range_begin( std::pair& p ) { return p.first; } @@ -68,13 +68,13 @@ namespace range_detail // May this be discarded? Or is it needed for bad compilers? // template< typename T, std::size_t sz > - inline const T* range_begin( const T (&array)[sz] ) + inline const T* boost_range_begin( const T (&array)[sz] ) { return array; } template< typename T, std::size_t sz > - inline T* range_begin( T (&array)[sz] ) + inline T* boost_range_begin( T (&array)[sz] ) { return array; } @@ -95,7 +95,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( T& r ) /**/ using namespace range_detail; #endif - return range_begin( r ); + return boost_range_begin( r ); } template< class T > @@ -106,7 +106,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( const T& r ) /**/ using namespace range_detail; #endif - return range_begin( r ); + return boost_range_begin( r ); } } // namespace boost diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp index be2f495..59bae67 100755 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -40,7 +40,7 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename C > inline BOOST_DEDUCED_TYPENAME range_iterator::type - range_end( C& c ) + boost_range_end( C& c ) { return c.end(); } @@ -50,13 +50,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator range_end( const std::pair& p ) + inline Iterator boost_range_end( const std::pair& p ) { return p.second; } template< typename Iterator > - inline Iterator range_end( std::pair& p ) + inline Iterator boost_range_end( std::pair& p ) { return p.second; } @@ -66,13 +66,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename T, std::size_t sz > - inline const T* range_end( const T (&array)[sz] ) + inline const T* boost_range_end( const T (&array)[sz] ) { return range_detail::array_end( array ); } template< typename T, std::size_t sz > - inline T* range_end( T (&array)[sz] ) + inline T* boost_range_end( T (&array)[sz] ) { return range_detail::array_end( array ); } @@ -91,7 +91,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type end( T& r ) /**/ using namespace range_detail; #endif - return range_end( r ); + return boost_range_end( r ); } template< class T > @@ -102,7 +102,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type end( const T& r ) /**/ using namespace range_detail; #endif - return range_end( r ); + return boost_range_end( r ); } } // namespace 'boost' From cf9ad808a6c91597b4027fcb3bba488df3301617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:12:19 +0000 Subject: [PATCH 21/92] new fancy quickbook documentaion [SVN r40373] --- doc/Jamfile.v2 | 18 + doc/boost_range.qbk | 1234 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1252 insertions(+) create mode 100644 doc/Jamfile.v2 create mode 100644 doc/boost_range.qbk diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 0000000..4f7b44b --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,18 @@ + +use-project boost : $(BOOST_ROOT) ; + + +#import boostbook : boostbook ; +import quickbook ; + +xml boost_range : boost_range.qbk ; + +boostbook standalone + : + boost_range + : + generate.section.toc.level=4 + chunk.first.sections=7 + toc.section.depth=10 + ; + diff --git a/doc/boost_range.qbk b/doc/boost_range.qbk new file mode 100644 index 0000000..80b5c8c --- /dev/null +++ b/doc/boost_range.qbk @@ -0,0 +1,1234 @@ +[article Boost.Range Documentation + [quickbook 1.3] + [id boost.range] + [copyright 2003-2007 Thorsten Ottosen] + [license + Distributed under 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]) + ] +] + +[/ Converted to Quickbook format by Darren Garvey, 2007] + +[def __ranges__ [link boost.range.concepts Ranges]] +[def __range_concepts__ [link boost.range.concepts Range concepts]] +[def __forward_range__ [link boost.range.concepts.forward_range Forward Range]] +[def __single_pass_range__ [link boost.range.concepts.single_pass_range Single Pass Range]] +[def __bidirectional_range__ [link boost.range.concepts.bidirectional_range Bidirectional Range]] +[def __random_access_range__ [link boost.range.concepts.random_access_range Random Access Range]] + +[def __iterator_range__ [link boost.range.utilities.iterator_range `iterator_range`]] +[def __sub_range__ [link boost.range.utilities.sub_range `sub_range`]] +[def __minimal_interface__ [link boost.range.reference.extending minimal interface]] +[def __range_result_iterator__ [link boost.range.reference.semantics.metafunctions `range_result_iterator`]] +[def __implementation_of_metafunctions__ [link boost.range.reference.semantics.metafunctions implementation of metafunctions]] +[def __implementation_of_functions__ [link boost.range.reference.semantics.functions implementation of functions]] + +[def __single_pass_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#singls-pass-iterators-lib-single-pass-iterators Single Pass Iterator]] +[def __forward_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators Forward Traversal Iterator]] +[def __bidirectional_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators Bidirectional Traversal Iterator]] +[def __random_access_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators Random Access Traversal Iterator]] +[def __new_style_iterators__ [@../../libs/iterator/doc/new-iter-concepts.html new style iterators]] +[def __iterator_concepts__ [@../../libs/iterator/doc/iterator_concepts.html Iterator concepts]] + +[def __container__ [@http://www.sgi.com/Technology/STL/Container.html Container]] +[def __metafunctions__ [@../../libs/mpl/doc/refmanual/metafunction.html metafunctions]] +[def __concept_check__ [@../../libs/concept_check/index.html Boost Concept Check library]] +[def __boost_array__ [@../../libs/array/index.html boost::array]] +[def __the_forwarding_problem__ [@http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]] + + +Boost.Range is a collection of concepts and utilities that are particularly useful for specifying and implementing generic algorithms. + + +[section 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 + +* simpler implementation and specification of generic range algorithms +* more flexible, compact and maintainable client code +* correct handling of null-terminated strings + +[:[*Warning: support for null-terminated strings is deprecated and will disappear in the next Boost release (1.34).]] + +* safe use of built-in arrays (for legacy code; why else would you use built-in arrays?) + +Below are given a small example (the complete example can be found [@http://www.boost.org/libs/range/test/algorithm_example.cpp 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 my_vector; + int values[] = { 1,2,3,4,5,6,7,8,9 }; + + my_vector.assign( values, boost::end( values ) ); + 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; + + std::cout << my_generic_replace( my_vector, 4, 2 ); + std::cout << my_generic_replace( my_view, 4, 2 ); + std::cout << my_generic_replace( str, 'a', 'b' ); + + // prints '3', '5' and '0' +`` + +By using the free-standing functions and __metafunctions__, the code automatically works for all the types supported by this library; now and in the future. Notice that we have to provide two version of `find()` since we cannot forward a non-const rvalue with reference arguments (see this article about __the_forwarding_problem__ ). + +[endsect] + + + +[section:concepts Range Concepts] + +[section Overview] + +A Range is a ['concept] similar to the STL [@http://www.sgi.com/Technology/STL/Container.html 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 + +* own the elements that can be accessed through it, +* have copy semantics, + +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 [@../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal 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 [@../../libs/mpl/doc/refmanual/metafunction.html metafunctions] and all functions as free-standing functions to allow for a layer of indirection. + +[endsect] + + +[section Single Pass Range] + +[h4 Notation] + +`X` A type that is a model of __single_pass_range__. +`a` Object of type X. + +[h4 Description] + +A range `X` where `boost::range_iterator::type` is a model of __single_pass_iterator__. + +[h4 Associated types] + +[table + [] + [[Value type ] [`boost::range_value::type` ] [The type of the object stored in a Range.]] + [[Iterator type ] [`boost::range_iterator::type` ] [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.]] + [[Const iterator type] [`boost::range_const_iterator::type`] [A type of iterator that may be used to examine, but not to modify, a Range's elements.]] +] + +[h4 Valid expressions] + +The following expressions must be valid. + +[table + [[Name ] [Expression ] [Return type ]] + [[Beginning of range] [`boost::begin(a)`] [`boost::range_iterator::type` if `a` is mutable,[br] `boost::range_const_iterator::type` otherwise]] + [[End of range ] [`boost::end(a)` ] [`boost::range_iterator::type` if `a` is mutable,[br] `boost::range_const_iterator::type` otherwise]] + [[Is range empty? ] [boost::empty(a) ] [Convertible to bool]] +] + +[h4 Expression semantics] + +[table + [[Expression ] [Semantics ] [Postcondition]] + [[`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.)] [- ]] +] + +[h4 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. + +[h4 Invariants] + +[table + [] + [[Valid range ] [For 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.]] + + [[Completeness] [An algorithm that iterates through the range `[boost::begin(a),boost::end(a))` will pass through every element of `a`.]] +] + +[h4 See also] + +__container__ + +__implementation_of_metafunctions__ + +__implementation_of_functions__ + +[endsect] + + +[section Forward Range] + +[h4 Notation] + +`X` A type that is a model of __forward_range__. +`a` Object of type X. + +[h4 Description] + +A range `X` where `boost::range_iterator::type` is a model of __forward_traversal_iterator__. + +[h4 Refinement of] + +__single_pass_range__ + +[h4 Associated types] + +[table + [] + [[Distance type] [`boost::range_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 ] [`boost::range_size::type` ] [An unsigned integral type that can represent any nonnegative value of the Range's distance type.]] +] + +[h4 Valid expressions] + +[table + [[Name ] [Expression ] [Return type ]] + [[Size of range] [`boost::size(a)`] [`boost::range_size::type`]] +] + +[h4 Expression semantics] + +[table + [[Expression ] [Semantics] [Postcondition]] + [[`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`]] +] + +[h4 Complexity guarantees] + +`boost::size(a)` is at most amortized linear time. + +[h4 Invariants] + +[table + [] + [[Range size] [`boost::size(a)` is equal to the distance from `boost::begin(a)` to `boost::end(a)`.]] +] + +[h4 See also] + +__implementation_of_metafunctions__ + +__implementation_of_functions__ + +[endsect] + + +[section Bidirectional Range] + +[h4 Notation] + +`X` A type that is a model of __bidirectional_range__. +`a` Object of type X. + +[h4 Description] + +This concept provides access to iterators that traverse in both directions (forward and reverse). The `boost::range_iterator::type` iterator must meet all of the requirements of __bidirectional_traversal_iterator__. + +[h4 Refinement of] + +__forward_range__ + +[h4 Associated types] + +[table + [] + [[Reverse Iterator type ] [`boost::range_reverse_iterator::type` ] [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.]] + + [[Const reverse iterator type] [`boost::range_const_reverse_iterator::type`] [A type of reverse iterator that may be used to examine, but not to modify, a Range's elements.]] +] + +[h4 Valid expressions] + +[table + [[Name ] [Expression ] [Return type] [Semantics]] + [[Beginning of range] [`boost::rbegin(a)`] [`boost::range_reverse_iterator::type` if `a` is mutable[br] `boost::range_const_reverse_iterator::type` otherwise.] [Equivalent to `boost::range_reverse_iterator::type(boost::end(a))`.]] + + [[End of range ] [`boost::rend(a)` ] [`boost::range_reverse_iterator::type` if `a` is mutable,[br] `boost::range_const_reverse_iterator::type` otherwise.] [Equivalent to `boost::range_reverse_iterator::type(boost::begin(a))`.]] +] + +[h4 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__. + +[h4 Invariants] + +[table + [] + [[Valid reverse range] [For 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.]] + + [[Completeness ] [`An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.]] +] + +[h4 See also] + +__implementation_of_metafunctions__ + +__implementation_of_functions__ + +[endsect] + + +[section Random Access Range] + +[h4 Description] + +A range `X` where `boost::range_iterator::type` is a model of __random_access_traversal_iterator__. + +[h4 Refinement of] + +__bidirectional_range__ + +[endsect] + + +[section Concept Checking] + +Each of the range concepts has a corresponding concept checking class in the file [@../../boost/range/concepts.hpp `boost/range/concepts.hpp`]. These classes may be used in conjunction with the __concept_check__ to insure that the type of a template parameter is compatible with a range concept. If not, a meaningful compile time error is generated. Checks are provided for the range concepts related to iterator traversal categories. For example, the following line checks that the type `T` models the __forward_range__ concept. + +`` +function_requires >(); +`` + +An additional concept check is required for the value access property of the range based on the range's iterator type. For example to check for a ForwardReadableRange, the following code is required. + +`` +function_requires >(); + function_requires< + ReadableIteratorConcept< + typename range_iterator::type + > + >(); +`` + +The following range concept checking classes are provided. + +* Class SinglePassRangeConcept checks for __single_pass_range__ +* Class ForwardRangeConcept checks for __forward_range__ +* Class BidirectionalRangeConcept checks for __bidirectional_range__ +* Class RandomAccessRangeConcept checks for __random_access_range__ + +[h4 See also] + +[link boost.range.style_guide Range Terminology and style guidelines] + +__iterator_concepts__ + +__concept_check__ + +[endsect] + +[endsect] + + + +[section Reference] + +[section Overview] + +Four types of objects are currently supported by the library: + +* standard-like containers +* `std::pair` +* null terminated strings (this includes `char[]`,`wchar_t[]`, `char*`, and `wchar_t*`) + +[:[*Warning: ['support for null-terminated strings is deprecated and will disappear in the next Boost release (1.34).]]] + +* built-in arrays + +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. + +[endsect] + + +[section 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::type + begin( T& c ); + + template< class T > + typename range_const_iterator::type + begin( const T& c ); + + template< class T > + typename range_iterator::type + end( T& c ); + + template< class T > + typename range_const_iterator::type + end( const T& c ); + + template< class T > + bool + empty( const T& c ); + + // + // Forward Range functions + // + + template< class T > + typename range_size::type + size( const T& c ); + + // + // Bidirectional Range functions + // + + template< class T > + typename range_reverse_iterator::type + rbegin( T& c ); + + template< class T > + typename range_const_reverse_iterator::type + rbegin( const T& c ); + + template< class T > + typename range_reverse_iterator::type + rend( T& c ); + + template< class T > + typename range_const_reverse_iterator::type + rend( const T& c ); + + // + // Special const Range functions + // + + template< class T > + typename range_const_iterator::type + const_begin( const T& r ); + + template< class T > + typename range_const_iterator::type + const_end( const T& r ); + + template< class T > + typename range_const_reverse_iterator::type + const_rbegin( const T& r ); + + template< class T > + typename range_const_reverse_iterator::type + const_rend( const T& r ); + +} // namespace 'boost' +`` + +[endsect] + + +[section Semantics] + +[h5 notation] + +[table + [[Type ] [Object] [Describes ]] + [[`X` ] [`x` ] [any type ]] + [[`T` ] [`t` ] [denotes behavior of the primary templates]] + [[`P` ] [`p` ] [denotes `std::pair` ]] + [[`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. + +[section Metafunctions] + +[table + [[Expression] [Return type] [Complexity]] + [[`range_value::type`] [`T::value_type`[br] +`boost::iterator_value::type`[br] +`A`[br] +`Char`] [compile time]] + [[`range_iterator::type`] [`T::iterator`[br] +`P::first_type`[br] +`A*`[br] +`Char*`] [compile time]] + [[`range_const_iterator::type`] [`T::const_iterator`[br] +`P::first_type`[br] +`const A*`[br] +`const Char*`] [compile time]] + [[`range_difference::type`] [`T::difference_type`[br] +`boost::iterator_difference::type`[br] +`std::ptrdiff_t`[br] +`std::ptrdiff_t`] [compile time]] + [[`range_size::type`] [`T::size_type`[br] +`std::size_t`[br] +`std::size_t`[br] +`std::size_t`] [compile time]] + [[`range_result_iterator::type`] [`range_const_iterator::type` if `X` is `const`[br] +`range_iterator::type` otherwise] [compile time]] + [[`range_reverse_iterator::type`] [`boost::reverse_iterator< typename range_iterator::type >`] [compile time]] + [[`range_const_reverse_iterator::type`] [`boost::reverse_iterator< typename range_const_iterator::type >`] [compile time]] + [[`range_reverse_result_iterator::type`] [`boost::reverse_iterator< typename range_result_iterator::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. + +[endsect] + +[section Functions] + +[table + [[Expression] [Return type] [Returns] [Complexity]] + + [[`begin(x)`] [`range_result_iterator::type`] [`p.first` if `p` is of type `std::pair`[br] +`a` if `a` is an array[br] +`s` if `s` is a string literal[br] +`boost_range_begin(x)` if that expression would invoke a function found by ADL[br] +`t.begin()` otherwise] [constant time]] + + [[`end(x)`] [`range_result_iterator::type`] [`p.second` if `p` is of type `std::pair`[br] +`a + sz` if `a` is an array of size `sz`[br] +`s + std::char_traits::length( s )` if `s` is a `Char*`[br] +`s + sz - 1` if `s` is a string literal of size `sz`[br] +`boost_range_end(x)` if that expression would invoke a function found by ADL[br] +`t.end()` otherwise] [linear if `X` is `Char*` +constant time otherwise]] + + [[`empty(x)`] [`bool`] [`begin(x) == end( x )`] [linear if `X` is `Char*`[br] +constant time otherwise]] + + [[`size(x)`] [`range_size::type`] [`std::distance(p.first,p.second)` if `p` is of type `std::pair`[br] +`sz` if `a` is an array of size `sz`[br] +`end(s) - s` if `s` is a string literal or a `Char*`[br] +`boost_range_size(x)` if that expression would invoke a function found by ADL[br] +`t.size()` otherwise] [linear if `X` is `Char*` or if `std::distance()` is linear[br] +constant time otherwise]] + + [[`rbegin(x)`] [`range_reverse_result_iterator::type`] [`range_reverse_result_iterator::type( end(x) )`] [same as `end(x)`]] + + [[`rend(x)`] [`range_reverse_result_iterator::type`] [`range_reverse_result_iterator::type( begin(x) )`] [same as `begin(x)`]] + + [[`const_begin(x)`] [`range_const_iterator::type`] [`range_const_iterator::type( begin(x) )`] [same as `begin(x)`]] + + [[`const_end(x)`] [`range_const_iterator::type`] [`range_const_iterator::type( end(x) )`] [same as `end(x)`]] + + [[`const_rbegin(x)`] [`range_const_reverse_iterator::type`] [`range_const_reverse_iterator::type( rbegin(x) )`] [same as `rbegin(x)`]] + + [[`const_rend(x)`] [`range_const_reverse_iterator::type`] [`range_const_reverse_iterator::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. + +[endsect] + +[endsect] + +[section:extending Extending the library] + +[section:method_1 Method 1: provide member functions and nested types] + +This procedure assumes that you have control over the types that should be made conformant to a Range concept. If not, see [link boost.range.reference.extending.method_2 method 2]. + +The primary templates in this library are implemented such that standard containers will work automatically and so will __boost_array__. Below is given an overview of which member functions and member types a class must specify to be useable as a certain Range concept. + +[table + [[Member function] [Related 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: + +[table + [[Member type ] [Related concept ]] + [[`iterator` ] [__single_pass_range__]] + [[`const_iterator`] [__single_pass_range__]] + [[`size_type` ] [__forward_range__ ]] +] + +Again one should notice that member types `reverse_iterator` and `const_reverse_iterator` are not needed. + +[endsect] + +[section:method_2 Method 2: provide free-standing functions and specialize metafunctions] + +This procedure assumes that you cannot (or do not wish to) change the types that should be made conformant to a Range concept. If this is not true, see [link boost.range.reference.extending.method_1 method 1]. + +The primary templates in this library are implemented such that certain functions are found via argument-dependent-lookup (ADL). Below is given an overview of which free-standing functions a class must specify to be useable as a certain Range concept. Let `x` be a variable (`const` or `mutable`) of the class in question. + +[table + [[Function ] [Related concept ]] + [[`boost_range_begin(x)`] [__single_pass_range__]] + [[`boost_range_end(x)` ] [__single_pass_range__]] + [[`boost_range_size(x)` ] [__forward_range__ ]] +] + +`boost_range_begin()` and `boost_range_end()` must be overloaded for both `const` and `mutable` reference arguments. + +You must also specialize 3 metafunctions for your type `X`: + +[table + [[Metafunction ] [Related concept ]] + [[`boost::range_iterator` ] [__single_pass_range__]] + [[`boost::range_const_iterator`] [__single_pass_range__]] + [[`boost::range_size` ] [__forward_range__ ]] +] + +A complete example is given here: + +`` + #include + #include // for std::iterator_traits, std::distance() + + namespace Foo + { + // + // Our sample UDT. A 'Pair' + // will work as a range when the stored + // elements are iterators. + // + template< class T > + struct Pair + { + T first, last; + }; + + } // namespace 'Foo' + + namespace boost + { + // + // Specialize metafunctions. We must include the range.hpp header. + // We must open the 'boost' namespace. + // + + template< class T > + struct range_iterator< Foo::Pair > + { + typedef T type; + }; + + template< class T > + struct range_const_iterator< Foo::Pair > + { + // + // Remark: this is defined similar to 'range_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 > + { + + typedef std::size_t type; + }; + + } // namespace 'boost' + + namespace Foo + { + // + // The required functions. These should be defined in + // the same namespace as 'Pair', in this case + // in namespace 'Foo'. + // + + template< class T > + inline T boost_range_begin( Pair& x ) + { + return x.first; + } + + template< class T > + inline T boost_range_begin( const Pair& x ) + { + return x.first; + } + + template< class T > + inline T boost_range_end( Pair& x ) + { + return x.last; + } + + template< class T > + inline T boost_range_end( const Pair& x ) + { + return x.last; + } + + template< class T > + inline typename boost::range_size< Pair >::type + boost_range_size( const Pair& x ) + { + return std::distance(x.first,x.last); + } + + } // namespace 'Foo' + + #include + + int main() + { + typedef std::vector::iterator iter; + std::vector vec; + Foo::Pair pair = { vec.begin(), vec.end() }; + const Foo::Pair& cpair = pair; + // + // Notice that we call 'begin' etc with qualification. + // + iter i = boost::begin( pair ); + iter e = boost::end( pair ); + i = boost::begin( cpair ); + e = boost::end( cpair ); + boost::range_size< Foo::Pair >::type s = boost::size( pair ); + s = boost::size( cpair ); + boost::range_const_reverse_iterator< Foo::Pair >::type + ri = boost::rbegin( cpair ), + re = boost::rend( cpair ); + } +`` + +[endsect] + +[endsect] + +[endsect] + + + +[section 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` is hardly self-documenting whereas more domain specific class names are. Therefore these two classes are provided: + +* Class `iterator_range` +* Class `sub_range` + +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. + +[section:iterator_range 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. + +[h4 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& + operator<<( std::basic_ostream& Os, + const iterator_range& r ); + + // comparison + template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > + bool operator==( const iterator_range& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator==( const iterator_range& l, + const ForwardRange& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator==( const ForwardRange& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > + bool operator!=( const iterator_range& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator!=( const iterator_range& l, + const ForwardRange& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator!=( const ForwardRange& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > + bool operator<( const iterator_range& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator<( const iterator_range& l, + const ForwardRange& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator<( const ForwardRange& l, + const iterator_range& r ); + + // external construction + template< class ForwardTraversalIterator > + iterator_range< ForwardTraversalIterator > + make_iterator_range( ForwardTraversalIterator Begin, + ForwardTraversalIterator End ); + + template< class ForwardRange > + iterator_range< typename iterator_of::type > + make_iterator_range( ForwardRange& r ); + + template< class ForwardRange > + iterator_range< typename const_iterator_of::type > + make_iterator_range( const ForwardRange& r ); + + template< class Range > + iterator_range< typename range_iterator::type > + make_iterator_range( Range& r, + typename range_difference::type advance_begin, + typename range_difference::type advance_end ); + + template< class Range > + iterator_range< typename range_const_iterator::type > + make_iterator_range( const Range& r, + typename range_difference::type advance_begin, + typename range_difference::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` to `iterator_range`. 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. + +[h4 Details member functions] + +`operator unspecified_bool_type() const;` + +[:['[*Returns]] `!empty();`] + +`bool equal( iterator_range& r ) const;` + +[:['[*Returns]] `begin() == r.begin() && end() == r.end();`] + +[h4 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::type advance_begin, + typename range_difference::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) );`] + +[endsect] + +[section:sub_range 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. + +[h4 Synopsis] + +`` +namespace boost +{ + template< class ForwardRange > + class sub_range : public iterator_range< typename range_result_iterator::type > + { + public: + typedef typename range_result_iterator::type iterator; + typedef typename range_const_iterator::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 ir = find_first( str, "ll" ); +sub_range sub = find_first( str, "ll" ); +`` + +[endsect] + +[endsect] + + + +[section:style_guide 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: + +* ['Value access] category: + * Readable Range + * Writeable Range + * Swappable Range + * Lvalue Range +* ['Traversal] category: + * __single_pass_range__ + * __forward_range__ + * __bidirectional_range__ + * __random_access_range__ + +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 + +* Random Access Readable Writeable Range +* Forward Lvalue Range + +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 ); +`` + +[endsect] + + + +[section Library Headers] + +[table + [[Header ] [Includes ] [Related Concept ]] + [[`` ] [everything ] [- ]] + [[`` ] [every metafunction ] [- ]] + [[`` ] [every function ] [- ]] + [[`` ] [`range_value` ] [__single_pass_range__ ]] + [[`` ] [`range_iterator` ] [__single_pass_range__ ]] + [[`` ] [`range_const_iterator` ] [__single_pass_range__ ]] + [[`` ] [`range_difference` ] [__forward_range__ ]] + [[`` ] [`range_size` ] [__forward_range__ ]] + [[`` ] [`range_result_iterator` ] [- ]] + [[``] [`range_reverse_iterator` ] [__bidirectional_range__ ]] + [[``] + [`range_const_reverse_iterator`] + [_bidirectional_range__ ]] + [[``] + [`range_reverse_result_iterator`] + [- ]] + [[`` ] [`begin` and `const_begin` ] [__single_pass_range__ ]] + [[`` ] [`end` and `const_end` ] [__single_pass_range__ ]] + [[`` ] [`empty` ] [__single_pass_range__ ]] + [[`` ] [`size` ] [__forward_range__ ]] + [[`` ] [`rbegin` and `const_rbegin`] [__bidirectional_range__ ]] + [[`` ] [`rend` and `const_rend` ] [__bidirectional_range__ ]] + [[`` ] [`iterator_range` ] [- ]] + [[`` ] [`sub_range` ] [- ]] + [[`` ] [`concept checks` ] [- ]] +] + +[endsect] + + + +[section Examples] + +Some examples are given in the accompanying test files: + +* [@http://www.boost.org/libs/range/test/string.cpp string.cpp][br] +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).]]] + +* [@http://www.boost.org/libs/range/test/algorithm_example.cpp algorithm_example.cpp][br]shows the replace example from the introduction. + +* [@http://www.boost.org/libs/range/test/iterator_range.cpp iterator_range.cpp] + +* [@http://www.boost.org/libs/range/test/sub_range.cpp sub_range.cpp] + +* [@http://www.boost.org/libs/range/test/iterator_pair.cpp iterator_pair.cpp] + +* [@http://www.boost.org/libs/range/test/reversible_range.cpp reversible_range.cpp] + +* [@http://www.boost.org/libs/range/test/std_container.cpp std_container.cpp] + +* [@http://www.boost.org/libs/range/test/array.cpp array.cpp] + +[endsect] + + + +[section 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: + +# do not use built-in arrays, +# do not pass rvalues to `begin()`, `end()` and `iterator_range` Range constructors and assignment operators, +# use `const_begin()` and `const_end()` whenever your code by intention is read-only; this will also solve most rvalue problems, +# do not rely on ADL: + * if you overload functions, include that header before the headers in this library, + * put all overloads in namespace boost. + + + +[endsect] + + + +[section FAQ] + +1. ['[*Why is there no difference between `range_iterator::type` and `range_const_iterator::type` for `std::pair`?]] + +[: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` object.] + +[:Note that an __iterator_range__ is somewhat more convenient than a `pair` and that a __sub_range__ does propagate const-ness.] + +2. ['[*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.] + +3. ['[*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.] + +4. ['[*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.] + +[endsect] + +[section:history_ack 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 + +* Pavol Droba for help with documentation and implementation +* Pavel Vozenilek for help with porting the library +* Jonathan Turkanis and John Torjo for help with documentation +* Hartmut Kaiser for being review manager +* Jonathan Turkanis for porting the lib (as far sa possible) to vc6 and vc7. + +The concept checks and their documentation was provided by Daniel Walker. + +[endsect] \ No newline at end of file From d759c2355260488b2d4af4a7e4fa30a982a2c00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:34:06 +0000 Subject: [PATCH 22/92] added test for operator() [SVN r40374] --- test/iterator_range.cpp | 1 + test/sub_range.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 7854a92..db531d3 100755 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -95,6 +95,7 @@ void check_iterator_range() BOOST_CHECK_EQUAL( cr.front(), 'h' ); BOOST_CHECK_EQUAL( cr.back(), 'd' ); BOOST_CHECK_EQUAL( cr[1], 'e' ); + BOOST_CHECK_EQUAL( cr(1), 'e' ); rrr = make_iterator_range( str, 1, -1 ); BOOST_CHECK( rrr == as_literal("ello worl") ); diff --git a/test/sub_range.cpp b/test/sub_range.cpp index 3694105..7d5bf05 100755 --- a/test/sub_range.cpp +++ b/test/sub_range.cpp @@ -127,6 +127,7 @@ void check_sub_range() BOOST_CHECK_EQUAL( cr.front(), 'h' ); BOOST_CHECK_EQUAL( cr.back(), 'd' ); BOOST_CHECK_EQUAL( cr[1], 'e' ); + BOOST_CHECK_EQUAL( cr(1), 'e' ); rrr = make_iterator_range( str, 1, -1 ); BOOST_CHECK( rrr == as_literal("ello worl") ); From 17514e1d446652efa14ce43bc490518dafae6774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:34:38 +0000 Subject: [PATCH 23/92] added operator() to allow random access index with transform iterators [SVN r40375] --- include/boost/range/iterator_range.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index ebdbc3e..41b30af 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -348,10 +348,21 @@ namespace boost return *--last; } - reference operator[]( size_type sz ) const + reference operator[]( size_type at ) const { - BOOST_ASSERT( sz < size() ); - return m_Begin[sz]; + BOOST_ASSERT( at < size() ); + return m_Begin[at]; + } + + // + // When storing transform iterators, operator[]() + // fails because it returns by reference. Therefore + // operator()() is provided for these cases. + // + value_type operator()( size_type at ) const + { + BOOST_ASSERT( at < size() ); + return m_Begin[at]; } iterator_range& advance_begin( difference_type n ) From bbd9fdb7bda2fc2cd0214488b41e319f944662f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:50:59 +0000 Subject: [PATCH 24/92] displabed some warnings and applied Ticket #1284: sub_range_copy.patch [SVN r40376] --- include/boost/range/iterator_range.hpp | 3 +++ include/boost/range/sub_range.hpp | 30 +++++++++++--------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 41b30af..bcead14 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -36,6 +36,9 @@ #endif #include +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) + #pragma warning( disable : 4996 ) +#endif /*! \file Defines the \c iterator_class and related functions. diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index 346c0e0..30daaea 100755 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -11,6 +11,10 @@ #ifndef BOOST_RANGE_SUB_RANGE_HPP #define BOOST_RANGE_SUB_RANGE_HPP +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) + #pragma warning( disable : 4996 ) +#endif + #include #include #include @@ -38,16 +42,12 @@ namespace boost public: sub_range() : base() { } - -/* - template< class ForwardRange2 > - sub_range( sub_range r ) : - -#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 ) - base( impl::adl_begin( r ), impl::adl_end( r ) ) -#else - base( r ) -#endif */ + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) + sub_range( const sub_range& r ) + : base( static_cast( r ) ) + { } +#endif template< class ForwardRange2 > sub_range( ForwardRange2& r ) : @@ -86,15 +86,11 @@ namespace boost { base::operator=( r ); return *this; - } + } - sub_range& operator=( sub_range r ) + sub_range& operator=( const sub_range& r ) { - // - // argument passed by value to avoid - // const_iterator to iterator conversion - // - base::operator=( r ); + base::operator=( static_cast(r) ); return *this; } From aa9158b199d46d248e5a78959e19c937a9a29ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 19:56:39 +0000 Subject: [PATCH 25/92] applied Ticket #1309 (new Patches) [SVN r40377] --- include/boost/range/iterator.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/boost/range/iterator.hpp b/include/boost/range/iterator.hpp index 3942cbc..21798c5 100755 --- a/include/boost/range/iterator.hpp +++ b/include/boost/range/iterator.hpp @@ -24,13 +24,45 @@ namespace boost { + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) + + namespace range_detail_vc7_1 + { + template< typename C, typename Sig = void(C) > + struct range_iterator + { + typedef BOOST_RANGE_DEDUCED_TYPENAME + mpl::eval_if_c< is_const::value, + range_const_iterator< typename remove_const::type >, + range_mutable_iterator >::type type; + }; + + template< typename C, typename T > + struct range_iterator< C, void(T[]) > + { + typedef T* type; + }; + } + +#endif + template< typename C > struct range_iterator { +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) + + typedef BOOST_RANGE_DEDUCED_TYPENAME + range_detail_vc7_1::range_iterator::type type; + +#else + typedef BOOST_RANGE_DEDUCED_TYPENAME mpl::eval_if_c< is_const::value, range_const_iterator< typename remove_const::type >, range_mutable_iterator >::type type; + +#endif }; } // namespace boost From d130dff5ec5df3e135865deeac8a37181727f6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 20:08:35 +0000 Subject: [PATCH 26/92] cleanup [SVN r40378] --- .../range/detail/implementation_help.hpp | 79 ------------------- 1 file changed, 79 deletions(-) diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index 31b7aea..da086f0 100755 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -57,55 +57,15 @@ namespace boost return const_cast( str_end( s, s ) ); } - /* - template< class T, std::size_t sz > - inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], int ) - { - return boost_range_array + sz; - } - - template< class T, std::size_t sz > - inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], int ) - { - return boost_range_array + sz; - } - - template< class T, std::size_t sz > - inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag ) - { - return boost_range_array + sz - 1; - } - - template< class T, std::size_t sz > - inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag ) - { - return boost_range_array + sz - 1; - } - */ - template< class T, std::size_t sz > inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] ) { - /* - typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value, - char_or_wchar_t_array_tag, - int >::type tag; - - return array_end( boost_range_array, tag() ); - */ return boost_range_array + sz; } template< class T, std::size_t sz > inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] ) { - /* - typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value, - char_or_wchar_t_array_tag, - int >::type tag; - - return array_end( boost_range_array, tag() ); - */ return boost_range_array + sz; } @@ -119,54 +79,15 @@ namespace boost return str_end( s ) - s; } - /* - template< class T, std::size_t sz > - inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], int ) - { - return sz; - } - - template< class T, std::size_t sz > - inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz], int ) - { - return sz; - } - - template< class T, std::size_t sz > - inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag ) - { - return sz - 1; - } - - template< class T, std::size_t sz > - inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag ) - { - return sz - 1; - } - */ - template< class T, std::size_t sz > inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] ) { - /* - typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value || - is_same::value || is_same::value, - char_or_wchar_t_array_tag, - int >::type tag; - return array_size( boost_range_array, tag() ); - */ return sz; } template< class T, std::size_t sz > inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] ) { - /* - typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same::value || is_same::value, - char_or_wchar_t_array_tag, - int >::type tag; - return array_size( boost_range_array, tag() ); - */ return sz; } From f4cde208f23995a6cc86ca0a6da9c0567e8d2a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 20:23:05 +0000 Subject: [PATCH 27/92] Adding Shunsuke Sogame fantastic MFC/ATL mappings [SVN r40379] --- include/boost/range/atl.hpp | 733 +++++++++++++++++ include/boost/range/detail/microsoft.hpp | 935 +++++++++++++++++++++ include/boost/range/mfc.hpp | 984 +++++++++++++++++++++++ 3 files changed, 2652 insertions(+) create mode 100644 include/boost/range/atl.hpp create mode 100644 include/boost/range/detail/microsoft.hpp create mode 100644 include/boost/range/mfc.hpp diff --git a/include/boost/range/atl.hpp b/include/boost/range/atl.hpp new file mode 100644 index 0000000..ab492d9 --- /dev/null +++ b/include/boost/range/atl.hpp @@ -0,0 +1,733 @@ +#ifndef BOOST_RANGE_ATL_HPP +#define BOOST_RANGE_ATL_HPP + + + + +// Boost.Range ATL Extension +// +// Copyright Shunsuke Sogame 2005-2006. +// Distributed under 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) + + + + +// config +// + + +#include // _ATL_VER + + +#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + #if (_ATL_VER < 0x0700) + #define BOOST_RANGE_ATL_NO_COLLECTIONS + #endif +#endif + + +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + #if (_ATL_VER < 0x0700) // dubious + #define BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX + #endif +#endif + + +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING) + #if (_MSC_VER < 1310) // from , but dubious + #define BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING + #endif +#endif + + + + +// forward declarations +// + + +#include // IID + + +namespace ATL { + + +#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + + + // arrays + // + template< class E, class ETraits > + class CAtlArray; + + template< class E > + class CAutoPtrArray; + + template< class I, const IID *piid > + class CInterfaceArray; + + + // lists + // + template< class E, class ETraits > + class CAtlList; + + template< class E > + class CAutoPtrList; + + template< class E, class Allocator > + class CHeapPtrList; + + template< class I, const IID *piid > + class CInterfaceList; + + + // maps + // + template< class K, class V, class KTraits, class VTraits > + class CAtlMap; + + template< class K, class V, class KTraits, class VTraits > + class CRBTree; + + template< class K, class V, class KTraits, class VTraits > + class CRBMap; + + template< class K, class V, class KTraits, class VTraits > + class CRBMultiMap; + + + // strings + // +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING) + template< class BaseType, bool t_bMFCDLL > + class CSimpleStringT; +#else + template< class BaseType > + class CSimpleStringT; +#endif + + template< class BaseType, class StringTraits > + class CStringT; + + template< class StringType, int t_nChars > + class CFixedStringT; + + template< class BaseType, const int t_nSize > + class CStaticString; + + +#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + + + // simples + // +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + + template< class T, class TEqual > + class CSimpleArray; + + template< class TKey, class TVal, class TEqual > + class CSimpleMap; + +#else + + template< class T > + class CSimpleArray; + + template< class T > + class CSimpleValArray; + + template< class TKey, class TVal > + class CSimpleMap; + +#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + + + // pointers + // + template< class E > + class CAutoPtr; + + template< class T > + class CComPtr; + + template< class T, const IID *piid > + class CComQIPtr; + + template< class E, class Allocator > + class CHeapPtr; + + template< class T > + class CAdapt; + + +} // namespace ATL + + + + +// indirect_iterator customizations +// + + +#include +#include + + +namespace boost { + + + template< class E > + struct pointee< ATL::CAutoPtr > : + mpl::identity + { }; + + template< class T > + struct pointee< ATL::CComPtr > : + mpl::identity + { }; + + template< class T, const IID *piid > + struct pointee< ATL::CComQIPtr > : + mpl::identity + { }; + + template< class E, class Allocator > + struct pointee< ATL::CHeapPtr > : + mpl::identity + { }; + + template< class T > + struct pointee< ATL::CAdapt > : + pointee + { }; + + +} // namespace boost + + + + +// extended customizations +// + + +#include +#include +#include +#include +#include // CComBSTR + + +namespace boost { namespace range_detail_microsoft { + + +#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + + + // arrays + // + + struct atl_array_functions : + array_functions + { + template< class Iterator, class X > + Iterator end(X& x) // redefine + { + return x.GetData() + x.GetCount(); // no 'GetSize()' + } + }; + + + template< class E, class ETraits > + struct customization< ATL::CAtlArray > : + atl_array_functions + { + template< class X > + struct meta + { + typedef E val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< class E > + struct customization< ATL::CAutoPtrArray > : + atl_array_functions + { + template< class X > + struct meta + { + // ATL::CAutoPtr/CHeapPtr is no assignable. + typedef ATL::CAutoPtr val_t; + typedef val_t *miter_t; + typedef val_t const *citer_t; + + typedef indirect_iterator mutable_iterator; + typedef indirect_iterator const_iterator; + }; + }; + + + template< class I, const IID *piid > + struct customization< ATL::CInterfaceArray > : + atl_array_functions + { + template< class X > + struct meta + { + typedef ATL::CComQIPtr val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< class E, class ETraits > + struct customization< ATL::CAtlList > : + list_functions + { + template< class X > + struct meta + { + typedef E val_t; + + typedef list_iterator mutable_iterator; + typedef list_iterator const_iterator; + }; + }; + + + struct indirected_list_functions + { + template< class Iterator, class X > + Iterator begin(X& x) + { + typedef typename Iterator::base_type base_t; // == list_iterator + return Iterator(base_t(x, x.GetHeadPosition())); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + typedef typename Iterator::base_type base_t; + return Iterator(base_t(x, POSITION(0))); + } + }; + + + template< class E > + struct customization< ATL::CAutoPtrList > : + indirected_list_functions + { + template< class X > + struct meta + { + typedef ATL::CAutoPtr val_t; + typedef list_iterator miter_t; + typedef list_iterator citer_t; + + typedef indirect_iterator mutable_iterator; + typedef indirect_iterator const_iterator; + }; + }; + + + template< class E, class Allocator > + struct customization< ATL::CHeapPtrList > : + indirected_list_functions + { + template< class X > + struct meta + { + typedef ATL::CHeapPtr val_t; + typedef list_iterator miter_t; + typedef list_iterator citer_t; + + typedef indirect_iterator mutable_iterator; + typedef indirect_iterator const_iterator; + }; + }; + + + template< class I, const IID *piid > + struct customization< ATL::CInterfaceList > : + list_functions + { + template< class X > + struct meta + { + typedef ATL::CComQIPtr val_t; + + typedef list_iterator mutable_iterator; + typedef list_iterator const_iterator; + }; + }; + + + // maps + // + + struct atl_rb_tree_tag + { }; + + template< > + struct customization< atl_rb_tree_tag > : + indirected_list_functions + { + template< class X > + struct meta + { + typedef typename X::CPair val_t; + + typedef list_iterator miter_t; + typedef list_iterator citer_t; + + typedef indirect_iterator mutable_iterator; + typedef indirect_iterator const_iterator; + }; + }; + + + template< class K, class V, class KTraits, class VTraits > + struct customization< ATL::CAtlMap > : + customization< atl_rb_tree_tag > + { + template< class Iterator, class X > + Iterator begin(X& x) // redefine + { + typedef typename Iterator::base_type base_t; // == list_iterator + return Iterator(base_t(x, x.GetStartPosition())); // no 'GetHeadPosition' + } + }; + + + // strings + // + + struct atl_string_tag + { }; + + template< > + struct customization< atl_string_tag > + { + template< class X > + struct meta + { + typedef typename X::PXSTR mutable_iterator; + typedef typename X::PCXSTR const_iterator; + }; + + template< class Iterator, class X > + typename mutable_::type begin(X& x) + { + return x.GetBuffer(0); + } + + template< class Iterator, class X > + Iterator begin(X const& x) + { + return x.GetString(); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return begin(x) + x.GetLength(); + } + }; + + + template< class BaseType, const int t_nSize > + struct customization< ATL::CStaticString > + { + template< class X > + struct meta + { + typedef BaseType const *mutable_iterator; + typedef mutable_iterator const_iterator; + }; + + template< class Iterator, class X > + Iterator begin(X const& x) + { + return x; + } + + template< class Iterator, class X > + Iterator end(X const& x) + { + return begin(x) + X::GetLength(); + } + }; + + +#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + + + template< > + struct customization< ATL::CComBSTR > + { + template< class X > + struct meta + { + typedef OLECHAR *mutable_iterator; + typedef OLECHAR const *const_iterator; + }; + + template< class Iterator, class X > + Iterator begin(X& x) + { + return x.operator BSTR(); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return begin(x) + x.Length(); + } + }; + + + // simples + // + +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + template< class T, class TEqual > + struct customization< ATL::CSimpleArray > : +#else + template< class T > + struct customization< ATL::CSimpleArray > : +#endif + array_functions + { + template< class X > + struct meta + { + typedef T val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + +#if defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + + template< class T > + struct customization< ATL::CSimpleValArray > : + array_functions + { + template< class X > + struct meta + { + typedef T val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + +#endif // defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + + +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + template< class TKey, class TVal, class TEqual > + struct customization< ATL::CSimpleMap > +#else + template< class TKey, class TVal > + struct customization< ATL::CSimpleMap > +#endif + { + template< class X > + struct meta + { + typedef TKey k_val_t; + typedef k_val_t *k_miter_t; + typedef k_val_t const *k_citer_t; + + typedef TVal v_val_t; + typedef v_val_t *v_miter_t; + typedef v_val_t const *v_citer_t; + + // Topic: + // 'std::pair' can't contain references + // because of reference to reference problem. + + typedef zip_iterator< tuple > mutable_iterator; + typedef zip_iterator< tuple > const_iterator; + }; + + template< class Iterator, class X > + Iterator begin(X& x) + { + return Iterator(boost::make_tuple(x.m_aKey, x.m_aVal)); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return Iterator(boost::make_tuple(x.m_aKey + x.GetSize(), x.m_aVal + x.GetSize())); + } + }; + + +} } // namespace boost::range_detail_microsoft + + + + +// range customizations +// + + +#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + + + // arrays + // + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CAtlArray, 2 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CAutoPtrArray, 1 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CInterfaceArray, (class)(const IID *) + ) + + + // lists + // + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CAtlList, 2 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CAutoPtrList, 1 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CHeapPtrList, 2 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CInterfaceList, (class)(const IID *) + ) + + + //maps + // + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CAtlMap, 4 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_rb_tree_tag, + (ATL, BOOST_PP_NIL), CRBTree, 4 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_rb_tree_tag, + (ATL, BOOST_PP_NIL), CRBMap, 4 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_rb_tree_tag, + (ATL, BOOST_PP_NIL), CRBMultiMap, 4 + ) + + + // strings + // + #if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING) + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_string_tag, + (ATL, BOOST_PP_NIL), CSimpleStringT, (class)(bool) + ) + #else + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_string_tag, + (ATL, BOOST_PP_NIL), CSimpleStringT, 1 + ) + #endif + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_string_tag, + (ATL, BOOST_PP_NIL), CStringT, 2 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::atl_string_tag, + (ATL, BOOST_PP_NIL), CFixedStringT, (class)(int) + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CStaticString, (class)(const int) + ) + + +#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS) + + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CComBSTR +) + + +// simples +// +#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CSimpleArray, 2 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CSimpleMap, 3 + ) + +#else + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CSimpleArray, 1 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CSimpleMap, 2 + ) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + (ATL, BOOST_PP_NIL), CSimpleValArray, 1 + ) + +#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX) + + + + +#endif diff --git a/include/boost/range/detail/microsoft.hpp b/include/boost/range/detail/microsoft.hpp new file mode 100644 index 0000000..6dfe1ca --- /dev/null +++ b/include/boost/range/detail/microsoft.hpp @@ -0,0 +1,935 @@ +#ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP +#define BOOST_RANGE_DETAIL_MICROSOFT_HPP + + + + +// Boost.Range MFC/ATL Extension +// +// Copyright Shunsuke Sogame 2005-2006. +// Distributed under 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) + + + + +// config +// + + +#include + + +#define BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1 1 + + +#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1) + #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator + #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin + #define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end +#else + #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator + #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin boost_range_begin + #define BOOST_RANGE_DETAIL_MICROSOFT_range_end boost_range_end +#endif + + + + +// yet another customization way +// + + +#include // iterator_difference +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // disable_if + +#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1) + #include +#else + #include // distance + #include + #include + #include +#endif + + +namespace boost { namespace range_detail_microsoft { + + + // customization point + // + + template< class Tag > + struct customization; + + + template< class T > + struct customization_tag; + + + struct using_type_as_tag + { }; + + + // Topic: + // In fact, it is unnecessary for VC++. + // VC++'s behavior seems conforming, while GCC fails without this. + template< class Iterator, class T > + struct mutable_ : + disable_if< is_const, Iterator > + { }; + + + // helpers + // + + template< class Tag, class T > + struct customization_tag_of + { + typedef typename mpl::if_< is_same, + T, + Tag + >::type type; + }; + + + template< class T > + struct customization_of + { + typedef typename remove_cv::type bare_t; + typedef typename customization_tag::type tag_t; + typedef customization type; + }; + + + template< class T > + struct mutable_iterator_of + { + typedef typename remove_cv::type bare_t; + typedef typename customization_of::type cust_t; + typedef typename cust_t::template meta::mutable_iterator type; + }; + + + template< class T > + struct const_iterator_of + { + typedef typename remove_cv::type bare_t; + typedef typename customization_of::type cust_t; + typedef typename cust_t::template meta::const_iterator type; + }; + + + template< class T > + struct size_type_of + { + typedef typename range_detail_microsoft::mutable_iterator_of::type miter_t; + typedef typename iterator_difference::type type; + }; + + + template< class T > inline + typename mutable_iterator_of::type + begin_of(T& x) + { + typedef typename customization_of::type cust_t; + return cust_t().template begin::type>(x); + } + + + template< class T > inline + typename const_iterator_of::type + begin_of(T const& x) + { + typedef typename customization_of::type cust_t; + return cust_t().template begin::type>(x); + } + + + template< class T > inline + typename mutable_iterator_of::type + end_of(T& x) + { + typedef typename customization_of::type cust_t; + return cust_t().template end::type>(x); + } + + + template< class T > inline + typename const_iterator_of::type + end_of(T const& x) + { + typedef typename customization_of::type cust_t; + return cust_t().template end::type>(x); + } + + +#if defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1) + + template< class T > inline + typename size_type_of::type + size_of(T const& x) + { + return std::distance(boost::begin(x), boost::end(x)); + } + +#endif + + + template< class Range > + struct compatible_mutable_iterator : + BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator + { }; + + +} } // namespace boost::range_detail_microsoft + + +#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \ + BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op, ~, NamespaceList) \ +/**/ + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op(r, data, elem) \ + namespace elem { \ + /**/ + + +#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \ + BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op, ~, NamespaceList) \ +/**/ + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op(r, data, elem) \ + } \ + /**/ + + +#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op(r, data, elem) \ + :: elem \ +/**/ + + +#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(Tag, NamespaceList, Name) \ + namespace boost { namespace range_detail_microsoft { \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + } } \ + \ + namespace boost { \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + } \ + \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \ +/**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name) \ + BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) :: Name \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, Fullname) \ + template< > \ + struct customization_tag< Fullname > : \ + customization_tag_of< Tag, Fullname > \ + { }; \ + /**/ + + + // metafunctions + // + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(Fullname) \ + template< > \ + struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \ + range_detail_microsoft::mutable_iterator_of< Fullname > \ + { }; \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(Fullname) \ + template< > \ + struct range_const_iterator< Fullname > : \ + range_detail_microsoft::const_iterator_of< Fullname > \ + { }; \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(Fullname) \ + template< > \ + struct range_size< Fullname > : \ + range_detail_microsoft::size_type_of< Fullname > \ + { }; \ + /**/ + + + // functions + // + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(Fullname) \ + inline \ + boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \ + { \ + return boost::range_detail_microsoft::begin_of(x); \ + } \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(Fullname) \ + inline \ + boost::range_detail_microsoft::const_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \ + { \ + return boost::range_detail_microsoft::begin_of(x); \ + } \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(Fullname) \ + inline \ + boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \ + { \ + return boost::range_detail_microsoft::end_of(x); \ + } \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(Fullname) \ + inline \ + boost::range_detail_microsoft::const_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \ + { \ + return boost::range_detail_microsoft::end_of(x); \ + } \ + /**/ + + + #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1) + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \ + /**/ + + #else + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \ + inline \ + boost::range_detail_microsoft::size_type_of< Fullname >::type \ + boost_range_size(Fullname const& x) \ + { \ + return boost::range_detail_microsoft::size_of(x); \ + } \ + /**/ + + #endif + + +#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(Tag, NamespaceList, Name, ParamSeqOrCount) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl( \ + Tag, NamespaceList, Name, \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \ + ) \ +/**/ + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \ + BOOST_PP_IIF(BOOST_PP_IS_UNARY(ParamSeqOrCount), \ + ParamSeqOrCount BOOST_PP_TUPLE_EAT(3), \ + BOOST_PP_REPEAT \ + )(ParamSeqOrCount, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op, ~) \ + /**/ + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op(z, n, _) \ + (class) \ + /**/ + + +#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl(Tag, NamespaceList, Name, ParamSeq) \ + namespace boost { namespace range_detail_microsoft { \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag( \ + Tag, \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + } } \ + \ + namespace boost { \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + } \ + \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size( \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + ) \ + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \ +/**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq) \ + BOOST_PP_SEQ_FOR_EACH_I(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op, ~, ParamSeq) \ + /**/ + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op(r, data, i, elem) \ + BOOST_PP_COMMA_IF(i) elem BOOST_PP_CAT(T, i) \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \ + BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) \ + :: Name < BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(ParamSeq), T) > \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag(Tag, Params, Fullname) \ + template< Params > \ + struct customization_tag< Fullname > : \ + customization_tag_of< Tag, Fullname > \ + { }; \ + /**/ + + + // metafunctions + // + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator(Params, Fullname) \ + template< Params > \ + struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \ + range_detail_microsoft::mutable_iterator_of< Fullname > \ + { }; \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator(Params, Fullname) \ + template< Params > \ + struct range_const_iterator< Fullname > : \ + range_detail_microsoft::const_iterator_of< Fullname > \ + { }; \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type(Params, Fullname) \ + template< Params > \ + struct range_size< Fullname > : \ + range_detail_microsoft::size_type_of< Fullname > \ + { }; \ + /**/ + + + // functions + // + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin(Params, Fullname) \ + template< Params > inline \ + typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \ + { \ + return boost::range_detail_microsoft::begin_of(x); \ + } \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const(Params, Fullname) \ + template< Params > inline \ + typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \ + { \ + return boost::range_detail_microsoft::begin_of(x); \ + } \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end(Params, Fullname) \ + template< Params > inline \ + typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \ + { \ + return boost::range_detail_microsoft::end_of(x); \ + } \ + /**/ + + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const(Params, Fullname) \ + template< Params > inline \ + typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \ + BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \ + { \ + return boost::range_detail_microsoft::end_of(x); \ + } \ + /**/ + + + #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1) + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \ + /**/ + + #else + + #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \ + template< Params > inline \ + typename boost::range_detail_microsoft::size_type_of< Fullname >::type \ + boost_range_size(Fullname const& x) \ + { \ + return boost::range_detail_microsoft::size_of(x); \ + } \ + /**/ + + #endif + + + + +// list_iterator and helpers +// + + +#include +#include +#include +#include +#include + + +// POSITION's header is undocumented, so is NULL. +// +struct __POSITION; // incomplete, but used as just a pointer. +typedef __POSITION *POSITION; + + +namespace boost { namespace range_detail_microsoft { + + + template< + class ListT, + class Value, + class Reference, + class Traversal + > + struct list_iterator; + + + template< + class ListT, + class Value, + class Reference, + class Traversal + > + struct list_iterator_super + { + typedef typename mpl::if_< is_same, + Value&, + Reference + >::type ref_t; + + typedef typename mpl::if_< is_same, + bidirectional_traversal_tag, + Traversal + >::type trv_t; + + typedef iterator_facade< + list_iterator, + Value, + trv_t, + ref_t + > type; + }; + + + template< + class ListT, + class Value, + class Reference = use_default, + class Traversal = use_default + > + struct list_iterator : + list_iterator_super::type + { + private: + typedef list_iterator self_t; + typedef typename list_iterator_super::type super_t; + typedef typename super_t::reference ref_t; + + public: + explicit list_iterator() + { } + + explicit list_iterator(ListT& lst, POSITION pos) : + m_plst(boost::addressof(lst)), m_pos(pos) + { } + + template< class, class, class, class > friend struct list_iterator; + template< class ListT_, class Value_, class Reference_, class Traversal_> + list_iterator(list_iterator const& other) : + m_plst(other.m_plst), m_pos(other.m_pos) + { } + + private: + ListT *m_plst; + POSITION m_pos; + + friend class iterator_core_access; + ref_t dereference() const + { + BOOST_ASSERT(m_pos != 0 && "out of range"); + return m_plst->GetAt(m_pos); + } + + // A B C D x + // Head Tail NULL(0) + // + void increment() + { + BOOST_ASSERT(m_pos != 0 && "out of range"); + m_plst->GetNext(m_pos); + } + + void decrement() + { + if (m_pos == 0) { + m_pos = m_plst->GetTailPosition(); + return; + } + + m_plst->GetPrev(m_pos); + } + + bool equal(self_t const& other) const + { + BOOST_ASSERT(m_plst == other.m_plst && "iterators incompatible"); + return m_pos == other.m_pos; + } + }; + + + // customization helpers + // + + struct array_functions + { + template< class Iterator, class X > + Iterator begin(X& x) + { + return x.GetData(); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return begin(x) + x.GetSize(); + } + }; + + + struct list_functions + { + template< class Iterator, class X > + Iterator begin(X& x) + { + return Iterator(x, x.GetHeadPosition()); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return Iterator(x, POSITION(0)); + } + }; + + +} } // namespace boost::range_detail_microsoft + + + + +// test +// + + +#if defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST) + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace range_detail_microsoft { + + + template< class Range1, class Range2 > + bool test_equals(Range1 const& rng1, Range2 const& rng2) + { + return + boost::distance(rng1) == boost::distance(rng2) && + std::equal(boost::begin(rng1), boost::end(rng1), boost::begin(rng2)) + ; + } + + + template< class AssocContainer, class PairT > + bool test_find_key_and_mapped(AssocContainer const& ac, PairT const& pa) + { + typedef typename boost::range_const_iterator::type iter_t; + for (iter_t it = boost::const_begin(ac), last = boost::const_end(ac); it != last; ++it) { + if (it->first == pa.first && it->second == pa.second) + return true; + } + + return false; + } + + + // test functions + // + + template< class Range > + bool test_emptiness(Range& ) + { + bool result = true; + + Range emptyRng; + result = result && boost::empty(emptyRng); + + return result; + } + + + template< class Range > + bool test_trivial(Range& rng) + { + bool result = true; + + // convertibility check + typedef typename range_const_iterator::type citer_t; + citer_t cit = boost::begin(rng); + (void)cit; // unused + + // mutability check + typedef typename range_value::type val_t; + val_t v = *boost::begin(rng); + *boost::begin(rng) = v; + result = result && *boost::begin(rng) == v; + + return result; + } + + + template< class Range > + bool test_forward(Range& rng) + { + boost::function_requires< ForwardRangeConcept >(); + + bool result = (test_trivial)(rng); + + typedef typename range_value::type val_t; + + std::vector saved; + std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved)); + std::rotate(boost::begin(saved), boost::next(boost::begin(saved)), boost::end(saved)); + + std::rotate(boost::begin(rng), boost::next(boost::begin(rng)), boost::end(rng)); + + return result && (test_equals)(saved, rng); + }; + + + template< class Range > + bool test_bidirectional(Range& rng) + { + boost::function_requires< BidirectionalRangeConcept >(); + + bool result = (test_forward)(rng); + + typedef typename range_value::type val_t; + + std::vector saved; + std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved)); + + result = result && (test_equals)( + boost::make_iterator_range(boost::rbegin(saved), boost::rend(saved)), + boost::make_iterator_range(boost::rbegin(rng), boost::rend(rng)) + ); + + return result; + } + + + template< class Range > + bool test_random_access(Range& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + + bool result = (test_bidirectional)(rng); + + typedef typename range_value::type val_t; + + std::vector saved; + std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved)); + std::sort(boost::begin(saved), boost::end(saved)); + + std::random_shuffle(boost::begin(rng), boost::end(rng)); + std::sort(boost::begin(rng), boost::end(rng)); + result = result && (test_equals)(rng, saved); + + std::random_shuffle(boost::begin(rng), boost::end(rng)); + std::stable_sort(boost::begin(rng), boost::end(rng)); + result = result && (test_equals)(rng, saved); + + std::random_shuffle(boost::begin(rng), boost::end(rng)); + std::partial_sort(boost::begin(rng), boost::end(rng), boost::end(rng)); + result = result && (test_equals)(rng, saved); + + return result; + } + + + // initializer + // + + template< class ArrayT, class SampleRange > + bool test_init_array(ArrayT& arr, SampleRange const& sample) + { + typedef typename range_const_iterator::type iter_t; + typedef typename range_value::type val_t; + + for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) { + val_t v = *it; // works around ATL3 CSimpleArray + arr.Add(v); + } + + return (test_equals)(arr, sample); + } + + + template< class ListT, class SampleRange > + bool test_init_list(ListT& lst, SampleRange const& sample) + { + typedef typename range_const_iterator::type iter_t; + + for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) { + lst.AddTail(*it); + } + + return (test_equals)(lst, sample); + } + + + template< class StringT, class SampleRange > + bool test_init_string(StringT& str, SampleRange const& sample) + { + typedef typename range_const_iterator::type iter_t; + typedef typename range_value::type val_t; + + for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) { + str += *it; + } + + return (test_equals)(str, sample); + } + + + template< class MapT, class SampleMap > + bool test_init_map(MapT& map, SampleMap const& sample) + { + typedef typename range_const_iterator::type iter_t; + + for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) { + map.SetAt(it->first, it->second); + } + + return boost::distance(map) == boost::distance(sample); + } + + + // metafunction test + // + + template< class Range, class Iter > + struct test_mutable_iter : + boost::is_same< typename boost::BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator::type, Iter > + { }; + + + template< class Range, class Iter > + struct test_const_iter : + boost::is_same< typename boost::range_const_iterator::type, Iter > + { }; + + +} } // namespace boost::range_detail_microsoft + + +#endif // defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST) + + + + +#endif diff --git a/include/boost/range/mfc.hpp b/include/boost/range/mfc.hpp new file mode 100644 index 0000000..058e54e --- /dev/null +++ b/include/boost/range/mfc.hpp @@ -0,0 +1,984 @@ +#ifndef BOOST_RANGE_MFC_HPP +#define BOOST_RANGE_MFC_HPP + + + + +// Boost.Range MFC Extension +// +// Copyright Shunsuke Sogame 2005-2006. +// Distributed under 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) + + + + +// config +// + + +#include // _MFC_VER + + +#if !defined(BOOST_RANGE_MFC_NO_CPAIR) + #if (_MFC_VER < 0x0700) // dubious + #define BOOST_RANGE_MFC_NO_CPAIR + #endif +#endif + + +#if !defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING) + #if (_MFC_VER < 0x0700) // dubious + #define BOOST_RANGE_MFC_HAS_LEGACY_STRING + #endif +#endif + + +// A const collection of old MFC doesn't return const reference. +// +#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + #if (_MFC_VER < 0x0700) // dubious + #define BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF + #endif +#endif + + + + +// forward declarations +// + + +template< class Type, class ArgType > +class CArray; + +template< class Type, class ArgType > +class CList; + +template< class Key, class ArgKey, class Mapped, class ArgMapped > +class CMap; + +template< class BaseClass, class PtrType > +class CTypedPtrArray; + +template< class BaseClass, class PtrType > +class CTypedPtrList; + +template< class BaseClass, class KeyPtrType, class MappedPtrType > +class CTypedPtrMap; + + + + +// extended customizations +// + + +#include // ptrdiff_t +#include // pair +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // legacy CString +#include // CXXXArray, CXXXList, CMapXXXToXXX +#include + + +namespace boost { namespace range_detail_microsoft { + + + // mfc_ptr_array_iterator + // + // 'void **' is not convertible to 'void const **', + // so we define... + // + + template< class ArrayT, class PtrType > + struct mfc_ptr_array_iterator; + + template< class ArrayT, class PtrType > + struct mfc_ptr_array_iterator_super + { + typedef iterator_adaptor< + mfc_ptr_array_iterator, + std::ptrdiff_t, // Base! + PtrType, // Value + random_access_traversal_tag, + use_default, + std::ptrdiff_t // Difference + > type; + }; + + template< class ArrayT, class PtrType > + struct mfc_ptr_array_iterator : + mfc_ptr_array_iterator_super::type + { + private: + typedef mfc_ptr_array_iterator self_t; + typedef typename mfc_ptr_array_iterator_super::type super_t; + typedef typename super_t::reference ref_t; + + public: + explicit mfc_ptr_array_iterator() + { } + + explicit mfc_ptr_array_iterator(ArrayT& arr, INT_PTR index) : + super_t(index), m_parr(boost::addressof(arr)) + { } + + template< class, class > friend struct mfc_ptr_array_iterator; + template< class ArrayT_, class PtrType_ > + mfc_ptr_array_iterator(mfc_ptr_array_iterator const& other) : + super_t(other.base()), m_parr(other.m_parr) + { } + + private: + ArrayT *m_parr; + + friend class iterator_core_access; + ref_t dereference() const + { + BOOST_ASSERT(0 <= this->base() && this->base() < m_parr->GetSize() && "out of range"); + return *( m_parr->GetData() + this->base() ); + } + + bool equal(self_t const& other) const + { + BOOST_ASSERT(m_parr == other.m_parr && "iterators incompatible"); + return this->base() == other.base(); + } + }; + + struct mfc_ptr_array_functions + { + template< class Iterator, class X > + Iterator begin(X& x) + { + return Iterator(x, 0); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return Iterator(x, x.GetSize()); + } + }; + + + // arrays + // + + template< > + struct customization< ::CByteArray > : + array_functions + { + template< class X > + struct meta + { + typedef BYTE val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< > + struct customization< ::CDWordArray > : + array_functions + { + template< class X > + struct meta + { + typedef DWORD val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< > + struct customization< ::CObArray > : + mfc_ptr_array_functions + { + template< class X > + struct meta + { + typedef mfc_ptr_array_iterator mutable_iterator; + typedef mfc_ptr_array_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CPtrArray > : + mfc_ptr_array_functions + { + template< class X > + struct meta + { + typedef mfc_ptr_array_iterator mutable_iterator; + typedef mfc_ptr_array_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CStringArray > : + array_functions + { + template< class X > + struct meta + { + typedef ::CString val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< > + struct customization< ::CUIntArray > : + array_functions + { + template< class X > + struct meta + { + typedef UINT val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< > + struct customization< ::CWordArray > : + array_functions + { + template< class X > + struct meta + { + typedef WORD val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + // lists + // + + template< > + struct customization< ::CObList > : + list_functions + { + template< class X > + struct meta + { + typedef list_iterator mutable_iterator; + #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + typedef list_iterator const_iterator; + #else + typedef list_iterator const_iterator; + #endif + }; + }; + + + template< > + struct customization< ::CPtrList > : + list_functions + { + template< class X > + struct meta + { + typedef list_iterator mutable_iterator; + #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + typedef list_iterator const_iterator; + #else + typedef list_iterator const_iterator; + #endif + }; + }; + + + template< > + struct customization< ::CStringList > : + list_functions + { + template< class X > + struct meta + { + typedef ::CString val_t; + + typedef list_iterator mutable_iterator; + #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + typedef list_iterator const_iterator; + #else + typedef list_iterator const_iterator; + #endif + }; + }; + + + // mfc_map_iterator + // + + template< class MapT, class KeyT, class MappedT > + struct mfc_map_iterator; + + template< class MapT, class KeyT, class MappedT > + struct mfc_map_iterator_super + { + typedef iterator_facade< + mfc_map_iterator, + std::pair, + forward_traversal_tag, + std::pair const + > type; + }; + + template< class MapT, class KeyT, class MappedT > + struct mfc_map_iterator : + mfc_map_iterator_super::type + { + private: + typedef mfc_map_iterator self_t; + typedef typename mfc_map_iterator_super::type super_t; + typedef typename super_t::reference ref_t; + + public: + explicit mfc_map_iterator() + { } + + explicit mfc_map_iterator(MapT const& map, POSITION pos) : + m_pmap(boost::addressof(map)), m_posNext(pos) + { + increment(); + } + + explicit mfc_map_iterator(MapT const& map) : + m_pmap(&map), m_pos(0) // end iterator + { } + + template< class, class, class > friend struct mfc_map_iterator; + template< class MapT_, class KeyT_, class MappedT_> + mfc_map_iterator(mfc_map_iterator const& other) : + m_pmap(other.m_pmap), + m_pos(other.m_pos), m_posNext(other.m_posNext), + m_key(other.m_key), m_mapped(other.m_mapped) + { } + + private: + MapT const *m_pmap; + POSITION m_pos, m_posNext; + KeyT m_key; MappedT m_mapped; + + friend class iterator_core_access; + ref_t dereference() const + { + BOOST_ASSERT(m_pos != 0 && "out of range"); + return std::make_pair(m_key, m_mapped); + } + + void increment() + { + BOOST_ASSERT(m_pos != 0 && "out of range"); + + if (m_posNext == 0) { + m_pos = 0; + return; + } + + m_pos = m_posNext; + m_pmap->GetNextAssoc(m_posNext, m_key, m_mapped); + } + + bool equal(self_t const& other) const + { + BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible"); + return m_pos == other.m_pos; + } + }; + + struct mfc_map_functions + { + template< class Iterator, class X > + Iterator begin(X& x) + { + return Iterator(x, x.GetStartPosition()); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return Iterator(x); + } + }; + + +#if !defined(BOOST_RANGE_MFC_NO_CPAIR) + + + // mfc_cpair_map_iterator + // + // used by ::CMap and ::CMapStringToString + // + + template< class MapT, class PairT > + struct mfc_cpair_map_iterator; + + template< class MapT, class PairT > + struct mfc_pget_map_iterator_super + { + typedef iterator_facade< + mfc_cpair_map_iterator, + PairT, + forward_traversal_tag + > type; + }; + + template< class MapT, class PairT > + struct mfc_cpair_map_iterator : + mfc_pget_map_iterator_super::type + { + private: + typedef mfc_cpair_map_iterator self_t; + typedef typename mfc_pget_map_iterator_super::type super_t; + typedef typename super_t::reference ref_t; + + public: + explicit mfc_cpair_map_iterator() + { } + + explicit mfc_cpair_map_iterator(MapT& map, PairT *pp) : + m_pmap(boost::addressof(map)), m_pp(pp) + { } + + template< class, class > friend struct mfc_cpair_map_iterator; + template< class MapT_, class PairT_> + mfc_cpair_map_iterator(mfc_cpair_map_iterator const& other) : + m_pmap(other.m_pmap), m_pp(other.m_pp) + { } + + private: + MapT *m_pmap; + PairT *m_pp; + + friend class iterator_core_access; + ref_t dereference() const + { + BOOST_ASSERT(m_pp != 0 && "out of range"); + return *m_pp; + } + + void increment() + { + BOOST_ASSERT(m_pp != 0 && "out of range"); + m_pp = m_pmap->PGetNextAssoc(m_pp); + } + + bool equal(self_t const& other) const + { + BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible"); + return m_pp == other.m_pp; + } + }; + + struct mfc_cpair_map_functions + { + template< class Iterator, class X > + Iterator begin(X& x) + { + // Workaround: + // Assertion fails if empty. + // MFC document is wrong. + #if !defined(NDEBUG) + if (x.GetCount() == 0) + return Iterator(x, 0); + #endif + + return Iterator(x, x.PGetFirstAssoc()); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return Iterator(x, 0); + } + }; + + +#endif // !defined(BOOST_RANGE_MFC_NO_CPAIR) + + + // maps + // + + template< > + struct customization< ::CMapPtrToWord > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef void *key_t; + typedef WORD mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CMapPtrToPtr > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef void *key_t; + typedef void *mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CMapStringToOb > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef ::CString key_t; + typedef ::CObject *mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CMapStringToPtr > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef ::CString key_t; + typedef void *mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CMapStringToString > : + #if !defined(BOOST_RANGE_MFC_NO_CPAIR) + mfc_cpair_map_functions + #else + mfc_map_functions + #endif + { + template< class X > + struct meta + { + #if !defined(BOOST_RANGE_MFC_NO_CPAIR) + typedef typename X::CPair pair_t; + + typedef mfc_cpair_map_iterator mutable_iterator; + typedef mfc_cpair_map_iterator const_iterator; + #else + typedef ::CString key_t; + typedef ::CString mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + #endif + }; + }; + + + template< > + struct customization< ::CMapWordToOb > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef WORD key_t; + typedef ::CObject *mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + template< > + struct customization< ::CMapWordToPtr > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef WORD key_t; + typedef void *mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + // templates + // + + template< class Type, class ArgType > + struct customization< ::CArray > : + array_functions + { + template< class X > + struct meta + { + typedef Type val_t; + + typedef val_t *mutable_iterator; + typedef val_t const *const_iterator; + }; + }; + + + template< class Type, class ArgType > + struct customization< ::CList > : + list_functions + { + template< class X > + struct meta + { + typedef Type val_t; + + typedef list_iterator mutable_iterator; + #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + typedef list_iterator const_iterator; + #else + typedef list_iterator const_iterator; + #endif + }; + }; + + + template< class Key, class ArgKey, class Mapped, class ArgMapped > + struct customization< ::CMap > : + #if !defined(BOOST_RANGE_MFC_NO_CPAIR) + mfc_cpair_map_functions + #else + mfc_map_functions + #endif + { + template< class X > + struct meta + { + #if !defined(BOOST_RANGE_MFC_NO_CPAIR) + typedef typename X::CPair pair_t; + + typedef mfc_cpair_map_iterator mutable_iterator; + typedef mfc_cpair_map_iterator const_iterator; + #else + typedef Key key_t; + typedef Mapped mapped_t; + + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + #endif + }; + }; + + + template< class BaseClass, class PtrType > + struct customization< ::CTypedPtrArray > + { + template< class X > + struct fun + { + typedef typename remove_pointer::type val_t; + + typedef typename mpl::if_< is_const, + val_t const, + val_t + >::type val_t_; + + typedef val_t_ * const result_type; + + template< class PtrType_ > + result_type operator()(PtrType_ p) const + { + return static_cast(p); + } + }; + + template< class X > + struct meta + { + typedef typename compatible_mutable_iterator::type miter_t; + typedef typename range_const_iterator::type citer_t; + + typedef transform_iterator, miter_t> mutable_iterator; + typedef transform_iterator, citer_t> const_iterator; + }; + + template< class Iterator, class X > + Iterator begin(X& x) + { + return Iterator(boost::begin(x), fun()); + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return Iterator(boost::end(x), fun()); + } + }; + + + template< class BaseClass, class PtrType > + struct customization< ::CTypedPtrList > : + list_functions + { + template< class X > + struct meta + { + typedef typename remove_pointer::type val_t; + + // not l-value + typedef list_iterator mutable_iterator; + typedef list_iterator const_iterator; + }; + }; + + + template< class BaseClass, class KeyPtrType, class MappedPtrType > + struct customization< ::CTypedPtrMap > : + mfc_map_functions + { + template< class X > + struct meta + { + typedef mfc_map_iterator mutable_iterator; + typedef mutable_iterator const_iterator; + }; + }; + + + // strings + // + +#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING) + + template< > + struct customization< ::CString > + { + template< class X > + struct meta + { + // LPTSTR/LPCTSTR is not always defined in . + typedef TCHAR *mutable_iterator; + typedef TCHAR const *const_iterator; + }; + + template< class Iterator, class X > + typename mutable_::type begin(X& x) + { + return x.GetBuffer(0); + } + + template< class Iterator, class X > + Iterator begin(X const& x) + { + return x; + } + + template< class Iterator, class X > + Iterator end(X& x) + { + return begin(x) + x.GetLength(); + } + }; + +#endif // defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING) + + +} } // namespace boost::range_detail_microsoft + + + + +// range customizations +// + + +// arrays +// +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CByteArray +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CDWordArray +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CStringArray +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CUIntArray +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CWordArray +) + + +// lists +// +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CObList +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CPtrList +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CStringList +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CObArray +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CPtrArray +) + + +// maps +// +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapPtrToWord +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapPtrToPtr +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapStringToOb +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapStringToPtr +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapStringToString +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapWordToOb +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMapWordToPtr +) + + +// templates +// +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CArray, 2 +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CList, 2 +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CMap, 4 +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CTypedPtrArray, 2 +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CTypedPtrList, 2 +) + +BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CTypedPtrMap, 3 +) + + +// strings +// +#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING) + + BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE( + boost::range_detail_microsoft::using_type_as_tag, + BOOST_PP_NIL, CString + ) + +#endif + + + + +#endif From 4db083cd6dd8675f83503ab172eef00b4e44e3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 23 Oct 2007 20:28:52 +0000 Subject: [PATCH 28/92] Shunsuke Sogame's MFC/ATL docs and tests [SVN r40381] --- doc/mfc_atl.html | 313 +++++++++++++++++++ doc/mfc_atl.rst | 232 ++++++++++++++ test/atl.cpp | 623 +++++++++++++++++++++++++++++++++++++ test/mfc.cpp | 789 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 1892 insertions(+), 65 deletions(-) create mode 100644 doc/mfc_atl.html create mode 100644 doc/mfc_atl.rst create mode 100644 test/atl.cpp diff --git a/doc/mfc_atl.html b/doc/mfc_atl.html new file mode 100644 index 0000000..5717cc8 --- /dev/null +++ b/doc/mfc_atl.html @@ -0,0 +1,313 @@ + + + + + + +Boost Range MFC/ATL Extension + + + + + + +

+

Boost Range MFC/ATL Extension

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

Overview

+

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

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

Requirements

+ +
+
+

MFC Ranges

+

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

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

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

+
+
+

ATL Ranges

+

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

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

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

+
+
+

const Ranges

+

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

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

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

+
+ +
+ + + diff --git a/doc/mfc_atl.rst b/doc/mfc_atl.rst new file mode 100644 index 0000000..3dcd8fe --- /dev/null +++ b/doc/mfc_atl.rst @@ -0,0 +1,232 @@ + +++++++++++++++++++++++++++++++++ + |Boost| Range MFC/ATL Extension +++++++++++++++++++++++++++++++++ + +.. |Boost| image:: http://www.boost.org/libs/ptr_container/doc/boost.png + + + +:Author: Shunsuke Sogame +:Contact: mb2act@yahoo.co.jp +:date: 26th of May 2006 +:copyright: Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__). + +__ http://www.boost.org/LICENSE_1_0.txt + + + +======== +Overview +======== + +Boost.Range MFC/ATL Extension provides `Boost.Range`_ support for MFC/ATL collection and string types. + + +.. parsed-literal:: + + CTypedPtrArray \*> myArray; + ... + BOOST_FOREACH (CList \*theList, myArray) + { + BOOST_FOREACH (CString& str, \*theList) + { + boost::to_upper(str); + std::sort(boost::begin(str), boost::end(str)); + ... + } + } + + + +* `Requirements`_ +* `MFC Ranges`_ +* `ATL Ranges`_ +* `const Ranges`_ +* `References`_ + + + +============ +Requirements +============ + +- `Boost C++ Libraries Version 1.34.0`__ or later (no compilation required) +- Visual C++ 7.1 or Visual C++ 8.0 + +__ Boost_ + + + +========== +MFC Ranges +========== + +If the ```` 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. + + +============================= ================== ======================================= +``Range`` Traversal Category ``range_reference::type`` +============================= ================== ======================================= +``CArray`` Random Access ``T&`` +----------------------------- ------------------ --------------------------------------- +``CList`` Bidirectional ``T&`` +----------------------------- ------------------ --------------------------------------- +``CMap`` Forward ``Range::CPair&`` +----------------------------- ------------------ --------------------------------------- +``CTypedPtrArray`` Random Access ``T* const`` +----------------------------- ------------------ --------------------------------------- +``CTypedPtrList`` Bidirectional ``T* const`` +----------------------------- ------------------ --------------------------------------- +``CTypedPtrMap`` Forward ``std::pair const`` +----------------------------- ------------------ --------------------------------------- +``CByteArray`` Random Access ``BYTE&`` +----------------------------- ------------------ --------------------------------------- +``CDWordArray`` Random Access ``DWORD&`` +----------------------------- ------------------ --------------------------------------- +``CObArray`` Random Access ``CObject* &`` +----------------------------- ------------------ --------------------------------------- +``CPtrArray`` Random Access ``void* &`` +----------------------------- ------------------ --------------------------------------- +``CStringArray`` Random Access ``CString&`` +----------------------------- ------------------ --------------------------------------- +``CUIntArray`` Random Access ``UINT&`` +----------------------------- ------------------ --------------------------------------- +``CWordArray`` Random Access ``WORD&`` +----------------------------- ------------------ --------------------------------------- +``CObList`` Bidirectional ``CObject* &`` +----------------------------- ------------------ --------------------------------------- +``CPtrList`` Bidirectional ``void* &`` +----------------------------- ------------------ --------------------------------------- +``CStringList`` Bidirectional ``CString&`` +----------------------------- ------------------ --------------------------------------- +``CMapPtrToWord`` Forward ``std::pair const`` +----------------------------- ------------------ --------------------------------------- +``CMapPtrToPtr`` Forward ``std::pair const`` +----------------------------- ------------------ --------------------------------------- +``CMapStringToOb`` Forward ``std::pair const`` +----------------------------- ------------------ --------------------------------------- +``CMapStringToString`` Forward ``Range::CPair&`` +----------------------------- ------------------ --------------------------------------- +``CMapWordToOb`` Forward ``std::pair const`` +----------------------------- ------------------ --------------------------------------- +``CMapWordToPtr`` Forward ``std::pair const`` +============================= ================== ======================================= + + +Other `Boost.Range`_ metafunctions are defined by the following. +Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference::type``. +``range_value::type`` is the same as ``remove_reference::type>::type``, +``range_difference::type`` is the same as ``std::ptrdiff_t``, and +``range_pointer::type`` is the same as ``add_pointer::type>::type``. +As for ``const Range``, see `const Ranges`_. + + + +========== +ATL Ranges +========== + +If the ```` 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. + + +============================= ================== ======================================= +``Range`` Traversal Category ``range_reference::type`` +============================= ================== ======================================= +``CAtlArray`` Random Access ``E&`` +----------------------------- ------------------ --------------------------------------- +``CAutoPtrArray`` Random Access ``E&`` +----------------------------- ------------------ --------------------------------------- +``CInterfaceArray`` Random Access ``CComQIPtr&`` +----------------------------- ------------------ --------------------------------------- +``CAtlList`` Bidirectional ``E&`` +----------------------------- ------------------ --------------------------------------- +``CAutoPtrList`` Bidirectional ``E&`` +----------------------------- ------------------ --------------------------------------- +``CHeapPtrList`` Bidirectional ``E&`` +----------------------------- ------------------ --------------------------------------- +``CInterfaceList`` Bidirectional ``CComQIPtr&`` +----------------------------- ------------------ --------------------------------------- +``CAtlMap`` Forward ``Range::CPair&`` +----------------------------- ------------------ --------------------------------------- +``CRBTree`` Bidirectional ``Range::CPair&`` +----------------------------- ------------------ --------------------------------------- +``CRBMap`` Bidirectional ``Range::CPair&`` +----------------------------- ------------------ --------------------------------------- +``CRBMultiMap`` Bidirectional ``Range::CPair&`` +----------------------------- ------------------ --------------------------------------- +``CSimpleStringT`` Random Access ``B&`` +----------------------------- ------------------ --------------------------------------- +``CStringT`` Random Access ``B&`` +----------------------------- ------------------ --------------------------------------- +``CFixedStringT`` Random Access ``range_reference::type`` +----------------------------- ------------------ --------------------------------------- +``CStringT`` Random Access ``B&`` +----------------------------- ------------------ --------------------------------------- +``CComBSTR`` Random Access ``OLECHAR&`` +----------------------------- ------------------ --------------------------------------- +``CSimpleArray`` Random Access ``T&`` +============================= ================== ======================================= + + +Other `Boost.Range`_ metafunctions are defined by the following. +Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference::type``. +``range_value::type`` is the same as ``remove_reference::type``, +``range_difference::type`` is the same as ``std::ptrdiff_t``, and +``range_pointer::type`` is the same as ``add_pointer::type>::type``. +As for ``const Range``, see `const Ranges`_. + + + +============ +const Ranges +============ + +``range_reference::type`` is defined by the following algorithm. +Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference::type``. + + +.. parsed-literal:: + + if (Range is CObArray || Range is CObList) + return CObject const \* & + else if (Range is CPtrArray || Range is CPtrList) + return void const \* & + else if (there is a type X such that X& is the same as ReF) + return X const & + else if (there is a type X such that X* const is the same as ReF) + return X const \* const + else + return ReF + + +Other `Boost.Range`_ metafunctions are defined by the following. +``range_value::type`` is the same as ``range_value::type``, +``range_difference::type`` is the same as ``std::ptrdiff_t``, and +``range_pointer::type`` is the same as ``add_pointer::type>::type>::type``. + + + +========== +References +========== +- `Boost.Range`_ +- `MFC Collections`__ +- `ATL Collection Classes`__ + +__ http://msdn2.microsoft.com/en-us/library/942860sh.aspx +__ 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 + diff --git a/test/atl.cpp b/test/atl.cpp new file mode 100644 index 0000000..50905b1 --- /dev/null +++ b/test/atl.cpp @@ -0,0 +1,623 @@ + + +// Boost.Range ATL Extension +// +// Copyright Shunsuke Sogame 2005-2006. +// Distributed under 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) + + +// #include + +#include +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS +#define _ATL_NO_AUTOMATIC_NAMESPACE + +#define BOOST_LIB_NAME boost_test_exec_monitor +#include + +#define BOOST_RANGE_DETAIL_MICROSOFT_TEST +#include // can be placed first + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + + +#include // for ATL3 CSimpleArray/CSimpleValArray +#if !(_ATL_VER < 0x0700) + #include + #include + #include + #include +#endif + + +namespace brdm = boost::range_detail_microsoft; + + +#if !(_ATL_VER < 0x0700) + + +template< class ArrayT, class SampleRange > +bool test_init_auto_ptr_array(ArrayT& arr, SampleRange& sample) +{ + typedef typename boost::range_iterator::type iter_t; + + for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) { + arr.Add(*it); // moves ownership + } + + return boost::distance(arr) == boost::distance(sample); +} + + +template< class ListT, class SampleRange > +bool test_init_auto_ptr_list(ListT& lst, SampleRange& sample) +{ + typedef typename boost::range_iterator::type iter_t; + typedef typename boost::range_value::type val_t; + + for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) { + lst.AddTail(*it); // moves ownership + } + + return boost::distance(lst) == boost::distance(sample); +} + + +// Workaround: +// CRBTree provides no easy access function, but yes, it is the range! +// +template< class AtlMapT, class KeyT, class MappedT > +bool test_atl_map_has(AtlMapT& map, const KeyT& k, const MappedT m) +{ + typedef typename boost::range_iterator::type iter_t; + + for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) { + if (it->m_key == k && it->m_value == m) + return true; + } + + return false; +} + + +template< class AtlMapT, class MapT > +bool test_atl_map(AtlMapT& map, const MapT& sample) +{ + typedef typename boost::range_iterator::type iter_t; + typedef typename boost::range_const_iterator::type siter_t; + + bool result = true; + + result = result && (boost::distance(map) == boost::distance(sample)); + if (!result) + return false; + + { + for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) { + result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->m_key, it->m_value)); + } + } + + { + for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) { + result = result && (test_atl_map_has)(map, it->first, it->second); + } + } + + return result; +} + + +template< class MapT, class SampleMap > +bool test_init_atl_multimap(MapT& map, const SampleMap& sample) +{ + typedef typename boost::range_const_iterator::type iter_t; + + for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) { + map.Insert(it->first, it->second); + } + + return boost::distance(map) == boost::distance(sample); +} + + +// arrays +// + +template< class Range > +void test_CAtlArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ATL::CAtlArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class ValT, class Range > +void test_CAutoPtrArray(Range& sample) +{ + typedef ValT val_t; + + typedef ATL::CAutoPtrArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter *> >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter const*> >::value )); + + rng_t rng; + BOOST_CHECK( ::test_init_auto_ptr_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class I, class Range > +void test_CInterfaceArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ATL::CInterfaceArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter * >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter const* >::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// lists +// + +template< class Range > +void test_CAtlList(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ATL::CAtlList rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class ValT, class Range > +void test_CAutoPtrList(Range& sample) +{ + typedef ValT val_t; + + typedef ATL::CAutoPtrList rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator > > >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, boost::indirect_iterator< brdm::list_iterator const> > >::value )); + + rng_t rng; + BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class ValT, class Range > +void test_CHeapPtrList(const Range& sample) +{ + typedef ValT val_t; + + typedef ATL::CHeapPtrList rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator > > >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, boost::indirect_iterator< brdm::list_iterator const> > >::value )); + + rng_t rng; + BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class I, class Range > +void test_CInterfaceList(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ATL::CInterfaceList rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator > >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator const> >::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// strings +// + +template< class Range > +void test_CSimpleStringT(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef typename boost::mpl::if_< boost::is_same, + ATL::CAtlStringA, + ATL::CAtlStringW + >::type derived_t; + + typedef ATL::CSimpleStringT rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + derived_t drng; + rng_t& rng = drng; + BOOST_CHECK( brdm::test_init_string(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + // BOOST_CHECK( brdm::test_emptiness(rng) ); no default constructible +} + + +template< int n, class Range > +void test_CFixedStringT(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef typename boost::mpl::if_< boost::is_same, + ATL::CAtlStringA, + ATL::CAtlStringW + >::type base_t; + + typedef ATL::CFixedStringT rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_string(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CStringT(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef typename boost::mpl::if_< boost::is_same, + ATL::CAtlStringA, // == CStringT + ATL::CAtlStringW // == CStringT + >::type rng_t; + + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_string(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CStaticString(const Range& sample) +{ +#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE) + { + typedef ATL::CStaticString rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng("hello static string"); + BOOST_CHECK( *(boost::begin(rng)+4) == 'o' ); + BOOST_CHECK( *(boost::end(rng)-3) == 'i' ); + } + + { + typedef ATL::CStaticString rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng(L"hello static string"); + BOOST_CHECK( *(boost::begin(rng)+4) == L'o' ); + BOOST_CHECK( *(boost::end(rng)-3) == L'i' ); + } +#endif + + (void)sample; // unused +} + + +#endif // !(_ATL_VER < 0x0700) + + +template< class Range > +void test_CComBSTR(const Range& sample) +{ + typedef ATL::CComBSTR rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng(OLESTR("hello CComBSTR range!")); + BOOST_CHECK( brdm::test_equals(rng, std::string("hello CComBSTR range!")) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); + + (void)sample; // unused +} + + +// simples +// + +template< class Range > +void test_CSimpleArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ATL::CSimpleArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CSimpleMap(const Range& sample) +{ +#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE) + + typedef ATL::CSimpleMap rng_t; + + rng_t rng; + rng.Add(3, 3.0); + rng.Add(4, 2.0); + + BOOST_CHECK( boost::begin(rng)->get<0>() == 3.0 ); + BOOST_CHECK( (boost::end(rng)-1)->get<1>() == 2.0 ); + +#endif + + (void)sample; // unused +} + + +template< class Range > +void test_CSimpleValArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ATL::CSimpleArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// maps +// + +template< class MapT > +void test_CAtlMap(const MapT& sample) +{ + typedef typename MapT::key_type k_t; + typedef typename MapT::mapped_type m_t; + + typedef ATL::CAtlMap rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_atl_map(rng, sample) ); +} + + +template< class MapT > +void test_CRBTree(const MapT& sample) +{ + typedef typename MapT::key_type k_t; + typedef typename MapT::mapped_type m_t; + + typedef ATL::CRBMap derived_t; + typedef ATL::CRBTree rng_t; + + derived_t drng; + rng_t& rng = drng; + + boost::function_requires< boost::BidirectionalRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(drng, sample) ); + BOOST_CHECK( ::test_atl_map(rng, sample) ); +} + + +template< class MapT > +void test_CRBMap(const MapT& sample) +{ + typedef typename MapT::key_type k_t; + typedef typename MapT::mapped_type m_t; + + typedef ATL::CRBMap rng_t; + + rng_t rng; + boost::function_requires< boost::BidirectionalRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_atl_map(rng, sample) ); +} + + +template< class MapT > +void test_CRBMultiMap(const MapT& sample) +{ + typedef typename MapT::key_type k_t; + typedef typename MapT::mapped_type m_t; + + typedef ATL::CRBMultiMap rng_t; + + rng_t rng; + boost::function_requires< boost::BidirectionalRangeConcept >(); + BOOST_CHECK( ::test_init_atl_multimap(rng, sample) ); + BOOST_CHECK( ::test_atl_map(rng, sample) ); +} + + +// main test +// + +void test_atl() +{ + + // ordinary ranges + // + { + std::string sample("rebecca judy and mary whiteberry chat monchy"); +#if !(_ATL_VER < 0x0700) + ::test_CAtlArray(sample); + ::test_CAtlList(sample); + ::test_CSimpleStringT(sample); + ::test_CFixedStringT<44>(sample); + ::test_CStringT(sample); + ::test_CStaticString(sample); +#endif + ::test_CComBSTR(sample); + ::test_CSimpleArray(sample); + ::test_CSimpleMap(sample); + ::test_CSimpleValArray(sample); + } + + + { + std::wstring sample(L"rebecca judy and mary whiteberry chat monchy"); +#if !(_ATL_VER < 0x0700) + ::test_CAtlArray(sample); + ::test_CAtlList(sample); + ::test_CSimpleStringT(sample); + ::test_CFixedStringT<44>(sample); + ::test_CStringT(sample); + ::test_CStaticString(sample); +#endif + ::test_CComBSTR(sample); + ::test_CSimpleArray(sample); + ::test_CSimpleMap(sample); + ::test_CSimpleValArray(sample); + } + + // pointer ranges + // +#if !(_ATL_VER < 0x0700) + { + typedef ATL::CAutoPtr ptr_t; + ptr_t + ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)), + ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0)); + + ptr_t ptrs[8] = { + ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7 + }; + + boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8); + ::test_CAutoPtrArray(workaround); + } + + { + typedef ATL::CAutoPtr ptr_t; + ptr_t + ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)), + ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0)); + + ptr_t ptrs[8] = { + ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7 + }; + + boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8); + ::test_CAutoPtrList(workaround); + } + + { + typedef ATL::CHeapPtr ptr_t; + ptr_t ptrs[5]; { + ptrs[0].AllocateBytes(sizeof(int)); + ptrs[1].AllocateBytes(sizeof(int)); + ptrs[2].AllocateBytes(sizeof(int)); + ptrs[3].AllocateBytes(sizeof(int)); + ptrs[4].AllocateBytes(sizeof(int)); + } + + boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+5); + ::test_CHeapPtrList(workaround); + } + + + { + typedef ATL::CComQIPtr ptr_t; + ptr_t ptrs[8]; + + boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8); + ::test_CInterfaceArray(workaround); + ::test_CInterfaceList(workaround); + } +#endif + + // maps + // + { +#if !(_ATL_VER < 0x0700) + std::map sample; { + sample[0] = "hello"; + sample[1] = "range"; + sample[2] = "atl"; + sample[3] = "mfc"; + sample[4] = "collections"; + } + + ::test_CAtlMap(sample); + ::test_CRBTree(sample); + ::test_CRBMap(sample); + ::test_CRBMultiMap(sample); +#endif + } + + +} // test_atl + + +#include +using boost::unit_test::test_suite; + + +test_suite * +init_unit_test_suite(int argc, char* argv[]) +{ + test_suite *test = BOOST_TEST_SUITE("ATL Range Test Suite"); + test->add(BOOST_TEST_CASE(&test_atl)); + + (void)argc, (void)argv; // unused + return test; +} diff --git a/test/mfc.cpp b/test/mfc.cpp index c429993..29f2234 100755 --- a/test/mfc.cpp +++ b/test/mfc.cpp @@ -1,86 +1,745 @@ -// 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/ + + +// Boost.Range MFC Extension // +// Copyright Shunsuke Sogame 2005-2006. +// Distributed under 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) -#define _MSL_USING_NAMESPACE 1 -#include +#include // must be here -#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 -#include +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS +#define _ATL_NO_AUTOMATIC_NAMESPACE + +#define BOOST_LIB_NAME boost_test_exec_monitor +#include + +#define BOOST_RANGE_DETAIL_MICROSOFT_TEST +#include // can be placed first -void check_mfc() +#include +#include +// #include +#include +#include +#include +#include +#include + + +#include +#include +#include + +#if !(_ATL_VER < 0x0700) + #include + #include + #include +#endif + + +namespace brdm = boost::range_detail_microsoft; + + +// helpers +// + +template< class MfcMapT, class MapT > +bool test_mfc_map(MfcMapT& map, const MapT& sample) { - 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 ) ); - + typedef typename boost::range_iterator::type iter_t; + typedef typename boost::range_const_iterator::type siter_t; + + bool result = true; + + result = result && (boost::distance(map) == boost::distance(sample)); + if (!result) + return false; + + { + for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) { + result = result && brdm::test_find_key_and_mapped(sample, *it); + } + } + + { + for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) { + result = result && (map[it->first] == it->second); + } + } + + return result; } +template< class MfcMapT, class MapT > +bool test_mfc_cpair_map(MfcMapT& map, const MapT& sample) +{ + typedef typename boost::range_iterator::type iter_t; + typedef typename boost::range_const_iterator::type siter_t; + + bool result = true; + + result = result && (boost::distance(map) == boost::distance(sample)); + if (!result) + return false; + + { + for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) { + result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->key, it->value)); + } + } + + { + for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) { + result = result && (map[it->first] == it->second); + } + } + + return result; +} + + +// arrays +// +template< class Range > +void test_CByteArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CByteArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CDWordArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CDWordArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CObArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CObArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter >::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CPtrArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CPtrArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter >::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter >::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CStringArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CStringArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CUIntArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CUIntArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CWordArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CWordArray rng_t; + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// lists +// + +template< class Range > +void test_CObList(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CObList rng_t; + + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator >::value )); +#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#else + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#endif + + rng_t rng; + BOOST_CHECK( brdm::test_init_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CPtrList(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CPtrList rng_t; + + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator >::value )); +#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#else + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#endif + + rng_t rng; + BOOST_CHECK( brdm::test_init_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CStringList(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CStringList rng_t; + + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator >::value )); +#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#else + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#endif + + rng_t rng; + BOOST_CHECK( brdm::test_init_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// maps +// + +template< class MapT > +void test_CMapPtrToWord(const MapT& sample) +{ + typedef ::CMapPtrToWord rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_mfc_map(rng, sample) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMapPtrToPtr(const MapT& sample) +{ + typedef ::CMapPtrToPtr rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_mfc_map(rng, sample) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMapStringToOb(const MapT& sample) +{ + typedef ::CMapStringToOb rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_mfc_map(rng, sample) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMapStringToPtr(const MapT& sample) +{ + typedef ::CMapStringToPtr rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_mfc_map(rng, sample) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMapStringToString(const MapT& sample) +{ + typedef ::CMapStringToString rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); +#if !defined(BOOST_RANGE_MFC_NO_CPAIR) + BOOST_CHECK( ::test_mfc_cpair_map(rng, sample) ); +#endif + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMapWordToOb(const MapT& sample) +{ + typedef ::CMapWordToOb rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_mfc_map(rng, sample) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMapWordToPtr(const MapT& sample) +{ + typedef ::CMapWordToPtr rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); + BOOST_CHECK( ::test_mfc_map(rng, sample) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// templates +// + +template< class Range > +void test_CArray(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CArray rng_t; // An old MFC needs the second template argument. + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_array(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class Range > +void test_CList(const Range& sample) +{ + typedef typename boost::range_value::type val_t; + + typedef ::CList rng_t; + + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator >::value )); +#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF) + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#else + BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator >::value )); +#endif + + rng_t rng; + BOOST_CHECK( brdm::test_init_list(rng, sample) ); + BOOST_CHECK( brdm::test_bidirectional(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +template< class MapT > +void test_CMap(const MapT& sample) +{ + typedef typename MapT::key_type k_t; + typedef typename MapT::mapped_type m_t; + + typedef ::CMap rng_t; + + rng_t rng; + boost::function_requires< boost::ForwardRangeConcept >(); + BOOST_CHECK( brdm::test_init_map(rng, sample) ); +#if !defined(BOOST_RANGE_MFC_NO_CPAIR) + BOOST_CHECK( ::test_mfc_cpair_map(rng, sample) ); +#endif + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +void test_CTypedPtrArray() +{ + typedef ::CTypedPtrArray< ::CPtrArray, int * > rng_t; + boost::function_requires< boost::RandomAccessRangeConcept >(); + + rng_t rng; + int o1, o2, o3, o4, o5; + int *data[] = { &o1, &o2, &o3, &o4, &o5 }; + BOOST_CHECK( brdm::test_init_array(rng, boost::make_iterator_range(data, data+5)) ); + + BOOST_CHECK( *(boost::begin(rng) + 2) == &o3 ); + BOOST_CHECK( *(boost::end(rng) - 1) == &o5 ); + + // BOOST_CHECK( brdm::test_random_access(rng) ); this range is not mutable + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +void test_CTypedPtrList() +{ + typedef ::CTypedPtrList< ::CObList, ::CObList * > rng_t; + boost::function_requires< boost::BidirectionalRangeConcept >(); + + rng_t rng; + + ::CObList o1, o2, o3, o4, o5; + ::CObList *data[] = { &o1, &o2, &o3, &o4, &o5 }; + BOOST_CHECK( brdm::test_init_list(rng, data) ); + + boost::range_iterator::type it = boost::begin(rng); + std::advance(it, 1); + BOOST_CHECK( *it == &o2 ); + std::advance(it, 2); + BOOST_CHECK( *it == &o4 ); + + // BOOST_CHECK( brdm::test_bidirectional(rng) ); this range is not mutable + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +void test_CTypedPtrMap() +{ + typedef ::CTypedPtrMap< ::CMapStringToPtr, ::CString, int *> rng_t; + boost::function_requires< boost::ForwardRangeConcept >(); + + rng_t rng; + ::CString o0(_T('a')), o1(_T('c')), o2(_T('f')), o3(_T('q')), o4(_T('g')); + int d0, d1, d2, d3, d4; + std::map< ::CString, int * > data; + data[o0] = &d0, data[o1] = &d1, data[o2] = &d2, data[o3] = &d3, data[o4] = &d4; + + BOOST_CHECK( brdm::test_init_map(rng, data) ); + BOOST_CHECK( ::test_mfc_map(rng, data) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); +} + + +// strings +// +#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING) + + template< class Range > + void test_CString(const Range& sample) + { + typedef typename boost::range_value::type val_t; + + typedef ::CString rng_t; // An old MFC needs the second template argument. + BOOST_STATIC_ASSERT(( brdm::test_mutable_iter::value )); + BOOST_STATIC_ASSERT(( brdm::test_const_iter ::value )); + + rng_t rng; + BOOST_CHECK( brdm::test_init_string(rng, sample) ); + BOOST_CHECK( brdm::test_random_access(rng) ); + BOOST_CHECK( brdm::test_emptiness(rng) ); + } + +#endif + + +struct CPerson +{ + void hello_range() { }; +}; + + +void test_mfc() +{ +#if 0 + // overview + // + { + CTypedPtrArray *> myArray; + // ... + BOOST_FOREACH (CList *theList, myArray) + { + BOOST_FOREACH (CString& str, *theList) + { + boost::to_upper(str); + std::sort(boost::begin(str), boost::end(str)); + // ... + } + } + } +#endif + + // arrays + // + { + BYTE data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 }; + + ::test_CByteArray(boost::make_iterator_range(data, data+22)); + } + + { + DWORD data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 }; + + test_CDWordArray(boost::make_iterator_range(data, data+22)); + } + + { + ::CObArray o1, o2, o3, o4, o5; + ::CObject *data[] = { &o1, &o2, &o3, &o4, &o5 }; + + ::test_CObArray(boost::make_iterator_range(data, data+5)); + } + + { + ::CPtrArray o1, o2, o3, o4, o5; + void *data[] = { &o1, &o2, &o3, &o4, &o5 }; + + ::test_CPtrArray(boost::make_iterator_range(data, data+5)); + } + + { + ::CString data[] = { + ::CString(_T('0')), ::CString(_T('1')), ::CString(_T('2')), ::CString(_T('3')), + ::CString(_T('4')), ::CString(_T('5')), ::CString(_T('6')), ::CString(_T('7')) + }; + + ::test_CStringArray(boost::make_iterator_range(data, data+8)); + } + + { + ::CUIntArray rng; + UINT data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 }; + + ::test_CUIntArray(boost::make_iterator_range(data, data+22)); + } + + { + ::CWordArray rng; + WORD data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 }; + + ::test_CWordArray(boost::make_iterator_range(data, data+22)); + } + + + // lists + // + { + ::CObList rng; + ::CObList o1, o2, o3, o4, o5; + ::CObject *data[] = { &o1, &o2, &o3, &o4, &o5 }; + + ::test_CObList(boost::make_iterator_range(data, data+5)); + } + + { + ::CPtrList rng; + ::CPtrList o1, o2, o3, o4, o5; + void *data[] = { &o1, &o2, &o3, &o4, &o5 }; + + ::test_CPtrList(boost::make_iterator_range(data, data+5)); + } + + { + ::CString data[] = { + ::CString(_T('0')), ::CString(_T('1')), ::CString(_T('2')), ::CString(_T('3')), + ::CString(_T('4')), ::CString(_T('5')), ::CString(_T('6')), ::CString(_T('7')) + }; + + ::test_CStringList(boost::make_iterator_range(data, data+8)); + } + + + // maps + // + { + std::map data; + int o0, o1, o2, o3, o4; + data[&o0] = 15, data[&o1] = 14, data[&o2] = 3, data[&o3] = 6, data[&o4] = 1; + + ::test_CMapPtrToWord(data); + } + + { + std::map data; + int o0, o1, o2, o3, o4; + data[&o0] = &o3, data[&o1] = &o2, data[&o2] = &o1, data[&o3] = &o0, data[&o4] = &o4; + + ::test_CMapPtrToPtr(data); + } + + { + std::map< ::CString, CObject * > data; + CObArray o0, o1, o2, o3, o4; + data[ ::CString('0') ] = &o0, data[ ::CString('1') ] = &o1, data[ ::CString('2') ] = &o2, + data[ ::CString('3') ] = &o3, data[ ::CString('4') ] = &o4; + + ::test_CMapStringToOb(data); + } + + { + std::map< ::CString, void * > data; + CObArray o0, o1, o2, o3, o4; + data[ ::CString('0') ] = &o0, data[ ::CString('1') ] = &o1, data[ ::CString('2') ] = &o2, + data[ ::CString('3') ] = &o3, data[ ::CString('4') ] = &o4; + + ::test_CMapStringToPtr(data); + } + + { + std::map< ::CString, ::CString > data; + CString o0('a'), o1('b'), o2('c'), o3('d'), o4('e'); + data[ ::CString('0') ] = o0, data[ ::CString('1') ] = o1, data[ ::CString('2') ] = o2, + data[ ::CString('3') ] = o3, data[ ::CString('4') ] = o4; + + ::test_CMapStringToString(data); + } + + { + std::map< WORD, CObject * > data; + ::CDWordArray o0, o1, o2, o3, o4; + data[21] = &o3, data[52] = &o2, data[12] = &o1, data[76] = &o0, data[54] = &o4; + + ::test_CMapWordToOb(data); + } + + { + std::map< WORD, void * > data; + ::CDWordArray o0, o1, o2, o3, o4; + data[21] = &o3, data[52] = &o2, data[12] = &o1, data[76] = &o0, data[54] = &o4; + + ::test_CMapWordToPtr(data); + } + + // templates + // + { + std::string data("0987654321qwertyuiop"); + ::test_CArray(data); + ::test_CList(data); + } + + { + std::wstring data(L"asdfghjklzxcvbnm"); + ::test_CArray(data); + ::test_CList(data); + } + + { + std::map< int, std::string > data; + data[0] = "abcde", data[1] = "ajfie", data[2] = "lij", data[3] = "abc", data[4] = "ioiu"; + + ::test_CMap(data); + } + + + // typed + // + { + ::test_CTypedPtrArray(); + ::test_CTypedPtrList(); + ::test_CTypedPtrMap(); + } + + + // strings + // +#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING) + { + std::string data("123456789 abcdefghijklmn"); + ::test_CString(data); + } +#endif + + +} // test_mfc + #include using boost::unit_test::test_suite; -test_suite* init_unit_test_suite( int argc, char* argv[] ) +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 ) ); + test_suite *test = BOOST_TEST_SUITE("MFC Range Test Suite"); + test->add(BOOST_TEST_CASE(&test_mfc)); + (void)argc, (void)argv; // unused return test; } - - - - - - From 8984de1c744aa6c1312ac3395951cfef126fa2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 24 Oct 2007 15:18:22 +0000 Subject: [PATCH 29/92] roll back of ADL names [SVN r40422] --- test/extension_mechanism.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/extension_mechanism.cpp b/test/extension_mechanism.cpp index 828b5cd..2fd7929 100755 --- a/test/extension_mechanism.cpp +++ b/test/extension_mechanism.cpp @@ -57,24 +57,24 @@ namespace Foo // to be defined because X defines the proper set of // nested types. // - inline X::iterator boost_range_begin( X& x ) + inline X::iterator range_begin( X& x ) { return x.vec.begin(); } - inline X::const_iterator boost_range_begin( const X& x ) + inline X::const_iterator range_begin( const X& x ) { return x.vec.begin(); } - inline X::iterator boost_range_end( X& x ) + inline X::iterator range_end( X& x ) { return x.vec.end(); } - inline X::const_iterator boost_range_end( const X& x ) + inline X::const_iterator range_end( const X& x ) { return x.vec.end(); } From 82768af3d2f06a49a0774f20ce078313e2c94350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 24 Oct 2007 15:19:16 +0000 Subject: [PATCH 30/92] roll-back of ADL names [SVN r40423] --- include/boost/range/begin.hpp | 14 +++++++------- include/boost/range/detail/microsoft.hpp | 4 ++-- include/boost/range/end.hpp | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp index 2f2cb3b..e8251c9 100755 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -39,7 +39,7 @@ namespace range_detail template< typename C > inline BOOST_DEDUCED_TYPENAME range_iterator::type - boost_range_begin( C& c ) + range_begin( C& c ) { return c.begin(); } @@ -49,13 +49,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator boost_range_begin( const std::pair& p ) + inline Iterator range_begin( const std::pair& p ) { return p.first; } template< typename Iterator > - inline Iterator boost_range_begin( std::pair& p ) + inline Iterator range_begin( std::pair& p ) { return p.first; } @@ -68,13 +68,13 @@ namespace range_detail // May this be discarded? Or is it needed for bad compilers? // template< typename T, std::size_t sz > - inline const T* boost_range_begin( const T (&array)[sz] ) + inline const T* range_begin( const T (&array)[sz] ) { return array; } template< typename T, std::size_t sz > - inline T* boost_range_begin( T (&array)[sz] ) + inline T* range_begin( T (&array)[sz] ) { return array; } @@ -95,7 +95,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( T& r ) /**/ using namespace range_detail; #endif - return boost_range_begin( r ); + return range_begin( r ); } template< class T > @@ -106,7 +106,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( const T& r ) /**/ using namespace range_detail; #endif - return boost_range_begin( r ); + return range_begin( r ); } } // namespace boost diff --git a/include/boost/range/detail/microsoft.hpp b/include/boost/range/detail/microsoft.hpp index 6dfe1ca..2c4b1ed 100644 --- a/include/boost/range/detail/microsoft.hpp +++ b/include/boost/range/detail/microsoft.hpp @@ -30,8 +30,8 @@ #define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end #else #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator - #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin boost_range_begin - #define BOOST_RANGE_DETAIL_MICROSOFT_range_end boost_range_end + #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin + #define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end #endif diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp index 59bae67..be2f495 100755 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -40,7 +40,7 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename C > inline BOOST_DEDUCED_TYPENAME range_iterator::type - boost_range_end( C& c ) + range_end( C& c ) { return c.end(); } @@ -50,13 +50,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator boost_range_end( const std::pair& p ) + inline Iterator range_end( const std::pair& p ) { return p.second; } template< typename Iterator > - inline Iterator boost_range_end( std::pair& p ) + inline Iterator range_end( std::pair& p ) { return p.second; } @@ -66,13 +66,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename T, std::size_t sz > - inline const T* boost_range_end( const T (&array)[sz] ) + inline const T* range_end( const T (&array)[sz] ) { return range_detail::array_end( array ); } template< typename T, std::size_t sz > - inline T* boost_range_end( T (&array)[sz] ) + inline T* range_end( T (&array)[sz] ) { return range_detail::array_end( array ); } @@ -91,7 +91,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type end( T& r ) /**/ using namespace range_detail; #endif - return boost_range_end( r ); + return range_end( r ); } template< class T > @@ -102,7 +102,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type end( const T& r ) /**/ using namespace range_detail; #endif - return boost_range_end( r ); + return range_end( r ); } } // namespace 'boost' From 336c12b60f1e457333addbd2c575abe6e80c6a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 24 Oct 2007 15:53:54 +0000 Subject: [PATCH 31/92] removed deprecated mfc stuff [SVN r40425] --- include/boost/range/detail/mfc/carray.hpp | 97 ---------------------- include/boost/range/detail/mfc/cstring.hpp | 92 -------------------- 2 files changed, 189 deletions(-) delete mode 100755 include/boost/range/detail/mfc/carray.hpp delete mode 100755 include/boost/range/detail/mfc/cstring.hpp diff --git a/include/boost/range/detail/mfc/carray.hpp b/include/boost/range/detail/mfc/carray.hpp deleted file mode 100755 index 71ab5cb..0000000 --- a/include/boost/range/detail/mfc/carray.hpp +++ /dev/null @@ -1,97 +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/ -// - -#if !defined( BOOST_RANGE_DETAIL_MFC_CARRAY_HPP ) && defined( BOOST_RANGE_ENABLE_MCF_CARRAY ) -#define BOOST_RANGE_DETAIL_MFC_CARRAY_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include // for CArray -#include -#include - -namespace boost -{ - template< class T, class U > - struct range_iterator< CArray > - { - typedef T* type; - }; - - // - // Why is this needed?!? - // - template< class T, class U > - struct range_iterator< const CArray > - { - typedef T* type; - }; - - template< class T, class U > - struct range_const_iterator< CArray > - { - typedef const T* type; - }; - - template< class T, class U > - struct range_difference< CArray > - { - typedef std::ptrdiff_t type; - }; - - template< class T, class U > - struct range_size< CArray > - { - typedef int type; - }; - - template< class T, class U > - struct range_value< CArray > - { - typedef T type; - }; - - template< class T, class U > - T* boost_range_begin( CArray& r ) - { - return r.GetData(); - } - - template< class T, class U > - const T* boost_range_begin( const CArray& r ) - { - return r.GetData(); - } - - template< class T, class U > - int boost_range_size( const CArray& r ) - { - return r.GetSize(); - } - - template< class T, class U > - T* boost_range_end( CArray& r ) - { - return boost_range_begin( r ) + boost_range_size( r ); - } - - template< class T, class U > - const T* boost_range_end( const CArray& r ) - { - return boost_range_begin( r ) + boost_range_size( r ); - } - - // default 'empty()' ok - -} // namespace 'boost' - -#endif diff --git a/include/boost/range/detail/mfc/cstring.hpp b/include/boost/range/detail/mfc/cstring.hpp deleted file mode 100755 index ccb0745..0000000 --- a/include/boost/range/detail/mfc/cstring.hpp +++ /dev/null @@ -1,92 +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/ -// - -#if !defined(BOOST_RANGE_DETAIL_MFC_CSTRING_HPP) && defined(BOOST_RANGE_ENABLE_MFC) -#define BOOST_RANGE_DETAIL_MFC_CSTRING_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include // for CString -#include -#include - -namespace boost -{ - template<> - struct range_iterator< CString > - { - typedef TCHAR* type; - }; - - // - // Why is this needed?!? - // - template<> - struct range_iterator< const CString > - { - typedef TCHAR* type; - }; - - template<> - struct range_const_iterator< CString > - { - typedef const TCHAR* type; - }; - - template<> - struct range_difference< CString > - { - typedef std::ptrdiff_t type; - }; - - template<> - struct range_size< CString > - { - typedef int type; - }; - - template<> - struct range_value< CString > - { - typedef TCHAR type; - }; - - TCHAR* boost_range_begin( CString& r ) - { - return r.GetBuffer(0); - } - - const TCHAR* boost_range_begin( const CString& r ) - { - return (LPCTSTR)r; - } - - int boost_range_size( const CString& r ) - { - return r.GetLength(); - } - - TCHAR* boost_range_end( CString& r ) - { - return boost_range_begin( r ) + boost_range_size( r ); - } - - const TCHAR* range_adl_end( const CString& r ) - { - return boost_range_begin( r ) + boost_range_size( r ); - } - - // default 'empty()' ok - -} // namespace 'boost' - -#endif From 01826978d63f2d8a87b6ba5b40170205ec101820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 27 Oct 2007 15:57:20 +0000 Subject: [PATCH 32/92] cleaned up deprecated headers [SVN r40506] --- .../boost/range/const_reverse_iterator.hpp | 32 ------------------ include/boost/range/metafunctions.hpp | 3 -- include/boost/range/result_iterator.hpp | 33 ------------------- .../boost/range/reverse_result_iterator.hpp | 32 ------------------ 4 files changed, 100 deletions(-) delete mode 100755 include/boost/range/const_reverse_iterator.hpp delete mode 100755 include/boost/range/result_iterator.hpp delete mode 100755 include/boost/range/reverse_result_iterator.hpp diff --git a/include/boost/range/const_reverse_iterator.hpp b/include/boost/range/const_reverse_iterator.hpp deleted file mode 100755 index 215bcc7..0000000 --- a/include/boost/range/const_reverse_iterator.hpp +++ /dev/null @@ -1,32 +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/ -// - -#ifndef BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP -#define BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include - -namespace boost -{ - // - // This interface is deprecated, use range_reverse_iterator - // - - template< typename C > - struct range_const_reverse_iterator : range_reverse_iterator - { }; - -} // namespace boost - -#endif diff --git a/include/boost/range/metafunctions.hpp b/include/boost/range/metafunctions.hpp index 5b25a8f..1ce7f85 100755 --- a/include/boost/range/metafunctions.hpp +++ b/include/boost/range/metafunctions.hpp @@ -16,10 +16,7 @@ #endif #include -#include #include -#include -#include #include #include #include diff --git a/include/boost/range/result_iterator.hpp b/include/boost/range/result_iterator.hpp deleted file mode 100755 index ba09c5f..0000000 --- a/include/boost/range/result_iterator.hpp +++ /dev/null @@ -1,33 +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/ -// - -#ifndef BOOST_RANGE_RESULT_ITERATOR_HPP -#define BOOST_RANGE_RESULT_ITERATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include - -namespace boost -{ - // - // This interface is deprecated, use range_iterator - // - - template< typename C > - struct range_result_iterator : range_iterator - { }; - -} // namespace boost - - -#endif diff --git a/include/boost/range/reverse_result_iterator.hpp b/include/boost/range/reverse_result_iterator.hpp deleted file mode 100755 index 62bf135..0000000 --- a/include/boost/range/reverse_result_iterator.hpp +++ /dev/null @@ -1,32 +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/ -// - -#ifndef BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP -#define BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include - -namespace boost -{ - // - // This interface is deprecated, use range_reverse_iterator - // - - template< typename C > - struct range_reverse_result_iterator : range_reverse_iterator - { }; - -} // namespace boost - -#endif From f6e555dda333202f4e83c0e4f0ee0a9991933374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 27 Oct 2007 15:57:56 +0000 Subject: [PATCH 33/92] updated example to new syntax [SVN r40507] --- test/algorithm_example.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/algorithm_example.cpp b/test/algorithm_example.cpp index 3bfb71f..d14a597 100755 --- a/test/algorithm_example.cpp +++ b/test/algorithm_example.cpp @@ -37,7 +37,7 @@ namespace } template< typename Range, typename T > - inline typename boost::range_const_iterator::type + inline typename boost::range_iterator::type find( const Range& c, const T& value ) { return std::find( boost::begin( c ), boost::end( c ), value ); @@ -47,7 +47,7 @@ namespace // replace first value and return its index // template< class Range, class T > - inline typename boost::range_size::type + inline typename boost::range_difference::type my_generic_replace( Range& c, const T& value, const T& replacement ) { typename boost::range_iterator::type found = find( c, value ); From 4767db522b0ea7a1a3033568ed35b36c88a7aa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 27 Oct 2007 15:58:22 +0000 Subject: [PATCH 34/92] first update ... more to come [SVN r40508] --- doc/Jamfile.v2 | 12 +- doc/boost_range.html | 1208 ++++++++++++++++++++-------------------- doc/headers.html | 54 +- doc/intro.html | 20 +- doc/utility_class.html | 6 +- 5 files changed, 656 insertions(+), 644 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 4f7b44b..0fafdd7 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -2,7 +2,7 @@ use-project boost : $(BOOST_ROOT) ; -#import boostbook : boostbook ; +import boostbook : boostbook ; import quickbook ; xml boost_range : boost_range.qbk ; @@ -11,8 +11,12 @@ boostbook standalone : boost_range : - generate.section.toc.level=4 - chunk.first.sections=7 - toc.section.depth=10 + toc.max.depth=2 + toc.section.depth=4 + chunk.section.depth=2 + +# generate.section.toc.level=4 +# chunk.first.sections=7 +# toc.section.depth=10 ; diff --git a/doc/boost_range.html b/doc/boost_range.html index 303f9d6..e652436 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -1,86 +1,83 @@ - - Boost.Range Reference - - - - - - - - - -


- Boost.Range -

-
-

Synopsis and Reference -

- -
- -

Overview

-

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

    -
  • - standard-like containers -
  • - std::pair<iterator,iterator> -
  • - null terminated strings (this includes char[],wchar_t[], - char*, and wchar_t*) -

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

    -
  • - built-in arrays -
  • -
- 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

-

-

+    
+        Boost.Range Reference 
+        
+        
+    
+    
+        
+            
+                
+                
+            
+        


+ Boost.Range +

+
+

Synopsis and Reference +

+ +
+ +

Overview

+

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

    +
  • + standard-like containers +
  • + std::pair<iterator,iterator> +
  • + built-in arrays +
  • +
+ 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;
+    struct range_value;
+  
+    template< class T >
+    struct range_pointer;
     
+    template< class T >
+    struct range_category;
+
     //
     // Forward Range metafunctions
     //
@@ -89,10 +86,6 @@ class=identifier>range_const_iterator;
     struct range_difference;
     
-    template< class T >
-    struct range_size;
-    
     //
     // Bidirectional Range metafunctions
     //
@@ -102,24 +95,14 @@ class=identifier>range_size;
 href="#range_reverse_iterator">range_reverse_iterator;
 
-    template< class T >
-    struct range_const_reverse_iterator;
-    
     //
-    // Special metafunctions
+    // Random Access Range metafunctions
     //
     
     template< class T >
-    struct range_result_iterator;
-                 
-    template< class T >
-    struct range_reverse_result_iterator;
-
+    struct range_size;
+    
     //
     // Single Pass Range functions
     //
@@ -129,7 +112,7 @@ class=identifier>range_reverse_result_iterator;
     begin( T& c );
     
     template< class T >
-    typename range_const_iterator<T>::type
+    typename range_iterator<T>::type
     begin( const T& c );
         
     template< class T >
@@ -137,7 +120,7 @@ class=identifier>range_reverse_result_iterator;
     end( T& c );
                       
     template< class T >
-    typename range_const_iterator<T>::type
+    typename range_iterator<T>::type
     end( const T& c );
     
     template< class T >
@@ -149,8 +132,8 @@ class=identifier>range_reverse_result_iterator;
     //
     
     template< class T >
-    typename range_size<T>::type
-    size( const T& c );
+    typename range_difference<T>::type
+    distance( const T& c );
                             
     //
     // Bidirectional Range functions
@@ -161,7 +144,7 @@ class=identifier>range_reverse_result_iterator;
     rbegin( T& c );
     
     template< class T >
-    typename range_const_reverse_iterator<T>::type
+    typename range_reverse_iterator<T>::type
     rbegin( const T& c );
         
     template< class T >
@@ -169,535 +152,544 @@ class=identifier>range_reverse_result_iterator;
     rend( T& c );
                       
     template< class T >
-    typename range_const_reverse_iterator<T>::type
+    typename range_reverse_iterator<T>::type
     rend( const T& c );
     
+	               
+    //
+    // Random Access Range functions
+    //
+    
+    template< class T >
+    typename range_size<T>::type
+    size( const T& c );
+	
     //
     // Special const Range functions
     // 
     
     template< class T >
-    typename range_const_iterator<T>::type 
+    typename range_iterator<const T>::type 
     const_begin( const T& r );
     
     template< class T >
-    typename range_const_iterator<T>::type 
+    typename range_iterator<const T>::type 
     const_end( const T& r );
     
     template< class T >
-    typename range_const_reverse_iterator<T>::type 
+    typename range_reverse_iterator<const T>::type 
     const_rbegin( const T& r );
     
     template< class T >
-    typename range_const_reverse_iterator<T>::type 
+    typename range_reverse_iterator<const 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

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Expression - Return type - Complexity
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

-

- - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- Expression - Return type - Returns - Complexity
begin(x)range_result_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
- t.begin() otherwise +

+ +

Semantics

+

notation

+

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

+

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

+

Metafunctions

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Expression + Return type + Complexity
range_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

+

+ + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ Expression + Return type + Returns + Complexity
begin(x)range_result_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
+ t.begin() otherwise -
constant time
end(x)range_result_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* -
- 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
- t.end() otherwise - -
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>::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
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

- +
constant time
end(x)range_result_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* +
+ 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
+ t.end() otherwise + +
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>::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
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

+ - + - -

Method 1: provide member functions and nested types

- -

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

- -

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

-

- - - - - - - - - - - - - - - - -
- Member function - Related concept
begin()Single Pass Range
end() - Single Pass Range
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 type - Related concept
iteratorSingle Pass Range
const_iteratorSingle Pass Range
size_typeForward Range
-

-

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

- -

Method 2: provide free-standing functions and specialize metafunctions

+ +

Method 1: provide member functions and nested types

+ +

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

+ +

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

+

+ + + + + + + + + + + + + + + + +
+ Member function + Related concept
begin()Single Pass Range
end() + Single Pass Range
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 type + Related concept
iteratorSingle Pass Range
const_iteratorSingle Pass Range
size_typeForward Range
+

+

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

+ +

Method 2: provide free-standing functions and specialize metafunctions

-

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

- -

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

-

- - - - - - - - - - - - - - - - -
- Function - Related concept
boost_range_begin(x)Single Pass Range
boost_range_end(x) - Single Pass Range
boost_range_size(x)Forward Range
-

-

boost_range_begin() and boost_range_end() must be - overloaded for both const and mutable reference arguments. -

- -

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

-

- - - - - - - - - - - - - - - - -
- Metafunction - Related concept
boost::range_iteratorSingle Pass Range
boost::range_const_iteratorSingle Pass Range
boost::range_sizeForward Range
-

-

- A complete example is given here: -

-
-
+        

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

+ +

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

+

+ + + + + + + + + + + + + + + + +
+ Function + Related concept
boost_range_begin(x)Single Pass Range
boost_range_end(x) + Single Pass Range
boost_range_size(x)Forward Range
+

+

boost_range_begin() and boost_range_end() must be + overloaded for both const and mutable reference arguments. +

+ +

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

+

+ + + + + + + + + + + + + + + + +
+ Metafunction + Related concept
boost::range_iteratorSingle Pass Range
boost::range_const_iteratorSingle Pass Range
boost::range_sizeForward Range
+

+

+ A complete example is given here: +

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

- (C) Copyright Thorsten Ottosen 2003-2004 -

-
-
-
-
-
-
-
-
-
-
-
-
- + +
+

+ (C) Copyright Thorsten Ottosen 2003-2004 +

+
+
+
+
+
+
+
+
+
+
+
+
+ diff --git a/doc/headers.html b/doc/headers.html index f8b12a3..1539ae8 100755 --- a/doc/headers.html +++ b/doc/headers.html @@ -49,6 +49,12 @@ range_iterator Single Pass Range + + + <boost/range/mutable_iterator.hpp> + range_mutable_iterator + Single Pass Range <boost/range/const_iterator.hpp> @@ -67,27 +73,24 @@ range_size Forward Range - - <boost/range/result_iterator.hpp> - range_result_iterator + + <boost/range/pointer.hpp> + range_pointer - + + <boost/range/category.hpp> + range_category + - + + <boost/range/reverse_iterator.hpp> range_reverse_iterator Bidirectional Range - - <boost/range/const_reverse_iterator.hpp> - range_const_reverse_iterator - Bidirectional Range - - - <boost/range/reverse_result_iterator.hpp> - range_reverse_result_iterator - - - <boost/range/begin.hpp> @@ -108,11 +111,17 @@ <boost/range/empty.hpp> empty Single Pass Range + + + <boost/range/distance.hpp> + distance + Forward Range <boost/range/size.hpp> size - Forward Range + Random Access Range + <boost/range/rbegin.hpp> @@ -130,6 +139,21 @@ Bidirectional Range + + <boost/range/as_array.hpp> + + as_array + + - + + + <boost/range/as_literal.hpp> + + as_literal + + - + + <boost/range/iterator_range.hpp>
  • - correct handling of null-terminated strings -

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

    + safe use of built-in arrays
  • -
  • - safe use of built-in arrays (for legacy code; why else would you use - built-in arrays?)
  • - Below are given a small example (the complete example can be found here - ): -

    + Below are given a small example (the complete example can be found here):
     
         //
    @@ -89,7 +81,7 @@ free-standing functions so syntactic and/or semantic differences can be removed.
         }
     
         template< class ForwardReadableRange, class T >
    -    inline typename boost::range_const_iterator< inline typename boost::range_iterator< const ForwardReadableRange >::type
         find( const ForwardReadableRange& c, const T& value )
         {
    @@ -100,7 +92,7 @@ class=identifier>ForwardReadableRange >::template< class ForwardReadableWriteableRange, class T >
    -    inline typename boost::range_size< ForwardReadableWriteableRange >::type
    +    inline typename boost::range_difference< ForwardReadableWriteableRange >::type
         my_generic_replace( ForwardReadableWriteableRange& c, const T& value, const T& replacement )
         {
            typename boost::range_iterator< ForwardReadableWriteableRange >::type found = find( c, value );
    @@ -146,7 +138,7 @@ Notice that we have to
     
         

    - (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 33c95ae..57bf5dc 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -173,11 +173,11 @@ class=keyword>const;
    ForwardTraversalIterator End ); template< class ForwardRange > - iterator_range< typename iterator_of<ForwardRange>::type > + iterator_range< typename iterator<ForwardRange>::type > make_iterator_range( ForwardRange& r ); template< class ForwardRange > - iterator_range< typename const_iterator_of<ForwardRange>::type > + iterator_range< typename const_iterator<ForwardRange>::type > make_iterator_range( const ForwardRange& r ); template< class Range > @@ -305,7 +305,7 @@ class can propagate constness since it knows what a corresponding sub_range( ForwardRange2& r ); template< class ForwardRange2 > - sub_range( const Range2& r ); + sub_range( const ForwardRange2& r ); template< class ForwardRange2 > sub_range& operator=( ForwardRange2& r ); From 3f98d69c9452606ab28d3f362f04b799d01bff3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 27 Oct 2007 22:00:47 +0000 Subject: [PATCH 35/92] added mfc/atl link [SVN r40514] --- index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 05a90d3..29af65a 100755 --- a/index.html +++ b/index.html @@ -51,7 +51,9 @@
  • Terminology and style guidelines
  • Headers
  • -
  • Examples +
  • Examples +
  • MFC/ATL mapping (courtesy of Shunsuke + Sogame)
  • Portability
  • FAQ
  • History and acknowledgment From 00e70244a5663b316e3d66e755cf5f30c7b046ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sun, 28 Oct 2007 10:11:10 +0000 Subject: [PATCH 36/92] fixes broken one from trunk ... still not finished [SVN r40520] --- include/boost/range/concepts.hpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index 2441d43..0732e26 100755 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -60,7 +60,8 @@ namespace boost { struct SinglePassRangeConcept { typedef typename range_value::type range_value; typedef typename range_iterator::type range_iterator; - typedef typename range_const_iterator::type range_const_iterator; + //typedef typename range_iterator::type range_const_iterator; + void constraints() { function_requires< @@ -80,7 +81,6 @@ namespace boost { } T a; range_iterator i; - range_const_iterator ci; bool b; }; @@ -88,7 +88,6 @@ namespace boost { template struct ForwardRangeConcept { typedef typename range_difference::type range_difference; - typedef typename range_size::type range_size; void constraints() { function_requires< @@ -99,17 +98,13 @@ namespace boost { typename range_iterator::type > >(); - s = boost::size(a); } - T a; - range_size s; }; //! Check if a type T models the BidirectionalRange range concept. template struct BidirectionalRangeConcept { typedef typename range_reverse_iterator::type range_reverse_iterator; - typedef typename range_const_reverse_iterator::type range_const_reverse_iterator; void constraints() { function_requires< @@ -131,12 +126,13 @@ namespace boost { } T a; range_reverse_iterator i; - range_const_reverse_iterator ci; }; //! Check if a type T models the RandomAccessRange range concept. template struct RandomAccessRangeConcept { + typedef typename range_size::type range_size; + void constraints() { function_requires< @@ -147,7 +143,12 @@ namespace boost { typename range_iterator::type > >(); - } + + s = boost::size(a); + } + + T a; + range_size s; }; } // namespace boost From 2e298b5e60f783cbe60cd526f68e96a61a994af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sun, 28 Oct 2007 10:11:54 +0000 Subject: [PATCH 37/92] adds test for inclusion of concept header [SVN r40521] --- test/iterator_pair.cpp | 1 + test/mfc.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp index 094a7c2..d50a1f7 100755 --- a/test/iterator_pair.cpp +++ b/test/iterator_pair.cpp @@ -15,6 +15,7 @@ # pragma warn -8057 // unused argument argc/argv in Boost.Test #endif +#include #include #include #include diff --git a/test/mfc.cpp b/test/mfc.cpp index 29f2234..7a13e8e 100755 --- a/test/mfc.cpp +++ b/test/mfc.cpp @@ -1,5 +1,3 @@ - - // Boost.Range MFC Extension // // Copyright Shunsuke Sogame 2005-2006. From 06c54ccd481fea5ba519ce719b14ab1cddcbb04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 30 Oct 2007 19:47:40 +0000 Subject: [PATCH 38/92] current version gave problem in regression ... to be updated later [SVN r40612] --- include/boost/range/concepts.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index 0732e26..5faf2de 100755 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -76,8 +76,8 @@ namespace boost { } 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; @@ -121,8 +121,8 @@ namespace boost { } void const_constraints(const T& a) { - ci = boost::rbegin(a); - ci = boost::rend(a); + //ci = boost::rbegin(a); + //ci = boost::rend(a); } T a; range_reverse_iterator i; From 68a63cab853db8bf85a05b24c90485af55b843ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 31 Oct 2007 21:48:11 +0000 Subject: [PATCH 39/92] added deprecated headers again for backward compatibility sake [SVN r40629] --- .../boost/range/const_reverse_iterator.hpp | 32 ++++++++++++++++++ include/boost/range/metafunctions.hpp | 3 ++ include/boost/range/result_iterator.hpp | 33 +++++++++++++++++++ .../boost/range/reverse_result_iterator.hpp | 32 ++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100755 include/boost/range/const_reverse_iterator.hpp create mode 100755 include/boost/range/result_iterator.hpp create mode 100755 include/boost/range/reverse_result_iterator.hpp diff --git a/include/boost/range/const_reverse_iterator.hpp b/include/boost/range/const_reverse_iterator.hpp new file mode 100755 index 0000000..215bcc7 --- /dev/null +++ b/include/boost/range/const_reverse_iterator.hpp @@ -0,0 +1,32 @@ +// 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/ +// + +#ifndef BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP +#define BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include + +namespace boost +{ + // + // This interface is deprecated, use range_reverse_iterator + // + + template< typename C > + struct range_const_reverse_iterator : range_reverse_iterator + { }; + +} // namespace boost + +#endif diff --git a/include/boost/range/metafunctions.hpp b/include/boost/range/metafunctions.hpp index 1ce7f85..5b25a8f 100755 --- a/include/boost/range/metafunctions.hpp +++ b/include/boost/range/metafunctions.hpp @@ -16,7 +16,10 @@ #endif #include +#include #include +#include +#include #include #include #include diff --git a/include/boost/range/result_iterator.hpp b/include/boost/range/result_iterator.hpp new file mode 100755 index 0000000..ba09c5f --- /dev/null +++ b/include/boost/range/result_iterator.hpp @@ -0,0 +1,33 @@ +// 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/ +// + +#ifndef BOOST_RANGE_RESULT_ITERATOR_HPP +#define BOOST_RANGE_RESULT_ITERATOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include + +namespace boost +{ + // + // This interface is deprecated, use range_iterator + // + + template< typename C > + struct range_result_iterator : range_iterator + { }; + +} // namespace boost + + +#endif diff --git a/include/boost/range/reverse_result_iterator.hpp b/include/boost/range/reverse_result_iterator.hpp new file mode 100755 index 0000000..62bf135 --- /dev/null +++ b/include/boost/range/reverse_result_iterator.hpp @@ -0,0 +1,32 @@ +// 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/ +// + +#ifndef BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP +#define BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include + +namespace boost +{ + // + // This interface is deprecated, use range_reverse_iterator + // + + template< typename C > + struct range_reverse_result_iterator : range_reverse_iterator + { }; + +} // namespace boost + +#endif From 93deddde63f533ef461a69ab6f357dc990ff90e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 9 Nov 2007 10:27:42 +0000 Subject: [PATCH 40/92] major update wrt. new range concepts [SVN r40962] --- doc/boost_range.html | 185 +++++++++---------------- 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 +-- 8 files changed, 393 insertions(+), 344 deletions(-) diff --git a/doc/boost_range.html b/doc/boost_range.html index e652436..d8d956d 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -94,14 +94,6 @@ class=identifier>range_difference; struct range_reverse_iterator; - - // - // Random Access Range metafunctions - // - - template< class T > - struct range_size; // // Single Pass Range functions @@ -112,7 +104,7 @@ class=identifier>range_size; begin( T& c ); template< class T > - typename range_iterator<T>::type + typename range_iterator<const T>::type begin( const T& c ); template< class T > @@ -120,7 +112,7 @@ class=identifier>range_size; end( T& c ); template< class T > - typename range_iterator<T>::type + typename range_iterator<const T>::type end( const T& c ); template< class T > @@ -144,7 +136,7 @@ class=identifier>range_size; rbegin( T& c ); template< class T > - typename range_reverse_iterator<T>::type + typename range_reverse_iterator<const T>::type rbegin( const T& c ); template< class T > @@ -152,11 +144,10 @@ class=identifier>range_size; rend( T& c ); template< class T > - typename range_reverse_iterator<T>::type + typename range_reverse_iterator<const T>::type rend( const T& c ); - // // Random Access Range functions // @@ -164,7 +155,7 @@ class=identifier>T& template< class T > typename range_size<T>::type size( const T& c ); - + // // Special const Range functions // @@ -247,10 +238,8 @@ class=identifier>T& range_value<X>::type - T::value_type
    - boost::iterator_value<P::first_type>::type
    - A
    - Char + boost::iterator_value<range_iterator<X>::type>::type + compile time @@ -264,7 +253,7 @@ class=identifier>T
    & - range_const_iterator<X>::type + range_iterator<const X>::type T::const_iterator
    P::first_type
    const A*
    @@ -274,20 +263,11 @@ class=identifier>T
    & 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 @@ -301,31 +281,18 @@ class=identifier>T
    & 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

    @@ -347,7 +314,7 @@ class=identifier>T& 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
    @@ -363,7 +330,7 @@ class=identifier>T& 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
    + + + + + + + + + - - + + - - + @@ -408,15 +380,15 @@ class=identifier>T& - - + - - + @@ -424,15 +396,15 @@ class=identifier>T& - - + - - + @@ -440,21 +412,22 @@ class=identifier>T& - - +
    constant timelinear if X is Char* @@ -380,27 +347,32 @@ class=identifier>T&
    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( end(x) )
    same as end(x) rend(x)range_reverse_result_iterator<X>::typerange_reverse_result_iterator<X>::type( begin(x) ) + range_reverse_iterator<X>::typerange_reverse_iterator<X>::type( begin(x) ) same as begin(x)
    const_begin(x)range_const_iterator<X>::typerange_const_iterator<X>::type( begin(x) ) + range_iterator<const X>::typerange_iterator<const X>::type( begin(x) )
    same as begin(x) const_end(x)range_const_iterator<X>::typerange_const_iterator<X>::type( end(x) ) + range_iterator<const X>::typerange_iterator<const X>::type( end(x) ) same as end(x)
    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( rbegin(x) )
    same as rbegin(x) const_rend(x)range_const_reverse_iterator<X>::typerange_const_reverse_iterator<X>::type( rend(x) ) + range_reverse_iterator<const X>::typerange_reverse_iterator<const 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. + The special const_-named functions are useful when you + want to document clearly that your code is read-only.


    Extending the library

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

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

    @@ -554,26 +519,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 +545,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 +586,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 +595,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 +613,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 +644,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 +653,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 +664,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 From 1509d5603ba1e4bfc4a8bfe832bb918da4617cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 9 Nov 2007 13:13:06 +0000 Subject: [PATCH 41/92] minor editorial issue [SVN r40964] --- index.html | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 -



    From 2605b9ee45eee0df583c6093603e1ea3c87d2b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 9 Nov 2007 13:30:57 +0000 Subject: [PATCH 42/92] update of new concepts, and replacement of range_size::type with range_difference::type throughut the library [SVN r40965] --- 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 +++--- 4 files changed, 34 insertions(+), 58 deletions(-) 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); } From 7b3857a9a81fe2f9e8deffd0ed6950463c48a8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 9 Nov 2007 13:31:43 +0000 Subject: [PATCH 43/92] minor tweaks to avoid warnings ... extension mechanism updated to follow new protocol [SVN r40966] --- test/algorithm_example.cpp | 4 ++-- test/array.cpp | 2 +- test/extension_mechanism.cpp | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) 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; From 6ac0cfe09c09ce5c6ec631129b96c6e668994725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 9 Nov 2007 15:15:28 +0000 Subject: [PATCH 44/92] improved reference [SVN r40968] --- doc/boost_range.html | 169 +++++++++++++++++++++++++++++-------------- 1 file changed, 114 insertions(+), 55 deletions(-) diff --git a/doc/boost_range.html b/doc/boost_range.html index d8d956d..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; @@ -101,23 +105,23 @@ class=identifier>range_reverse_iterator; template< class T > typename range_iterator<T>::type - begin( T& c ); + begin( T& r ); template< class T > typename range_iterator<const T>::type - begin( const T& c ); + begin( const T& r ); template< class T > typename range_iterator<T>::type - end( T& c ); + end( T& r ); template< class T > typename range_iterator<const T>::type - end( const T& c ); + end( const T& r ); template< class T > bool - empty( const T& c ); + empty( const T& r ); // // Forward Range functions @@ -125,7 +129,7 @@ class=identifier>range_reverse_iterator; template< class T > typename range_difference<T>::type - distance( const T& c ); + distance( const T& r ); // // Bidirectional Range functions @@ -133,20 +137,20 @@ class=identifier>range_reverse_iterator; template< class T > typename range_reverse_iterator<T>::type - rbegin( T& c ); + rbegin( T& r ); template< class T > typename range_reverse_iterator<const T>::type - rbegin( const T& c ); + 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<const T>::type rend( const T& c ); +class=identifier>T& r ); // // Random Access Range functions @@ -154,7 +158,7 @@ class=identifier>T& template< class T > typename range_size<T>::type - size( const T& c ); + size( const T& r ); // // Special const Range functions @@ -176,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'
  • @@ -235,20 +259,13 @@ class=identifier>T& Complexity - - - range_value<X>::type - boost::iterator_value<range_iterator<X>::type>::type - - compile time - range_iterator<X>::type T::iterator
    P::first_type
    A*
    - Char* + compile time @@ -257,7 +274,37 @@ class=identifier>T
    & 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 @@ -269,15 +316,7 @@ class=identifier>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 @@ -309,11 +348,10 @@ class=identifier>T
    & begin(x) - range_result_iterator<X>::type + range_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
    range_begin(x) if that expression would invoke a function found by ADL
    t.begin() otherwise @@ -322,29 +360,24 @@ class=identifier>T
    & end(x) - range_result_iterator<X>::type + range_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* -
    - s + sz - 1 if s is a string literal of size sz + a + sz if a is an array of size sz +
    range_end(x) if that expression would invoke a function found by ADL
    t.end() otherwise - linear if X is Char* -
    - constant time otherwise + + constant time empty(x) bool - begin(x) == end( x )
    - linear if X is Char* -
    - constant time otherwise
    + boost::begin(x) == boost::end(x)
    + constant time
    @@ -372,49 +405,71 @@ class=identifier>T
    & rbegin(x) range_reverse_iterator<X>::type - range_reverse_iterator<X>::type( end(x) ) + range_reverse_iterator<X>::type( boost::end(x) )
    - same as end(x) + constant time rend(x) range_reverse_iterator<X>::type - range_reverse_iterator<X>::type( begin(x) ) - same as begin(x) + range_reverse_iterator<X>::type( boost::begin(x) ) + constant time const_begin(x) range_iterator<const X>::type - range_iterator<const X>::type( begin(x) ) + range_iterator<const X>::type( boost::begin(x) )
    - same as begin(x) + constant time const_end(x) range_iterator<const X>::type - range_iterator<const X>::type( end(x) ) - same as end(x) + range_iterator<const X>::type( boost::end(x) ) + constant time const_rbegin(x) range_reverse_iterator<const X>::type - range_reverse_iterator<const X>::type( rbegin(x) ) + range_reverse_iterator<const X>::type( boost::rbegin(x) )
    - same as rbegin(x) + constant time const_rend(x) range_reverse_iterator<const X>::type - range_reverse_iterator<const X>::type( rend(x) ) - same as rend(x) + range_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

    @@ -422,6 +477,10 @@ class=identifier>T
    & 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

    From a2f3a45214ca4ceb11a87e34709fad93d47d67c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 17 Nov 2007 20:22:05 +0000 Subject: [PATCH 45/92] minor update of comments [SVN r41175] --- include/boost/range/begin.hpp | 5 +++++ include/boost/range/concepts.hpp | 1 - include/boost/range/end.hpp | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) 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/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(); } From ba96d075b216f080095161bfb7a097c8480cbdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 17 Nov 2007 20:22:20 +0000 Subject: [PATCH 46/92] last updates [SVN r41176] --- doc/boost_range.html | 24 ++++++++++++++++- doc/headers.html | 23 +++++++---------- doc/utility_class.html | 58 ++++++++++++++++++++++-------------------- 3 files changed, 63 insertions(+), 42 deletions(-) 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


    From dd1459f221605e63adc2e7745f922cd36c264f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 17 Nov 2007 20:44:29 +0000 Subject: [PATCH 47/92] works after local test with vc8 [SVN r41177] --- include/boost/range/detail/microsoft.hpp | 4 ---- 1 file changed, 4 deletions(-) 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 From 637dc618d19cffe1347ce3031d2177196e485566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 17 Nov 2007 21:19:13 +0000 Subject: [PATCH 48/92] iostream macro patch [SVN r41180] --- include/boost/range/iterator_range.hpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 From 2e0d7eab4abfe838a6995576e9b4b0fef0a551e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 17 Nov 2007 21:21:53 +0000 Subject: [PATCH 49/92] removed some warnings [SVN r41181] --- test/iterator_pair.cpp | 6 +++--- test/std_container.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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() ); } From 0eb365edbe727d708488990370b33eff75723a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 17 Nov 2007 21:24:16 +0000 Subject: [PATCH 50/92] macro patch [SVN r41183] --- include/boost/range/config.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 From 8085605217683ee016cf7f760d46c61e24175649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 29 Nov 2007 09:19:24 +0000 Subject: [PATCH 51/92] fixed a serious oversigt [SVN r41457] --- include/boost/range/iterator_range.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 4304ecc..31b8ea8 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -77,8 +77,8 @@ namespace boost { typedef BOOST_DEDUCED_TYPENAME boost::range_difference::type sz_type; - sz_type l_size = boost::size( l ), - r_size = boost::size( r ); + sz_type l_size = boost::distance( l ), + r_size = boost::distance( r ); if( l_size != r_size ) return false; From f65c137e736a3da22fa70b6a6f97a79e30d0029a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Mon, 3 Dec 2007 09:00:23 +0000 Subject: [PATCH 52/92] missing include [SVN r41636] --- include/boost/range/sub_range.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index 802454b..35dfb27 100755 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -11,6 +11,8 @@ #ifndef BOOST_RANGE_SUB_RANGE_HPP #define BOOST_RANGE_SUB_RANGE_HPP +#include + #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) #pragma warning( disable : 4996 ) #endif From 14a9a1906b0126d828bf164753a70b0f9815bf0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Mon, 3 Dec 2007 09:08:02 +0000 Subject: [PATCH 53/92] Ticket #1477 [SVN r41638] --- include/boost/range/detail/sizer.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/range/detail/sizer.hpp b/include/boost/range/detail/sizer.hpp index 5d75437..b4c1c91 100755 --- a/include/boost/range/detail/sizer.hpp +++ b/include/boost/range/detail/sizer.hpp @@ -25,12 +25,10 @@ namespace boost ////////////////////////////////////////////////////////////////////// template< typename T, std::size_t sz > - char& - sizer( const T BOOST_RANGE_ARRAY_REF()[sz] )[sz]; + char (& sizer( const T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz]; template< typename T, std::size_t sz > - char& - sizer( T BOOST_RANGE_ARRAY_REF()[sz] )[sz]; + char (& sizer( T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz]; } // namespace 'boost' From d31787daae612b09b1ea7cf24b7c264f1bdcab91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 12 Jan 2008 12:38:57 +0000 Subject: [PATCH 54/92] doc fixes [SVN r42693] --- doc/boost_range.html | 2 +- doc/history_ack.html | 8 ++++---- doc/intro.html | 3 +-- doc/portability.html | 2 +- doc/utility_class.html | 9 +++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/boost_range.html b/doc/boost_range.html index ace1901..ed84e1a 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -493,7 +493,7 @@ class=identifier>T
    &

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

    diff --git a/doc/history_ack.html b/doc/history_ack.html index 40ee5dc..289bfa8 100755 --- a/doc/history_ack.html +++ b/doc/history_ack.html @@ -18,10 +18,10 @@

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

    diff --git a/doc/intro.html b/doc/intro.html index 8478d3e..4ed653b 100755 --- a/doc/intro.html +++ b/doc/intro.html @@ -63,8 +63,7 @@ free-standing functions so syntactic and/or semantic differences can be removed.

    -

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

     
    diff --git a/doc/portability.html b/doc/portability.html
    index 20b1355..506d5b2 100755
    --- a/doc/portability.html
    +++ b/doc/portability.html
    @@ -35,7 +35,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_iterator and a single function definition instead of overloaded versions for const and non-const arguments. diff --git a/doc/utility_class.html b/doc/utility_class.html index f7b5535..c4afe54 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -33,11 +33,12 @@ - The iterator_range class is templated on an - Forward + The iterator_range class is templated on a Forward Traversal Iterator and should be used whenever fairly general code is needed. - The sub_range class is templated on an Forward - Range and it is less general, but a bit easier to use since its template + The sub_range class is templated on a Forward Range and it is less general, + but a bit easier to use since its template argument is easier to specify. The biggest difference is, however, that a sub_range can propagate constness because it knows what a corresponding const_iterator is.

    From 507d1e8075cde410e0339346a887fa56c217bcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sun, 13 Jan 2008 11:37:41 +0000 Subject: [PATCH 55/92] fixed #if to #ifdef [SVN r42715] --- include/boost/range/as_literal.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 72f0eb5..b0d7593 100755 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -15,7 +15,7 @@ # pragma once #endif -#if BOOST_NO_FUNCTION_TEMPLATE_ORDERING +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING #include #else @@ -116,14 +116,14 @@ namespace boost template< class Char, std::size_t sz > - inline iterator_range as_literal( const Char (&arr)[sz] ) + inline iterator_range as_literal( const Char (&arr)[sz] ) { #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 return boost::make_iterator_range( arr, arr + sz - 1 ); #else return boost::make_iterator_range( arr, arr + sz - 1 ); #endif - } + } } #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING From 73db2a05b60c0fe3b91b93219964b089e8994665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 6 Feb 2008 23:12:21 +0000 Subject: [PATCH 56/92] cleanup to pass inspection tool [SVN r43135] --- doc/Jamfile.v2 | 10 ++++++++++ doc/boost_range.html | 8 +++++++- doc/example.cpp | 10 ++++++++++ doc/examples.html | 9 ++++++++- doc/faq.html | 11 +++++++++-- doc/headers.html | 9 ++++++++- doc/history_ack.html | 9 ++++++++- doc/intro.html | 9 ++++++++- doc/portability.html | 11 +++++++++-- doc/range.html | 36 +++++++++--------------------------- doc/style.css | 11 +++++++++++ doc/style.html | 8 +++++++- doc/utility_class.html | 15 +++++++++++---- test/TODO | 1 - test/compat1.cpp | 0 15 files changed, 115 insertions(+), 42 deletions(-) delete mode 100644 test/TODO delete mode 100755 test/compat1.cpp diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 0fafdd7..bfe0908 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -1,3 +1,13 @@ +#// Boost.Range library +#// +#// Copyright Thorsten Ottosen 2003-2008. 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/ +#// + use-project boost : $(BOOST_ROOT) ; diff --git a/doc/boost_range.html b/doc/boost_range.html index ed84e1a..465bd18 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -745,7 +745,13 @@ class=identifier>T
    &

    - (C) Copyright Thorsten Ottosen 2003-2007 + © Copyright Thorsten Ottosen 2008. +

    + +

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



    diff --git a/doc/example.cpp b/doc/example.cpp index afe448f..d3dec7c 100644 --- a/doc/example.cpp +++ b/doc/example.cpp @@ -1,3 +1,13 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2008. 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 // for std::iterator_traits, std::distance() diff --git a/doc/examples.html b/doc/examples.html index 0ea235d..0d24509 100755 --- a/doc/examples.html +++ b/doc/examples.html @@ -41,9 +41,16 @@
  • array.cpp +

    - (C) Copyright Thorsten Ottosen 2003-2004 + © Copyright Thorsten Ottosen 2008. +

    + +

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


    diff --git a/doc/faq.html b/doc/faq.html index 34304ef..244df80 100755 --- a/doc/faq.html +++ b/doc/faq.html @@ -114,9 +114,16 @@ Cool indeed! -
    +

    - (C) Copyright Thorsten Ottosen 2003-2004 + © Copyright Thorsten Ottosen 2008. +

    + +

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


    diff --git a/doc/headers.html b/doc/headers.html index 69987ce..7628591 100755 --- a/doc/headers.html +++ b/doc/headers.html @@ -173,7 +173,14 @@

    - (C) Copyright Thorsten Ottosen 2003-2007 + © Copyright Thorsten Ottosen 2008. +

    + +

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


    diff --git a/doc/history_ack.html b/doc/history_ack.html index 289bfa8..3191dd0 100755 --- a/doc/history_ack.html +++ b/doc/history_ack.html @@ -61,7 +61,14 @@ C++ standard:

    - (C) Copyright Thorsten Ottosen 2003-2006 + © Copyright Thorsten Ottosen 2008. +

    + +

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


    diff --git a/doc/intro.html b/doc/intro.html index 4ed653b..9f41c72 100755 --- a/doc/intro.html +++ b/doc/intro.html @@ -135,7 +135,14 @@ Notice that we have to

    - (C) Copyright Thorsten Ottosen 2003-2007 + © Copyright Thorsten Ottosen 2008. +

    + +

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


    diff --git a/doc/portability.html b/doc/portability.html index 506d5b2..9e63978 100755 --- a/doc/portability.html +++ b/doc/portability.html @@ -73,11 +73,18 @@ href="http://boost.sourceforge.net/regression-logs/developer/range.html">here

    -
    +

    - (C) Copyright Thorsten Ottosen 2003-2004 + © Copyright Thorsten Ottosen 2008.

    +

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

    > +


    diff --git a/doc/range.html b/doc/range.html index dfe9345..b140888 100755 --- a/doc/range.html +++ b/doc/range.html @@ -352,34 +352,16 @@ href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterator

    Boost Concept Check library


    +

    + © Copyright Thorsten Ottosen 2008. +

    - - - - - - - - -
    Copyright © 2000Jeremy Siek -
    Copyright © 2004-2007Thorsten Ottosen. -
    - +

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




    diff --git a/doc/style.css b/doc/style.css index 1890b52..ce44c30 100755 --- a/doc/style.css +++ b/doc/style.css @@ -1,3 +1,14 @@ +/* +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2008. 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/ +// +*/ pre{ BORDER-RIGHT: gray 1pt solid; PADDING-RIGHT: 2pt; diff --git a/doc/style.html b/doc/style.html index 9a5617e..cd82c94 100755 --- a/doc/style.html +++ b/doc/style.html @@ -104,9 +104,15 @@

    - (C) Copyright Thorsten Ottosen 2003-2004 + © Copyright Thorsten Ottosen 2008.

    +

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




    diff --git a/doc/utility_class.html b/doc/utility_class.html index c4afe54..ea51503 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -350,10 +350,17 @@ store the result
  • -
    -

    - (C) Copyright Thorsten Ottosen 2003-2007 -

    +
    +

    + © Copyright Thorsten Ottosen 2008. +

    + +

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



    diff --git a/test/TODO b/test/TODO deleted file mode 100644 index 8b13789..0000000 --- a/test/TODO +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/compat1.cpp b/test/compat1.cpp deleted file mode 100755 index e69de29..0000000 From 428e72ed225724c4fdfca9ef5867f95279ac8415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 7 Feb 2008 14:41:04 +0000 Subject: [PATCH 57/92] iterator_range disables msvc warning 4996 [range] sub_range assignment issue [SVN r43155] --- include/boost/range/iterator_range.hpp | 13 +++++++++---- include/boost/range/sub_range.hpp | 12 ++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 31b8ea8..7dcf033 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -11,6 +11,11 @@ #ifndef BOOST_RANGE_ITERATOR_RANGE_HPP #define BOOST_RANGE_ITERATOR_RANGE_HPP +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) + #pragma warning( push ) + #pragma warning( disable : 4996 ) +#endif + // From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch. #include // Define __STL_CONFIG_H, if appropriate. #ifndef BOOST_OLD_IOSTREAMS @@ -38,10 +43,6 @@ #endif // _STLP_NO_IOSTREAMS #include -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) - #pragma warning( disable : 4996 ) -#endif - /*! \file Defines the \c iterator_class and related functions. \c iterator_range is a simple wrapper of iterator pair idiom. It provides @@ -639,5 +640,9 @@ namespace boost #undef BOOST_OLD_IOSTREAMS +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) + #pragma warning( pop ) +#endif + #endif diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index 35dfb27..d28da93 100755 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -11,12 +11,12 @@ #ifndef BOOST_RANGE_SUB_RANGE_HPP #define BOOST_RANGE_SUB_RANGE_HPP -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) + #pragma warning( push ) #pragma warning( disable : 4996 ) #endif +#include #include #include #include @@ -46,7 +46,7 @@ namespace boost sub_range() : base() { } -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) ) sub_range( const sub_range& r ) : base( static_cast( r ) ) { } @@ -163,5 +163,9 @@ namespace boost } // namespace 'boost' +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) + #pragma warning( pop ) +#endif + #endif From 8b712359a2a074139a6f9f53aaaf6529e56c706a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 7 Feb 2008 14:46:19 +0000 Subject: [PATCH 58/92] test [SVN r43156] --- test/partial_workaround.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/partial_workaround.cpp b/test/partial_workaround.cpp index 8ac6f66..76d902f 100755 --- a/test/partial_workaround.cpp +++ b/test/partial_workaround.cpp @@ -10,6 +10,8 @@ #include #include +#include +#include #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) # pragma warn -8091 // supress warning in Boost.Test @@ -30,7 +32,6 @@ #include #include -#include #include #include @@ -91,6 +92,11 @@ void check_partial_workaround() void check_partial_workaround() { + // + // test if warnings are generated + // + std::size_t s = boost::range_detail::array_size( "foo" ); + BOOST_CHECK_EQUAL( s, 4u ); } #endif From e115ac1006200bdce2a066c767b97bc3108279e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 8 Feb 2008 09:58:35 +0000 Subject: [PATCH 59/92] silence of warnings for unused arguments [SVN r43171] --- include/boost/range/detail/implementation_help.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index da086f0..ca12fa4 100755 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -25,6 +25,8 @@ namespace boost { namespace range_detail { + template + inline void boost_range_silence_warning( const T& ) { } ///////////////////////////////////////////////////////////////////// // end() help @@ -82,12 +84,14 @@ namespace boost template< class T, std::size_t sz > inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] ) { + boost_range_silence_warning( boost_range_array ); return sz; } template< class T, std::size_t sz > inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] ) { + boost_range_silence_warning( boost_range_array ); return sz; } From 94b45ef51eee837d7c5e2b819c39e8d057b7e650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 8 Feb 2008 15:25:01 +0000 Subject: [PATCH 60/92] missing ) fixed [SVN r43175] --- include/boost/range/iterator_range.hpp | 4 ++-- include/boost/range/sub_range.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 7dcf033..21e503b 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -11,7 +11,7 @@ #ifndef BOOST_RANGE_ITERATOR_RANGE_HPP #define BOOST_RANGE_ITERATOR_RANGE_HPP -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) #pragma warning( push ) #pragma warning( disable : 4996 ) #endif @@ -640,7 +640,7 @@ namespace boost #undef BOOST_OLD_IOSTREAMS -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) #pragma warning( pop ) #endif diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index d28da93..d033b14 100755 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -11,7 +11,7 @@ #ifndef BOOST_RANGE_SUB_RANGE_HPP #define BOOST_RANGE_SUB_RANGE_HPP -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) #pragma warning( push ) #pragma warning( disable : 4996 ) #endif @@ -163,7 +163,7 @@ namespace boost } // namespace 'boost' -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) #pragma warning( pop ) #endif From 405ebd8cca4c28fef1cbd7510dcb1b7aec402198 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 11 Feb 2008 03:48:41 +0000 Subject: [PATCH 61/92] include config.hpp and workaround.hpp before uses of BOOST_WORKAROUND and BOOST_MSVC [SVN r43220] --- include/boost/range/iterator_range.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 21e503b..3853ea6 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -11,13 +11,15 @@ #ifndef BOOST_RANGE_ITERATOR_RANGE_HPP #define BOOST_RANGE_ITERATOR_RANGE_HPP +#include // Define __STL_CONFIG_H, if appropriate. +#include + #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) #pragma warning( push ) #pragma warning( disable : 4996 ) #endif // From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch. -#include // Define __STL_CONFIG_H, if appropriate. #ifndef BOOST_OLD_IOSTREAMS # if defined(__STL_CONFIG_H) && \ !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ @@ -26,7 +28,6 @@ # endif #endif // #ifndef BOOST_OLD_IOSTREAMS -#include #include #include #include From 7c0d73b8cfb6f310defe11364e2f2e731c78c057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 19 Feb 2008 15:10:05 +0000 Subject: [PATCH 62/92] fixed problem with operator()() when the value_type was abstract. [SVN r43322] --- include/boost/range/iterator_range.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 3853ea6..6a85a45 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -28,11 +28,13 @@ # endif #endif // #ifndef BOOST_OLD_IOSTREAMS +#include +#include +#include #include #include #include -#include -#include +#include #include #include #ifndef _STLP_NO_IOSTREAMS @@ -165,6 +167,12 @@ namespace boost //! iterator type typedef IteratorT iterator; + private: // for return value of operator()() + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::if_< boost::is_abstract, + reference, value_type >::type abstract_value_type; + + public: iterator_range() : m_Begin( iterator() ), m_End( iterator() ) #ifndef NDEBUG , singular( true ) @@ -352,8 +360,8 @@ namespace boost // When storing transform iterators, operator[]() // fails because it returns by reference. Therefore // operator()() is provided for these cases. - // - value_type operator()( difference_type at ) const + // + abstract_value_type operator()( difference_type at ) const { BOOST_ASSERT( at >= 0 && at < size() ); return m_Begin[at]; From f117011b60400b225abd2e018cbabd3d8811abfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Mon, 5 May 2008 06:41:54 +0000 Subject: [PATCH 63/92] fix for as_literal() [SVN r45123] --- include/boost/range/as_literal.hpp | 17 ++++------------- include/boost/range/detail/as_literal.hpp | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-) mode change 100755 => 100644 include/boost/range/as_literal.hpp mode change 100755 => 100644 include/boost/range/detail/as_literal.hpp diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp old mode 100755 new mode 100644 index b0d7593..97eff15 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -8,8 +8,8 @@ // For more information, see http://www.boost.org/libs/range/ // -#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP -#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP +#ifndef BOOST_RANGE_AS_LITERAL_HPP +#define BOOST_RANGE_AS_LITERAL_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once @@ -107,22 +107,13 @@ namespace boost template< class Char, std::size_t sz > inline iterator_range as_literal( Char (&arr)[sz] ) { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 - return boost::make_iterator_range( arr, arr + sz - 1 ); -#else - return boost::make_iterator_range( arr, arr + sz - 1 ); -#endif + return range_detail::make_range( arr, range_detail::is_char_ptr(arr) ); } - template< class Char, std::size_t sz > inline iterator_range as_literal( const Char (&arr)[sz] ) { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 - return boost::make_iterator_range( arr, arr + sz - 1 ); -#else - return boost::make_iterator_range( arr, arr + sz - 1 ); -#endif + return range_detail::make_range( arr, range_detail::is_char_ptr(arr) ); } } diff --git a/include/boost/range/detail/as_literal.hpp b/include/boost/range/detail/as_literal.hpp old mode 100755 new mode 100644 index b4fd925..0bd9a15 --- a/include/boost/range/detail/as_literal.hpp +++ b/include/boost/range/detail/as_literal.hpp @@ -8,8 +8,8 @@ // For more information, see http://www.boost.org/libs/range/ // -#ifndef BOOST_RANGE_AS_LITERAL_HPP -#define BOOST_RANGE_AS_LITERAL_HPP +#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP +#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once From 36a99eb0a0c0351d1b897523f66a5d5610dc4d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Mon, 5 May 2008 06:42:30 +0000 Subject: [PATCH 64/92] test of updated as_literal() [SVN r45124] --- test/string.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) mode change 100755 => 100644 test/string.cpp diff --git a/test/string.cpp b/test/string.cpp old mode 100755 new mode 100644 index 9a2e5a8..127f70a --- a/test/string.cpp +++ b/test/string.cpp @@ -137,14 +137,7 @@ void check_char() BOOST_CHECK_EQUAL( str_end( char_s ), str_end1 ); BOOST_CHECK_EQUAL( str_empty( char_s ), (char_s == 0 || char_s[0] == char()) ); BOOST_CHECK_EQUAL( sz, std::char_traits::length( char_s ) ); -/* - BOOST_CHECK_EQUAL( str_begin( char_s2 ), char_s2 ); - std::size_t sz2 = size( char_s2 ); - const char* str_end12 = str_begin( char_s2 ) + sz; - BOOST_CHECK_EQUAL( str_end( char_s2 ), str_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( str_begin( my_string ), my_string ); range_iterator::type str_end2 = str_begin( my_string ) + str_size(my_string); range_iterator::type str_end3 = str_end(my_string); @@ -165,6 +158,20 @@ void check_char() BOOST_CHECK( find_const( as_array( my_string ), to_search ) != str_end(my_string) ); BOOST_CHECK( find_const( as_array( my_const_string ), to_search ) != str_end(my_string) ); + + // + // Test that as_literal() always scan for null terminator + // + char an_array[] = "foo\0bar"; + BOOST_CHECK_EQUAL( str_begin( an_array ), an_array ); + BOOST_CHECK_EQUAL( str_end( an_array ), an_array + 3 ); + BOOST_CHECK_EQUAL( str_size( an_array ), 3 ); + + const char a_const_array[] = "foobar\0doh"; + BOOST_CHECK_EQUAL( str_begin( a_const_array ), a_const_array ); + BOOST_CHECK_EQUAL( str_end( a_const_array ), a_const_array + 6 ); + BOOST_CHECK_EQUAL( str_size( a_const_array ), 6 ); + } @@ -172,9 +179,6 @@ void check_char() void check_string() { check_char(); -// check_char(); -// check_char(); -// check_char(); #ifndef BOOST_NO_STD_WSTRING typedef wchar_t* wchar_iterator_t; @@ -197,13 +201,7 @@ void check_string() BOOST_CHECK_EQUAL( str_end(char_ws), (str_begin( char_ws ) + sz) ); BOOST_CHECK_EQUAL( str_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( str_begin( char_ws2 ), char_ws2 ); - BOOST_CHECK_EQUAL( str_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 ) != str_end(char_ws) ); From 95d424012b165811f7c6817e6f40e039a4c941d6 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 11 May 2008 13:49:20 +0000 Subject: [PATCH 65/92] Quote href values - our tools don't support unquoted values. [SVN r45283] --- doc/intro.html | 2 +- doc/style.html | 2 +- doc/utility_class.html | 6 +++--- index.html | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) mode change 100755 => 100644 doc/intro.html mode change 100755 => 100644 doc/style.html mode change 100755 => 100644 index.html diff --git a/doc/intro.html b/doc/intro.html old mode 100755 new mode 100644 index 9f41c72..82f10dc --- a/doc/intro.html +++ b/doc/intro.html @@ -24,7 +24,7 @@ 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. + href="range.html">Ranges as much as possible.

    diff --git a/doc/style.html b/doc/style.html old mode 100755 new mode 100644 index cd82c94..4240a8c --- a/doc/style.html +++ b/doc/style.html @@ -53,7 +53,7 @@ Bidirectional Range

  • Random Access Range - Notice how we have used the categories from the new + Notice how we have used the categories from the new style iterators.

    diff --git a/doc/utility_class.html b/doc/utility_class.html index ea51503..e100859 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -27,9 +27,9 @@

    @@ -329,7 +329,7 @@ class can propagate constness since it knows what a corresponding const value_type& operator[]( difference_type at ) const; public: - // rest of interface inherited from iterator_range + // rest of interface inherited from iterator_range }; } // namespace 'boost' diff --git a/index.html b/index.html old mode 100755 new mode 100644 index 5313690..56ba4eb --- a/index.html +++ b/index.html @@ -22,7 +22,7 @@

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

    From b948d9af17c4aadb4cc0b057ea85ee86f0915e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 12 Jun 2008 10:00:54 +0000 Subject: [PATCH 66/92] fixes for problems from Trac [SVN r46345] --- include/boost/range/iterator_range.hpp | 12 +++++++----- include/boost/range/sub_range.hpp | 14 +++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) mode change 100755 => 100644 include/boost/range/iterator_range.hpp mode change 100755 => 100644 include/boost/range/sub_range.hpp diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp old mode 100755 new mode 100644 index 6a85a45..d118224 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -185,7 +185,7 @@ namespace boost m_Begin(Begin), m_End(End) #ifndef NDEBUG , singular(false) - #endif + #endif {} //! Constructor from a Range @@ -210,7 +210,7 @@ namespace boost template< class Range > iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG + #ifndef NDEBUG , singular(false) #endif {} @@ -219,7 +219,7 @@ namespace boost template< class Range > iterator_range( Range& r, iterator_range_detail::range_tag ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG + #ifndef NDEBUG , singular(false) #endif {} @@ -390,13 +390,15 @@ namespace boost bool singular; #endif - #ifndef NDEBUG public: bool is_singular() const { + #ifndef NDEBUG return singular; + #else + return false; + #endif } - #endif protected: // diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp old mode 100755 new mode 100644 index d033b14..dc66692 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include namespace boost { @@ -41,6 +43,12 @@ namespace boost 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: // for return value of front/back + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::if_< boost::is_reference, + const BOOST_DEDUCED_TYPENAME boost::remove_reference::type&, + reference >::type const_reference; public: sub_range() : base() @@ -112,7 +120,7 @@ namespace boost return base::front(); } - const value_type& front() const + const_reference front() const { return base::front(); } @@ -122,7 +130,7 @@ namespace boost return base::back(); } - const value_type& back() const + const_reference back() const { return base::back(); } @@ -132,7 +140,7 @@ namespace boost return base::operator[](sz); } - const value_type& operator[]( difference_type sz ) const + const_reference operator[]( difference_type sz ) const { return base::operator[](sz); } From dbef3564c43f4b789f26b8c8db832f0b32a5100e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 12 Jun 2008 10:54:44 +0000 Subject: [PATCH 67/92] fixes from Trac [SVN r46346] --- include/boost/range/as_literal.hpp | 7 ++++++- include/boost/range/begin.hpp | 8 ++++---- include/boost/range/end.hpp | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) mode change 100755 => 100644 include/boost/range/begin.hpp mode change 100755 => 100644 include/boost/range/end.hpp diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 97eff15..38cc9cf 100644 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -25,7 +25,9 @@ #include #include +#ifndef BOOST_NO_CWCHAR #include +#endif namespace boost { @@ -36,10 +38,12 @@ namespace boost return strlen( s ); } +#ifndef BOOST_NO_INTRINSIC_WCHAR_T inline std::size_t length( const wchar_t* s ) { return wcslen( s ); } +#endif // // Remark: the compiler cannot choose between T* and T[sz] @@ -57,7 +61,7 @@ namespace boost return true; } - +#ifndef BOOST_NO_INTRINSIC_WCHAR_T inline bool is_char_ptr( wchar_t* ) { return true; @@ -67,6 +71,7 @@ namespace boost { return true; } +#endif template< class T > inline long is_char_ptr( T /* r */ ) diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp old mode 100755 new mode 100644 index 9abf313..a4a5e10 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -73,15 +73,15 @@ namespace range_detail // May this be discarded? Or is it needed for bad compilers? // template< typename T, std::size_t sz > - inline const T* range_begin( const T (&array)[sz] ) + inline const T* range_begin( const T (&a)[sz] ) { - return array; + return a; } template< typename T, std::size_t sz > - inline T* range_begin( T (&array)[sz] ) + inline T* range_begin( T (&a)[sz] ) { - return array; + return a; } diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp old mode 100755 new mode 100644 index b777a55..3063c02 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -71,15 +71,15 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename T, std::size_t sz > - inline const T* range_end( const T (&array)[sz] ) + inline const T* range_end( const T (&a)[sz] ) { - return range_detail::array_end( array ); + return range_detail::array_end( a ); } template< typename T, std::size_t sz > - inline T* range_end( T (&array)[sz] ) + inline T* range_end( T (&a)[sz] ) { - return range_detail::array_end( array ); + return range_detail::array_end( a ); } #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ From 15a697f86b3458fe47cb201362209f450de2486b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Thu, 12 Jun 2008 12:00:57 +0000 Subject: [PATCH 68/92] new jamfile to see warnings better [SVN r46348] --- test/Jamfile.v2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b6942ca..c82a6c9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -12,9 +12,9 @@ rule range-test ( name : includes * ) { return [ run $(name).cpp /boost/test//boost_unit_test_framework/static + : : - : - : $(includes) + : gcc:"-Wall -Wunused " ] ; } From d20121bf12bc0c425a28d5b3d221ecc830577b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 24 Jun 2008 15:39:28 +0000 Subject: [PATCH 69/92] html fix [SVN r46650] --- doc/boost_range.html | 110 ++++++++++++++++++++--------------------- doc/examples.html | 8 +-- doc/faq.html | 4 +- doc/headers.html | 2 +- doc/intro.html | 2 +- doc/portability.html | 5 +- doc/range.html | 14 +++--- doc/utility_class.html | 27 +++++----- index.html | 2 +- 9 files changed, 87 insertions(+), 87 deletions(-) mode change 100755 => 100644 doc/examples.html mode change 100755 => 100644 doc/faq.html mode change 100755 => 100644 doc/headers.html mode change 100755 => 100644 doc/portability.html mode change 100755 => 100644 doc/range.html diff --git a/doc/boost_range.html b/doc/boost_range.html index 465bd18..b9fd0ca 100644 --- a/doc/boost_range.html +++ b/doc/boost_range.html @@ -152,7 +152,7 @@ class=identifier>range_reverse_iterator; rend( const T& r ); - // + // // Random Access Range functions // @@ -235,7 +235,7 @@ class=identifier>T& A[sz] a denotes an array of type A of size sz - + Char* s @@ -259,9 +259,9 @@ class=identifier>T& Complexity - - - range_iterator<X>::type + + + range_iterator<X>::type T::iterator
    P::first_type
    A*
    @@ -269,8 +269,8 @@ class=identifier>T
    & compile time - - range_iterator<const X>::type + + range_iterator<const X>::type T::const_iterator
    P::first_type
    const A*
    @@ -278,54 +278,53 @@ class=identifier>T
    & compile time - - range_value<X>::type + + range_value<X>::type boost::iterator_value<range_iterator<X>::type>::type compile time - - range_reference<X>::type + + range_reference<X>::type boost::iterator_reference<range_iterator<X>::type>::type compile time - - range_pointer<X>::type + + range_pointer<X>::type boost::iterator_pointer<range_iterator<X>::type>::type compile time - - range_category<X>::type + + range_category<X>::type boost::iterator_category<range_iterator<X>::type>::type compile time - - range_difference<X>::type + + range_difference<X>::type boost::iterator_difference<range_iterator<X>::type>::type compile time - - - range_reverse_iterator<X>::type + + range_reverse_iterator<X>::type boost::reverse_iterator<range_iterator<X>::type>
    compile time - - range_reverse_iterator<const X>::type + + range_reverse_iterator<const X>::type boost::reverse_iterator<range_iterator<const X>::type>
    compile time @@ -346,11 +345,11 @@ class=identifier>T
    & - - begin(x) + + begin(x) range_iterator<X>::type - p.first if p is of type std::pair<T>
    + p.first if p is of type std::pair<T>
    a if a is an array
    range_begin(x) if that expression would invoke a function found by ADL
    t.begin() otherwise @@ -358,11 +357,11 @@ class=identifier>T
    & constant time - - end(x) + + end(x) range_iterator<X>::type - p.second if p is of type std::pair<T>
    + p.second if p is of type std::pair<T>
    a + sz if a is an array of size sz
    @@ -373,16 +372,16 @@ class=identifier>T
    & - - empty(x) + + empty(x) bool boost::begin(x) == boost::end(x)
    constant time
    - - distance(x) + + distance(x) range_difference<X>::type @@ -394,16 +393,16 @@ class=identifier>T
    & - - size(x) + + size(x) range_difference<X>::type boost::end(x) - boost::begin(x) constant time - - rbegin(x) + + rbegin(x) range_reverse_iterator<X>::type range_reverse_iterator<X>::type( boost::end(x) )
    @@ -411,15 +410,15 @@ class=identifier>T
    & - - rend(x) + + rend(x) range_reverse_iterator<X>::type range_reverse_iterator<X>::type( boost::begin(x) ) constant time - - const_begin(x) + + const_begin(x) range_iterator<const X>::type range_iterator<const X>::type( boost::begin(x) )
    @@ -427,15 +426,15 @@ class=identifier>T
    & - - const_end(x) + + const_end(x) range_iterator<const X>::type range_iterator<const X>::type( boost::end(x) ) constant time - - const_rbegin(x) + + const_rbegin(x) range_reverse_iterator<const X>::type range_reverse_iterator<const X>::type( boost::rbegin(x) )
    @@ -443,16 +442,16 @@ class=identifier>T
    & - - const_rend(x) + + const_rend(x) range_reverse_iterator<const X>::type range_reverse_iterator<const X>::type( boost::rend(x) ) constant time - - as_literal(x) + + as_literal(x) iterator_range<U> where U is Char* if x is a pointer to a string and U is @@ -460,20 +459,21 @@ class=identifier>T& - [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* + + [s,s + std::char_traits<X>::length(s)) if s is a Char* or an array of Char
    [boost::begin(x),boost::end(x)) otherwise - linear time for pointers to a string, constant time - otherwise + linear time for pointers to a string or arrays of + Char, constant time otherwise - - as_array(x) + + as_array(x) iterator_range<X> [boost::begin(x),boost::end(x)) @@ -561,7 +561,7 @@ class=identifier>T
    & Related concept - + iterator Single Pass Range diff --git a/doc/examples.html b/doc/examples.html old mode 100755 new mode 100644 index 0d24509..d1f9887 --- a/doc/examples.html +++ b/doc/examples.html @@ -23,16 +23,16 @@
    • string.cpp -
    • + shows how to implement a container version of std::find() that works with char[],wchar_t[],char*,wchar_t*. - +
    • algorithm_example.cpp -
    • + shows the replace example from the introduction. - +
    • iterator_range.cpp
    • sub_range.cpp
    • iterator_pair.cpp diff --git a/doc/faq.html b/doc/faq.html old mode 100755 new mode 100644 index 244df80..fcacf98 --- a/doc/faq.html +++ b/doc/faq.html @@ -22,7 +22,7 @@
    • Why is there no difference between range_iterator<C>::type and range_const_iterator<C>::type for std::pair<iterator, iterator>. -
    • +

      In general it is not possible nor desirable to find a corresponding const_iterator. When it is possible to come up with one, the client might choose to construct a std::pair<const_iterator,const_iterator> @@ -33,7 +33,7 @@ is somewhat more convenient than a pair and that a sub_range does propagate const-ness.

      - +
    • Why is there not supplied more types or more functions?

      diff --git a/doc/headers.html b/doc/headers.html old mode 100755 new mode 100644 index 7628591..c896bff --- a/doc/headers.html +++ b/doc/headers.html @@ -167,7 +167,7 @@ -

      diff --git a/doc/intro.html b/doc/intro.html index 82f10dc..89d3504 100644 --- a/doc/intro.html +++ b/doc/intro.html @@ -108,7 +108,7 @@ class=identifier>ForwardReadableRange >:: my_vector.assign( values, boost::end( values ) ); - typedef std::vector<int>::iterator iterator; + 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"; diff --git a/doc/portability.html b/doc/portability.html old mode 100755 new mode 100644 index 9e63978..bb73e78 --- a/doc/portability.html +++ b/doc/portability.html @@ -29,9 +29,8 @@ href="http://boost.sourceforge.net/regression-logs/developer/range.html">here - - Visual C++ 6/7.0 has a limited support for arrays: as long as the arrays are - of built-in type it should work. +

      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. diff --git a/doc/range.html b/doc/range.html old mode 100755 new mode 100644 index b140888..8646141 --- a/doc/range.html +++ b/doc/range.html @@ -1,3 +1,4 @@ +


      - +

      Single Pass Range

      Notation

      @@ -227,7 +228,7 @@ otherwise
      -

      Forward Range

      +

      Forward Range

      Notation

      @@ -255,7 +256,7 @@ Range
      -

      Bidirectional Range

      +

      Bidirectional Range

      Notation

      @@ -283,7 +284,8 @@ s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.
      -

      Random Access Range

      Description

      +

      Random Access Range

      +

      Description

      A range X where boost::range_iterator<X>::type is a model of Boost Concept Check library to insure that the type of a template parameter diff --git a/doc/utility_class.html b/doc/utility_class.html index e100859..956bf99 100644 --- a/doc/utility_class.html +++ b/doc/utility_class.html @@ -31,7 +31,6 @@

    • Class sub_range - The iterator_range class is templated on a Forward @@ -84,7 +83,7 @@ corresponding const_iterator is.

      typedef ForwardTraversalIterator const_iterator; typedef iterator_difference<iterator>::type difference_type; - public: // construction, assignment + public: // construction, assignment template< class ForwardTraversalIterator2 > iterator_range( ForwardTraversalIterator2 Begin, ForwardTraversalIterator2 End ); @@ -110,7 +109,7 @@ corresponding const_iterator is.

      operator
      unspecified_bool_type() const; bool equal( const iterator_range& ) ( const iterator_range& ) const; reference front() const; reference back() const; @@ -119,7 +118,7 @@ class=keyword>const; // for Random Access Range only: reference operator[]( difference_type at ) const; value_type operator()( difference_type at ) const; - }; + }; // stream output template< class ForwardTraversalIterator, class T, class Traits > @@ -164,7 +163,7 @@ class=keyword>const; bool operator<( const ForwardRange& l, const iterator_range<ForwardTraversalIterator>& r ); - // external construction + // external construction template< class ForwardTraversalIterator > iterator_range< ForwardTraversalIterator > make_iterator_range( ForwardTraversalIterator Begin, @@ -190,7 +189,7 @@ class=keyword>const; typename range_difference<Range>::type advance_begin, typename range_difference<Range>::type advance_end ); - // convenience + // convenience template< class Sequence, class ForwardRange > Sequence copy_range(

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

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

      @@ -236,21 +235,21 @@ non-const iterators from the same container.

      -bool operator==( const ForwardRange1& l, const ForwardRange2& r ); +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 ); +bool operator!=( const ForwardRange1& l, const ForwardRange2& r );
      Returns !( l == r );
      -bool operator<( const ForwardRange1& l, const ForwardRange2& 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, 
      +iterator_range make_iterator_range( Range& r, 
                                           typename range_difference<Range>::type advance_begin, 
                                           typename range_difference<Range>::type advance_end );
       
      @@ -266,7 +265,7 @@ return make_iterator_range( new_begin, new_end );

      -Sequence copy_range( const ForwardRange& r ); +Sequence copy_range( const ForwardRange& r );

      Returns Sequence( begin(r), end(r) );
      @@ -292,7 +291,7 @@ class can propagate constness since it knows what a corresponding
      class sub_range : public iterator_range< typename range_iterator<ForwardRange>::type > { public: - typedef typename range_iterator<ForwardRange>::
      type 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; diff --git a/index.html b/index.html index 56ba4eb..e846421 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,7 @@

        -
      • Introduction +
      • Introduction
      • Range concepts:
          From 8724a83c49e856edd0d96eac560a682b62750ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Wed, 16 Jul 2008 19:59:34 +0000 Subject: [PATCH 70/92] doc updates [SVN r47482] --- doc/upgrading.html | 78 ++++++++++++++++++++++++++++++++++++++++++++++ index.html | 2 ++ 2 files changed, 80 insertions(+) create mode 100644 doc/upgrading.html diff --git a/doc/upgrading.html b/doc/upgrading.html new file mode 100644 index 0000000..fdab5ab --- /dev/null +++ b/doc/upgrading.html @@ -0,0 +1,78 @@ + + + + + + Boost.Range Upgrading + + + + +
    • + + + + +

      Boost.Range

      + +

      Upgrading from Boost v. 1.34.*

      +

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

      +
        +
      • Direct support for character arrays was abandoned in favor of + uniform treatment of all arrays. Instead string algorithms can use + the new function as_literal().
      • +
      • boost::size() now requires a Random Access Range. The old behavior is provided as boost::distance()
      • +
      • range_size<T>::type has been completely removed + in favor of range_difference<T>::type +
      • + boost_range_begin() and boost_range_end() + have been renamed range_begin() and range_begin(), respectively.
      • + + +
      • range_result_iterator<T>::type and + range_reverse_result_iterator<T>::type are have + been renamed + range_iterator<T>::type and + range_reverse_iterator<T>::type. +
      • +
      • The procedure that makes a custom type work with the library + has been greatly simplified. See extending the library + for details.
      • +
      + + +
      +

      + © Copyright Thorsten Ottosen 2008. +

      + +

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

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + + + diff --git a/index.html b/index.html index e846421..3e5f4bb 100644 --- a/index.html +++ b/index.html @@ -55,6 +55,8 @@
    • MFC/ATL mapping (courtesy of Shunsuke Sogame)
    • Portability +
    • Upgrading from Boost v. + 1.34.*
    • FAQ
    • History and acknowledgment From 2dab8cfbc9fcd88bf77fa118b4f604eb3c9df7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 22 Jul 2008 09:15:00 +0000 Subject: [PATCH 71/92] update in response to inspection report [SVN r47678] --- doc/upgrading.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/upgrading.html b/doc/upgrading.html index fdab5ab..2d76111 100644 --- a/doc/upgrading.html +++ b/doc/upgrading.html @@ -26,8 +26,9 @@ the new function as_literal().
    • boost::size() now requires a Random Access Range. The old behavior is provided as boost::distance()
    • + href="boost_range.html#size">boost::size() now requires a Random + Access Range. The old behavior is provided as boost::distance()
    • range_size<T>::type has been completely removed in favor of range_difference<T>::type
    • From a65512ed5c5a6f2f2ea7f78a23d8382deae2ff87 Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Sat, 1 Nov 2008 13:15:41 +0000 Subject: [PATCH 72/92] Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor [SVN r49510] --- CMakeLists.txt | 22 ++++++++++++++++++++++ doc/CMakeLists.txt | 1 + module.cmake | 1 + test/CMakeLists.txt | 17 +++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 doc/CMakeLists.txt create mode 100644 module.cmake create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f0c2263 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + range.hpp + range +) + +# Add a library target to the build system +boost_library_project( + range + # SRCDIRS + TESTDIRS test + HEADERS ${lib_headers} + DOCDIRS doc + DESCRIPTION "A new infrastructure for generic algorithms that builds on top of the new iterator concepts." + MODULARIZED + AUTHORS "Thorsten Ottosen " + # MAINTAINERS +) + + diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..3aea8c0 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1 @@ +boost_add_documentation(boost_range.qbk) \ No newline at end of file diff --git a/module.cmake b/module.cmake new file mode 100644 index 0000000..49c9bc9 --- /dev/null +++ b/module.cmake @@ -0,0 +1 @@ +boost_module(range DEPENDS algorithm) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..a076f07 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,17 @@ +message(STATUS "libs/range/test: need -Wall -Wunused here when under gcc") +set( test_compile_flags "") +IF(CMAKE_COMPILER_IS_GNUCC) + SET(test_compile_flags "-Wall -Wunused") +ENDIF(CMAKE_COMPILER_IS_GNUCC) + +boost_test_run(array DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(iterator_pair DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(std_container DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(string DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(iterator_range DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(sub_range DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(partial_workaround DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(algorithm_example DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(reversible_range DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(const_ranges DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) +boost_test_run(extension_mechanism DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) From 5e7948667e983c2b165afea66b1650dd30431d44 Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Fri, 7 Nov 2008 17:02:56 +0000 Subject: [PATCH 73/92] Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use. [SVN r49627] --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a076f07..83d1210 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +boost_additional_test_dependencies(range BOOST_DEPENDS test) + message(STATUS "libs/range/test: need -Wall -Wunused here when under gcc") set( test_compile_flags "") IF(CMAKE_COMPILER_IS_GNUCC) From 837bf058677bb0eebf95cef3f1ea7d48cdd1a32a Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 17 Feb 2009 10:05:58 +0000 Subject: [PATCH 74/92] Add PDF generation options to fix external links to point to the web site. Added a few more Boostbook based libs that were missed first time around. Fixed PDF naming issues. [SVN r51284] --- doc/Jamfile.v2 | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index bfe0908..fd54f7a 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -28,5 +28,6 @@ boostbook standalone # generate.section.toc.level=4 # chunk.first.sections=7 # toc.section.depth=10 + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html ; From bcc0ea30cfae00934d0467cd84add3224c966136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sun, 5 Apr 2009 20:46:02 +0000 Subject: [PATCH 75/92] Ticket #2903 [SVN r52202] --- include/boost/range/as_literal.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 38cc9cf..2f04ca8 100644 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -38,7 +38,7 @@ namespace boost return strlen( s ); } -#ifndef BOOST_NO_INTRINSIC_WCHAR_T +#ifndef BOOST_NO_CWCHAR inline std::size_t length( const wchar_t* s ) { return wcslen( s ); @@ -61,7 +61,7 @@ namespace boost return true; } -#ifndef BOOST_NO_INTRINSIC_WCHAR_T +#ifndef BOOST_NO_CWCHAR inline bool is_char_ptr( wchar_t* ) { return true; From 52b9581e4fdce9cad85144981f4fd318afc6522a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 29 Apr 2009 21:19:12 +0000 Subject: [PATCH 76/92] Use local copies of the boost logo. [SVN r52666] --- doc/mfc_atl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mfc_atl.html b/doc/mfc_atl.html index a022fe3..cc8eeb0 100644 --- a/doc/mfc_atl.html +++ b/doc/mfc_atl.html @@ -291,7 +291,7 @@ ul.auto-toc {
      -

      Boost Range MFC/ATL Extension

      +

      Boost Range MFC/ATL Extension

      From 7663f559f2a7eee181af2d77a635b6105c69e01d Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sun, 26 Jul 2009 00:49:56 +0000 Subject: [PATCH 77/92] Copyrights on CMakeLists.txt to keep them from clogging up the inspect reports. This is essentially the same commit as r55095 on the release branch. [SVN r55159] --- CMakeLists.txt | 6 ++++++ doc/CMakeLists.txt | 6 ++++++ test/CMakeLists.txt | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0c2263..44214cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 3aea8c0..2a15cc3 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1 +1,7 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_add_documentation(boost_range.qbk) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 83d1210..0907adc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_additional_test_dependencies(range BOOST_DEPENDS test) message(STATUS "libs/range/test: need -Wall -Wunused here when under gcc") From 1461479a179cb74dc0ccdd9869e8b6038127c60a Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 02:07:38 +0000 Subject: [PATCH 78/92] rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back [SVN r56942] --- CMakeLists.txt | 28 ---------------------------- doc/CMakeLists.txt | 7 ------- module.cmake | 1 - test/CMakeLists.txt | 25 ------------------------- 4 files changed, 61 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 doc/CMakeLists.txt delete mode 100644 module.cmake delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 44214cf..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - range.hpp - range -) - -# Add a library target to the build system -boost_library_project( - range - # SRCDIRS - TESTDIRS test - HEADERS ${lib_headers} - DOCDIRS doc - DESCRIPTION "A new infrastructure for generic algorithms that builds on top of the new iterator concepts." - MODULARIZED - AUTHORS "Thorsten Ottosen " - # MAINTAINERS -) - - diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt deleted file mode 100644 index 2a15cc3..0000000 --- a/doc/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_add_documentation(boost_range.qbk) \ No newline at end of file diff --git a/module.cmake b/module.cmake deleted file mode 100644 index 49c9bc9..0000000 --- a/module.cmake +++ /dev/null @@ -1 +0,0 @@ -boost_module(range DEPENDS algorithm) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 0907adc..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_additional_test_dependencies(range BOOST_DEPENDS test) - -message(STATUS "libs/range/test: need -Wall -Wunused here when under gcc") -set( test_compile_flags "") -IF(CMAKE_COMPILER_IS_GNUCC) - SET(test_compile_flags "-Wall -Wunused") -ENDIF(CMAKE_COMPILER_IS_GNUCC) - -boost_test_run(array DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(iterator_pair DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(std_container DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(string DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(iterator_range DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(sub_range DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(partial_workaround DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(algorithm_example DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(reversible_range DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(const_ranges DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) -boost_test_run(extension_mechanism DEPENDS boost_unit_test_framework COMPILE_FLAGS ${test_compile_flags}) From b0d1db7c2ef35110e00482e832626e201429a97d Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 28 Mar 2010 16:08:35 +0000 Subject: [PATCH 79/92] Boost.RangeEx merged into Boost.Range [SVN r60897] --- doc/Jamfile.v2 | 29 +- doc/boost_range.qbk | 1276 +---------------- doc/concepts.qbk | 251 ++++ doc/counting_range.html | 70 + doc/examples.qbk | 23 + doc/faq.qbk | 25 + doc/headers.qbk | 29 + doc/history_ack.qbk | 22 + doc/html/index.html | 144 ++ doc/html/quickbook_HTML.manifest | 132 ++ doc/html/range/concepts.html | 51 + .../range/concepts/bidirectional_range.html | 305 ++++ doc/html/range/concepts/concept_checking.html | 108 ++ doc/html/range/concepts/forward_range.html | 159 ++ doc/html/range/concepts/overview.html | 79 + .../range/concepts/random_access_range.html | 187 +++ .../range/concepts/single_pass_range.html | 349 +++++ doc/html/range/examples.html | 62 + doc/html/range/faq.html | 127 ++ doc/html/range/history_ack.html | 90 ++ doc/html/range/introduction.html | 154 ++ doc/html/range/library_headers.html | 430 ++++++ doc/html/range/mfc_atl.html | 141 ++ doc/html/range/mfc_atl/atl_ranges.html | 374 +++++ doc/html/range/mfc_atl/const_ranges.html | 125 ++ doc/html/range/mfc_atl/mfc_ranges.html | 480 +++++++ doc/html/range/mfc_atl/references.html | 50 + doc/html/range/mfc_atl/requirements.html | 51 + doc/html/range/portability.html | 89 ++ doc/html/range/reference.html | 93 ++ doc/html/range/reference/adaptors.html | 51 + .../adaptors_general_requirements.html | 141 ++ .../adaptors/adaptors_introduction.html | 274 ++++ .../adaptors/adaptors_reference.html | 75 + .../adaptors_reference/adjacent_filtered.html | 151 ++ .../adaptors/adaptors_reference/copied.html | 152 ++ .../adaptors/adaptors_reference/filtered.html | 156 ++ .../adaptors/adaptors_reference/indexed.html | 186 +++ .../adaptors_reference/indirected.html | 146 ++ .../adaptors/adaptors_reference/map_keys.html | 146 ++ .../adaptors_reference/map_values.html | 146 ++ .../adaptors/adaptors_reference/replaced.html | 161 +++ .../adaptors_reference/replaced_if.html | 165 +++ .../adaptors/adaptors_reference/reversed.html | 140 ++ .../adaptors/adaptors_reference/sliced.html | 150 ++ .../adaptors/adaptors_reference/strided.html | 147 ++ .../adaptors_reference/tokenized.html | 143 ++ .../adaptors_reference/transformed.html | 156 ++ .../adaptors/adaptors_reference/uniqued.html | 142 ++ .../reference/adaptors/adaptors_synopsis.html | 67 + doc/html/range/reference/algorithms.html | 59 + .../reference/algorithms/heap_algorithms.html | 51 + .../algorithms/heap_algorithms/make_heap.html | 144 ++ .../algorithms/heap_algorithms/pop_heap.html | 156 ++ .../algorithms/heap_algorithms/push_heap.html | 154 ++ .../algorithms/permutation_algorithms.html | 50 + .../next_permutation.html | 149 ++ .../prev_permutation.html | 149 ++ .../range_algorithm_introduction.html | 257 ++++ .../range_algorithm_mutating_algorithms.html | 86 ++ .../copy.html | 116 ++ .../copy_backward.html | 125 ++ .../fill.html | 105 ++ .../generate.html | 121 ++ .../inplace_merge.html | 187 +++ .../merge.html | 247 ++++ .../nth_element.html | 147 ++ .../partial_sort.html | 152 ++ .../partition.html | 133 ++ .../random_shuffle.html | 132 ++ .../remove.html | 139 ++ .../remove_if.html | 138 ++ .../replace.html | 119 ++ .../replace_if.html | 117 ++ .../rotate.html | 110 ++ .../sort.html | 154 ++ .../stable_partition.html | 135 ++ .../stable_sort.html | 157 ++ .../transform.html | 226 +++ .../unique.html | 164 +++ .../range_algorithm_new_algorithms.html | 62 + .../range_algorithm_new_algorithms/erase.html | 91 ++ .../for_each.html | 150 ++ .../insert.html | 106 ++ .../overwrite.html | 111 ++ .../push_back.html | 104 ++ .../push_front.html | 104 ++ .../remove_erase.html | 92 ++ .../remove_erase_if.html | 99 ++ ...nge_algorithm_non_mutating_algorithms.html | 80 ++ .../adjacent_find.html | 168 +++ .../binary_search.html | 157 ++ .../count.html | 108 ++ .../equal.html | 163 +++ .../equal_range.html | 179 +++ .../find.html | 123 ++ .../find_end.html | 204 +++ .../find_first_of.html | 200 +++ .../find_if.html | 133 ++ .../for_each.html | 113 ++ .../lexicographical_compare.html | 170 +++ .../lower_bound.html | 188 +++ .../max_element.html | 166 +++ .../min_element.html | 166 +++ .../mismatch.html | 222 +++ .../search.html | 206 +++ .../upper_bound.html | 185 +++ .../reference/algorithms/range_numeric.html | 54 + .../algorithms/range_numeric/accumulate.html | 157 ++ .../range_numeric/adjacent_difference.html | 179 +++ .../range_numeric/inner_product.html | 192 +++ .../algorithms/range_numeric/irange.html | 105 ++ .../algorithms/range_numeric/partial_sum.html | 161 +++ .../reference/algorithms/set_algorithms.html | 55 + .../algorithms/set_algorithms/includes.html | 187 +++ .../set_algorithms/set_difference.html | 206 +++ .../set_algorithms/set_intersection.html | 206 +++ .../set_symmetric_difference.html | 210 +++ .../algorithms/set_algorithms/set_union.html | 205 +++ doc/html/range/reference/extending.html | 51 + .../range/reference/extending/method_1.html | 161 +++ .../range/reference/extending/method_2.html | 265 ++++ .../range/reference/extending/method_3.html | 50 + .../extending/method_3/method_3_1.html | 100 ++ .../extending/method_3/method_3_2.html | 155 ++ doc/html/range/reference/overview.html | 68 + doc/html/range/reference/range_algorithm.html | 52 + .../range_algorithm_introduction.html | 257 ++++ .../range_algorithm_mutating_algorithms.html | 50 + .../copy.html | 115 ++ .../copy_backward.html | 124 ++ .../range_algorithm_new_algorithms.html | 41 + ...nge_algorithm_non_mutating_algorithms.html | 42 + doc/html/range/reference/ranges.html | 48 + .../reference/ranges/counting_range.html | 90 ++ .../range/reference/ranges/introduction.html | 46 + doc/html/range/reference/ranges/irange.html | 103 ++ .../range/reference/ranges/istream_range.html | 72 + .../range/reference/ranges/reference.html | 50 + .../ranges/reference/counting_range.html | 91 ++ .../reference/ranges/reference/irange.html | 104 ++ .../ranges/reference/istream_range.html | 73 + doc/html/range/reference/semantics.html | 163 +++ .../range/reference/semantics/functions.html | 408 ++++++ .../reference/semantics/metafunctions.html | 236 +++ doc/html/range/reference/synopsis.html | 185 +++ doc/html/range/style_guide.html | 141 ++ doc/html/range/upgrade.html | 49 + .../range/upgrade/upgrade_1_34_to_1_35.html | 77 + doc/html/range/upgrade/upgrade_from_1_34.html | 77 + doc/html/range/upgrade/upgrade_from_1_42.html | 64 + doc/html/range/utilities.html | 82 ++ doc/html/range/utilities/iterator_range.html | 322 +++++ doc/html/range/utilities/join.html | 89 ++ doc/html/range/utilities/sub_range.html | 122 ++ doc/html/standalone_HTML.manifest | 19 + doc/introduction.qbk | 73 + doc/istream_range.html | 64 + doc/mfc_atl.qbk | 139 ++ doc/portability.qbk | 22 + doc/reference.qbk | 11 + doc/reference/adaptors.qbk | 205 +++ doc/reference/adaptors/adjacent_filtered.html | 101 ++ doc/reference/adaptors/adjacent_filtered.qbk | 47 + doc/reference/adaptors/copied.html | 93 ++ doc/reference/adaptors/copied.qbk | 45 + .../adaptors/examples/adjacent_filtered.cpp | 23 + doc/reference/adaptors/examples/copied.cpp | 22 + doc/reference/adaptors/examples/filtered.cpp | 27 + doc/reference/adaptors/examples/indexed.cpp | 36 + .../adaptors/examples/indirected.cpp | 23 + doc/reference/adaptors/examples/map_keys.cpp | 24 + .../adaptors/examples/map_values.cpp | 24 + doc/reference/adaptors/examples/replaced.cpp | 22 + .../adaptors/examples/replaced_if.cpp | 26 + doc/reference/adaptors/examples/reversed.cpp | 22 + doc/reference/adaptors/examples/sliced.cpp | 22 + doc/reference/adaptors/examples/strided.cpp | 22 + doc/reference/adaptors/examples/tokenized.cpp | 19 + .../adaptors/examples/transformed.cpp | 28 + doc/reference/adaptors/examples/uniqued.cpp | 22 + doc/reference/adaptors/filtered.html | 108 ++ doc/reference/adaptors/filtered.qbk | 50 + doc/reference/adaptors/indexed.html | 117 ++ doc/reference/adaptors/indexed.qbk | 86 ++ doc/reference/adaptors/indirected.html | 95 ++ doc/reference/adaptors/indirected.qbk | 46 + doc/reference/adaptors/map_keys.html | 99 ++ doc/reference/adaptors/map_keys.qbk | 47 + doc/reference/adaptors/map_values.html | 98 ++ doc/reference/adaptors/map_values.qbk | 47 + doc/reference/adaptors/replaced.html | 107 ++ doc/reference/adaptors/replaced.qbk | 47 + doc/reference/adaptors/replaced_if.html | 114 ++ doc/reference/adaptors/replaced_if.qbk | 52 + doc/reference/adaptors/reversed.html | 91 ++ doc/reference/adaptors/reversed.qbk | 44 + doc/reference/adaptors/sliced.html | 94 ++ doc/reference/adaptors/sliced.qbk | 45 + doc/reference/adaptors/strided.html | 94 ++ doc/reference/adaptors/strided.qbk | 45 + doc/reference/adaptors/tokenized.html | 118 ++ doc/reference/adaptors/tokenized.qbk | 42 + doc/reference/adaptors/transformed.html | 107 ++ doc/reference/adaptors/transformed.qbk | 52 + doc/reference/adaptors/uniqued.html | 95 ++ doc/reference/adaptors/uniqued.qbk | 43 + doc/reference/algorithm/adjacent_find.qbk | 80 ++ doc/reference/algorithm/binary_search.qbk | 55 + doc/reference/algorithm/copy.qbk | 36 + doc/reference/algorithm/copy_backward.qbk | 41 + doc/reference/algorithm/count.qbk | 36 + doc/reference/algorithm/equal.qbk | 59 + doc/reference/algorithm/equal_range.qbk | 78 + doc/reference/algorithm/fill.qbk | 34 + doc/reference/algorithm/find.qbk | 52 + doc/reference/algorithm/find_end.qbk | 99 ++ doc/reference/algorithm/find_first_of.qbk | 99 ++ doc/reference/algorithm/find_if.qbk | 57 + doc/reference/algorithm/for_each.qbk | 40 + doc/reference/algorithm/generate.qbk | 39 + doc/reference/algorithm/includes.qbk | 64 + doc/reference/algorithm/inplace_merge.qbk | 72 + .../algorithm/lexicographical_compare.qbk | 55 + doc/reference/algorithm/lower_bound.qbk | 80 ++ doc/reference/algorithm/make_heap.qbk | 51 + doc/reference/algorithm/max_element.qbk | 81 ++ doc/reference/algorithm/merge.qbk | 83 ++ doc/reference/algorithm/min_element.qbk | 81 ++ doc/reference/algorithm/mismatch.qbk | 116 ++ doc/reference/algorithm/next_permutation.qbk | 51 + doc/reference/algorithm/nth_element.qbk | 58 + doc/reference/algorithm/partial_sort.qbk | 60 + doc/reference/algorithm/partition.qbk | 58 + doc/reference/algorithm/pop_heap.qbk | 56 + doc/reference/algorithm/prev_permutation.qbk | 51 + doc/reference/algorithm/push_heap.qbk | 56 + doc/reference/algorithm/random_shuffle.qbk | 50 + doc/reference/algorithm/remove.qbk | 58 + doc/reference/algorithm/remove_if.qbk | 58 + doc/reference/algorithm/replace.qbk | 41 + doc/reference/algorithm/replace_if.qbk | 36 + doc/reference/algorithm/reverse.qbk | 32 + doc/reference/algorithm/rotate.qbk | 39 + doc/reference/algorithm/search.qbk | 101 ++ doc/reference/algorithm/set_difference.qbk | 76 + doc/reference/algorithm/set_intersection.qbk | 76 + .../algorithm/set_symmetric_difference.qbk | 78 + doc/reference/algorithm/set_union.qbk | 75 + doc/reference/algorithm/sort.qbk | 53 + doc/reference/algorithm/sort_heap.qbk | 55 + doc/reference/algorithm/stable_partition.qbk | 56 + doc/reference/algorithm/stable_sort.qbk | 54 + doc/reference/algorithm/transform.qbk | 83 ++ doc/reference/algorithm/unique.qbk | 72 + doc/reference/algorithm/upper_bound.qbk | 77 + doc/reference/algorithm_ext/erase.qbk | 30 + doc/reference/algorithm_ext/for_each.qbk | 68 + doc/reference/algorithm_ext/insert.qbk | 33 + doc/reference/algorithm_ext/overwrite.qbk | 34 + doc/reference/algorithm_ext/push_back.qbk | 32 + doc/reference/algorithm_ext/push_front.qbk | 32 + doc/reference/algorithm_ext/remove_erase.qbk | 31 + .../algorithm_ext/remove_erase_if.qbk | 32 + doc/reference/algorithms.qbk | 162 +++ doc/reference/extending.qbk | 316 ++++ doc/reference/numeric/accumulate.qbk | 56 + doc/reference/numeric/adjacent_difference.qbk | 63 + doc/reference/numeric/inner_product.qbk | 67 + doc/reference/numeric/partial_sum.qbk | 55 + doc/reference/overview.qbk | 14 + doc/reference/ranges.qbk | 8 + doc/reference/ranges/counting_range.qbk | 31 + doc/reference/ranges/irange.qbk | 35 + doc/reference/ranges/istream_range.qbk | 19 + doc/reference/semantics.qbk | 185 +++ doc/reference/synopsis.qbk | 143 ++ doc/style.qbk | 45 + doc/upgrade.qbk | 30 + doc/utilities.qbk | 296 ++++ .../boost/range/adaptor/adjacent_filtered.hpp | 255 ++++ include/boost/range/adaptor/argument_fwd.hpp | 80 ++ include/boost/range/adaptor/copied.hpp | 68 + .../boost/range/adaptor/define_adaptor.hpp | 117 ++ include/boost/range/adaptor/filtered.hpp | 102 ++ include/boost/range/adaptor/indexed.hpp | 173 +++ include/boost/range/adaptor/indirected.hpp | 88 ++ include/boost/range/adaptor/map.hpp | 188 +++ include/boost/range/adaptor/replaced.hpp | 134 ++ include/boost/range/adaptor/replaced_if.hpp | 136 ++ include/boost/range/adaptor/reversed.hpp | 90 ++ include/boost/range/adaptor/sliced.hpp | 92 ++ include/boost/range/adaptor/strided.hpp | 149 ++ include/boost/range/adaptor/tokenized.hpp | 137 ++ include/boost/range/adaptor/transformed.hpp | 103 ++ include/boost/range/adaptor/uniqued.hpp | 90 ++ include/boost/range/adaptors.hpp | 29 + include/boost/range/algorithm.hpp | 104 ++ .../boost/range/algorithm/adjacent_find.hpp | 119 ++ .../boost/range/algorithm/binary_search.hpp | 43 + include/boost/range/algorithm/copy.hpp | 35 + .../boost/range/algorithm/copy_backward.hpp | 37 + include/boost/range/algorithm/count.hpp | 44 + include/boost/range/algorithm/count_if.hpp | 45 + include/boost/range/algorithm/equal.hpp | 182 +++ include/boost/range/algorithm/equal_range.hpp | 74 + include/boost/range/algorithm/fill.hpp | 34 + include/boost/range/algorithm/fill_n.hpp | 36 + include/boost/range/algorithm/find.hpp | 66 + include/boost/range/algorithm/find_end.hpp | 136 ++ .../boost/range/algorithm/find_first_of.hpp | 139 ++ include/boost/range/algorithm/find_if.hpp | 69 + include/boost/range/algorithm/for_each.hpp | 42 + include/boost/range/algorithm/generate.hpp | 44 + .../boost/range/algorithm/heap_algorithm.hpp | 169 +++ .../boost/range/algorithm/inplace_merge.hpp | 68 + .../algorithm/lexicographical_compare.hpp | 52 + include/boost/range/algorithm/lower_bound.hpp | 99 ++ include/boost/range/algorithm/max_element.hpp | 109 ++ include/boost/range/algorithm/merge.hpp | 55 + include/boost/range/algorithm/min_element.hpp | 109 ++ include/boost/range/algorithm/mismatch.hpp | 182 +++ include/boost/range/algorithm/nth_element.hpp | 64 + .../boost/range/algorithm/partial_sort.hpp | 65 + .../range/algorithm/partial_sort_copy.hpp | 58 + include/boost/range/algorithm/partition.hpp | 68 + include/boost/range/algorithm/permutation.hpp | 117 ++ .../boost/range/algorithm/random_shuffle.hpp | 62 + include/boost/range/algorithm/remove.hpp | 70 + include/boost/range/algorithm/remove_copy.hpp | 38 + .../boost/range/algorithm/remove_copy_if.hpp | 38 + include/boost/range/algorithm/remove_if.hpp | 70 + include/boost/range/algorithm/replace.hpp | 47 + .../boost/range/algorithm/replace_copy.hpp | 36 + .../boost/range/algorithm/replace_copy_if.hpp | 40 + include/boost/range/algorithm/replace_if.hpp | 49 + include/boost/range/algorithm/reverse.hpp | 44 + .../boost/range/algorithm/reverse_copy.hpp | 42 + include/boost/range/algorithm/rotate.hpp | 46 + include/boost/range/algorithm/rotate_copy.hpp | 38 + include/boost/range/algorithm/search.hpp | 131 ++ include/boost/range/algorithm/search_n.hpp | 140 ++ .../boost/range/algorithm/set_algorithm.hpp | 188 +++ include/boost/range/algorithm/sort.hpp | 63 + .../range/algorithm/stable_partition.hpp | 68 + include/boost/range/algorithm/stable_sort.hpp | 62 + include/boost/range/algorithm/swap_ranges.hpp | 81 ++ include/boost/range/algorithm/transform.hpp | 85 ++ include/boost/range/algorithm/unique.hpp | 101 ++ include/boost/range/algorithm/unique_copy.hpp | 45 + include/boost/range/algorithm/upper_bound.hpp | 101 ++ include/boost/range/algorithm_ext.hpp | 27 + include/boost/range/algorithm_ext/copy_n.hpp | 47 + include/boost/range/algorithm_ext/erase.hpp | 45 + .../boost/range/algorithm_ext/for_each.hpp | 65 + include/boost/range/algorithm_ext/insert.hpp | 32 + .../boost/range/algorithm_ext/is_sorted.hpp | 65 + .../boost/range/algorithm_ext/overwrite.hpp | 46 + .../boost/range/algorithm_ext/push_back.hpp | 31 + .../boost/range/algorithm_ext/push_front.hpp | 30 + include/boost/range/combine.hpp | 310 ++++ include/boost/range/concepts.hpp | 265 +++- include/boost/range/const_iterator.hpp | 11 +- include/boost/range/counting_range.hpp | 69 + .../detail/demote_iterator_traversal_tag.hpp | 79 + .../range/detail/extract_optional_type.hpp | 52 + include/boost/range/detail/join_iterator.hpp | 357 +++++ include/boost/range/detail/misc_concept.hpp | 33 + include/boost/range/detail/range_return.hpp | 180 +++ include/boost/range/irange.hpp | 202 +++ include/boost/range/istream_range.hpp | 34 + include/boost/range/iterator_range.hpp | 659 +-------- include/boost/range/iterator_range_core.hpp | 540 +++++++ include/boost/range/iterator_range_io.hpp | 93 ++ include/boost/range/join.hpp | 68 + include/boost/range/mutable_iterator.hpp | 11 +- include/boost/range/numeric.hpp | 117 ++ include/boost/range/sub_range.hpp | 6 +- include/boost/range/unbounded_range.hpp | 73 + index.html | 83 +- test/Jamfile.v2 | 125 +- test/adaptor_test/adjacent_filtered.cpp | 110 ++ .../adjacent_filtered_example.cpp | 58 + test/adaptor_test/copied.cpp | 84 ++ test/adaptor_test/copied_example.cpp | 58 + test/adaptor_test/filtered.cpp | 135 ++ test/adaptor_test/filtered_example.cpp | 62 + test/adaptor_test/indexed.cpp | 99 ++ test/adaptor_test/indexed_example.cpp | 95 ++ test/adaptor_test/indirected.cpp | 99 ++ test/adaptor_test/indirected_example.cpp | 60 + test/adaptor_test/map.cpp | 127 ++ test/adaptor_test/map_keys_example.cpp | 60 + test/adaptor_test/map_values_example.cpp | 60 + test/adaptor_test/replaced.cpp | 87 ++ test/adaptor_test/replaced_example.cpp | 58 + test/adaptor_test/replaced_if.cpp | 96 ++ test/adaptor_test/replaced_if_example.cpp | 62 + test/adaptor_test/reversed.cpp | 84 ++ test/adaptor_test/reversed_example.cpp | 55 + test/adaptor_test/sliced.cpp | 99 ++ test/adaptor_test/sliced_example.cpp | 58 + test/adaptor_test/strided.cpp | 111 ++ test/adaptor_test/strided_example.cpp | 58 + test/adaptor_test/tokenized.cpp | 79 + test/adaptor_test/transformed.cpp | 107 ++ test/adaptor_test/transformed_example.cpp | 64 + test/adaptor_test/uniqued.cpp | 89 ++ test/adaptor_test/uniqued_example.cpp | 57 + test/adaptors.cpp | 238 +++ test/adl_conformance.cpp | 67 +- test/algorithm.cpp | 471 ++++++ test/algorithm_test/adjacent_find.cpp | 89 ++ test/algorithm_test/binary_search.cpp | 122 ++ test/algorithm_test/copy.cpp | 67 + test/algorithm_test/copy_backward.cpp | 64 + test/algorithm_test/count.cpp | 77 + test/algorithm_test/count_if.cpp | 85 ++ test/algorithm_test/equal.cpp | 103 ++ test/algorithm_test/equal_range.cpp | 175 +++ test/algorithm_test/fill.cpp | 80 ++ test/algorithm_test/find.cpp | 102 ++ test/algorithm_test/find_end.cpp | 181 +++ test/algorithm_test/find_first_of.cpp | 181 +++ test/algorithm_test/find_if.cpp | 123 ++ test/algorithm_test/for_each.cpp | 86 ++ test/algorithm_test/generate.cpp | 90 ++ test/algorithm_test/heap.cpp | 122 ++ test/algorithm_test/includes.cpp | 157 ++ test/algorithm_test/inplace_merge.cpp | 145 ++ .../lexicographical_compare.cpp | 151 ++ test/algorithm_test/lower_bound.cpp | 172 +++ test/algorithm_test/max_element.cpp | 149 ++ test/algorithm_test/merge.cpp | 157 ++ test/algorithm_test/min_element.cpp | 149 ++ test/algorithm_test/mismatch.cpp | 181 +++ test/algorithm_test/next_permutation.cpp | 108 ++ test/algorithm_test/nth_element.cpp | 149 ++ test/algorithm_test/partial_sort.cpp | 149 ++ test/algorithm_test/partition.cpp | 111 ++ test/algorithm_test/prev_permutation.cpp | 108 ++ test/algorithm_test/random_shuffle.cpp | 178 +++ test/algorithm_test/remove.cpp | 92 ++ test/algorithm_test/remove_if.cpp | 99 ++ test/algorithm_test/replace.cpp | 79 + test/algorithm_test/replace_if.cpp | 90 ++ test/algorithm_test/reverse.cpp | 78 + test/algorithm_test/rotate.cpp | 99 ++ test/algorithm_test/search.cpp | 97 ++ test/algorithm_test/set_difference.cpp | 170 +++ test/algorithm_test/set_intersection.cpp | 170 +++ .../set_symmetric_difference.cpp | 172 +++ test/algorithm_test/set_union.cpp | 170 +++ test/algorithm_test/sort.cpp | 97 ++ test/algorithm_test/stable_partition.cpp | 112 ++ test/algorithm_test/stable_sort.cpp | 97 ++ test/algorithm_test/transform.cpp | 158 ++ test/algorithm_test/unique.cpp | 166 +++ test/algorithm_test/upper_bound.cpp | 170 +++ test/combine.cpp | 69 + test/compat2.cpp | 2 +- test/counting_range.cpp | 73 + test/irange.cpp | 131 ++ test/join.cpp | 273 ++++ test/test_driver/range_return_test_driver.hpp | 405 ++++++ test/test_function/check_equal_fn.hpp | 49 + test/test_function/counted_function.hpp | 40 + test/test_function/equal_to_x.hpp | 33 + test/test_function/false_predicate.hpp | 29 + test/test_function/greater_than_x.hpp | 32 + test/test_function/multiply_by_x.hpp | 32 + 471 files changed, 48610 insertions(+), 2065 deletions(-) create mode 100644 doc/concepts.qbk create mode 100755 doc/counting_range.html create mode 100644 doc/examples.qbk create mode 100644 doc/faq.qbk create mode 100644 doc/headers.qbk create mode 100644 doc/history_ack.qbk create mode 100644 doc/html/index.html create mode 100644 doc/html/quickbook_HTML.manifest create mode 100644 doc/html/range/concepts.html create mode 100644 doc/html/range/concepts/bidirectional_range.html create mode 100644 doc/html/range/concepts/concept_checking.html create mode 100644 doc/html/range/concepts/forward_range.html create mode 100644 doc/html/range/concepts/overview.html create mode 100644 doc/html/range/concepts/random_access_range.html create mode 100644 doc/html/range/concepts/single_pass_range.html create mode 100644 doc/html/range/examples.html create mode 100644 doc/html/range/faq.html create mode 100644 doc/html/range/history_ack.html create mode 100644 doc/html/range/introduction.html create mode 100644 doc/html/range/library_headers.html create mode 100644 doc/html/range/mfc_atl.html create mode 100644 doc/html/range/mfc_atl/atl_ranges.html create mode 100644 doc/html/range/mfc_atl/const_ranges.html create mode 100644 doc/html/range/mfc_atl/mfc_ranges.html create mode 100644 doc/html/range/mfc_atl/references.html create mode 100644 doc/html/range/mfc_atl/requirements.html create mode 100644 doc/html/range/portability.html create mode 100644 doc/html/range/reference.html create mode 100644 doc/html/range/reference/adaptors.html create mode 100644 doc/html/range/reference/adaptors/adaptors_general_requirements.html create mode 100644 doc/html/range/reference/adaptors/adaptors_introduction.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/adjacent_filtered.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/copied.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/filtered.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/indexed.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/indirected.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/map_keys.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/map_values.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/replaced.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/replaced_if.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/reversed.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/sliced.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/strided.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/tokenized.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/transformed.html create mode 100644 doc/html/range/reference/adaptors/adaptors_reference/uniqued.html create mode 100644 doc/html/range/reference/adaptors/adaptors_synopsis.html create mode 100644 doc/html/range/reference/algorithms.html create mode 100644 doc/html/range/reference/algorithms/heap_algorithms.html create mode 100644 doc/html/range/reference/algorithms/heap_algorithms/make_heap.html create mode 100644 doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html create mode 100644 doc/html/range/reference/algorithms/heap_algorithms/push_heap.html create mode 100644 doc/html/range/reference/algorithms/permutation_algorithms.html create mode 100644 doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html create mode 100644 doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_introduction.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html create mode 100644 doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html create mode 100644 doc/html/range/reference/algorithms/range_numeric.html create mode 100644 doc/html/range/reference/algorithms/range_numeric/accumulate.html create mode 100644 doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html create mode 100644 doc/html/range/reference/algorithms/range_numeric/inner_product.html create mode 100644 doc/html/range/reference/algorithms/range_numeric/irange.html create mode 100644 doc/html/range/reference/algorithms/range_numeric/partial_sum.html create mode 100644 doc/html/range/reference/algorithms/set_algorithms.html create mode 100644 doc/html/range/reference/algorithms/set_algorithms/includes.html create mode 100644 doc/html/range/reference/algorithms/set_algorithms/set_difference.html create mode 100644 doc/html/range/reference/algorithms/set_algorithms/set_intersection.html create mode 100644 doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html create mode 100644 doc/html/range/reference/algorithms/set_algorithms/set_union.html create mode 100644 doc/html/range/reference/extending.html create mode 100644 doc/html/range/reference/extending/method_1.html create mode 100644 doc/html/range/reference/extending/method_2.html create mode 100644 doc/html/range/reference/extending/method_3.html create mode 100644 doc/html/range/reference/extending/method_3/method_3_1.html create mode 100644 doc/html/range/reference/extending/method_3/method_3_2.html create mode 100644 doc/html/range/reference/overview.html create mode 100644 doc/html/range/reference/range_algorithm.html create mode 100644 doc/html/range/reference/range_algorithm/range_algorithm_introduction.html create mode 100644 doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms.html create mode 100644 doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy.html create mode 100644 doc/html/range/reference/range_algorithm/range_algorithm_mutating_algorithms/copy_backward.html create mode 100644 doc/html/range/reference/range_algorithm/range_algorithm_new_algorithms.html create mode 100644 doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html create mode 100644 doc/html/range/reference/ranges.html create mode 100644 doc/html/range/reference/ranges/counting_range.html create mode 100644 doc/html/range/reference/ranges/introduction.html create mode 100644 doc/html/range/reference/ranges/irange.html create mode 100644 doc/html/range/reference/ranges/istream_range.html create mode 100644 doc/html/range/reference/ranges/reference.html create mode 100644 doc/html/range/reference/ranges/reference/counting_range.html create mode 100644 doc/html/range/reference/ranges/reference/irange.html create mode 100644 doc/html/range/reference/ranges/reference/istream_range.html create mode 100644 doc/html/range/reference/semantics.html create mode 100644 doc/html/range/reference/semantics/functions.html create mode 100644 doc/html/range/reference/semantics/metafunctions.html create mode 100644 doc/html/range/reference/synopsis.html create mode 100644 doc/html/range/style_guide.html create mode 100644 doc/html/range/upgrade.html create mode 100644 doc/html/range/upgrade/upgrade_1_34_to_1_35.html create mode 100644 doc/html/range/upgrade/upgrade_from_1_34.html create mode 100644 doc/html/range/upgrade/upgrade_from_1_42.html create mode 100644 doc/html/range/utilities.html create mode 100644 doc/html/range/utilities/iterator_range.html create mode 100644 doc/html/range/utilities/join.html create mode 100644 doc/html/range/utilities/sub_range.html create mode 100644 doc/html/standalone_HTML.manifest create mode 100644 doc/introduction.qbk create mode 100755 doc/istream_range.html create mode 100644 doc/mfc_atl.qbk create mode 100644 doc/portability.qbk create mode 100644 doc/reference.qbk create mode 100644 doc/reference/adaptors.qbk create mode 100755 doc/reference/adaptors/adjacent_filtered.html create mode 100644 doc/reference/adaptors/adjacent_filtered.qbk create mode 100755 doc/reference/adaptors/copied.html create mode 100644 doc/reference/adaptors/copied.qbk create mode 100644 doc/reference/adaptors/examples/adjacent_filtered.cpp create mode 100644 doc/reference/adaptors/examples/copied.cpp create mode 100644 doc/reference/adaptors/examples/filtered.cpp create mode 100644 doc/reference/adaptors/examples/indexed.cpp create mode 100644 doc/reference/adaptors/examples/indirected.cpp create mode 100644 doc/reference/adaptors/examples/map_keys.cpp create mode 100644 doc/reference/adaptors/examples/map_values.cpp create mode 100644 doc/reference/adaptors/examples/replaced.cpp create mode 100644 doc/reference/adaptors/examples/replaced_if.cpp create mode 100644 doc/reference/adaptors/examples/reversed.cpp create mode 100644 doc/reference/adaptors/examples/sliced.cpp create mode 100644 doc/reference/adaptors/examples/strided.cpp create mode 100644 doc/reference/adaptors/examples/tokenized.cpp create mode 100644 doc/reference/adaptors/examples/transformed.cpp create mode 100644 doc/reference/adaptors/examples/uniqued.cpp create mode 100755 doc/reference/adaptors/filtered.html create mode 100644 doc/reference/adaptors/filtered.qbk create mode 100755 doc/reference/adaptors/indexed.html create mode 100644 doc/reference/adaptors/indexed.qbk create mode 100755 doc/reference/adaptors/indirected.html create mode 100644 doc/reference/adaptors/indirected.qbk create mode 100755 doc/reference/adaptors/map_keys.html create mode 100644 doc/reference/adaptors/map_keys.qbk create mode 100755 doc/reference/adaptors/map_values.html create mode 100644 doc/reference/adaptors/map_values.qbk create mode 100755 doc/reference/adaptors/replaced.html create mode 100644 doc/reference/adaptors/replaced.qbk create mode 100755 doc/reference/adaptors/replaced_if.html create mode 100644 doc/reference/adaptors/replaced_if.qbk create mode 100755 doc/reference/adaptors/reversed.html create mode 100644 doc/reference/adaptors/reversed.qbk create mode 100755 doc/reference/adaptors/sliced.html create mode 100644 doc/reference/adaptors/sliced.qbk create mode 100755 doc/reference/adaptors/strided.html create mode 100644 doc/reference/adaptors/strided.qbk create mode 100755 doc/reference/adaptors/tokenized.html create mode 100644 doc/reference/adaptors/tokenized.qbk create mode 100755 doc/reference/adaptors/transformed.html create mode 100644 doc/reference/adaptors/transformed.qbk create mode 100755 doc/reference/adaptors/uniqued.html create mode 100644 doc/reference/adaptors/uniqued.qbk create mode 100644 doc/reference/algorithm/adjacent_find.qbk create mode 100644 doc/reference/algorithm/binary_search.qbk create mode 100644 doc/reference/algorithm/copy.qbk create mode 100644 doc/reference/algorithm/copy_backward.qbk create mode 100644 doc/reference/algorithm/count.qbk create mode 100644 doc/reference/algorithm/equal.qbk create mode 100644 doc/reference/algorithm/equal_range.qbk create mode 100644 doc/reference/algorithm/fill.qbk create mode 100644 doc/reference/algorithm/find.qbk create mode 100644 doc/reference/algorithm/find_end.qbk create mode 100644 doc/reference/algorithm/find_first_of.qbk create mode 100644 doc/reference/algorithm/find_if.qbk create mode 100644 doc/reference/algorithm/for_each.qbk create mode 100644 doc/reference/algorithm/generate.qbk create mode 100644 doc/reference/algorithm/includes.qbk create mode 100644 doc/reference/algorithm/inplace_merge.qbk create mode 100644 doc/reference/algorithm/lexicographical_compare.qbk create mode 100644 doc/reference/algorithm/lower_bound.qbk create mode 100644 doc/reference/algorithm/make_heap.qbk create mode 100644 doc/reference/algorithm/max_element.qbk create mode 100644 doc/reference/algorithm/merge.qbk create mode 100644 doc/reference/algorithm/min_element.qbk create mode 100644 doc/reference/algorithm/mismatch.qbk create mode 100644 doc/reference/algorithm/next_permutation.qbk create mode 100644 doc/reference/algorithm/nth_element.qbk create mode 100644 doc/reference/algorithm/partial_sort.qbk create mode 100644 doc/reference/algorithm/partition.qbk create mode 100644 doc/reference/algorithm/pop_heap.qbk create mode 100644 doc/reference/algorithm/prev_permutation.qbk create mode 100644 doc/reference/algorithm/push_heap.qbk create mode 100644 doc/reference/algorithm/random_shuffle.qbk create mode 100644 doc/reference/algorithm/remove.qbk create mode 100644 doc/reference/algorithm/remove_if.qbk create mode 100644 doc/reference/algorithm/replace.qbk create mode 100644 doc/reference/algorithm/replace_if.qbk create mode 100644 doc/reference/algorithm/reverse.qbk create mode 100644 doc/reference/algorithm/rotate.qbk create mode 100644 doc/reference/algorithm/search.qbk create mode 100644 doc/reference/algorithm/set_difference.qbk create mode 100644 doc/reference/algorithm/set_intersection.qbk create mode 100644 doc/reference/algorithm/set_symmetric_difference.qbk create mode 100644 doc/reference/algorithm/set_union.qbk create mode 100644 doc/reference/algorithm/sort.qbk create mode 100644 doc/reference/algorithm/sort_heap.qbk create mode 100644 doc/reference/algorithm/stable_partition.qbk create mode 100644 doc/reference/algorithm/stable_sort.qbk create mode 100644 doc/reference/algorithm/transform.qbk create mode 100644 doc/reference/algorithm/unique.qbk create mode 100644 doc/reference/algorithm/upper_bound.qbk create mode 100644 doc/reference/algorithm_ext/erase.qbk create mode 100644 doc/reference/algorithm_ext/for_each.qbk create mode 100644 doc/reference/algorithm_ext/insert.qbk create mode 100644 doc/reference/algorithm_ext/overwrite.qbk create mode 100644 doc/reference/algorithm_ext/push_back.qbk create mode 100644 doc/reference/algorithm_ext/push_front.qbk create mode 100644 doc/reference/algorithm_ext/remove_erase.qbk create mode 100644 doc/reference/algorithm_ext/remove_erase_if.qbk create mode 100644 doc/reference/algorithms.qbk create mode 100644 doc/reference/extending.qbk create mode 100644 doc/reference/numeric/accumulate.qbk create mode 100644 doc/reference/numeric/adjacent_difference.qbk create mode 100644 doc/reference/numeric/inner_product.qbk create mode 100644 doc/reference/numeric/partial_sum.qbk create mode 100644 doc/reference/overview.qbk create mode 100644 doc/reference/ranges.qbk create mode 100644 doc/reference/ranges/counting_range.qbk create mode 100644 doc/reference/ranges/irange.qbk create mode 100644 doc/reference/ranges/istream_range.qbk create mode 100644 doc/reference/semantics.qbk create mode 100644 doc/reference/synopsis.qbk create mode 100644 doc/style.qbk create mode 100644 doc/upgrade.qbk create mode 100644 doc/utilities.qbk create mode 100644 include/boost/range/adaptor/adjacent_filtered.hpp create mode 100755 include/boost/range/adaptor/argument_fwd.hpp create mode 100755 include/boost/range/adaptor/copied.hpp create mode 100644 include/boost/range/adaptor/define_adaptor.hpp create mode 100755 include/boost/range/adaptor/filtered.hpp create mode 100755 include/boost/range/adaptor/indexed.hpp create mode 100644 include/boost/range/adaptor/indirected.hpp create mode 100755 include/boost/range/adaptor/map.hpp create mode 100644 include/boost/range/adaptor/replaced.hpp create mode 100644 include/boost/range/adaptor/replaced_if.hpp create mode 100755 include/boost/range/adaptor/reversed.hpp create mode 100755 include/boost/range/adaptor/sliced.hpp create mode 100755 include/boost/range/adaptor/strided.hpp create mode 100755 include/boost/range/adaptor/tokenized.hpp create mode 100755 include/boost/range/adaptor/transformed.hpp create mode 100755 include/boost/range/adaptor/uniqued.hpp create mode 100755 include/boost/range/adaptors.hpp create mode 100755 include/boost/range/algorithm.hpp create mode 100755 include/boost/range/algorithm/adjacent_find.hpp create mode 100755 include/boost/range/algorithm/binary_search.hpp create mode 100644 include/boost/range/algorithm/copy.hpp create mode 100755 include/boost/range/algorithm/copy_backward.hpp create mode 100755 include/boost/range/algorithm/count.hpp create mode 100755 include/boost/range/algorithm/count_if.hpp create mode 100755 include/boost/range/algorithm/equal.hpp create mode 100755 include/boost/range/algorithm/equal_range.hpp create mode 100755 include/boost/range/algorithm/fill.hpp create mode 100755 include/boost/range/algorithm/fill_n.hpp create mode 100755 include/boost/range/algorithm/find.hpp create mode 100755 include/boost/range/algorithm/find_end.hpp create mode 100755 include/boost/range/algorithm/find_first_of.hpp create mode 100755 include/boost/range/algorithm/find_if.hpp create mode 100755 include/boost/range/algorithm/for_each.hpp create mode 100755 include/boost/range/algorithm/generate.hpp create mode 100755 include/boost/range/algorithm/heap_algorithm.hpp create mode 100755 include/boost/range/algorithm/inplace_merge.hpp create mode 100755 include/boost/range/algorithm/lexicographical_compare.hpp create mode 100755 include/boost/range/algorithm/lower_bound.hpp create mode 100755 include/boost/range/algorithm/max_element.hpp create mode 100755 include/boost/range/algorithm/merge.hpp create mode 100755 include/boost/range/algorithm/min_element.hpp create mode 100755 include/boost/range/algorithm/mismatch.hpp create mode 100755 include/boost/range/algorithm/nth_element.hpp create mode 100755 include/boost/range/algorithm/partial_sort.hpp create mode 100755 include/boost/range/algorithm/partial_sort_copy.hpp create mode 100755 include/boost/range/algorithm/partition.hpp create mode 100755 include/boost/range/algorithm/permutation.hpp create mode 100755 include/boost/range/algorithm/random_shuffle.hpp create mode 100755 include/boost/range/algorithm/remove.hpp create mode 100755 include/boost/range/algorithm/remove_copy.hpp create mode 100755 include/boost/range/algorithm/remove_copy_if.hpp create mode 100755 include/boost/range/algorithm/remove_if.hpp create mode 100755 include/boost/range/algorithm/replace.hpp create mode 100755 include/boost/range/algorithm/replace_copy.hpp create mode 100755 include/boost/range/algorithm/replace_copy_if.hpp create mode 100755 include/boost/range/algorithm/replace_if.hpp create mode 100755 include/boost/range/algorithm/reverse.hpp create mode 100755 include/boost/range/algorithm/reverse_copy.hpp create mode 100755 include/boost/range/algorithm/rotate.hpp create mode 100755 include/boost/range/algorithm/rotate_copy.hpp create mode 100755 include/boost/range/algorithm/search.hpp create mode 100755 include/boost/range/algorithm/search_n.hpp create mode 100755 include/boost/range/algorithm/set_algorithm.hpp create mode 100755 include/boost/range/algorithm/sort.hpp create mode 100755 include/boost/range/algorithm/stable_partition.hpp create mode 100755 include/boost/range/algorithm/stable_sort.hpp create mode 100755 include/boost/range/algorithm/swap_ranges.hpp create mode 100755 include/boost/range/algorithm/transform.hpp create mode 100755 include/boost/range/algorithm/unique.hpp create mode 100755 include/boost/range/algorithm/unique_copy.hpp create mode 100755 include/boost/range/algorithm/upper_bound.hpp create mode 100755 include/boost/range/algorithm_ext.hpp create mode 100755 include/boost/range/algorithm_ext/copy_n.hpp create mode 100755 include/boost/range/algorithm_ext/erase.hpp create mode 100755 include/boost/range/algorithm_ext/for_each.hpp create mode 100755 include/boost/range/algorithm_ext/insert.hpp create mode 100755 include/boost/range/algorithm_ext/is_sorted.hpp create mode 100755 include/boost/range/algorithm_ext/overwrite.hpp create mode 100755 include/boost/range/algorithm_ext/push_back.hpp create mode 100755 include/boost/range/algorithm_ext/push_front.hpp create mode 100755 include/boost/range/combine.hpp mode change 100755 => 100644 include/boost/range/concepts.hpp mode change 100755 => 100644 include/boost/range/const_iterator.hpp create mode 100755 include/boost/range/counting_range.hpp create mode 100755 include/boost/range/detail/demote_iterator_traversal_tag.hpp create mode 100755 include/boost/range/detail/extract_optional_type.hpp create mode 100644 include/boost/range/detail/join_iterator.hpp create mode 100755 include/boost/range/detail/misc_concept.hpp create mode 100755 include/boost/range/detail/range_return.hpp create mode 100644 include/boost/range/irange.hpp create mode 100755 include/boost/range/istream_range.hpp create mode 100755 include/boost/range/iterator_range_core.hpp create mode 100755 include/boost/range/iterator_range_io.hpp create mode 100644 include/boost/range/join.hpp mode change 100755 => 100644 include/boost/range/mutable_iterator.hpp create mode 100755 include/boost/range/numeric.hpp create mode 100755 include/boost/range/unbounded_range.hpp create mode 100644 test/adaptor_test/adjacent_filtered.cpp create mode 100644 test/adaptor_test/adjacent_filtered_example.cpp create mode 100644 test/adaptor_test/copied.cpp create mode 100644 test/adaptor_test/copied_example.cpp create mode 100644 test/adaptor_test/filtered.cpp create mode 100644 test/adaptor_test/filtered_example.cpp create mode 100644 test/adaptor_test/indexed.cpp create mode 100644 test/adaptor_test/indexed_example.cpp create mode 100644 test/adaptor_test/indirected.cpp create mode 100644 test/adaptor_test/indirected_example.cpp create mode 100644 test/adaptor_test/map.cpp create mode 100644 test/adaptor_test/map_keys_example.cpp create mode 100644 test/adaptor_test/map_values_example.cpp create mode 100644 test/adaptor_test/replaced.cpp create mode 100644 test/adaptor_test/replaced_example.cpp create mode 100644 test/adaptor_test/replaced_if.cpp create mode 100644 test/adaptor_test/replaced_if_example.cpp create mode 100644 test/adaptor_test/reversed.cpp create mode 100644 test/adaptor_test/reversed_example.cpp create mode 100644 test/adaptor_test/sliced.cpp create mode 100644 test/adaptor_test/sliced_example.cpp create mode 100644 test/adaptor_test/strided.cpp create mode 100644 test/adaptor_test/strided_example.cpp create mode 100644 test/adaptor_test/tokenized.cpp create mode 100644 test/adaptor_test/transformed.cpp create mode 100644 test/adaptor_test/transformed_example.cpp create mode 100644 test/adaptor_test/uniqued.cpp create mode 100644 test/adaptor_test/uniqued_example.cpp create mode 100644 test/adaptors.cpp mode change 100755 => 100644 test/adl_conformance.cpp create mode 100644 test/algorithm.cpp create mode 100644 test/algorithm_test/adjacent_find.cpp create mode 100644 test/algorithm_test/binary_search.cpp create mode 100644 test/algorithm_test/copy.cpp create mode 100644 test/algorithm_test/copy_backward.cpp create mode 100644 test/algorithm_test/count.cpp create mode 100644 test/algorithm_test/count_if.cpp create mode 100644 test/algorithm_test/equal.cpp create mode 100644 test/algorithm_test/equal_range.cpp create mode 100644 test/algorithm_test/fill.cpp create mode 100644 test/algorithm_test/find.cpp create mode 100644 test/algorithm_test/find_end.cpp create mode 100644 test/algorithm_test/find_first_of.cpp create mode 100644 test/algorithm_test/find_if.cpp create mode 100644 test/algorithm_test/for_each.cpp create mode 100644 test/algorithm_test/generate.cpp create mode 100644 test/algorithm_test/heap.cpp create mode 100644 test/algorithm_test/includes.cpp create mode 100644 test/algorithm_test/inplace_merge.cpp create mode 100644 test/algorithm_test/lexicographical_compare.cpp create mode 100644 test/algorithm_test/lower_bound.cpp create mode 100644 test/algorithm_test/max_element.cpp create mode 100644 test/algorithm_test/merge.cpp create mode 100644 test/algorithm_test/min_element.cpp create mode 100644 test/algorithm_test/mismatch.cpp create mode 100644 test/algorithm_test/next_permutation.cpp create mode 100644 test/algorithm_test/nth_element.cpp create mode 100644 test/algorithm_test/partial_sort.cpp create mode 100644 test/algorithm_test/partition.cpp create mode 100644 test/algorithm_test/prev_permutation.cpp create mode 100644 test/algorithm_test/random_shuffle.cpp create mode 100644 test/algorithm_test/remove.cpp create mode 100644 test/algorithm_test/remove_if.cpp create mode 100644 test/algorithm_test/replace.cpp create mode 100644 test/algorithm_test/replace_if.cpp create mode 100644 test/algorithm_test/reverse.cpp create mode 100644 test/algorithm_test/rotate.cpp create mode 100644 test/algorithm_test/search.cpp create mode 100644 test/algorithm_test/set_difference.cpp create mode 100644 test/algorithm_test/set_intersection.cpp create mode 100644 test/algorithm_test/set_symmetric_difference.cpp create mode 100644 test/algorithm_test/set_union.cpp create mode 100644 test/algorithm_test/sort.cpp create mode 100644 test/algorithm_test/stable_partition.cpp create mode 100644 test/algorithm_test/stable_sort.cpp create mode 100644 test/algorithm_test/transform.cpp create mode 100644 test/algorithm_test/unique.cpp create mode 100644 test/algorithm_test/upper_bound.cpp create mode 100644 test/combine.cpp mode change 100755 => 100644 test/compat2.cpp create mode 100644 test/counting_range.cpp create mode 100644 test/irange.cpp create mode 100644 test/join.cpp create mode 100644 test/test_driver/range_return_test_driver.hpp create mode 100644 test/test_function/check_equal_fn.hpp create mode 100644 test/test_function/counted_function.hpp create mode 100644 test/test_function/equal_to_x.hpp create mode 100644 test/test_function/false_predicate.hpp create mode 100644 test/test_function/greater_than_x.hpp create mode 100644 test/test_function/multiply_by_x.hpp diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index fd54f7a..e286110 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -9,25 +9,36 @@ #// -use-project boost : $(BOOST_ROOT) ; - +#use-project boost : $(BOOST_ROOT) ; +project boost/libs/range/doc ; import boostbook : boostbook ; -import quickbook ; +#import quickbook ; +using quickbook ; -xml boost_range : boost_range.qbk ; +path-constant images_location : html ; -boostbook standalone +#xml boost_range : boost_range.qbk ; + +#boostbook standalone + +boostbook quickbook : - boost_range + boost_range.qbk : - toc.max.depth=2 - toc.section.depth=4 - chunk.section.depth=2 + boost.root=../../../.. + boost.libraries=../../../libraries.htm + html.stylesheet=../../../../doc/html/boostbook.css + chunk.section.depth=4 + chunk.first.sections=1 + toc.section.depth=3 + toc.max.depth=3 + generate.section.toc.level=4 # generate.section.toc.level=4 # chunk.first.sections=7 # toc.section.depth=10 pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html + pdf:img.src.path=$(images_location)/ ; diff --git a/doc/boost_range.qbk b/doc/boost_range.qbk index 80b5c8c..45af6c4 100644 --- a/doc/boost_range.qbk +++ b/doc/boost_range.qbk @@ -1,7 +1,16 @@ -[article Boost.Range Documentation - [quickbook 1.3] - [id boost.range] - [copyright 2003-2007 Thorsten Ottosen] +[/============================================================================== + Copyright (C) 2003-2010 Thorsten Ottosen, Neil Groves + + 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 +==============================================================================/] +[library Range + [quickbook 1.5] + [version 2.0] + [authors [Ottosen, Thorsten], [Groves, Neil]] + [copyright 2003-2010 Thorsten Ottosen, Neil Groves] + [purpose Half-open range library] [license Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,19 +20,49 @@ [/ Converted to Quickbook format by Darren Garvey, 2007] -[def __ranges__ [link boost.range.concepts Ranges]] -[def __range_concepts__ [link boost.range.concepts Range concepts]] -[def __forward_range__ [link boost.range.concepts.forward_range Forward Range]] -[def __single_pass_range__ [link boost.range.concepts.single_pass_range Single Pass Range]] -[def __bidirectional_range__ [link boost.range.concepts.bidirectional_range Bidirectional Range]] -[def __random_access_range__ [link boost.range.concepts.random_access_range Random Access Range]] +[def __note__ [$images/note.png]] +[def __alert__ [$images/alert.png]] +[def __tip__ [$images/tip.png]] +[def __caution__ [$images/caution.png]] -[def __iterator_range__ [link boost.range.utilities.iterator_range `iterator_range`]] -[def __sub_range__ [link boost.range.utilities.sub_range `sub_range`]] -[def __minimal_interface__ [link boost.range.reference.extending minimal interface]] -[def __range_result_iterator__ [link boost.range.reference.semantics.metafunctions `range_result_iterator`]] -[def __implementation_of_metafunctions__ [link boost.range.reference.semantics.metafunctions implementation of metafunctions]] -[def __implementation_of_functions__ [link boost.range.reference.semantics.functions implementation of functions]] +[def __boost_range_home__ [link range Boost.Range]] +[def __ranges__ [link range.concepts Ranges]] +[def __range_concepts__ [link range.concepts Range concepts]] +[def __forward_range__ [link range.concepts.forward_range Forward Range]] +[def __single_pass_range__ [link range.concepts.single_pass_range Single Pass Range]] +[def __bidirectional_range__ [link range.concepts.bidirectional_range Bidirectional Range]] +[def __random_access_range__ [link range.concepts.random_access_range Random Access Range]] + +[def __iterator_range__ [link range.utilities.iterator_range `iterator_range`]] +[def __sub_range__ [link range.utilities.sub_range `sub_range`]] +[def __minimal_interface__ [link range.reference.extending minimal interface]] +[def __range_result_iterator__ [link range.reference.semantics.metafunctions `range_result_iterator`]] +[def __extending_for_udts__ [link range.reference.extending Extending the library for UDTs]] +[def __implementation_of_metafunctions__ [link range.reference.semantics.metafunctions Implementation of metafunctions]] +[def __implementation_of_functions__ [link range.reference.semantics.functions Implementation of functions]] + +[def __range_value__ [link range.reference.semantics.metafunctions `range_value`]] +[def __range_iterator__ [link range.reference.semantics.metafunctions `range_iterator`]] +[def __range_difference__ [link range.reference.semantics.metafunctions `range_difference`]] +[def __range_pointer__ [link range.reference.semantics.metafunctions `range_pointer`]] +[def __range_category__ [link range.reference.semantics.metafunctions `range_category`]] +[def __range_reverse_iterator__ [link range.reference.semantics.metafunctions `range_reverse_iterator`]] +[def __begin__ [link range.reference.semantics.functions `begin`]] +[def __const_begin__ [link range.reference.semantics.functions `const_begin`]] +[def __end__ [link range.reference.semantics.functions `end`]] +[def __const_end__ [link range.reference.semantics.functions `const_end`]] +[def __empty__ [link range.reference.semantics.functions `empty`]] +[def __distance__ [link range.reference.semantics.functions `distance`]] +[def __size__ [link range.reference.semantics.functions `size`]] +[def __rbegin__ [link range.reference.semantics.functions `rbegin`]] +[def __const_rbegin__ [link range.reference.semantics.functions `const_rbegin`]] +[def __rend__ [link range.reference.semantics.functions `rend`]] +[def __const_rend__ [link range.reference.semantics.functions `const_rend`]] +[def __as_array__ [link range.reference.semantics.functions `as_array`]] +[def __as_literal__ [link range.reference.semantics.functions `as_literal`]] + +[def __range_adaptors__ [link range.reference.adaptors Range adaptors]] +[def __range_algorithms__ [link range.reference.algorithms Range algorithms]] [def __single_pass_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#singls-pass-iterators-lib-single-pass-iterators Single Pass Iterator]] [def __forward_traversal_iterator__ [@../../libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators Forward Traversal Iterator]] @@ -38,1197 +77,20 @@ [def __boost_array__ [@../../libs/array/index.html boost::array]] [def __the_forwarding_problem__ [@http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]] +[def __sgi_inner_product__ [@http://www.sgi.com/tech/stl/inner_product.html inner_product]] +[def __sgi_partial_sum__ [@http://www.sgi.com/tech/stl/partial_sum.html partial_sum]] Boost.Range is a collection of concepts and utilities that are particularly useful for specifying and implementing generic algorithms. +[include introduction.qbk] +[include concepts.qbk] +[include reference.qbk] +[include utilities.qbk] +[include style.qbk] +[include headers.qbk] +[include examples.qbk] +[include mfc_atl.qbk] +[include upgrade.qbk] +[include portability.qbk] +[include faq.qbk] +[include history_ack.qbk] - -[section 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 - -* simpler implementation and specification of generic range algorithms -* more flexible, compact and maintainable client code -* correct handling of null-terminated strings - -[:[*Warning: support for null-terminated strings is deprecated and will disappear in the next Boost release (1.34).]] - -* safe use of built-in arrays (for legacy code; why else would you use built-in arrays?) - -Below are given a small example (the complete example can be found [@http://www.boost.org/libs/range/test/algorithm_example.cpp 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 my_vector; - int values[] = { 1,2,3,4,5,6,7,8,9 }; - - my_vector.assign( values, boost::end( values ) ); - 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; - - std::cout << my_generic_replace( my_vector, 4, 2 ); - std::cout << my_generic_replace( my_view, 4, 2 ); - std::cout << my_generic_replace( str, 'a', 'b' ); - - // prints '3', '5' and '0' -`` - -By using the free-standing functions and __metafunctions__, the code automatically works for all the types supported by this library; now and in the future. Notice that we have to provide two version of `find()` since we cannot forward a non-const rvalue with reference arguments (see this article about __the_forwarding_problem__ ). - -[endsect] - - - -[section:concepts Range Concepts] - -[section Overview] - -A Range is a ['concept] similar to the STL [@http://www.sgi.com/Technology/STL/Container.html 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 - -* own the elements that can be accessed through it, -* have copy semantics, - -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 [@../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal 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 [@../../libs/mpl/doc/refmanual/metafunction.html metafunctions] and all functions as free-standing functions to allow for a layer of indirection. - -[endsect] - - -[section Single Pass Range] - -[h4 Notation] - -`X` A type that is a model of __single_pass_range__. -`a` Object of type X. - -[h4 Description] - -A range `X` where `boost::range_iterator::type` is a model of __single_pass_iterator__. - -[h4 Associated types] - -[table - [] - [[Value type ] [`boost::range_value::type` ] [The type of the object stored in a Range.]] - [[Iterator type ] [`boost::range_iterator::type` ] [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.]] - [[Const iterator type] [`boost::range_const_iterator::type`] [A type of iterator that may be used to examine, but not to modify, a Range's elements.]] -] - -[h4 Valid expressions] - -The following expressions must be valid. - -[table - [[Name ] [Expression ] [Return type ]] - [[Beginning of range] [`boost::begin(a)`] [`boost::range_iterator::type` if `a` is mutable,[br] `boost::range_const_iterator::type` otherwise]] - [[End of range ] [`boost::end(a)` ] [`boost::range_iterator::type` if `a` is mutable,[br] `boost::range_const_iterator::type` otherwise]] - [[Is range empty? ] [boost::empty(a) ] [Convertible to bool]] -] - -[h4 Expression semantics] - -[table - [[Expression ] [Semantics ] [Postcondition]] - [[`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.)] [- ]] -] - -[h4 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. - -[h4 Invariants] - -[table - [] - [[Valid range ] [For 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.]] - - [[Completeness] [An algorithm that iterates through the range `[boost::begin(a),boost::end(a))` will pass through every element of `a`.]] -] - -[h4 See also] - -__container__ - -__implementation_of_metafunctions__ - -__implementation_of_functions__ - -[endsect] - - -[section Forward Range] - -[h4 Notation] - -`X` A type that is a model of __forward_range__. -`a` Object of type X. - -[h4 Description] - -A range `X` where `boost::range_iterator::type` is a model of __forward_traversal_iterator__. - -[h4 Refinement of] - -__single_pass_range__ - -[h4 Associated types] - -[table - [] - [[Distance type] [`boost::range_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 ] [`boost::range_size::type` ] [An unsigned integral type that can represent any nonnegative value of the Range's distance type.]] -] - -[h4 Valid expressions] - -[table - [[Name ] [Expression ] [Return type ]] - [[Size of range] [`boost::size(a)`] [`boost::range_size::type`]] -] - -[h4 Expression semantics] - -[table - [[Expression ] [Semantics] [Postcondition]] - [[`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`]] -] - -[h4 Complexity guarantees] - -`boost::size(a)` is at most amortized linear time. - -[h4 Invariants] - -[table - [] - [[Range size] [`boost::size(a)` is equal to the distance from `boost::begin(a)` to `boost::end(a)`.]] -] - -[h4 See also] - -__implementation_of_metafunctions__ - -__implementation_of_functions__ - -[endsect] - - -[section Bidirectional Range] - -[h4 Notation] - -`X` A type that is a model of __bidirectional_range__. -`a` Object of type X. - -[h4 Description] - -This concept provides access to iterators that traverse in both directions (forward and reverse). The `boost::range_iterator::type` iterator must meet all of the requirements of __bidirectional_traversal_iterator__. - -[h4 Refinement of] - -__forward_range__ - -[h4 Associated types] - -[table - [] - [[Reverse Iterator type ] [`boost::range_reverse_iterator::type` ] [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.]] - - [[Const reverse iterator type] [`boost::range_const_reverse_iterator::type`] [A type of reverse iterator that may be used to examine, but not to modify, a Range's elements.]] -] - -[h4 Valid expressions] - -[table - [[Name ] [Expression ] [Return type] [Semantics]] - [[Beginning of range] [`boost::rbegin(a)`] [`boost::range_reverse_iterator::type` if `a` is mutable[br] `boost::range_const_reverse_iterator::type` otherwise.] [Equivalent to `boost::range_reverse_iterator::type(boost::end(a))`.]] - - [[End of range ] [`boost::rend(a)` ] [`boost::range_reverse_iterator::type` if `a` is mutable,[br] `boost::range_const_reverse_iterator::type` otherwise.] [Equivalent to `boost::range_reverse_iterator::type(boost::begin(a))`.]] -] - -[h4 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__. - -[h4 Invariants] - -[table - [] - [[Valid reverse range] [For 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.]] - - [[Completeness ] [`An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.]] -] - -[h4 See also] - -__implementation_of_metafunctions__ - -__implementation_of_functions__ - -[endsect] - - -[section Random Access Range] - -[h4 Description] - -A range `X` where `boost::range_iterator::type` is a model of __random_access_traversal_iterator__. - -[h4 Refinement of] - -__bidirectional_range__ - -[endsect] - - -[section Concept Checking] - -Each of the range concepts has a corresponding concept checking class in the file [@../../boost/range/concepts.hpp `boost/range/concepts.hpp`]. These classes may be used in conjunction with the __concept_check__ to insure that the type of a template parameter is compatible with a range concept. If not, a meaningful compile time error is generated. Checks are provided for the range concepts related to iterator traversal categories. For example, the following line checks that the type `T` models the __forward_range__ concept. - -`` -function_requires >(); -`` - -An additional concept check is required for the value access property of the range based on the range's iterator type. For example to check for a ForwardReadableRange, the following code is required. - -`` -function_requires >(); - function_requires< - ReadableIteratorConcept< - typename range_iterator::type - > - >(); -`` - -The following range concept checking classes are provided. - -* Class SinglePassRangeConcept checks for __single_pass_range__ -* Class ForwardRangeConcept checks for __forward_range__ -* Class BidirectionalRangeConcept checks for __bidirectional_range__ -* Class RandomAccessRangeConcept checks for __random_access_range__ - -[h4 See also] - -[link boost.range.style_guide Range Terminology and style guidelines] - -__iterator_concepts__ - -__concept_check__ - -[endsect] - -[endsect] - - - -[section Reference] - -[section Overview] - -Four types of objects are currently supported by the library: - -* standard-like containers -* `std::pair` -* null terminated strings (this includes `char[]`,`wchar_t[]`, `char*`, and `wchar_t*`) - -[:[*Warning: ['support for null-terminated strings is deprecated and will disappear in the next Boost release (1.34).]]] - -* built-in arrays - -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. - -[endsect] - - -[section 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::type - begin( T& c ); - - template< class T > - typename range_const_iterator::type - begin( const T& c ); - - template< class T > - typename range_iterator::type - end( T& c ); - - template< class T > - typename range_const_iterator::type - end( const T& c ); - - template< class T > - bool - empty( const T& c ); - - // - // Forward Range functions - // - - template< class T > - typename range_size::type - size( const T& c ); - - // - // Bidirectional Range functions - // - - template< class T > - typename range_reverse_iterator::type - rbegin( T& c ); - - template< class T > - typename range_const_reverse_iterator::type - rbegin( const T& c ); - - template< class T > - typename range_reverse_iterator::type - rend( T& c ); - - template< class T > - typename range_const_reverse_iterator::type - rend( const T& c ); - - // - // Special const Range functions - // - - template< class T > - typename range_const_iterator::type - const_begin( const T& r ); - - template< class T > - typename range_const_iterator::type - const_end( const T& r ); - - template< class T > - typename range_const_reverse_iterator::type - const_rbegin( const T& r ); - - template< class T > - typename range_const_reverse_iterator::type - const_rend( const T& r ); - -} // namespace 'boost' -`` - -[endsect] - - -[section Semantics] - -[h5 notation] - -[table - [[Type ] [Object] [Describes ]] - [[`X` ] [`x` ] [any type ]] - [[`T` ] [`t` ] [denotes behavior of the primary templates]] - [[`P` ] [`p` ] [denotes `std::pair` ]] - [[`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. - -[section Metafunctions] - -[table - [[Expression] [Return type] [Complexity]] - [[`range_value::type`] [`T::value_type`[br] -`boost::iterator_value::type`[br] -`A`[br] -`Char`] [compile time]] - [[`range_iterator::type`] [`T::iterator`[br] -`P::first_type`[br] -`A*`[br] -`Char*`] [compile time]] - [[`range_const_iterator::type`] [`T::const_iterator`[br] -`P::first_type`[br] -`const A*`[br] -`const Char*`] [compile time]] - [[`range_difference::type`] [`T::difference_type`[br] -`boost::iterator_difference::type`[br] -`std::ptrdiff_t`[br] -`std::ptrdiff_t`] [compile time]] - [[`range_size::type`] [`T::size_type`[br] -`std::size_t`[br] -`std::size_t`[br] -`std::size_t`] [compile time]] - [[`range_result_iterator::type`] [`range_const_iterator::type` if `X` is `const`[br] -`range_iterator::type` otherwise] [compile time]] - [[`range_reverse_iterator::type`] [`boost::reverse_iterator< typename range_iterator::type >`] [compile time]] - [[`range_const_reverse_iterator::type`] [`boost::reverse_iterator< typename range_const_iterator::type >`] [compile time]] - [[`range_reverse_result_iterator::type`] [`boost::reverse_iterator< typename range_result_iterator::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. - -[endsect] - -[section Functions] - -[table - [[Expression] [Return type] [Returns] [Complexity]] - - [[`begin(x)`] [`range_result_iterator::type`] [`p.first` if `p` is of type `std::pair`[br] -`a` if `a` is an array[br] -`s` if `s` is a string literal[br] -`boost_range_begin(x)` if that expression would invoke a function found by ADL[br] -`t.begin()` otherwise] [constant time]] - - [[`end(x)`] [`range_result_iterator::type`] [`p.second` if `p` is of type `std::pair`[br] -`a + sz` if `a` is an array of size `sz`[br] -`s + std::char_traits::length( s )` if `s` is a `Char*`[br] -`s + sz - 1` if `s` is a string literal of size `sz`[br] -`boost_range_end(x)` if that expression would invoke a function found by ADL[br] -`t.end()` otherwise] [linear if `X` is `Char*` -constant time otherwise]] - - [[`empty(x)`] [`bool`] [`begin(x) == end( x )`] [linear if `X` is `Char*`[br] -constant time otherwise]] - - [[`size(x)`] [`range_size::type`] [`std::distance(p.first,p.second)` if `p` is of type `std::pair`[br] -`sz` if `a` is an array of size `sz`[br] -`end(s) - s` if `s` is a string literal or a `Char*`[br] -`boost_range_size(x)` if that expression would invoke a function found by ADL[br] -`t.size()` otherwise] [linear if `X` is `Char*` or if `std::distance()` is linear[br] -constant time otherwise]] - - [[`rbegin(x)`] [`range_reverse_result_iterator::type`] [`range_reverse_result_iterator::type( end(x) )`] [same as `end(x)`]] - - [[`rend(x)`] [`range_reverse_result_iterator::type`] [`range_reverse_result_iterator::type( begin(x) )`] [same as `begin(x)`]] - - [[`const_begin(x)`] [`range_const_iterator::type`] [`range_const_iterator::type( begin(x) )`] [same as `begin(x)`]] - - [[`const_end(x)`] [`range_const_iterator::type`] [`range_const_iterator::type( end(x) )`] [same as `end(x)`]] - - [[`const_rbegin(x)`] [`range_const_reverse_iterator::type`] [`range_const_reverse_iterator::type( rbegin(x) )`] [same as `rbegin(x)`]] - - [[`const_rend(x)`] [`range_const_reverse_iterator::type`] [`range_const_reverse_iterator::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. - -[endsect] - -[endsect] - -[section:extending Extending the library] - -[section:method_1 Method 1: provide member functions and nested types] - -This procedure assumes that you have control over the types that should be made conformant to a Range concept. If not, see [link boost.range.reference.extending.method_2 method 2]. - -The primary templates in this library are implemented such that standard containers will work automatically and so will __boost_array__. Below is given an overview of which member functions and member types a class must specify to be useable as a certain Range concept. - -[table - [[Member function] [Related 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: - -[table - [[Member type ] [Related concept ]] - [[`iterator` ] [__single_pass_range__]] - [[`const_iterator`] [__single_pass_range__]] - [[`size_type` ] [__forward_range__ ]] -] - -Again one should notice that member types `reverse_iterator` and `const_reverse_iterator` are not needed. - -[endsect] - -[section:method_2 Method 2: provide free-standing functions and specialize metafunctions] - -This procedure assumes that you cannot (or do not wish to) change the types that should be made conformant to a Range concept. If this is not true, see [link boost.range.reference.extending.method_1 method 1]. - -The primary templates in this library are implemented such that certain functions are found via argument-dependent-lookup (ADL). Below is given an overview of which free-standing functions a class must specify to be useable as a certain Range concept. Let `x` be a variable (`const` or `mutable`) of the class in question. - -[table - [[Function ] [Related concept ]] - [[`boost_range_begin(x)`] [__single_pass_range__]] - [[`boost_range_end(x)` ] [__single_pass_range__]] - [[`boost_range_size(x)` ] [__forward_range__ ]] -] - -`boost_range_begin()` and `boost_range_end()` must be overloaded for both `const` and `mutable` reference arguments. - -You must also specialize 3 metafunctions for your type `X`: - -[table - [[Metafunction ] [Related concept ]] - [[`boost::range_iterator` ] [__single_pass_range__]] - [[`boost::range_const_iterator`] [__single_pass_range__]] - [[`boost::range_size` ] [__forward_range__ ]] -] - -A complete example is given here: - -`` - #include - #include // for std::iterator_traits, std::distance() - - namespace Foo - { - // - // Our sample UDT. A 'Pair' - // will work as a range when the stored - // elements are iterators. - // - template< class T > - struct Pair - { - T first, last; - }; - - } // namespace 'Foo' - - namespace boost - { - // - // Specialize metafunctions. We must include the range.hpp header. - // We must open the 'boost' namespace. - // - - template< class T > - struct range_iterator< Foo::Pair > - { - typedef T type; - }; - - template< class T > - struct range_const_iterator< Foo::Pair > - { - // - // Remark: this is defined similar to 'range_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 > - { - - typedef std::size_t type; - }; - - } // namespace 'boost' - - namespace Foo - { - // - // The required functions. These should be defined in - // the same namespace as 'Pair', in this case - // in namespace 'Foo'. - // - - template< class T > - inline T boost_range_begin( Pair& x ) - { - return x.first; - } - - template< class T > - inline T boost_range_begin( const Pair& x ) - { - return x.first; - } - - template< class T > - inline T boost_range_end( Pair& x ) - { - return x.last; - } - - template< class T > - inline T boost_range_end( const Pair& x ) - { - return x.last; - } - - template< class T > - inline typename boost::range_size< Pair >::type - boost_range_size( const Pair& x ) - { - return std::distance(x.first,x.last); - } - - } // namespace 'Foo' - - #include - - int main() - { - typedef std::vector::iterator iter; - std::vector vec; - Foo::Pair pair = { vec.begin(), vec.end() }; - const Foo::Pair& cpair = pair; - // - // Notice that we call 'begin' etc with qualification. - // - iter i = boost::begin( pair ); - iter e = boost::end( pair ); - i = boost::begin( cpair ); - e = boost::end( cpair ); - boost::range_size< Foo::Pair >::type s = boost::size( pair ); - s = boost::size( cpair ); - boost::range_const_reverse_iterator< Foo::Pair >::type - ri = boost::rbegin( cpair ), - re = boost::rend( cpair ); - } -`` - -[endsect] - -[endsect] - -[endsect] - - - -[section 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` is hardly self-documenting whereas more domain specific class names are. Therefore these two classes are provided: - -* Class `iterator_range` -* Class `sub_range` - -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. - -[section:iterator_range 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. - -[h4 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& - operator<<( std::basic_ostream& Os, - const iterator_range& r ); - - // comparison - template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > - bool operator==( const iterator_range& l, - const iterator_range& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator==( const iterator_range& l, - const ForwardRange& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator==( const ForwardRange& l, - const iterator_range& r ); - - template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > - bool operator!=( const iterator_range& l, - const iterator_range& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator!=( const iterator_range& l, - const ForwardRange& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator!=( const ForwardRange& l, - const iterator_range& r ); - - template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > - bool operator<( const iterator_range& l, - const iterator_range& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator<( const iterator_range& l, - const ForwardRange& r ); - - template< class ForwardTraversalIterator, class ForwardRange > - bool operator<( const ForwardRange& l, - const iterator_range& r ); - - // external construction - template< class ForwardTraversalIterator > - iterator_range< ForwardTraversalIterator > - make_iterator_range( ForwardTraversalIterator Begin, - ForwardTraversalIterator End ); - - template< class ForwardRange > - iterator_range< typename iterator_of::type > - make_iterator_range( ForwardRange& r ); - - template< class ForwardRange > - iterator_range< typename const_iterator_of::type > - make_iterator_range( const ForwardRange& r ); - - template< class Range > - iterator_range< typename range_iterator::type > - make_iterator_range( Range& r, - typename range_difference::type advance_begin, - typename range_difference::type advance_end ); - - template< class Range > - iterator_range< typename range_const_iterator::type > - make_iterator_range( const Range& r, - typename range_difference::type advance_begin, - typename range_difference::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` to `iterator_range`. 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. - -[h4 Details member functions] - -`operator unspecified_bool_type() const;` - -[:['[*Returns]] `!empty();`] - -`bool equal( iterator_range& r ) const;` - -[:['[*Returns]] `begin() == r.begin() && end() == r.end();`] - -[h4 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::type advance_begin, - typename range_difference::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) );`] - -[endsect] - -[section:sub_range 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. - -[h4 Synopsis] - -`` -namespace boost -{ - template< class ForwardRange > - class sub_range : public iterator_range< typename range_result_iterator::type > - { - public: - typedef typename range_result_iterator::type iterator; - typedef typename range_const_iterator::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 ir = find_first( str, "ll" ); -sub_range sub = find_first( str, "ll" ); -`` - -[endsect] - -[endsect] - - - -[section:style_guide 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: - -* ['Value access] category: - * Readable Range - * Writeable Range - * Swappable Range - * Lvalue Range -* ['Traversal] category: - * __single_pass_range__ - * __forward_range__ - * __bidirectional_range__ - * __random_access_range__ - -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 - -* Random Access Readable Writeable Range -* Forward Lvalue Range - -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 ); -`` - -[endsect] - - - -[section Library Headers] - -[table - [[Header ] [Includes ] [Related Concept ]] - [[`` ] [everything ] [- ]] - [[`` ] [every metafunction ] [- ]] - [[`` ] [every function ] [- ]] - [[`` ] [`range_value` ] [__single_pass_range__ ]] - [[`` ] [`range_iterator` ] [__single_pass_range__ ]] - [[`` ] [`range_const_iterator` ] [__single_pass_range__ ]] - [[`` ] [`range_difference` ] [__forward_range__ ]] - [[`` ] [`range_size` ] [__forward_range__ ]] - [[`` ] [`range_result_iterator` ] [- ]] - [[``] [`range_reverse_iterator` ] [__bidirectional_range__ ]] - [[``] - [`range_const_reverse_iterator`] - [_bidirectional_range__ ]] - [[``] - [`range_reverse_result_iterator`] - [- ]] - [[`` ] [`begin` and `const_begin` ] [__single_pass_range__ ]] - [[`` ] [`end` and `const_end` ] [__single_pass_range__ ]] - [[`` ] [`empty` ] [__single_pass_range__ ]] - [[`` ] [`size` ] [__forward_range__ ]] - [[`` ] [`rbegin` and `const_rbegin`] [__bidirectional_range__ ]] - [[`` ] [`rend` and `const_rend` ] [__bidirectional_range__ ]] - [[`` ] [`iterator_range` ] [- ]] - [[`` ] [`sub_range` ] [- ]] - [[`` ] [`concept checks` ] [- ]] -] - -[endsect] - - - -[section Examples] - -Some examples are given in the accompanying test files: - -* [@http://www.boost.org/libs/range/test/string.cpp string.cpp][br] -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).]]] - -* [@http://www.boost.org/libs/range/test/algorithm_example.cpp algorithm_example.cpp][br]shows the replace example from the introduction. - -* [@http://www.boost.org/libs/range/test/iterator_range.cpp iterator_range.cpp] - -* [@http://www.boost.org/libs/range/test/sub_range.cpp sub_range.cpp] - -* [@http://www.boost.org/libs/range/test/iterator_pair.cpp iterator_pair.cpp] - -* [@http://www.boost.org/libs/range/test/reversible_range.cpp reversible_range.cpp] - -* [@http://www.boost.org/libs/range/test/std_container.cpp std_container.cpp] - -* [@http://www.boost.org/libs/range/test/array.cpp array.cpp] - -[endsect] - - - -[section 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: - -# do not use built-in arrays, -# do not pass rvalues to `begin()`, `end()` and `iterator_range` Range constructors and assignment operators, -# use `const_begin()` and `const_end()` whenever your code by intention is read-only; this will also solve most rvalue problems, -# do not rely on ADL: - * if you overload functions, include that header before the headers in this library, - * put all overloads in namespace boost. - - - -[endsect] - - - -[section FAQ] - -1. ['[*Why is there no difference between `range_iterator::type` and `range_const_iterator::type` for `std::pair`?]] - -[: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` object.] - -[:Note that an __iterator_range__ is somewhat more convenient than a `pair` and that a __sub_range__ does propagate const-ness.] - -2. ['[*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.] - -3. ['[*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.] - -4. ['[*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.] - -[endsect] - -[section:history_ack 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 - -* Pavol Droba for help with documentation and implementation -* Pavel Vozenilek for help with porting the library -* Jonathan Turkanis and John Torjo for help with documentation -* Hartmut Kaiser for being review manager -* Jonathan Turkanis for porting the lib (as far sa possible) to vc6 and vc7. - -The concept checks and their documentation was provided by Daniel Walker. - -[endsect] \ No newline at end of file diff --git a/doc/concepts.qbk b/doc/concepts.qbk new file mode 100644 index 0000000..b7c408d --- /dev/null +++ b/doc/concepts.qbk @@ -0,0 +1,251 @@ +[section:concepts Range Concepts] + +[section Overview] + +A Range is a [*/concept/] similar to the STL [@http://www.sgi.com/Technology/STL/Container.html 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 + +* own the elements that can be accessed through it, +* have copy semantics, + +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 [@../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal 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 [@../../libs/mpl/doc/refmanual/metafunction.html metafunctions] and all functions as free-standing functions to allow for a layer of indirection. + +[endsect] + + +[section Single Pass Range] + +[heading Notation] + +[table + [] + [[`X`] [A type that is a model of __single_pass_range__.]] + [[`a`] [Object of type X.]] +] + +[heading Description] + +A range `X` where `boost::range_iterator::type` is a model of __single_pass_iterator__. + +[heading Associated types] + +[table + [] + [[Iterator type ] [`boost::range_iterator::type` ] [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.]] + [[Const iterator type] [`boost::range_iterator::type`] [A type of iterator that may be used to examine, but not to modify, a Range's elements.]] +] + +[heading Valid expressions] + +The following expressions must be valid. + +[table + [[Name ] [Expression ] [Return type ]] + [[Beginning of range] [`boost::begin(a)`] [`boost::range_iterator::type` if `a` is mutable, `boost::range_iterator::type` otherwise]] + [[End of range ] [`boost::end(a)` ] [`boost::range_iterator::type` if `a` is mutable, `boost::range_iterator::type` otherwise]] +] + +[heading Expression semantics] + +[table + [[Expression ] [Semantics ] [Postcondition]] + [[`boost::begin(a)`] [Returns an iterator pointing to the first element in the Range. ] [`boost::begin(a)` is either dereferenceable or past-the-end. It is past-the-end if and only if `boost::distance(a) == 0`.]] + [[`boost::end(a)` ] [Returns an iterator pointing one past the last element in the Range. ] [`boost::end(a)` is past-the-end.]] +] + +[heading Complexity guarantees] + +`boost::end(a)` is at most amortized linear time, `boost::begin(a)` is amortized constant time. For most practical purposes, one can expect both to be amortized constant time. + +[heading Invariants] + +[table + [] + [[Valid range ] [For 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.]] + + [[Completeness] [An algorithm that iterates through the range `[boost::begin(a),boost::end(a))` will pass through every element of `a`.]] +] + +[heading See also] + +__extending_for_udts__ + +__implementation_of_metafunctions__ + +__implementation_of_functions__ + +__container__ + +[endsect] + + +[section Forward Range] + +[heading Notation] + +[table + [] + [[`X`] [A type that is a model of __forward_range__.]] + [[`a`] [Object of type X.]] +] + +[heading Description] + +A range `X` where `boost::range_iterator::type` is a model of __forward_traversal_iterator__. + +[heading Refinement of] + +__single_pass_range__ + +[heading Associated types] + +[table + [] + [[Distance type] [`boost::range_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 ] [`boost::range_size::type` ] [An unsigned integral type that can represent any nonnegative value of the Range's distance type.]] +] + +[heading See also] + +__implementation_of_metafunctions__ + +__implementation_of_functions__ + +[endsect] + + +[section Bidirectional Range] + +[heading Notation] + +[table + [] + [[`X`] [A type that is a model of __bidirectional_range__.]] + [[`a`] [Object of type X.]] +] + +[heading Description] + +This concept provides access to iterators that traverse in both directions (forward and reverse). The `boost::range_iterator::type` iterator must meet all of the requirements of __bidirectional_traversal_iterator__. + +[heading Refinement of] + +__forward_range__ + +[heading Associated types] + +[table + [] + [[Reverse Iterator type ] [`boost::range_reverse_iterator::type` ] [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.]] + + [[Const reverse iterator type] [`boost::range_reverse_iterator::type`] [A type of reverse iterator that may be used to examine, but not to modify, a Range's elements.]] +] + +[heading Valid expressions] + +[table + [[Name ] [Expression ] [Return type] [Semantics]] + [[Beginning of range] [`boost::rbegin(a)`] [`boost::range_reverse_iterator::type` if `a` is mutable `boost::range_reverse_iterator::type` otherwise.] [Equivalent to `boost::range_reverse_iterator::type(boost::end(a))`.]] + + [[End of range ] [`boost::rend(a)` ] [`boost::range_reverse_iterator::type` if `a` is mutable, `boost::range_reverse_iterator::type` otherwise.] [Equivalent to `boost::range_reverse_iterator::type(boost::begin(a))`.]] +] + +[heading 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__. + +[heading Invariants] + +[table + [] + [[Valid reverse range] [For 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.]] + + [[Completeness ] [`An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.]] +] + +[heading See also] + +__implementation_of_metafunctions__ + +__implementation_of_functions__ + +[endsect] + + +[section Random Access Range] + +[heading Description] + +A range `X` where `boost::range_iterator::type` is a model of __random_access_traversal_iterator__. + +[heading Refinement of] + +__bidirectional_range__ + +[heading Valid expressions] + +[table + [[Name ] [Expression ] [Return type ]] + [[Size of range] [`boost::size(a)`] [`boost::range_size::type`]] +] + +[heading Expression semantics] + +[table + [[Expression ] [Semantics] [Postcondition]] + [[`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`]] +] + +[heading Complexity guarantees] + +`boost::size(a)` is completes in amortized constant time. + +[heading Invariants] + +[table + [] + [[Range size] [`boost::size(a)` is equal to the `boost::end(a)` - `boost::begin(a)`.]] +] + +[endsect] + + +[section Concept Checking] + +Each of the range concepts has a corresponding concept checking class in the file [@../../boost/range/concepts.hpp ``]. These classes may be used in conjunction with the __concept_check__ to ensure that the type of a template parameter is compatible with a range concept. If not, a meaningful compile time error is generated. Checks are provided for the range concepts related to iterator traversal categories. For example, the following line checks that the type `T` models the __forward_range__ concept. + +`` +BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); +`` + +An additional concept check is required for the value access property of the range based on the range's iterator type. For example to check for a ForwardReadableRange, the following code is required. + +`` +BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); +BOOST_CONCEPT_ASSERT(( ReadableIteratorConcept::type> )); +`` + +The following range concept checking classes are provided. + +* Class SinglePassRangeConcept checks for __single_pass_range__ +* Class ForwardRangeConcept checks for __forward_range__ +* Class BidirectionalRangeConcept checks for __bidirectional_range__ +* Class RandomAccessRangeConcept checks for __random_access_range__ + +[heading See also] + +[link range.style_guide Range Terminology and style guidelines] + +__iterator_concepts__ + +__concept_check__ + +[endsect] + +[endsect] + diff --git a/doc/counting_range.html b/doc/counting_range.html new file mode 100755 index 0000000..c44edcc --- /dev/null +++ b/doc/counting_range.html @@ -0,0 +1,70 @@ + + + + + + Boost.Range Utilities + + + + +
      + + + + +

      Boost.Range

      +

      Function counting_range

      +

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

      + +

      Synopsis

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

      + © Copyright Neil Groves 2009. +

      + +

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

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + + + diff --git a/doc/examples.qbk b/doc/examples.qbk new file mode 100644 index 0000000..bea16e2 --- /dev/null +++ b/doc/examples.qbk @@ -0,0 +1,23 @@ +[section Examples] + +Some examples are given in the accompanying test files: + +* [@http://www.boost.org/libs/range/test/string.cpp string.cpp] shows how to implement a container version of `std::find()` that works with `char[]`,`wchar_t[]`,`char*`,`wchar_t*`. + +* [@http://www.boost.org/libs/range/test/algorithm_example.cpp algorithm_example.cpp] shows the replace example from the introduction. + +* [@http://www.boost.org/libs/range/test/iterator_range.cpp iterator_range.cpp] + +* [@http://www.boost.org/libs/range/test/sub_range.cpp sub_range.cpp] + +* [@http://www.boost.org/libs/range/test/iterator_pair.cpp iterator_pair.cpp] + +* [@http://www.boost.org/libs/range/test/reversible_range.cpp reversible_range.cpp] + +* [@http://www.boost.org/libs/range/test/std_container.cpp std_container.cpp] + +* [@http://www.boost.org/libs/range/test/array.cpp array.cpp] + +[endsect] + + diff --git a/doc/faq.qbk b/doc/faq.qbk new file mode 100644 index 0000000..f01ffe8 --- /dev/null +++ b/doc/faq.qbk @@ -0,0 +1,25 @@ +[section FAQ] + +1. ['[*Why is there no difference between `range_iterator::type` and `range_const_iterator::type` for `std::pair`?]] + +[: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` object.] + +[:Note that an __iterator_range__ is somewhat more convenient than a `pair` and that a __sub_range__ does propagate const-ness.] + +2. ['[*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.] + +3. ['[*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.] + +4. ['[*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.] + +[endsect] + + diff --git a/doc/headers.qbk b/doc/headers.qbk new file mode 100644 index 0000000..6edefbd --- /dev/null +++ b/doc/headers.qbk @@ -0,0 +1,29 @@ +[section Library Headers] + +[table + [[Header ] [Includes ] [Related Concept ]] + [[`` ] [everything ] [- ]] + [[`` ] [every metafunction ] [- ]] + [[`` ] [every function ] [- ]] + [[`` ] [__range_value__ ] [__single_pass_range__ ]] + [[`` ] [__range_iterator__ ] [__single_pass_range__ ]] + [[`` ] [__range_difference__ ] [__forward_range__ ]] + [[`` ] [__range_pointer__ ] [-]] + [[`` ] [__range_category__ ] [-]] + [[``] [__range_reverse_iterator__ ] [__bidirectional_range__ ]] + [[`` ] [__begin__ and __const_begin__ ] [__single_pass_range__ ]] + [[`` ] [__end__ and __const_end__ ] [__single_pass_range__ ]] + [[`` ] [__empty__ ] [__single_pass_range__ ]] + [[`` ] [__distance__ ] [__forward_range__ ]] + [[`` ] [__size__ ] [__random_access_range__ ]] + [[`` ] [__rbegin__ and __const_rbegin__] [__bidirectional_range__ ]] + [[`` ] [__rend__ and __const_rend__ ] [__bidirectional_range__ ]] + [[`` ] [__as_array__ ] [- ]] + [[`` ] [__as_literal__ ] [- ]] + [[`` ] [__iterator_range__ ] [- ]] + [[`` ] [__sub_range__ ] [- ]] + [[`` ] [__range_concepts__ ] [- ]] +] + +[endsect] + diff --git a/doc/history_ack.qbk b/doc/history_ack.qbk new file mode 100644 index 0000000..4d4b103 --- /dev/null +++ b/doc/history_ack.qbk @@ -0,0 +1,22 @@ +[section:history_ack 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 + +* Pavol Droba for help with documentation and implementation +* Pavel Vozenilek for help with porting the library +* Jonathan Turkanis and John Torjo for help with documentation +* Hartmut Kaiser for being review manager +* Jonathan Turkanis for porting the lib (as far sa possible) to vc6 and vc7. + +The concept checks and their documentation was provided by Daniel Walker. + +[endsect] + diff --git a/doc/html/index.html b/doc/html/index.html new file mode 100644 index 0000000..e52fb31 --- /dev/null +++ b/doc/html/index.html @@ -0,0 +1,144 @@ + + + +Chapter 1. Range 2.0 + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      Next
      +
      +
      +

      +Chapter 1. Range 2.0

      +

      +Thorsten Ottosen +

      +

      +Neil Groves +

      +
      +
      +

      + Distributed under 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) +

      +
      +
      + +

      + Boost.Range is a collection of concepts and utilities that are particularly useful + for specifying and implementing generic algorithms. +

      +
      + + + +

      Last revised: March 28, 2010 at 14:28:09 GMT

      +
      +
      Next
      + + diff --git a/doc/html/quickbook_HTML.manifest b/doc/html/quickbook_HTML.manifest new file mode 100644 index 0000000..b3be8f5 --- /dev/null +++ b/doc/html/quickbook_HTML.manifest @@ -0,0 +1,132 @@ +index.html +range/introduction.html +range/concepts.html +range/concepts/overview.html +range/concepts/single_pass_range.html +range/concepts/forward_range.html +range/concepts/bidirectional_range.html +range/concepts/random_access_range.html +range/concepts/concept_checking.html +range/reference.html +range/reference/overview.html +range/reference/synopsis.html +range/reference/semantics.html +range/reference/semantics/metafunctions.html +range/reference/semantics/functions.html +range/reference/adaptors.html +range/reference/adaptors/adaptors_introduction.html +range/reference/adaptors/adaptors_synopsis.html +range/reference/adaptors/adaptors_general_requirements.html +range/reference/adaptors/adaptors_reference.html +range/reference/adaptors/adaptors_reference/adjacent_filtered.html +range/reference/adaptors/adaptors_reference/copied.html +range/reference/adaptors/adaptors_reference/filtered.html +range/reference/adaptors/adaptors_reference/indexed.html +range/reference/adaptors/adaptors_reference/indirected.html +range/reference/adaptors/adaptors_reference/map_keys.html +range/reference/adaptors/adaptors_reference/map_values.html +range/reference/adaptors/adaptors_reference/replaced.html +range/reference/adaptors/adaptors_reference/replaced_if.html +range/reference/adaptors/adaptors_reference/reversed.html +range/reference/adaptors/adaptors_reference/sliced.html +range/reference/adaptors/adaptors_reference/strided.html +range/reference/adaptors/adaptors_reference/tokenized.html +range/reference/adaptors/adaptors_reference/transformed.html +range/reference/adaptors/adaptors_reference/uniqued.html +range/reference/algorithms.html +range/reference/algorithms/range_algorithm_introduction.html +range/reference/algorithms/range_algorithm_mutating_algorithms.html +range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html +range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html +range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html +range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html +range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html +range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html +range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html +range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html +range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html +range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html +range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html +range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html +range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html +range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html +range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html +range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html +range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html +range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html +range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html +range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html +range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html +range/reference/algorithms/set_algorithms.html +range/reference/algorithms/set_algorithms/includes.html +range/reference/algorithms/set_algorithms/set_union.html +range/reference/algorithms/set_algorithms/set_intersection.html +range/reference/algorithms/set_algorithms/set_difference.html +range/reference/algorithms/set_algorithms/set_symmetric_difference.html +range/reference/algorithms/heap_algorithms.html +range/reference/algorithms/heap_algorithms/push_heap.html +range/reference/algorithms/heap_algorithms/pop_heap.html +range/reference/algorithms/heap_algorithms/make_heap.html +range/reference/algorithms/permutation_algorithms.html +range/reference/algorithms/permutation_algorithms/next_permutation.html +range/reference/algorithms/permutation_algorithms/prev_permutation.html +range/reference/algorithms/range_algorithm_new_algorithms.html +range/reference/algorithms/range_algorithm_new_algorithms/erase.html +range/reference/algorithms/range_algorithm_new_algorithms/for_each.html +range/reference/algorithms/range_algorithm_new_algorithms/insert.html +range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html +range/reference/algorithms/range_algorithm_new_algorithms/push_back.html +range/reference/algorithms/range_algorithm_new_algorithms/push_front.html +range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html +range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html +range/reference/algorithms/range_numeric.html +range/reference/algorithms/range_numeric/accumulate.html +range/reference/algorithms/range_numeric/adjacent_difference.html +range/reference/algorithms/range_numeric/inner_product.html +range/reference/algorithms/range_numeric/partial_sum.html +range/reference/ranges.html +range/reference/ranges/counting_range.html +range/reference/ranges/istream_range.html +range/reference/ranges/irange.html +range/reference/extending.html +range/reference/extending/method_1.html +range/reference/extending/method_2.html +range/reference/extending/method_3.html +range/reference/extending/method_3/method_3_1.html +range/reference/extending/method_3/method_3_2.html +range/utilities.html +range/utilities/iterator_range.html +range/utilities/sub_range.html +range/utilities/join.html +range/style_guide.html +range/library_headers.html +range/examples.html +range/mfc_atl.html +range/mfc_atl/requirements.html +range/mfc_atl/mfc_ranges.html +range/mfc_atl/atl_ranges.html +range/mfc_atl/const_ranges.html +range/mfc_atl/references.html +range/upgrade.html +range/upgrade/upgrade_from_1_42.html +range/upgrade/upgrade_from_1_34.html +range/portability.html +range/faq.html +range/history_ack.html diff --git a/doc/html/range/concepts.html b/doc/html/range/concepts.html new file mode 100644 index 0000000..c384122 --- /dev/null +++ b/doc/html/range/concepts.html @@ -0,0 +1,51 @@ + + + +Range Concepts + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/concepts/bidirectional_range.html b/doc/html/range/concepts/bidirectional_range.html new file mode 100644 index 0000000..99a8ccb --- /dev/null +++ b/doc/html/range/concepts/bidirectional_range.html @@ -0,0 +1,305 @@ + + + +Bidirectional Range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Notation +
      +
      ++++ + + + + + + + + + + + +
      +

      + X +

      +
      +

      + A type that is a model of Bidirectional + Range. +

      +
      +

      + a +

      +
      +

      + Object 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 type +

      +
      +

      + boost::range_reverse_iterator<X>::type +

      +
      +

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

      +
      +

      + Const reverse iterator type +

      +
      +

      + boost::range_reverse_iterator<const X>::type +

      +
      +

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

      +
      +

      + boost::rbegin(a) +

      +
      +

      + boost::range_reverse_iterator<X>::type if a + is mutable boost::range_reverse_iterator<const + X>::type otherwise. +

      +
      +

      + Equivalent to boost::range_reverse_iterator<X>::type(boost::end(a)). +

      +
      +

      + End of range +

      +
      +

      + boost::rend(a) +

      +
      +

      + boost::range_reverse_iterator<X>::type if a + is mutable, boost::range_reverse_iterator<const + 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 range +

      +
      +

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

      +
      +

      + Completeness +

      +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/concepts/concept_checking.html b/doc/html/range/concepts/concept_checking.html new file mode 100644 index 0000000..65088d1 --- /dev/null +++ b/doc/html/range/concepts/concept_checking.html @@ -0,0 +1,108 @@ + + + +Concept Checking + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + Each of the range concepts has a corresponding concept checking class in + the file <boost/range/concepts.hpp>. + These classes may be used in conjunction with the Boost + Concept Check library to ensure that the type of a template parameter + is compatible with a range concept. If not, a meaningful compile time error + is generated. Checks are provided for the range concepts related to iterator + traversal categories. For example, the following line checks that the type + T models the Forward + Range concept. +

      +

      + +

      +
      BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<T> ));
      +
      +

      +

      +

      + An additional concept check is required for the value access property of + the range based on the range's iterator type. For example to check for a + ForwardReadableRange, the following code is required. +

      +

      + +

      +
      BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<T> ));
      +BOOST_CONCEPT_ASSERT(( ReadableIteratorConcept<typename range_iterator<T>::type> ));
      +
      +

      +

      +

      + The following range concept checking classes are provided. +

      +
      +
      + + See also +
      +

      + Range Terminology and style guidelines +

      +

      + Iterator concepts +

      +

      + Boost Concept Check library +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/concepts/forward_range.html b/doc/html/range/concepts/forward_range.html new file mode 100644 index 0000000..42ba1f0 --- /dev/null +++ b/doc/html/range/concepts/forward_range.html @@ -0,0 +1,159 @@ + + + +Forward Range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Notation +
      +
      ++++ + + + + + + + + + + + +
      +

      + X +

      +
      +

      + A type that is a model of Forward + Range. +

      +
      +

      + a +

      +
      +

      + Object 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 type +

      +
      +

      + boost::range_difference<X>::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 +

      +
      +

      + boost::range_size<X>::type +

      +
      +

      + An unsigned integral type that can represent any nonnegative value + of the Range's distance type. +

      +
      +
      + + See also +
      +

      + Implementation of + metafunctions +

      +

      + Implementation of functions +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/concepts/overview.html b/doc/html/range/concepts/overview.html new file mode 100644 index 0000000..7cd19e8 --- /dev/null +++ b/doc/html/range/concepts/overview.html @@ -0,0 +1,79 @@ + + + +Overview + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
        +
      • + own the elements that can be accessed through it, +
      • +
      • + have copy semantics, +
      • +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/concepts/random_access_range.html b/doc/html/range/concepts/random_access_range.html new file mode 100644 index 0000000..adbf102 --- /dev/null +++ b/doc/html/range/concepts/random_access_range.html @@ -0,0 +1,187 @@ + + + +Random Access Range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Description +
      +

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

      +
      + + Refinement + of +
      +

      + Bidirectional Range +

      +
      + + Valid + expressions +
      +
      +++++ + + + + + + + + + + +
      +

      + Name +

      +
      +

      + Expression +

      +
      +

      + Return type +

      +
      +

      + Size of range +

      +
      +

      + boost::size(a) +

      +
      +

      + boost::range_size<X>::type +

      +
      +
      + + Expression + semantics +
      +
      +++++ + + + + + + + + + + +
      +

      + Expression +

      +
      +

      + Semantics +

      +
      +

      + Postcondition +

      +
      +

      + 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 completes in amortized constant time. +

      +
      + + Invariants +
      +
      ++++ + + + + + +
      +

      + Range size +

      +
      +

      + boost::size(a) + is equal to the boost::end(a) - boost::begin(a). +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/concepts/single_pass_range.html b/doc/html/range/concepts/single_pass_range.html new file mode 100644 index 0000000..92daf10 --- /dev/null +++ b/doc/html/range/concepts/single_pass_range.html @@ -0,0 +1,349 @@ + + + +Single Pass Range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Notation +
      +
      ++++ + + + + + + + + + + + +
      +

      + X +

      +
      +

      + A type that is a model of Single + Pass Range. +

      +
      +

      + a +

      +
      +

      + Object of type X. +

      +
      +
      + + Description +
      +

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

      +
      + + Associated + types +
      +
      +++++ + + + + + + + + + + + + + +
      +

      + Iterator type +

      +
      +

      + boost::range_iterator<X>::type +

      +
      +

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

      +
      +

      + Const iterator type +

      +
      +

      + boost::range_iterator<const X>::type +

      +
      +

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

      +
      +++++ + + + + + + + + + + + + + + + + + +
      +

      + Name +

      +
      +

      + Expression +

      +
      +

      + Return type +

      +
      +

      + Beginning of range +

      +
      +

      + boost::begin(a) +

      +
      +

      + boost::range_iterator<X>::type if 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_iterator<const + X>::type otherwise +

      +
      +
      + + Expression + semantics +
      +
      +++++ + + + + + + + + + + + + + + + + + +
      +

      + Expression +

      +
      +

      + Semantics +

      +
      +

      + Postcondition +

      +
      +

      + boost::begin(a) +

      +
      +

      + Returns an iterator pointing to the first element in the Range. +

      +
      +

      + boost::begin(a) + is either dereferenceable or past-the-end. It is past-the-end if + and only if boost::distance(a) == 0. +

      +
      +

      + boost::end(a) +

      +
      +

      + Returns an iterator pointing one past the last element in the Range. +

      +
      +

      + boost::end(a) + is past-the-end. +

      +
      +
      + + Complexity + guarantees +
      +

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

      +
      + + Invariants +
      +
      ++++ + + + + + + + + + + + +
      +

      + Valid range +

      +
      +

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

      +
      +

      + Completeness +

      +
      +

      + An algorithm that iterates through the range [boost::begin(a),boost::end(a)) + will pass through every element of a. +

      +
      +
      + + See also +
      +

      + Extending the library for UDTs +

      +

      + Implementation of + metafunctions +

      +

      + Implementation of functions +

      +

      + Container +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/examples.html b/doc/html/range/examples.html new file mode 100644 index 0000000..b272df8 --- /dev/null +++ b/doc/html/range/examples.html @@ -0,0 +1,62 @@ + + + +Examples + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/faq.html b/doc/html/range/faq.html new file mode 100644 index 0000000..0c9d40b --- /dev/null +++ b/doc/html/range/faq.html @@ -0,0 +1,127 @@ + + + +FAQ + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      +

      +FAQ +

      +

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

      +
      +

      +

      +

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

      +

      +

      +
      +
      +

      +

      +

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

      +

      +

      +
      +

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

      +

      +

      +
      +

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

      +

      +

      +
      +

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

      +

      +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/history_ack.html b/doc/html/range/history_ack.html new file mode 100644 index 0000000..930b6b6 --- /dev/null +++ b/doc/html/range/history_ack.html @@ -0,0 +1,90 @@ + + + +History and Acknowledgement + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHome +
      +
      + +

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

      +
        +
      • + Pavol Droba for help with documentation and implementation +
      • +
      • + Pavel Vozenilek for help with porting the library +
      • +
      • + Jonathan Turkanis and John Torjo for help with documentation +
      • +
      • + Hartmut Kaiser for being review manager +
      • +
      • + Jonathan Turkanis for porting the lib (as far sa possible) to vc6 and vc7. +
      • +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHome +
      + + diff --git a/doc/html/range/introduction.html b/doc/html/range/introduction.html new file mode 100644 index 0000000..6bef0ed --- /dev/null +++ b/doc/html/range/introduction.html @@ -0,0 +1,154 @@ + + + +Introduction + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
        +
      • + simpler implementation and specification of generic range algorithms +
      • +
      • + more flexible, compact and maintainable client code +
      • +
      • + safe use of built-in arrays (for legacy code; why else would you use built-in + arrays?) +
      • +
      +

      + 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_iterator< const ForwardReadableRange >::type
      +find( const ForwardReadableRange& c, const T& value )
      +{
      +   return std::find( boost::begin( c ), boost::end( c ), value );
      +}
      +
      +//
      +// replace first value and return its index
      +//
      +template< class ForwardReadableWriteableRange, class T >
      +inline typename boost::range_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 );
      +std::cout << my_generic_replace( my_view, 4, 2 );
      +std::cout << my_generic_replace( str, 'a', 'b' );
      +
      +// prints '3', '5' and '0'     
      +
      +

      +

      +

      + By using the free-standing functions and metafunctions, + the code automatically works for all the types supported by this library; now + and in the future. Notice that we have to provide two versions of find() since + we cannot forward a non-const rvalue with reference arguments (see this article + about The + Forwarding Problem ). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/library_headers.html b/doc/html/range/library_headers.html new file mode 100644 index 0000000..a5bd095 --- /dev/null +++ b/doc/html/range/library_headers.html @@ -0,0 +1,430 @@ + + + +Library Headers + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Header +

      +
      +

      + Includes +

      +
      +

      + Related Concept +

      +
      +

      + <boost/range.hpp> +

      +
      +

      + everything +

      +
      +

      + - +

      +
      +

      + <boost/range/metafunctions.hpp> +

      +
      +

      + every metafunction +

      +
      +

      + - +

      +
      +

      + <boost/range/functions.hpp> +

      +
      +

      + every function +

      +
      +

      + - +

      +
      +

      + <boost/range/value_type.hpp> +

      +
      +

      + range_value +

      +
      +

      + Single Pass Range +

      +
      +

      + <boost/range/iterator.hpp> +

      +
      +

      + range_iterator +

      +
      +

      + Single Pass Range +

      +
      +

      + <boost/range/difference_type.hpp> +

      +
      +

      + range_difference +

      +
      +

      + Forward Range +

      +
      +

      + <boost/range/pointer.hpp> +

      +
      +

      + range_pointer +

      +
      +

      + - +

      +
      +

      + <boost/range/category.hpp> +

      +
      +

      + range_category +

      +
      +

      + - +

      +
      +

      + <boost/range/reverse_iterator.hpp> +

      +
      +

      + range_reverse_iterator +

      +
      +

      + Bidirectional + Range +

      +
      +

      + <boost/range/begin.hpp> +

      +
      +

      + begin and const_begin +

      +
      +

      + Single Pass Range +

      +
      +

      + <boost/range/end.hpp> +

      +
      +

      + end and const_end +

      +
      +

      + Single Pass Range +

      +
      +

      + <boost/range/empty.hpp> +

      +
      +

      + empty +

      +
      +

      + Single Pass Range +

      +
      +

      + <boost/range/distance.hpp> +

      +
      +

      + distance +

      +
      +

      + Forward Range +

      +
      +

      + <boost/range/size.hpp> +

      +
      +

      + size +

      +
      +

      + Random Access + Range +

      +
      +

      + <boost/range/rbegin.hpp> +

      +
      +

      + rbegin and const_rbegin +

      +
      +

      + Bidirectional + Range +

      +
      +

      + <boost/range/rend.hpp> +

      +
      +

      + rend and const_rend +

      +
      +

      + Bidirectional + Range +

      +
      +

      + <boost/range/as_array.hpp> +

      +
      +

      + as_array +

      +
      +

      + - +

      +
      +

      + <boost/range/as_literal.hpp> +

      +
      +

      + as_literal +

      +
      +

      + - +

      +
      +

      + <boost/range/iterator_range.hpp> +

      +
      +

      + iterator_range +

      +
      +

      + - +

      +
      +

      + <boost/range/sub_range.hpp> +

      +
      +

      + sub_range +

      +
      +

      + - +

      +
      +

      + <boost/range/concepts.hpp> +

      +
      +

      + Range concepts +

      +
      +

      + - +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/mfc_atl.html b/doc/html/range/mfc_atl.html new file mode 100644 index 0000000..4ae5a35 --- /dev/null +++ b/doc/html/range/mfc_atl.html @@ -0,0 +1,141 @@ + + + +MFC/ATL (courtesy of Shunsuke Sogame) + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      + + Introduction +
      +

      + This implementation was kindly donated by Shunsuke Sogame. This header adapts + MFC and ATL containers to the appropriate Range concepts. +

      +
      ++++ + + + + + + + + + + + + + + + + + + + +
      +

      + Author: +

      +
      +

      + Shunsuke Sogame +

      +
      +

      + Contact: +

      +
      +

      + mb2act@yahoo.co.jp +

      +
      +

      + Date: +

      +
      +

      + 26th of May 2006 +

      +
      +

      + Copyright: +

      +
      +

      + Shunsuke Sogame 2005-2006. Use, modification and distribution is + subject to the Boost Software License, Version 1.0 +

      +
      +
      + + Overview +
      +

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

      +

      + +

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

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/mfc_atl/atl_ranges.html b/doc/html/range/mfc_atl/atl_ranges.html new file mode 100644 index 0000000..65ee355 --- /dev/null +++ b/doc/html/range/mfc_atl/atl_ranges.html @@ -0,0 +1,374 @@ + + + +ATL Ranges + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
      +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Range +

      +
      +

      + Traversal Category +

      +
      +

      + range_reference<Range>::type +

      +
      +

      + CAtlArray<E,ET> +

      +
      +

      + Random Access + Range +

      +
      +

      + E& +

      +
      +

      + CAutoPtrArray<E> +

      +
      +

      + Random Access + Range +

      +
      +

      + E& +

      +
      +

      + CInterfaceArray<I,pi> +

      +
      +

      + Random Access + Range +

      +
      +

      + CComQIPtr<I,pi>& +

      +
      +

      + CAtlList<E,ET> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + E& +

      +
      +

      + CAutoPtrList<E> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + E& +

      +
      +

      + CHeapPtrList<E,A> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + E& +

      +
      +

      + CInterfaceList<I,pi> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + CComQIPtr<I,pi>& +

      +
      +

      + CAtlMap<K,V,KT,VT> +

      +
      +

      + Forward Range +

      +
      +

      + Range::CPair& +

      +
      +

      + CRBTree<K,V,KT,VT> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + Range::CPair& +

      +
      +

      + CRBMap<K,V,KT,VT> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + Range::CPair& +

      +
      +

      + CRBMultiMap<K,V,KT,VT> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + Range::CPair& +

      +
      +

      + CSimpleStringT<B,b> +

      +
      +

      + Random Access + Range +

      +
      +

      + B& +

      +
      +

      + CStringT<B,ST> +

      +
      +

      + Random Access + Range +

      +
      +

      + B& +

      +
      +

      + CFixedStringT<S,n> +

      +
      +

      + Random Access + Range +

      +
      +

      + range_reference<S>::type +

      +
      +

      + CComBSTR +

      +
      +

      + Random Access + Range +

      +
      +

      + OLECHAR& +

      +
      +

      + CSimpleArray<T,TE> +

      +
      +

      + Random Access + Range +

      +
      +

      + T& +

      +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/mfc_atl/const_ranges.html b/doc/html/range/mfc_atl/const_ranges.html new file mode 100644 index 0000000..2e047f6 --- /dev/null +++ b/doc/html/range/mfc_atl/const_ranges.html @@ -0,0 +1,125 @@ + + + +const Ranges + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +

      + +

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

      +

      +

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

      +
      ++++ + + + + + + + + + + + + + + + + + + +
      +

      + Range metafunction +

      +
      +

      + Result +

      +
      +

      + range_value<const Range>::type +

      +
      +

      + range_value<Range>::type +

      +
      +

      + range_difference<const + Range>::type +

      +
      +

      + std::ptrdiff_t +

      +
      +

      + range_pointer<const Range>::type +

      +
      +

      + add_pointer<remove_reference<range_reference<const Range>::type>::type>::type +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/mfc_atl/mfc_ranges.html b/doc/html/range/mfc_atl/mfc_ranges.html new file mode 100644 index 0000000..af0c6e9 --- /dev/null +++ b/doc/html/range/mfc_atl/mfc_ranges.html @@ -0,0 +1,480 @@ + + + +MFC Ranges + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
      +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Range +

      +
      +

      + Traversal Category +

      +
      +

      + range_reference<Range>::type +

      +
      +

      + CArray<T,A> +

      +
      +

      + Random Access + Range +

      +
      +

      + T& +

      +
      +

      + CList<T,A> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + T& +

      +
      +

      + CMap<K,AK,M,AM> +

      +
      +

      + Forward Range +

      +
      +

      + Range::CPair& +

      +
      +

      + CTypedPtrArray<B,T*> +

      +
      +

      + Random Access + Range +

      +
      +

      + T* + const +

      +
      +

      + CTypedPtrList<B,T*> +

      +
      +

      + Bidirectional + Range +

      +
      +

      + T* + const +

      +
      +

      + CTypedPtrMap<B,T*,V*> +

      +
      +

      + Forward Range +

      +
      +

      + std::pair<T*,V*> + const +

      +
      +

      + CByteArray +

      +
      +

      + Random Access + Range +

      +
      +

      + BYTE& +

      +
      +

      + CDWordArray +

      +
      +

      + Random Access + Range +

      +
      +

      + DWORD& +

      +
      +

      + CObArray +

      +
      +

      + Random Access + Range +

      +
      +

      + CObject*& +

      +
      +

      + CPtrArray +

      +
      +

      + Random Access + Range +

      +
      +

      + void*& +

      +
      +

      + CStringArray +

      +
      +

      + Random Access + Range +

      +
      +

      + CString& +

      +
      +

      + CUIntArray +

      +
      +

      + Random Access + Range +

      +
      +

      + UINT& +

      +
      +

      + CWordArray +

      +
      +

      + Random Access + Range +

      +
      +

      + WORD& +

      +
      +

      + CObList +

      +
      +

      + Bidirectional + Range +

      +
      +

      + CObject*& +

      +
      +

      + CPtrList +

      +
      +

      + Bidirectional + Range +

      +
      +

      + void*& +

      +
      +

      + CStringList +

      +
      +

      + Bidirectional + Range +

      +
      +

      + CString& +

      +
      +

      + CMapPtrToWord +

      +
      +

      + Forward Range +

      +
      +

      + std::pair<void*,WORD> + const +

      +
      +

      + CMapPtrToPtr +

      +
      +

      + Forward Range +

      +
      +

      + std::pair<void*,void*> + const +

      +
      +

      + CMapStringToOb +

      +
      +

      + Forward Range +

      +
      +

      + std::pair<String,CObject*> + const +

      +
      +

      + CMapStringToString +

      +
      +

      + Forward Range +

      +
      +

      + Range::CPair& +

      +
      +

      + CMapWordToOb +

      +
      +

      + Forward Range +

      +
      +

      + std::pair<WORD,CObject*> + const +

      +
      +

      + CMapWordToPtr +

      +
      +

      + Forward Range +

      +
      +

      + std::pair<WORD,void*> + const +

      +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/mfc_atl/references.html b/doc/html/range/mfc_atl/references.html new file mode 100644 index 0000000..124a538 --- /dev/null +++ b/doc/html/range/mfc_atl/references.html @@ -0,0 +1,50 @@ + + + +References + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/mfc_atl/requirements.html b/doc/html/range/mfc_atl/requirements.html new file mode 100644 index 0000000..131433f --- /dev/null +++ b/doc/html/range/mfc_atl/requirements.html @@ -0,0 +1,51 @@ + + + +Requirements + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
        +
      • + Boost C++ Libraries Version 1.34.0 or later (no compilation required) +
      • +
      • + Visual C++ 7.1 or later (for MFC and ATL) +
      • +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/portability.html b/doc/html/range/portability.html new file mode 100644 index 0000000..901e0b1 --- /dev/null +++ b/doc/html/range/portability.html @@ -0,0 +1,89 @@ + + + +Portability + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + 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_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. +
      3. + do not pass rvalues to begin(), + end() and iterator_range Range constructors + and assignment operators, +
      4. +
      5. + use const_begin() and const_end() + whenever your code by intention is read-only; this will also solve most rvalue + problems, +
      6. +
      7. + do not rely on ADL: +
          +
        • + if you overload functions, include that header before the headers in + this library, +
        • +
        • + put all overloads in namespace boost. +
        • +
        +
      8. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference.html b/doc/html/range/reference.html new file mode 100644 index 0000000..70c17dc --- /dev/null +++ b/doc/html/range/reference.html @@ -0,0 +1,93 @@ + + + +Reference + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors.html b/doc/html/range/reference/adaptors.html new file mode 100644 index 0000000..5ab0ecd --- /dev/null +++ b/doc/html/range/reference/adaptors.html @@ -0,0 +1,51 @@ + + + +Range Adaptors + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_general_requirements.html b/doc/html/range/reference/adaptors/adaptors_general_requirements.html new file mode 100644 index 0000000..a815bae --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_general_requirements.html @@ -0,0 +1,141 @@ + + + +General Requirements + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + In the description of generator expressions, the following notation is + used: +

      +
        +
      • +fwdRng is an expression + of a type R that models + ForwardRange +
      • +
      • +biRng is an expression + of a type R that models + BidirectionalRange +
      • +
      • +rndRng is an expression + of a type R that models + RandomAccessRange +
      • +
      • +pred is an expression + of a type that models UnaryPredicate +
      • +
      • +bi_pred is an expression + of a type that models BinaryPredicate +
      • +
      • +fun is an expression + of a type that models UnaryFunction +
      • +
      • +value, new_value and old_value + are objects convertible to boost::range_value<R>::type +
      • +
      • +n,m are integer expressions convertible + to range_difference<R>::type +
      • +
      +

      + Also note that boost::range_value<R>::type must be implicitly convertible to + the type arguments to pred, + bi_pred and fun. +

      +

      + Range Category in the following adaptor descriptions refers to the minimum + range concept required by the range passed to the adaptor. The resultant + range is a model of the same range concept as the input range unless specified + otherwise. +

      +

      + Returned Range Category is the concept of the returned range. In some cases + the returned range is of a lesser category than the range passed to the + adaptor. For example, the filtered + adaptor returns only a ForwardRange + regardless of the input. +

      +

      + Furthermore, the following rules apply to any expression of the form +

      +
      rng | boost::adaptors::adaptor_generator
      +
      +

      +

      +

      + 1. Applying operator|() + to a range R (always left + argument) and a range adapter RA + (always right argument) yields a new range type which may not conform to + the same range concept as R. +

      +

      + 2. The return-type of operator|() is otherwise unspecified. +

      +

      + 3. operator|() + is found by Argument Dependent Lookup (ADL) because a range adaptor is + implemented in namespace boost::adaptors. +

      +

      + 4. operator|() + is used to add new behaviour lazily + and never modifies its left argument. +

      +

      + 5. All iterators extracted from the left argument are extracted using qualified + calls to boost::begin() + and boost::end(). +

      +

      + 6. In addition to the throw-clauses + below, operator|() + may throw exceptions as a result of copying iterators. If such copying + cannot throw an exception, then neither can the whole expression. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_introduction.html b/doc/html/range/reference/adaptors/adaptors_introduction.html new file mode 100644 index 0000000..bcd20b4 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_introduction.html @@ -0,0 +1,274 @@ + + + +Introduction and motivation + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + A Range Adaptor is a class that wraps + an existing Range to provide a new Range with different behaviour. Since + the behaviour of Ranges is determined by their associated iterators, a + Range Adaptor simply wraps the underlying iterators with new special iterators. + In this example +

      +

      + +

      +
      #include <boost/range/adaptors.hpp>
      +#include <boost/range/algorithm.hpp>
      +#include <iostream>
      +#include <vector>
      +
      +std::vector<int> vec;
      +boost::copy( vec | boost::adaptors::reversed,
      +             std::ostream_iterator<int>(std::cout) );
      +
      +

      +

      +

      + the iterators from vec + are wrapped reverse_iterators. + The type of the underlying Range Adapter is not documented because you + do not need to know it. All that is relevant is that the expression +

      +

      + +

      +
      vec | boost::adaptors::reversed
      +
      +

      +

      +

      + returns a Range Adaptor where the iterator type is now the iterator type + of the range vec wrapped + in reverse_iterator. The + expression boost::adaptors::reversed is called an Adaptor + Generator. +

      +

      + There are two ways of constructing a range adaptor. The first is by using + operator|(). + This is my preferred technique, however while discussing range adaptors + with others it became clear that some users of the library strongly prefer + a more familiar function syntax, so equivalent functions of the present + tense form have been added as an alternative syntax. The equivalent to + rng | + reversed is adaptors::reverse(rng) for example. +

      +

      + Why do I prefer the operator| syntax? The answer is readability: +

      +

      + +

      +
      std::vector<int> vec;
      +boost::copy( boost::adaptors::reverse(vec),
      +             std::ostream_iterator<int>(std::cout) );
      +
      +

      +

      +

      + This might not look so bad, but when we apply several adaptors, it becomes + much worse. Just compare +

      +

      + +

      +
      std::vector<int> vec;
      +boost::copy( boost::adaptors::unique( boost::adaptors::reverse( vec ) ),
      +             std::ostream_iterator<int>(std::cout) );
      +
      +

      +

      +

      + to +

      +

      + +

      +
      std::vector<int> vec;
      +boost::copy( vec | boost::adaptors::reversed
      +                 | boost::adaptors::uniqued,
      +             std::ostream_iterator<int>(std::cout) );
      +
      +

      +

      +

      + Furthermore, some of the adaptor generators take arguments themselves and + these arguments are expressed with function call notation too. In those + situations, you will really appreciate the succinctness of operator|(). +

      +
      + + Composition + of Adaptors +
      +

      + Range Adaptors are a powerful complement to Range algorithms. The reason + is that adaptors are orthogonal + to algorithms. For example, consider these Range algorithms: +

      +
        +
      • boost::copy( rng, out )
      • +
      • boost::count( rng, pred )
      • +
      +

      + What should we do if we only want to copy an element a + if it satisfies some predicate, say pred(a)? + And what if we only want to count the elements that satisfy the same predicate? + The naive answer would be to use these algorithms: +

      +
        +
      • boost::copy_if( + rng, + pred, + out )
      • +
      • boost::count_if( + rng, + pred )
      • +
      +

      + These algorithms are only defined to maintain a one to one relationship + with the standard library algorithms. This approach of adding algorithm + suffers a combinatorial explosion. Inevitably many algorithms are missing + _if variants and there + is redundant development overhead for each new algorithm. The Adaptor Generator + is the design solution to this problem. +

      +
      + + Range + Adaptor alternative to copy_if algorithm +
      +

      + +

      +
      boost::copy_if( rng, pred, out );
      +
      +

      + can be expressed as +

      +
      boost::copy( rng | boost::adaptors::filtered(pred), out );
      +
      +

      +

      +
      + + Range + Adaptor alternative to count_if algorithm +
      +

      + +

      +
      boost::count_if( rng, pred );
      +
      +

      + can be expressed as +

      +
      boost::count( rng | boost::adaptors::filtered(pred), out );
      +
      +

      +

      +

      + What this means is that no + algorithm with the _if + suffix is needed. Furthermore, it turns out that algorithms with the _copy suffix are not needed either. Consider + the somewhat misdesigned replace_copy_if() which may be used as +

      +

      + +

      +
      std::vector<int> vec;
      +boost::replace_copy_if( rng, std::back_inserter(vec), pred );
      +
      +

      +

      +

      + With adaptors and algorithms we can express this as +

      +

      + +

      +
      std::vector<int> vec;
      +boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value));
      +
      +

      +

      +

      + The latter code has several benefits: +

      +

      + 1. it is more efficient + because we avoid extra allocations as might happen with std::back_inserter +

      +

      + 2. it is flexible + as we can subsequently apply even more adaptors, for example: +

      +
      boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value)
      +                          | boost::adaptors::reversed);
      +
      +

      +

      +

      + 3. it is safer because + there is no use of an unbounded output iterator. +

      +

      + In this manner, the composition + of Range Adaptors has the following consequences: +

      +

      + 1. we no longer need _if, + _copy, _copy_if + and _n variants of algorithms. +

      +

      + 2. we can generate a multitude of new algorithms on the fly, for example, + above we generated reverse_replace_copy_if() +

      +

      + In other words: +

      +

      + Range Adaptors are to algorithms what algorithms + are to containers +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference.html b/doc/html/range/reference/adaptors/adaptors_reference.html new file mode 100644 index 0000000..d284888 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference.html @@ -0,0 +1,75 @@ + + + +Reference + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/adjacent_filtered.html b/doc/html/range/reference/adaptors/adaptors_reference/adjacent_filtered.html new file mode 100644 index 0000000..fa763c8 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/adjacent_filtered.html @@ -0,0 +1,151 @@ + + + +adjacent_filtered + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::adjacent_filtered(bi_pred) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::adjacent_filter(rng, + bi_pred) +

      +
      +
        +
      • +Precondition: The value_type + of the range is convertible to both argument types of bi_pred. +
      • +
      • +Postcondition: For all adjacent elements + [x,y] in the returned range, bi_pred(x,y) + is true. +
      • +
      • +Throws: Whatever the copy constructor + of bi_pred might throw. +
      • +
      • +Range Category:SinglePassRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/adjacent_filtered.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <functional>
      +#include <iostream>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::vector<int> input;
      +    input += 1,1,2,2,2,3,4,5,6;
      +
      +    boost::copy(
      +        input | adjacent_filtered(std::not_equal_to<int>()),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      1,2,3,4,5,6
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/copied.html b/doc/html/range/reference/adaptors/adaptors_reference/copied.html new file mode 100644 index 0000000..650e29a --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/copied.html @@ -0,0 +1,152 @@ + + + +copied + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::copied(n, + m) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::copy(rng, + n, + m) +

      +
      +
        +
      • +Precondition:0 + <= n + && n + <= m + && m + < distance(rng) +
      • +
      • +Returns: A new iterator_range + that holds the sliced range [n,m) + of the original range. +
      • +
      • +Range Category:RandomAccessRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/copied.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9,10;
      +
      +    boost::copy(
      +        input | copied(1, 5),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      2,3,4,5
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/filtered.html b/doc/html/range/reference/adaptors/adaptors_reference/filtered.html new file mode 100644 index 0000000..1551a9f --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/filtered.html @@ -0,0 +1,156 @@ + + + +filtered + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::filtered(pred) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::filter(rng, + pred) +

      +
      +
        +
      • +Precondition: The value_type + of the range is convertible to the argument type of pred. +
      • +
      • +Postcondition: For all adjacent elements + [x] in the returned range, pred(x) + is true. +
      • +
      • +Throws: Whatever the copy constructor + of pred might throw. +
      • +
      • +Range Category:ForwardRange +
      • +
      • +Returned Range Category:ForwardRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/filtered.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +struct is_even
      +{
      +    bool operator()( int x ) const { return x % 2 == 0; }
      +};
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9;
      +
      +    boost::copy(
      +        input | filtered(is_even()),
      +        std::ostream_iterator<int>(std::cout, ","));
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      2,4,6,8
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/indexed.html b/doc/html/range/reference/adaptors/adaptors_reference/indexed.html new file mode 100644 index 0000000..d8c8674 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/indexed.html @@ -0,0 +1,186 @@ + + + +indexed + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::indexed +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::index(rng) +

      +
      +
        +
      • +Returns: A range adapted to return + both the element and the associated index. The returned range consists + of iterators that have in addition to the usual iterator member functions + an index() + member function that returns the appropriate index for the element + in the sequence corresponding with the iterator. +
      • +
      • +Range Category:SinglePassRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/indexed.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +template<class Iterator>
      +void display_element_and_index(Iterator first, Iterator last)
      +{
      +    for (Iterator it = first; it != last; ++it)
      +    {
      +        std::cout << "Element = " << *it << " Index = " << it.index() << std::endl;
      +    }
      +}
      +
      +template<class SinglePassRange>
      +void display_element_and_index(const SinglePassRange& rng)
      +{
      +    display_element_and_index(boost::begin(rng), boost::end(rng));
      +}
      +
      +template<class Iterator1, class Iterator2>
      +void check_element_and_index(
      +        Iterator1 test_first,
      +        Iterator1 test_last,
      +        Iterator2 reference_first,
      +        Iterator2 reference_last)
      +{
      +    BOOST_CHECK_EQUAL( std::distance(test_first, test_last),
      +                       std::distance(reference_first, reference_last) );
      +
      +    int reference_index = 0;
      +
      +    Iterator1 test_it = test_first;
      +    Iterator2 reference_it = reference_first;
      +    for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index)
      +    {
      +        BOOST_CHECK_EQUAL( *test_it, *reference_it );
      +        BOOST_CHECK_EQUAL( test_it.index(), reference_index );
      +    }
      +}
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::vector<int> input;
      +    input += 10,20,30,40,50,60,70,80,90;
      +
      +    display_element_and_index( input | indexed(0) );
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      Element = 10 Index = 0
      +Element = 20 Index = 1
      +Element = 30 Index = 2
      +Element = 40 Index = 3
      +Element = 50 Index = 4
      +Element = 60 Index = 5
      +Element = 70 Index = 6
      +Element = 80 Index = 7
      +Element = 90 Index = 8
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/indirected.html b/doc/html/range/reference/adaptors/adaptors_reference/indirected.html new file mode 100644 index 0000000..adcd57a --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/indirected.html @@ -0,0 +1,146 @@ + + + +indirected + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::indirected +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::indirect(rng) +

      +
      +
        +
      • +Precondition: The value_type + of the range defines unary operator*() +
      • +
      • +Postcondition: For all elements x in the returned range, x is the result of *y + where y is the corresponding + element in the original range. +
      • +
      • +Range Category:SinglePassRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/indirected.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/shared_ptr.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::adaptors;
      +
      +    std::vector<boost::shared_ptr<int> > input;
      +
      +    for (int i = 0; i < 10; ++i)
      +        input.push_back(boost::shared_ptr<int>(new int(i)));
      +
      +    boost::copy(
      +        input | indirected,
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      0,1,2,3,4,5,6,7,8,9
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/map_keys.html b/doc/html/range/reference/adaptors/adaptors_reference/map_keys.html new file mode 100644 index 0000000..95c1746 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/map_keys.html @@ -0,0 +1,146 @@ + + + +map_keys + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::map_keys +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::keys(rng) +

      +
      +
        +
      • +Precondition: The value_type + of the range is an instantiation of std::pair. +
      • +
      • +Postcondition: For all elements x in the returned range, x is the result of y.first where y + is the corresponding element in the original range. +
      • +
      • +Range Category:SinglePassRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/map.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <map>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::map<int,int> input;
      +    for (int i = 0; i < 10; ++i)
      +        input.insert(std::make_pair(i, i * 10));
      +
      +    boost::copy(
      +        input | map_keys,
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      0,1,2,3,4,5,6,7,8,9
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/map_values.html b/doc/html/range/reference/adaptors/adaptors_reference/map_values.html new file mode 100644 index 0000000..553a8f3 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/map_values.html @@ -0,0 +1,146 @@ + + + +map_values + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::map_values +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::values(rng) +

      +
      +
        +
      • +Precondition: The value_type + of the range is an instantiation of std::pair. +
      • +
      • +Postcondition: For all elements x in the returned range, x is the result of y.second where y + is the corresponding element in the original range. +
      • +
      • +Range Category:SinglePassRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/map.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <map>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::map<int,int> input;
      +    for (int i = 0; i < 10; ++i)
      +        input.insert(std::make_pair(i, i * 10));
      +
      +    boost::copy(
      +        input | map_values,
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      0,10,20,30,40,50,60,70,80,90
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/replaced.html b/doc/html/range/reference/adaptors/adaptors_reference/replaced.html new file mode 100644 index 0000000..0990ede --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/replaced.html @@ -0,0 +1,161 @@ + + + +replaced + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::replaced(new_value, + old_value) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::replace(rng, + new_value, + old_value) +

      +
      +
        +
      • +Precondition:
          +
        • +new_value is convertible + to the value_type + of the range. +
        • +
        • +old_value is convertible + to the value_type + of the range. +
        • +
        +
      • +
      • +Postcondition: For all elements x in the returned range, the value + x is equal to the value + of (y + == old_value) ? new_value : + y where y + is the corresponding element in the original range. +
      • +
      • +Range Category:ForwardRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/replaced.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::adaptors;
      +    using namespace boost::assign;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,2,5,2,7,2,9;
      +
      +    boost::copy(
      +        input | replaced(2, 10),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      1,10,3,10,5,10,7,10,9
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/replaced_if.html b/doc/html/range/reference/adaptors/adaptors_reference/replaced_if.html new file mode 100644 index 0000000..abcf00f --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/replaced_if.html @@ -0,0 +1,165 @@ + + + +replaced_if + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::replaced_if(pred, + new_value) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::replace_if(rng, + pred, + new_value) +

      +
      +
        +
      • +Precondition:
          +
        • + The range value_type + is convertible to the argument type of pred. +
        • +
        • +new_value is convertible + to the value_type + of the range. +
        • +
        +
      • +
      • +Postconditions: For all elements + x in the returned range, + the value x is equal + to the value of pred(y) ? new_value : + y where y + is the corresponding element in the original range. +
      • +
      • +Range Category:ForwardRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/replaced_if.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +struct is_even
      +{
      +    bool operator()(int x) const { return x % 2 == 0; }
      +};
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::adaptors;
      +    using namespace boost::assign;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9;
      +
      +    boost::copy(
      +        input | replaced_if(is_even(), 10),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      1,10,3,10,5,10,7,10,9
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/reversed.html b/doc/html/range/reference/adaptors/adaptors_reference/reversed.html new file mode 100644 index 0000000..52f4cda --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/reversed.html @@ -0,0 +1,140 @@ + + + +reversed + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::reversed +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::reverse(rng) +

      +
      +
        +
      • +Returns: A range whose iterators behave + as if they were the original iterators wrapped in reverse_iterator. +
      • +
      • +Range Category:BidirectionalRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/reversed.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +void reversed_example_test()
      +{
      +    using namespace boost::adaptors;
      +    using namespace boost::assign;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9;
      +
      +    boost::copy(
      +        input | reversed,
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      9,8,7,6,5,4,3,2,1
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/sliced.html b/doc/html/range/reference/adaptors/adaptors_reference/sliced.html new file mode 100644 index 0000000..9793092 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/sliced.html @@ -0,0 +1,150 @@ + + + +sliced + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::sliced(n, + m) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::slice(rng, + n, + m) +

      +
      +
        +
      • +Precondition:0 + <= n + && n + <= m + && m + < distance(rng) +
      • +
      • +Returns:make_range(rng, n, m) +
      • +
      • +Range Category:RandomAccessRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/sliced.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::adaptors;
      +    using namespace boost::assign;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9;
      +
      +    boost::copy(
      +        input | sliced(2, 5),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      3,4,5
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/strided.html b/doc/html/range/reference/adaptors/adaptors_reference/strided.html new file mode 100644 index 0000000..6fcc281 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/strided.html @@ -0,0 +1,147 @@ + + + +strided + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::strided(n) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::stride(rng, + n) +

      +
      +
        +
      • +Precondition:0 + <= n + && n + < distance(rng) +
      • +
      • +Returns: A new range based on rng where traversal is performed + in steps of n. +
      • +
      • +Range Category:RandomAccessRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/strided.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::adaptors;
      +    using namespace boost::assign;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9,10;
      +
      +    boost::copy(
      +        input | strided(2),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      1,3,5,7,9
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/tokenized.html b/doc/html/range/reference/adaptors/adaptors_reference/tokenized.html new file mode 100644 index 0000000..fc4bc42 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/tokenized.html @@ -0,0 +1,143 @@ + + + +tokenized + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + +

      +
      rng | boost::adaptors::tokenized(regex)
      +rng | boost::adaptors::tokenized(regex, i)
      +rng | boost::adaptors::tokenized(regex, rndRng)
      +rng | boost::adaptors::tokenized(regex, i, flags)
      +rng | boost::adaptors::tokenized(regex, rndRng, flags)
      +
      +

      +

      +
      +

      + Function +

      +
      +

      + +

      +
      boost::adaptors::tokenize(rng, regex)
      +boost::adaptors::tokenize(rng, regex, i)
      +boost::adaptors::tokenize(rng, regex, rndRng)
      +boost::adaptors::tokenize(rng, regex, i, flags)
      +boost::adaptors::tokenize(rng, regex, rndRng, flags)
      +
      +

      +

      +
      +
        +
      • +Precondition:
          +
        • + Let T denote typename range_value<decltype(rng)>::type, + then regex has + the type basic_regex<T> or is implicitly convertible + to one of these types. +
        • +
        • +i has the type + int. +
        • +
        • + the value_type + of rndRng is int. +
        • +
        • +flags has the type + regex_constants::syntax_option_type. +
        • +
        +
      • +
      • +Returns: A range whose iterators behave + as if they were the original iterators wrapped in regex_token_iterator. + The first iterator in the range would be constructed by forwarding + all the arguments of tokenized() to the regex_token_iterator + constructor. +
      • +
      • +Throws: Whatever constructing and + copying equivalent regex_token_iterators + might throw. +
      • +
      • +Range Category:RandomAccessRange +
      • +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/transformed.html b/doc/html/range/reference/adaptors/adaptors_reference/transformed.html new file mode 100644 index 0000000..56a6170 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/transformed.html @@ -0,0 +1,156 @@ + + + +transformed + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::transformed(fun) +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::transform(rng, + fun) +

      +
      +
        +
      • +Precondition: The value_type + of the range is convertible to the argument type of fun. +
      • +
      • +Postcondition: For all elements x in the returned range, x is the result of fun(y) + where y is the corresponding + element in the original range. +
      • +
      • +Throws: Whatever the copy-constructor + of fun might throw. +
      • +
      • +Range Category:SinglePassRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/transformed.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +struct double_int
      +{
      +    typedef int result_type;
      +    int operator()(int x) const { return x * 2; }
      +};
      +
      +int main(int argc, const char* argv[])
      +{
      +    using namespace boost::adaptors;
      +    using namespace boost::assign;
      +
      +    std::vector<int> input;
      +    input += 1,2,3,4,5,6,7,8,9,10;
      +
      +    boost::copy(
      +        input | transformed(double_int()),
      +        std::ostream_iterator<int>(std::cout, ","));
      +
      +    return 0;
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      2,4,6,8,10,12,14,16,18,20
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_reference/uniqued.html b/doc/html/range/reference/adaptors/adaptors_reference/uniqued.html new file mode 100644 index 0000000..3b314ab --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_reference/uniqued.html @@ -0,0 +1,142 @@ + + + +uniqued + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      ++++ + + + + + + + + + + + + + + +
      +

      + Syntax +

      +
      +

      + Code +

      +
      +

      + Pipe +

      +
      +

      + rng | + boost::adaptors::uniqued +

      +
      +

      + Function +

      +
      +

      + boost::adaptors::unique(rng) +

      +
      +
        +
      • +Precondition: The value_type + of the range is comparable with operator==(). +
      • +
      • +Postcondition: For all adjacent elements + [x,y] in the returned range, x==y is false. +
      • +
      • +Range Category:ForwardRange +
      • +
      +
      + +

      + +

      +
      #include <boost/range/adaptor/uniqued.hpp>
      +#include <boost/range/algorithm/copy.hpp>
      +#include <boost/assign.hpp>
      +#include <algorithm>
      +#include <iostream>
      +#include <vector>
      +
      +void uniqued_example_test()
      +{
      +    using namespace boost::assign;
      +    using namespace boost::adaptors;
      +
      +    std::vector<int> input;
      +    input += 1,1,2,2,2,3,4,5,6;
      +
      +    boost::copy(
      +        input | uniqued,
      +        std::ostream_iterator<int>(std::cout, ","));
      +}
      +
      +

      +

      +
      +

      + This would produce the output: +

      +
      1,2,3,4,5,6
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/adaptors/adaptors_synopsis.html b/doc/html/range/reference/adaptors/adaptors_synopsis.html new file mode 100644 index 0000000..d0fea59 --- /dev/null +++ b/doc/html/range/reference/adaptors/adaptors_synopsis.html @@ -0,0 +1,67 @@ + + + +Synopsis + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + The library provides the following Adapter Generator expressions: +

      +

      + +

      +
      rng | boost::adaptors::adjacent_filtered(bi_pred)
      +rng | boost::adaptors::copied(n,m)
      +rng | boost::adaptors::filtered(pred)
      +rng | boost::adaptors::indexed
      +rng | boost::adaptors::indirected
      +rng | boost::adaptors::map_keys
      +rng | boost::adaptors::map_values
      +rng | boost::adaptors::replaced(new_value, old_value)
      +rng | boost::adaptors::replaced_if(pred, new_value)
      +rng | boost::adaptors::reversed
      +rng | boost::adaptors::sliced(n, m)
      +rng | boost::adaptors::strided(n)
      +rng | boost::adaptors::tokenized( <see arguments below> )
      +rng | boost::adaptors::transformed(fun)
      +rng | boost::adaptors::uniqued
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms.html b/doc/html/range/reference/algorithms.html new file mode 100644 index 0000000..fc70d02 --- /dev/null +++ b/doc/html/range/reference/algorithms.html @@ -0,0 +1,59 @@ + + + +Range Algorithm + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/heap_algorithms.html b/doc/html/range/reference/algorithms/heap_algorithms.html new file mode 100644 index 0000000..25c45e4 --- /dev/null +++ b/doc/html/range/reference/algorithms/heap_algorithms.html @@ -0,0 +1,51 @@ + + + +Heap algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html b/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html new file mode 100644 index 0000000..5645d07 --- /dev/null +++ b/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html @@ -0,0 +1,144 @@ + + + +make_heap + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +void make_heap(RandomAccessRange& rng);
      +
      +template<class RandomAccessRange>
      +void make_heap(const RandomAccessRange& rng);
      +
      +template<class RandomAccessRange, class Compare>
      +void make_heap(RandomAccessRange& rng, Compare pred);
      +
      +template<class RandomAccessRange, class Compare>
      +void make_heap(const RandomAccessRange& rng, Compare pred);
      +
      +

      +

      +
      + + Description +
      +

      + make_heap turns rng into a heap. +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/heap_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +Compare is a model + of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of Compare's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most 3 * + distance(rng) + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html b/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html new file mode 100644 index 0000000..524f86c --- /dev/null +++ b/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html @@ -0,0 +1,156 @@ + + + +pop_heap + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +void pop_heap(RandomAccessRange& rng);
      +
      +template<class RandomAccessRange>
      +void pop_heap(const RandomAccessRange& rng);
      +
      +template<class RandomAccessRange, class Compare>
      +void pop_heap(RandomAccessRange& rng, Compare pred);
      +
      +template<class RandomAccessRange, class Compare>
      +void pop_heap(const RandomAccessRange& rng, Compare pred);
      +
      +

      +

      +
      + + Description +
      +

      + pop_heap removes the + largest element from the heap. It is assumed that begin(rng), prior(end(rng)) is already a heap and that the element + to be added is *prior(end(rng)). +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/heap_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +Compare is a model + of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of Compare's + argument types. +
      • +
      +
      + + Precondition: +
      +
        +
      • !empty(rng)
      • +
      • +rng is a heap. +
      • +
      +
      + + Complexity +
      +

      + Logarithmic. At most 2 * + log(distance(rng)) + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html b/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html new file mode 100644 index 0000000..357465b --- /dev/null +++ b/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html @@ -0,0 +1,154 @@ + + + +push_heap + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +void push_heap(RandomAccessRange& rng);
      +
      +template<class RandomAccessRange>
      +void push_heap(const RandomAccessRange& rng);
      +
      +template<class RandomAccessRange, class Compare>
      +void push_heap(RandomAccessRange& rng, Compare pred);
      +
      +template<class RandomAccessRange, class Compare>
      +void push_heap(const RandomAccessRange& rng, Compare pred);
      +
      +

      +

      +
      + + Description +
      +

      + push_heap adds an element + to a heap. It is assumed that begin(rng), prior(end(rng)) is already a heap and that the element + to be added is *prior(end(rng)). +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/heap_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +Compare is a model + of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of Compare's + argument types. +
      • +
      +
      + + Precondition: +
      +
        +
      • !empty(rng)
      • +
      • +[begin(rng), prior(end(rng))) is a heap. +
      • +
      +
      + + Complexity +
      +

      + Logarithmic. At most log(distance(rng)) comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/permutation_algorithms.html b/doc/html/range/reference/algorithms/permutation_algorithms.html new file mode 100644 index 0000000..12e33f9 --- /dev/null +++ b/doc/html/range/reference/algorithms/permutation_algorithms.html @@ -0,0 +1,50 @@ + + + +Permutation algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html b/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html new file mode 100644 index 0000000..5f7dce0 --- /dev/null +++ b/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html @@ -0,0 +1,149 @@ + + + +next_permutation + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class BidirectionalRange>
      +void next_permutation(BidirectionalRange& rng);
      +
      +template<class BidirectionalRange>
      +void next_permutation(const BidirectionalRange& rng);
      +
      +template<class BidirectionalRange, class Compare>
      +void next_permutation(BidirectionalRange& rng, Compare pred);
      +
      +template<class BidirectionalRange, class Compare>
      +void next_permutation(const BidirectionalRange& rng, Compare pred);
      +
      +

      +

      +
      + + Description +
      +

      + next_permutation transforms + the range of elements rng + into the lexicographically next greater permutation of the elements if + such a permutation exists. If one does not exist then the range is transformed + into the lexicographically smallest permutation and false + is returned. true is returned + when the next greater permutation is successfully generated. +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/permutation.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +BidirectionalRange + is a model of the Bidirectional + Range Concept. +
      • +
      • +BidirectionalRange + is mutable. +
      • +
      • +BidirectionalRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type BidirectionalRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +BidirectionalRange + is a model of the Bidirectional + Range Concept. +
      • +
      • +BidirectionalRange + is mutable. +
      • +
      • +Compare is a model + of the StrictWeakOrderingConcept. +
      • +
      • +BidirectionalRange's + value type is convertible to both of Compare's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most distance(rng) / 2 + swaps. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html b/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html new file mode 100644 index 0000000..6a37365 --- /dev/null +++ b/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html @@ -0,0 +1,149 @@ + + + +prev_permutation + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class BidirectionalRange>
      +void prev_permutation(BidirectionalRange& rng);
      +
      +template<class BidirectionalRange>
      +void prev_permutation(const BidirectionalRange& rng);
      +
      +template<class BidirectionalRange, class Compare>
      +void prev_permutation(BidirectionalRange& rng, Compare pred);
      +
      +template<class BidirectionalRange, class Compare>
      +void prev_permutation(const BidirectionalRange& rng, Compare pred);
      +
      +

      +

      +
      + + Description +
      +

      + prev_permutation transforms + the range of elements rng + into the lexicographically next smaller permutation of the elements if + such a permutation exists. If one does not exist then the range is transformed + into the lexicographically largest permutation and false + is returned. true is returned + when the next smaller permutation is successfully generated. +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/permutation.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +BidirectionalRange + is a model of the Bidirectional + Range Concept. +
      • +
      • +BidirectionalRange + is mutable. +
      • +
      • +BidirectionalRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type BidirectionalRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +BidirectionalRange + is a model of the Bidirectional + Range Concept. +
      • +
      • +BidirectionalRange + is mutable. +
      • +
      • +Compare is a model + of the StrictWeakOrderingConcept. +
      • +
      • +BidirectionalRange's + value type is convertible to both of Compare's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most distance(rng) / 2 + swaps. +

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

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

      +

      + +

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

      +

      +

      + instead of +

      +

      + +

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

      +

      +

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

      +

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

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

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

      +

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

      +

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

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

      +

      +

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

      +
      ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Expression +

      +
      +

      + Return +

      +
      +

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

      +
      +

      + returns a single iterator like std::unique +

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

      + returns the entire original range. +

      +
      +

      + This functionality has the following advantages: +

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

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

      +

      + +

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

      +

      +

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

      +

      + +

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

      +

      +

      + The same task may be accomplished simply with +

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

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms.html new file mode 100644 index 0000000..80710b0 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms.html @@ -0,0 +1,86 @@ + + + +Mutating algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html new file mode 100644 index 0000000..401b24e --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html @@ -0,0 +1,116 @@ + + + +Range Algorithm - copy + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

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

      +

      +
      + + Description +
      +

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

      +
      + + Definition +
      +

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

      +
      + + Requirements +
      +
        +
      • +SinglePassRange is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • + The value_type of + Single Pass Range + Concept is convertible to a type in OutputIterator's + set of value types. +
      • +
      +
      + + Precondition: +
      +
        +
      • +out_it is not an iterator + within the source_rng. +
      • +
      • +[out_it, out_it + + distance(source_rng)) is a valid range. +
      • +
      +
      + + Complexity +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html new file mode 100644 index 0000000..53e315e --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html @@ -0,0 +1,125 @@ + + + +Range Algorithm - copy_backward + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

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

      +

      +
      + + Description +
      +

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

      +

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

      +

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

      +
      + + Definition +
      +

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

      +
      + + Requirements +
      +
        +
      • +BidirectionalRange + is a model of Bidirectional + Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • + The value_type of + Bidirectional Range + Concept is convertible to a type in OutputIterator's + set of value types. +
      • +
      +
      + + Precondition: +
      +
        +
      • +out_it is not an iterator + within the source_rng. +
      • +
      • +[out_it, out_it + + distance(source_rng)) is a valid range. +
      • +
      +
      + + Complexity +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html new file mode 100644 index 0000000..ad3f8a8 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html @@ -0,0 +1,105 @@ + + + +Range Algorithm - fill + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class Value>
      +void fill( ForwardRange& rng, const Value& val );
      +
      +template<class ForwardRange, class Value>
      +void fill( const ForwardRange& rng, const Value& val );
      +
      +

      +

      +
      + + Description +
      +

      + fill assigns the value + val to every element + in the range rng. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/fill.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +Value is a model of + the AssignableConcept. +
      • +
      • +Value is convertible + to ForwardRange's value + type. +
      • +
      +
      + + Complexity +
      +

      + Linear. Exactly distance(rng) assignments are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html new file mode 100644 index 0000000..a78b8e9 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html @@ -0,0 +1,121 @@ + + + +Range Algorithm - generate + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class Generator>
      +ForwardRange& generate( ForwardRange& rng, Generator gen );
      +
      +template<class ForwardRange, class Generator>
      +const ForwardRange& generate( const ForwardRange& rng, Generator gen );
      +
      +

      +

      +
      + + Description +
      +

      + generate assigns the + result of gen() + to each element in range rng. + Returns the resultant range. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/generate.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +Generator is a model + of the GeneratorConcept. +
      • +
      • + The value_type of + SinglePassRange is + convertible to a type in OutputIterator's + set of value types. +
      • +
      +
      + + Precondition: +
      +
        +
      • +out_it is not an iterator + within rng. +
      • +
      • +[out_it, out_it + + distance(rng)) is a valid range. +
      • +
      +
      + + Complexity +
      +

      + Linear. Exactly distance(rng) assignments are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html new file mode 100644 index 0000000..4192d22 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html @@ -0,0 +1,187 @@ + + + +Range Algorithm - inplace_merge + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class BidirectionalRange>
      +BidirectionalRange&
      +inplace_merge( BidirectionalRange& rng,
      +               typename range_iterator<BidirectionalRange>::type middle );
      +               
      +template<class BidirectionalRange>
      +const BidirectionalRange&
      +inplace_merge( const BidirectionalRange& rng,
      +               typename range_iterator<const BidirectionalRange>::type middle );
      +               
      +template<class BidirectionalRange, class BinaryPredicate>
      +BidirectionalRange&
      +inplace_merge( BidirectionalRange& rng,
      +               typename range_iterator<BidirectionalRange>::type middle,
      +               BinaryPredicate pred );
      +               
      +template<class BidirectionalRange, class BinaryPredicate>
      +const BidirectionalRange&
      +inplace_merge( const BidirectionalRange& rng,
      +               typename range_iterator<const BidirectionalRange>::type middle,
      +               BinaryPredicate pred );
      +
      +

      +

      +
      + + Description +
      +

      + inplace_merge combines + two consecutive sorted ranges [begin(rng), middle) + and [middle, end(rng)) into a single sorted range [begin(rng), end(rng)). That is, it starts with a range [begin(rng), end(rng)) that consists of two pieces each of + which is in ascending order, and rearranges it so that the entire range + is in ascending order. inplace_merge + is stable, meaning both that the relative order of elements within each + input range is preserved. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/inplace_merge.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate version: +

      +
        +
      • +BidirectionalRange + is a model of the Bidirectional + Range Concept. +
      • +
      • +BidirectionalRange + is mutable. +
      • +
      • +range_value<BidirectionalRange>::type is a model of LessThanComparableConcept +
      • +
      • + The ordering on objects of range_type<BidirectionalRange>::type + is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate version: * BidirectionalRange is a model of the + Bidirectional Range + Concept. * BidirectionalRange + is mutable. * BinaryPredicate + is a model of the StrictWeakOrderingConcept. + * BidirectionalRange's + value type is convertible to both BinaryPredicate's + argument types. +

      +
      + + Precondition: +
      +
      + + For + the non-predicate version: +
      +
        +
      • +middle is in the range + rng. +
      • +
      • +[begin(rng), middle) is in ascending order. That is for + each pair of adjacent elements [x,y], + y < + x is false. +
      • +
      • +[middle, end(rng)) is in ascending order. That is for + each pair of adjacent elements [x,y], + y < + x is false. +
      • +
      +
      + + For + the predicate version: +
      +
        +
      • +middle is in the range + rng. +
      • +
      • +[begin(rng), middle) is in ascending order. That is for + each pair of adjacent elements [x,y], + pred(y,x) == false. +
      • +
      • +[middle, end(rng)) is in ascending order. That is for + each pair of adjacent elements [x,y], + pred(y,x) == false. +
      • +
      +
      + + Complexity +
      +

      + Worst case: O(N log(N)) +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html new file mode 100644 index 0000000..5df7c4d --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html @@ -0,0 +1,247 @@ + + + +Range Algorithm - merge + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator
      +    >
      +OutputIterator merge(const SinglePassRange1& rng1,
      +                     const SinglePassRange2& rng2,
      +                     OutputIterator          out);
      +                     
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator,
      +    class BinaryPredicate
      +    >
      +OutputIterator merge(const SinglePassRange1& rng1,
      +                     const SinglePassRange2& rng2,
      +                     OutputIterator          out,
      +                     BinaryPredicate         pred);
      +
      +

      +

      +
      + + Description +
      +

      + merge combines two sorted + ranges rng1 and rng2 into a single sorted range by + copying elements. merge + is stable. The return value is out + + distance(rng1) + distance(rng2). +

      +

      + The two versions of merge + differ by how they compare the elements. +

      +

      + The non-predicate version uses the operator<() for the range value type. The predicate + version uses the predicate instead of operator<(). +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/merge.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate version: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +range_value<SinglePassRange1>::type is the same as range_value<SinglePassRange2>::type. +
      • +
      • +range_value<SinglePassRange1>::type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering on objects of range_value<SinglePassRange1>::type + is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • +range_value<SinglePassRange1>::type is convertible to a type in + OutputIterator's set + of value types. +
      • +
      +

      + For the predicate version: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +range_value<SinglePassRange1>::type is the same as range_value<SinglePassRange2>::type. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to both BinaryPredicate's + argument types. +
      • +
      • +range_value<SinglePassRange1>::type is convertible to a type in + OutputIterator's set + of value types. +
      • +
      +
      + + Precondition: +
      +
      + + For + the non-predicate version: +
      +
        +
      • + The elements of rng1 + are in ascending order. That is, for each adjacent element pair [x,y] of rng1, + y < + x == + false. +
      • +
      • + The elements of rng2 + are in ascending order. That is, for each adjacent element pair [x,y] of rng2, + y < + x == + false. +
      • +
      • + The ranges rng1 and + [out, out + distance(rng1) + distance(rng2)) + do not overlap. +
      • +
      • + The ranges rng2 and + [out, out + distance(rng1) + distance(rng2)) + do not overlap. +
      • +
      • +[out, out + distance(rng1) + distance(rng2)) + is a valid range. +
      • +
      +
      + + For + the predicate version: +
      +
        +
      • + The elements of rng1 + is in ascending order. That is, for each adjacent element pair [x,y], of rng1, + pred(y, x) == false. +
      • +
      • + The elements of rng2 + is in ascending order. That is, for each adjacent element pair [x,y], of rng2, + pred(y, x) == false. +
      • +
      • + The ranges rng1 and + [out, out + distance(rng1) + distance(rng2)) + do not overlap. +
      • +
      • + The ranges rng2 and + [out, out + distance(rng1) + distance(rng2)) + do not overlap. +
      • +
      • +[out, out + distance(rng1) + distance(rng2)) + is a valid range. +
      • +
      +
      + + Complexity +
      +

      + Linear. There are no comparisons if both rng1 + and rng2 are empty, otherwise + at most distance(rng1) + distance(rng2) - 1 + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html new file mode 100644 index 0000000..bc4497a --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html @@ -0,0 +1,147 @@ + + + +Range Algorithm - nth_element + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +void nth_element(RandomAccessRange& rng,
      +                 typename range_iterator<RandomAccessRange>::type nth);
      +                 
      +template<class RandomAccessRange>
      +void nth_element(const RandomAccessRange& rng,
      +                 typename range_iterator<const RandomAccessRange>::type nth);
      +                 
      +template<class RandomAccessRange>
      +void nth_element(RandomAccessRange& rng,
      +                 typename range_iterator<RandomAccessRange>::type nth,
      +                 BinaryPredicate sort_pred);
      +                 
      +template<class RandomAccessRange>
      +void nth_element(const RandomAccessRange& rng,
      +                 typename range_iterator<const RandomAccessRange>::type nth,
      +                 BinaryPredicate sort_pred);
      +
      +

      +

      +
      + + Description +
      +

      + nth_element partially + orders a range of elements. nth_element + arranges the range rng + such that the element corresponding with the iterator nth + is the same as the element that would be in that position if rng has been sorted. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/nth_element.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate version: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering relation on RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate version: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Complexity +
      +

      + On average, linear in distance(rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html new file mode 100644 index 0000000..1c161c7 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html @@ -0,0 +1,152 @@ + + + +Range Algorithm - partial_sort + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +void partial_sort(RandomAccessRange& rng,
      +                  typename range_iterator<RandomAccessRange>::type middle);
      +                 
      +template<class RandomAccessRange>
      +void partial_sort(const RandomAccessRange& rng,
      +                  typename range_iterator<const RandomAccessRange>::type middle);
      +                 
      +template<class RandomAccessRange>
      +void partial_sort(RandomAccessRange& rng,
      +                  typename range_iterator<RandomAccessRange>::type middle,
      +                  BinaryPredicate sort_pred);
      +                 
      +template<class RandomAccessRange>
      +void partial_sort(const RandomAccessRange& rng,
      +                  typename range_iterator<const RandomAccessRange>::type middle,
      +                  BinaryPredicate sort_pred);
      +
      +

      +

      +
      + + Description +
      +

      + partial_sort rearranges + the elements in rng. + It places the smallest distance(begin(rng), middle) elements, sorted in ascending order, + into the range [begin(rng), middle). The remaining elements are placed in + an unspecified order into [middle, last). +

      +

      + The non-predicative versions of this function specify that one element + is less than another by using operator<(). The predicate versions use the + predicate instead. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/partial_sort.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate version: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering relation on RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate version: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Approximately distance(rng) * log(distance(begin(rng), middle)) comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html new file mode 100644 index 0000000..e592ec2 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html @@ -0,0 +1,133 @@ + + + +Range Algorithm - partition + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_iterator<ForwardRange>::type
      +partition(ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_iterator<const ForwardRange>::type
      +partition(const ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_return<ForwardRange, re>::type
      +partition(ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_return<const ForwardRange, re>::type
      +partition(const ForwardRange& rng, UnaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + partition orders the + elements in rng based + on pred, such that the + elements that satisfy pred + precede the elements that do not. In the versions that return a single + iterator, the return value is the middle iterator. In the versions that + have a configurable range_return, found + corresponds to the middle iterator. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/partition.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +UnaryPredicate is a + model of the PredicateConcept. +
      • +
      • +ForwardRange's value + type is convertible to UnaryPredicate's + argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. Exactly distance(rng) applications of pred, + and at most distance(rng) / 2 + swaps. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html new file mode 100644 index 0000000..56e47b7 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html @@ -0,0 +1,132 @@ + + + +Range Algorithm - random_shuffle + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +RandomAccessRange& random_shuffle(RandomAccessRange& rng);
      +
      +template<class RandomAccessRange>
      +const RandomAccessRange& random_shuffle(const RandomAccessRange& rng);
      +
      +template<class RandomAccessRange, class Generator>
      +RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen);
      +
      +template<class RandomAccessRange, class Generator>
      +const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen);
      +
      +

      +

      +
      + + Description +
      +

      + random_shuffle randomly + rearranges the elements in rng. + The versions of random_shuffle + that do not specify a Generator + use an internal random number generator. The versions of random_shuffle that do specify a Generator use this instead. Returns + the shuffles range. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/random_shuffle.hpp +

      +
      + + Requirements +
      +

      + For the version without a Generator: +

      +
      +

      + For the version with a Generator: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +Generator is a model + of the RandomNumberGeneratorConcept. +
      • +
      • +RandomAccessRange's + distance type is convertible to Generator's + argument type. +
      • +
      +
      + + Precondition: +
      +
      • +distance(rng) + is less than gen's + maximum value. +
      +
      + + Complexity +
      +

      + Linear. If !empty(rng), exactly distance(rng) - 1 + swaps are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html new file mode 100644 index 0000000..525845d --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html @@ -0,0 +1,139 @@ + + + +Range Algorithm - remove + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_iterator<ForwardRange>::type
      +remove(ForwardRange& rng, const Value& val);
      +
      +template<
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_iterator<const ForwardRange>::type
      +remove(const ForwardRange& rng, const Value& val);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_return<ForwardRange,re>::type
      +remove(ForwardRange& rng, const Value& val);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_return<const ForwardRange,re>::type
      +remove(const ForwardRange& rng, const Value& val);
      +
      +

      +

      +
      + + Description +
      +

      + remove removes from + rng all of the elements + x for which x == val is true. + The versions of remove + that return an iterator, return an iterator new_last + such that the range [begin(rng), new_last) contains no elements equal to val. The range_return + versions of remove defines + found as the new last + element. The iterators in the range [new_last, + end(rng)) + are dereferenceable, but the elements are unspecified. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/remove.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +Value is a model of + the EqualityComparableConcept. +
      • +
      • + Objects of type Value + can be compared for equality with objects of ForwardRange's + value type. +
      • +
      +
      + + Complexity +
      +

      + Linear. remove performs + exactly distance(rng) + comparisons for equality. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html new file mode 100644 index 0000000..a6d8c56 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html @@ -0,0 +1,138 @@ + + + +Range Algorithm - remove_if + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_iterator<ForwardRange>::type
      +remove(ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_iterator<const ForwardRange>::type
      +remove(const ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_return<ForwardRange,re>::type
      +remove(ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +typename range_return<const ForwardRange,re>::type
      +remove(const ForwardRange& rng, UnaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + remove_if removes from + rng all of the elements + x for which pred(x) + is true. The versions of + remove_if that return + an iterator, return an iterator new_last + such that the range [begin(rng), new_last) contains no elements where pred(x) + is true. The iterators in + the range [new_last, end(rng)) are dereferenceable, but the elements + are unspecified. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/remove_if.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +UnaryPredicate is a + model of the PredicateConcept. +
      • +
      • +ForwardRange's value + type is convertible to UnaryPredicate's + argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. remove_if performs + exactly distance(rng) + applications of pred. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html new file mode 100644 index 0000000..ab1ea36 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html @@ -0,0 +1,119 @@ + + + +Range Algorithm - replace + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class ForwardRange,
      +    class Value
      +    >
      +ForwardRange& replace(ForwardRange& rng, const Value& what, const Value& with_what);
      +
      +template<
      +    class ForwardRange,
      +    class UnaryPredicate
      +    >
      +const ForwardRange& replace(const ForwardRange& rng, const Value& what, const Value& with_what);
      +
      +

      +

      +
      + + Description +
      +

      + replace every element + in rng equal to what with with_what. + Return a reference to rng. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/replace.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +Value is convertible + to ForwardRange's value + type. +
      • +
      • +Value is a model of + the AssignableConcept. +
      • +
      • +Value is a model of + the EqualityComparableConcept, + and may be compared for equality with objects of ForwardRange's + value type. +
      • +
      +
      + + Complexity +
      +

      + Linear. replace performs + exactly distance(rng) + comparisons for equality and at most distance(rng) assignments. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html new file mode 100644 index 0000000..8f0e4b3 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html @@ -0,0 +1,117 @@ + + + +Range Algorithm - replace_if + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class UnaryPredicate, class Value>
      +ForwardRange& replace_if(ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
      +
      +template<class ForwardRange, class UnaryPredicate, class Value>
      +const ForwardRange& replace_if(const ForwardRange& rng, UnaryPredicate pred, const Value& with_what);
      +
      +

      +

      +
      + + Description +
      +

      + replace_if replaces every + element x in rng for which pred(x) == true with with_what. + Returns a reference to rng. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/replace_if.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +UnaryPredicate is a + model of the PredicateConcept +
      • +
      • +ForwardRange's value + type is convertible to UnaryPredicate's + argument type. +
      • +
      • +Value is convertible + to ForwardRange's value + type. +
      • +
      • +Value is a model of + the AssignableConcept. +
      • +
      +
      + + Complexity +
      +

      + Linear. replace_if performs + exactly distance(rng) + applications of pred, + and at most distance(rng) assignments. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html new file mode 100644 index 0000000..6930b56 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html @@ -0,0 +1,110 @@ + + + +Range Algorithm - rotate + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange>
      +ForwardRange& rotate(ForwardRange& rng,
      +                     typename range_iterator<ForwardRange>::type middle);
      +                     
      +template<class ForwardRange>
      +const ForwardRange& rotate(const ForwardRange& rng,
      +                           typename range_iterator<const ForwardRange>::type middle);
      +
      +

      +

      +
      + + Description +
      +

      + rotate rotates the elements + in a range. It exchanges the two ranges [begin(rng), middle) + and [middle, end(rng)). Returns a reference to rng. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/rotate.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      +
      + + Precondition: +
      +
        +
      • +[begin(rng), middle) is a valid range. +
      • +
      • +[middle, end(rng)) is a valid range. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most distance(rng) swaps are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html new file mode 100644 index 0000000..55764e6 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html @@ -0,0 +1,154 @@ + + + +Range Algorithm - sort + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +RandomAccessRange& sort(RandomAccessRange& rng);
      +
      +template<class RandomAccessRange>
      +const RandomAccessRange& sort(const RandomAccessRange& rng);
      +
      +template<class RandomAccessRange, class BinaryPredicate>
      +RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred);
      +
      +template<class RandomAccessRange, class BinaryPredicate>
      +const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + sort sorts the elements + in rng into ascending + order. sort is not guaranteed + to be stable. Returns the sorted range. +

      +

      + For versions of the sort + function without a predicate, ascending order is defined by operator<() + such that for all adjacent elements [x,y], + y < + x == + false. +

      +

      + For versions of the sort + function with a predicate, ascending order is defined by pred such that for all adjacent elements + [x,y], pred(y, x) == false. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/sort.hpp +

      +
      + + Requirements +
      +

      + For versions of sort without a predicate: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering relation on RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For versions of sort with a predicate +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Complexity +
      +

      + O(N log(N)) comparisons (both average and worst-case), + where N is distance(rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html new file mode 100644 index 0000000..016e37f --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html @@ -0,0 +1,135 @@ + + + +Range Algorithm - stable_partition + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class UnaryPredicate>
      +typename range_iterator<ForwardRange>::type
      +stable_partition(ForwardRange& rng, UnaryPredicate pred);
      +
      +template<class ForwardRange, class UnaryPredicate>
      +typename range_iterator<const ForwardRange>::type
      +stable_partition(const ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class UnaryPredicate
      +>
      +typename range_return<ForwardRange, re>::type
      +stable_partition(ForwardRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class UnaryPredicate
      +>
      +typename range_return<const ForwardRange, re>::type
      +stable_partition(const ForwardRange& rng, UnaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + stable_partition reorders + the elements in the range rng + base on the function object pred. + Once this function has completed all of the elements that satisfy pred appear before all of the elements + that fail to satisfy it. stable_partition + differs from partition + because it preserves relative order. It is table. +

      +

      + For the versions that return an iterator, the return value is the iterator + to the first element that fails to satisfy pred. +

      +

      + For versions that return a range_return, + the found iterator is + the iterator to the first element that fails to satisfy pred. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/stable_partition.hpp +

      +
      + + Requirements +
      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +UnaryPredicate is a + model of the PredicateConcept. +
      • +
      +
      + + Complexity +
      +

      + Best case: O(N) + where N is distance(rng). + Worst case: N * + log(N) + swaps, where N is distance(rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html new file mode 100644 index 0000000..613739f --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html @@ -0,0 +1,157 @@ + + + +Range Algorithm - stable_sort + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class RandomAccessRange>
      +RandomAccessRange& stable_sort(RandomAccessRange& rng);
      +
      +template<class RandomAccessRange>
      +const RandomAccessRange& stable_sort(const RandomAccessRange& rng);
      +
      +template<class RandomAccessRange, class BinaryPredicate>
      +RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate pred);
      +
      +template<class RandomAccessRange, class BinaryPredicate>
      +const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + stable_sort sorts the + elements in rng into + ascending order. stable_sort + is guaranteed to be stable. The order is preserved for equivalent elements. +

      +

      + For versions of the stable_sort + function without a predicate ascending order is defined by operator<() + such that for all adjacent elements [x,y], + y < + x == + false. +

      +

      + For versions of the stable_sort + function with a predicate, ascending order is designed by pred such that for all adjacent elements + [x,y], pred(y,x) == false. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/stable_sort.hpp +

      +
      + + Requirements +
      +

      + For versions of stable_sort without a predicate +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +RandomAccessRange's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering relation on RandomAccessRange's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For versions of stable_sort with a predicate: +

      +
        +
      • +RandomAccessRange is + a model of the Random + Access Range Concept. +
      • +
      • +RandomAccessRange is + mutable. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +RandomAccessRange's + value type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Best case: O(N) + where N is distance(rng). + Worst case: O(N log(N)^2) + comparisons, where N + is distance(rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html new file mode 100644 index 0000000..458f1b4 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html @@ -0,0 +1,226 @@ + + + +Range Algorithm - transform + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class OutputIterator,
      +    class UnaryOperation
      +>
      +OutputIterator transform(const SinglePassRange1& rng,
      +                         OutputIterator out,
      +                         UnaryOperation fun);
      +                         
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator,
      +    class BinaryOperation
      +>
      +OutputIterator transform(const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         OutputIterator out,
      +                         BinaryOperation fun);
      +
      +

      +

      +
      + + Description +
      +

      + UnaryOperation version: +

      +

      + transform assigns the + value y to each element + [out, out + distance(rng)), y = fun(x) where x + is the corresponding value to y + in rng1. The return value + is out + + distance(rng). +

      +

      + BinaryOperation version: +

      +

      + transform assigns the + value z to each element + [out, out + min(distance(rng1), distance(rng2))), z = fun(x,y) where x + is the corresponding value in rng1 + and y is the corresponding + value in rng2. This version + of transform stops upon + reaching either the end of rng1, + or the end of rng2. Hence + there isn't a requirement for distance(rng1) == distance(rng2) + since there is a safe guaranteed behaviour, unlike with the iterator + counterpart in the standard library. +

      +

      + The return value is out + min(distance(rng1), distance(rng2)). +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/transform.hpp +

      +
      + + Requirements +
      +

      + For the unary versions of transform: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +UnaryOperation is a + model of the UnaryFunctionConcept. +
      • +
      • +SinglePassRange1's + value type must be convertible to UnaryFunction's + argument type. +
      • +
      • +UnaryFunction's result + type must be convertible to a type in OutputIterator's + set of value types. +
      • +
      +

      + For the binary versions of transform: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +BinaryOperation is + a model of the BinaryFunctionConcept. +
      • +
      • +SinglePassRange1's + value type must be convertible to BinaryFunction's + first argument type. +
      • +
      • +SinglePassRange2's + value type must be convertible to BinaryFunction's + second argument type. +
      • +
      • +BinaryOperation's result + type must be convertible to a type in OutputIterator's + set of value types. +
      • +
      +
      + + Precondition: +
      +

      + For the unary version of transform: +

      +
        +
      • +out is not an iterator + within the range [begin(rng1) + 1, end(rng1)). +
      • +
      • +[out, out + distance(rng1)) is a valid range. +
      • +
      +

      + For the binary version of transform: +

      +
        +
      • +out is not an iterator + within the range [begin(rng1) + 1, end(rng1)). +
      • +
      • +out is not an iterator + within the range [begin(rng2) + 1, end(rng2)). +
      • +
      • +[out, out + min(distance(rng1), distance(rng2))) is a valid range. +
      • +
      +
      + + Complexity +
      +

      + Linear. The operation is applied exactly distance(rng1) for the unary version and min(distance(rng1), distance(rng2)) + for the binary version. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html new file mode 100644 index 0000000..bad1018 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html @@ -0,0 +1,164 @@ + + + +Range Algorithm - unique + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange>
      +typename range_return<ForwardRange, return_begin_found>::type
      +unique(ForwardRange& rng);
      +
      +template<class ForwardRange>
      +typename range_return<const ForwardRange, return_begin_found>::type
      +unique(const ForwardRange& rng);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_return<ForwardRange, return_begin_found>::type
      +unique(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_return<const ForwardRange, return_begin_found>::type
      +unique(const ForwardRange& rng, BinaryPredicate pred);
      +
      +template<range_return_value re, class ForwardRange>
      +typename range_return<ForwardRange, re>::type
      +unique(ForwardRange& rng);
      +
      +template<range_return_value re, class ForwardRange>
      +typename range_return<const ForwardRange, re>::type
      +unique(const ForwardRange& rng);
      +
      +template<range_return_value re, class ForwardRange, class BinaryPredicate>
      +typename range_return<ForwardRange, re>::type
      +unique(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<range_return_value re, class ForwardRange, class BinaryPredicate>
      +typename range_return<const ForwardRange, re>::type
      +unique(const ForwardRange& rng, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + unique removes all but + the first element of each sequence of duplicate encountered in rng. +

      +

      + Elements in the range [new_last, + end(rng)) + are dereferenceable but undefined. +

      +

      + Equality is determined by the predicate if one is supplied, or by operator==() + for ForwardRange's value + type. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/unique.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions of unique: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +ForwardRange's value + type is a model of the EqualityComparableConcept. +
      • +
      +

      + For the predicate versions of unique: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange is mutable. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +ForwardRange's value + type is convertible to BinaryPredicate's + first argument type and to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. O(N) + where N is distance(rng). + Exactly distance(rng) + comparisons are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms.html new file mode 100644 index 0000000..7b34570 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms.html @@ -0,0 +1,62 @@ + + + +New algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html new file mode 100644 index 0000000..37fbd37 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html @@ -0,0 +1,91 @@ + + + +erase + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class Container,
      +    class SinglePassRange
      +    >
      +void erase(Container& target,
      +           iterator_range<typename Container::iterator> to_erase);
      +
      +

      +

      +
      + + Description +
      +

      + erase the iterator range + to_erase from the container + target. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/erase.hpp +

      +
      + + Requirements +
      +
      1. +Container supports + erase of an iterator range. +
      +
      + + Complexity +
      +

      + Linear. Proprotional to distance(to_erase). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html new file mode 100644 index 0000000..bbeb90f --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html @@ -0,0 +1,150 @@ + + + +for_each + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryFunction
      +    >
      +BinaryFunction for_each(const SinglePassRange1& rng1,
      +                        const SinglePassRange2& rng2,
      +                        BinaryFunction fn);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryFunction
      +    >
      +BinaryFunction for_each(const SinglePassRange1& rng1,
      +                        SinglePassRange2& rng2,
      +                        BinaryFunction fn);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryFunction
      +    >
      +BinaryFunction for_each(SinglePassRange1& rng1,
      +                        const SinglePassRange2& rng2,
      +                        BinaryFunction fn);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryFunction
      +    >
      +BinaryFunction for_each(SinglePassRange1& rng1,
      +                        SinglePassRange2& rng2,
      +                        BinaryFunction fn);
      +
      +

      +

      +
      + + Description +
      +

      + for_each traverses forward + through rng1 and rng2 simultaneously. For each iteration, + the element x is used + from rng1 and the corresponding + element y is used from + rng2 to invoke fn(x,y). +

      +

      + Iteration is stopped upon reaching the end of the shorter of rng1, or rng2. + It is safe to call this function with unequal length ranges. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/for_each.hpp +

      +
      + + Requirements +
      +
        +
      1. +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      2. +
      3. +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      4. +
      5. +BinaryFunction is a + model of the BinaryFunctionConcept. +
      6. +
      7. +SinglePassRange1's + value type is convertible to BinaryFunction's + first argument type. +
      8. +
      9. +SinglepassRange2's + value type is convertible to BinaryFunction's + second argument type. +
      10. +
      +
      + + Complexity +
      +

      + Linear. Exactly min(distance(rng1), distance(rng2)) + applications of BinaryFunction. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html new file mode 100644 index 0000000..bac1fdf --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html @@ -0,0 +1,106 @@ + + + +insert + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class Container,
      +    class SinglePassRange
      +    >
      +void insert(Container& target,
      +            typename Container::iterator before,
      +            const SinglePassRange& from);
      +
      +

      +

      +
      + + Description +
      +

      + insert all of the elements + in the range from before + the before iterator into + target. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/insert.hpp +

      +
      + + Requirements +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +Container supports + insert at a specified position. +
      4. +
      5. +SinglePassRange's value + type is convertible to Container's + value type. +
      6. +
      +
      + + Complexity +
      +

      + Linear. distance(from) + assignments are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html new file mode 100644 index 0000000..a83b172 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html @@ -0,0 +1,111 @@ + + + +overwrite + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2
      +    >
      +void overwrite(const SinglePassRange1& from,
      +               SinglePassRange2& to);
      +
      +

      +

      +
      + + Description +
      +

      + overwrite assigns the + values from the range from + into the range to. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/overwrite.hpp +

      +
      + + Requirements +
      +
        +
      1. +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      2. +
      3. +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      4. +
      5. +SinglePassRange2 is + mutable. +
      6. +
      7. distance(SinglePassRange1) + <= distance(SinglePassRange2)
      8. +
      9. +SinglePassRange1's + value type is convertible to SinglePassRange2's + value type. +
      10. +
      +
      + + Complexity +
      +

      + Linear. distance(rng1) + assignments are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html new file mode 100644 index 0000000..ab51754 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html @@ -0,0 +1,104 @@ + + + +push_back + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class Container,
      +    class SinglePassRange
      +    >
      +void push_back(Container& target,
      +               const SinglePassRange& from);
      +
      +

      +

      +
      + + Description +
      +

      + push_back all of the + elements in the range from + to the back of the container target. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/push_back.hpp +

      +
      + + Requirements +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +Container supports + insert at end(). +
      4. +
      5. +SinglePassRange's value + type is convertible to Container's + value type. +
      6. +
      +
      + + Complexity +
      +

      + Linear. distance(from) + assignments are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html new file mode 100644 index 0000000..a1658e2 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html @@ -0,0 +1,104 @@ + + + +push_front + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class Container,
      +    class SinglePassRange
      +    >
      +void push_front(Container& target,
      +                const SinglePassRange& from);
      +
      +

      +

      +
      + + Description +
      +

      + push_front all of the + elements in the range from + to the front of the container target. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/push_front.hpp +

      +
      + + Requirements +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +Container supports + insert at begin(). +
      4. +
      5. +SinglePassRange's value + type is convertible to Container's + value type. +
      6. +
      +
      + + Complexity +
      +

      + Linear. distance(from) + assignments are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html new file mode 100644 index 0000000..b6ab1b0 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html @@ -0,0 +1,92 @@ + + + +remove_erase + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class Container,
      +    class T
      +    >
      +void remove_erase(Container& target,
      +                  const T& val);
      +
      +

      +

      +
      + + Description +
      +

      + remove_erase actually + eliminates the elements equal to val + from the container. This is in contrast to the remove + algorithm which merely rearranges elements. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/erase.hpp +

      +
      + + Requirements +
      +
      1. +Container supports + erase of an iterator range. +
      +
      + + Complexity +
      +

      + Linear. Proportional to distance(target)s. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html new file mode 100644 index 0000000..39eef41 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html @@ -0,0 +1,99 @@ + + + +remove_erase_if + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class Container,
      +    class Pred
      +    >
      +void remove_erase(Container& target,
      +                  Pred pred);
      +
      +

      +

      +
      + + Description +
      +

      + remove_erase_if removes + the elements x that satisfy + pred(x) + from the container. This is in contrast to the erase + algorithm which merely rearranges elements. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm_ext/erase.hpp +

      +
      + + Requirements +
      +
        +
      1. +Container supports + erase of an iterator range. +
      2. +
      3. +Pred is a model of + the Predicate Concept. +
      4. +
      +
      + + Complexity +
      +

      + Linear. Proportional to distance(target)s. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms.html new file mode 100644 index 0000000..87820b8 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms.html @@ -0,0 +1,80 @@ + + + +Non-mutating algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html new file mode 100644 index 0000000..c9a58d1 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html @@ -0,0 +1,168 @@ + + + +Range Algorithm - adjacent_find + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange>
      +typename range_iterator<ForwardRange>::type
      +adjacent_find(ForwardRange& rng);
      +
      +template<class ForwardRange>
      +typename range_iterator<const ForwardRange>::type
      +adjacent_find(const ForwardRange& rng);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_iterator<ForwardRange>::type
      +adjacent_find(ForwardRange& rng, BinaryPred pred);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_iterator<const ForwardRange>::type
      +adjacent_find(const ForwardRange& rng, BinaryPred pred);
      +
      +template<range_return_value_re, class ForwardRange>
      +typename range_return<ForwardRange, re>::type
      +adjacent_find(ForwardRange& rng);
      +
      +template<range_return_value_re, class ForwardRange>
      +typename range_return<const ForwardRange, re>::type
      +adjacent_find(const ForwardRange& rng);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class BinaryPredicate
      +    >
      +typename range_return<ForwardRange, re>::type
      +adjacent_find(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class BinaryPredicate
      +    >
      +typename range_return<const ForwardRange, re>::type
      +adjacent_find(const ForwardRange& rng, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + Non-predicate versions: +

      +

      + adjacent_find finds the + first adjacent elements [x,y] + in rng where x == y +

      +

      + Predicate versions: +

      +

      + adjacent_find finds the + first adjacent elements [x,y] + in rng where pred(x,y) + is true. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/adjacent_find.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions of adjacent_find: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange's value + type is a model of the EqualityComparableConcept. +
      • +
      +

      + For the predicate versions of adjacent_find: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +ForwardRange's value + type is convertible to BinaryPredicate's + first argument type and to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. If empty(rng) + then no comparisons are performed; otherwise, at most distance(rng) - 1 + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html new file mode 100644 index 0000000..ddabdc7 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html @@ -0,0 +1,157 @@ + + + +binary_search + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class Value>
      +bool binary_search(const ForwardRange& rng, const Value& val);
      +
      +template<class ForwardRange, class Value, class BinaryPredicate>
      +bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + binary_search returns + true if and only if the + value val exists in the + range rng. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/binary_search.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions of binary_search: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +Value is a model of + the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type Value + is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      +

      + For the predicate versions of binary_search: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      • +ForwardRange's value + type is convertible to BinaryPredicate's + argument type. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate version: +

      +

      + rng is ordered in ascending + order according to operator<. +

      +

      + For the predicate version: +

      +

      + rng is ordered in ascending + order according to the function object pred. +

      +
      + + Complexity +
      +

      + For non-random-access ranges, the complexity is O(N) where N + is distance(rng). +

      +

      + For random-access ranges, the complexity is O(log N) + where N is distance(rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html new file mode 100644 index 0000000..c30c6e6 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html @@ -0,0 +1,108 @@ + + + +count + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange, class Value>
      +typename range_difference<SinglePassRange>::type
      +count(SinglePassRange& rng, const Value& val);
      +
      +template<class SinglePassRange, class Value>
      +typename range_difference<const SinglePassRange>::type
      +count(const SinglePassRange& rng, const Value& val);
      +
      +

      +

      +
      + + Description +
      +

      + count returns the number + of elements x in rng where x + == val + is true. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/count.hpp +

      +
      + + Requirements +
      +
        +
      • +SinglePassRange is + a model of the Single + Pass Range Concept. +
      • +
      • +Value is a model of + the EqualityComparableConcept. +
      • +
      • +SinglePassRange's value + type is a model of the EqualityComparableConcept. +
      • +
      • + An object of SinglePassRange's + value type can be compared for equality with an object of type Value. +
      • +
      +
      + + Complexity +
      +

      + Linear. Exactly distance(rng) comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html new file mode 100644 index 0000000..8d45dcd --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html @@ -0,0 +1,163 @@ + + + +equal + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2
      +>
      +bool equal(const SinglePassRange1& rng1,
      +           const SinglePassRange2& rng2);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +>
      +bool equal(const SinglePassRange1& rng1,
      +           const SinglePassRange2& rng2,
      +           BinaryPredicate         pred);
      +
      +

      +

      +
      + + Description +
      +

      + equal returns true if distance(rng1) is equal to the distance(rng2) and for each element x + in rng1, the corresponding + element y in rng2 is equal. Otherwise false is returned. +

      +

      + In this range version of equal + it is perfectly acceptable to pass in two ranges of unequal lengths. +

      +

      + Elements are considered equal in the non-predicate version if operator== + returns true. Elements are + considered equal in the predicate version if pred(x,y) is true. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/equal.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange1's + value type is a model of the EqualityComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the EqualityComparableConcept. +
      • +
      • +SinglePassRange1's + value type can be compared for equality with SinglePassRange2's + value type. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most min(distance(rng1), distance(rng2)) + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html new file mode 100644 index 0000000..ff5a0b9 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html @@ -0,0 +1,179 @@ + + + +equal_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class ForwardRange,
      +    class Value
      +    >
      +std::pair<typename range_iterator<ForwardRange>::type,
      +          typename range_iterator<ForwardRange>::type>
      +equal_range(ForwardRange& rng, const Value& val);
      +
      +template<
      +    class ForwardRange,
      +    class Value
      +    >
      +std::pair<typename range_iterator<const ForwardRange>::type,
      +          typename range_iterator<const ForwardRange>::type>
      +equal_range(const ForwardRange& rng, const Value& val);
      +
      +template<
      +    class ForwardRange,
      +    class Value,
      +    class SortPredicate
      +    >
      +std::pair<typename range_iterator<ForwardRange>::type,
      +          typename range_iterator<ForwardRange>::type>
      +equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);
      +
      +template<
      +    class ForwardRange,
      +    class Value,
      +    class SortPredicate
      +    >
      +std::pair<typename range_iterator<const ForwardRange>::type,
      +          typename range_iterator<const ForwardRange>::type>
      +equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);                      
      + 
      +

      +

      +
      + + Description +
      +

      + equal_range returns a + range in the form of a pair of iterators where all of the elements are + equal to val. If no values + are found that are equal to val, + then an empty range is returned, hence result.first == result.second. + For the non-predicate versions of equal_range + the equality of elements is determined by operator<. For the predicate versions of equal_range the equality of elements + is determined by pred. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/equal_range.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +Value is a model of + the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type Value + is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +SortPredicate is a + model of the StrictWeakOrderingConcept. +
      • +
      • +ForwardRange's value + type is the same as Value. +
      • +
      • +ForwardRange's value + type is convertible to both of SortPredicate's + argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: rng + is ordered in ascending order according to operator<. +

      +

      + For the predicate versions: rng + is ordered in ascending order according to pred. +

      +
      + + Complexity +
      +

      + For random-access ranges, the complexity is O(log N), + otherwise the complexity is O(N). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html new file mode 100644 index 0000000..5c89b56 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html @@ -0,0 +1,123 @@ + + + +find + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange, class Value>
      +typename range_iterator<SinglePassRange>::type
      +find(SinglePassRange& rng, Value val);
      +
      +template<class SinglePassRange, class Value>
      +typename range_iterator<const SinglePassRange>::type
      +find(const SinglePassRange& rng, Value val);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange,
      +    class Value
      +    >
      +typename range_return<SinglePassRange, re>::type
      +find(SinglePassRange& rng, Value val);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange,
      +    class Value
      +    >
      +typename range_return<const SinglePassRange, re>::type
      +find(const SinglePassRange& rng, Value val);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of find + that return an iterator, returns the first iterator in the range rng such that *i == value. end(rng) is returned if no such iterator exists. + The versions of find that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/find.hpp +

      +
      + + Requirements +
      +
        +
      • +SinglePassRange is + a model of the Single + Pass Range Concept. +
      • +
      • +Value is a model of + the EqualityComparableConcept. +
      • +
      • + The operator== + is defined for type Value + to be compared with the SinglePassRange's + value type. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most distance(rng) comparisons for equality. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html new file mode 100644 index 0000000..a1fd3c0 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html @@ -0,0 +1,204 @@ + + + +find_end + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange1, class ForwardRange2>
      +typename range_iterator<ForwardRange1>::type
      +find_end(ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<class ForwardRange1, class ForwardRange2>
      +typename range_iterator<const ForwardRange1>::type
      +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_iterator<ForwardRange1>::type
      +find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +template<
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_iterator<const ForwardRange1>::type
      +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2
      +    >
      +typename range_return<ForwardRange1, re>::type
      +find_end(ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2
      +    >
      +typename range_return<const ForwardRange1, re>::type
      +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_return<ForwardRange1, re>::type
      +find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_return<const ForwardRange1, re>::type
      +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of find_end + that return an iterator, return an iterator to the beginning of the last + sub-sequence equal to rng2 + within rng1. Equality + is determined by operator== for non-predicate versions of find_end, and by satisfying pred in the predicate versions. The + versions of find_end + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/find_end.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange1 is a + model of the Forward Range + Concept. +
      • +
      • +ForwardRange2 is a + model of the Forward Range + Concept. +
      • +
      • +ForwardRange1's value + type is a model of the EqualityComparableConcept. +
      • +
      • +ForwardRange2's value + type is a model of the EqualityComparableConcept. +
      • +
      • + Objects of ForwardRange1's + value type can be compared for equality with objects of ForwardRange2's value type. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange1 is a + model of the Forward Range + Concept. +
      • +
      • +ForwardRange2 is a + model of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +ForwardRange1's value + type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +ForwardRange2's value + type is convertible to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + The number of comparisons is proportional to distance(rng1) * distance(rng2). If both ForwardRange1 + and ForwardRange2 are + models of BidirectionalRangeConcept + then the average complexity is linear and the worst case is distance(rng1) * distance(rng2). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html new file mode 100644 index 0000000..5a353e2 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html @@ -0,0 +1,200 @@ + + + +find_first_of + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange1, class ForwardRange2>
      +typename range_iterator<SinglePassRange1>::type
      +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2);
      +
      +template<class SinglePassRange1, class ForwardRange2>
      +typename range_iterator<const SinglePassRange1>::type
      +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    class SinglePassRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_iterator<SinglePassRange1>::type
      +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +template<
      +    class SinglePassRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_iterator<const SinglePassRange1>::type
      +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange1,
      +    class ForwardRange2
      +    >
      +typename range_return<SinglePassRange1, re>::type
      +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange1,
      +    class ForwardRange2
      +    >
      +typename range_return<const SinglePassRange1, re>::type
      +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_return<SinglePassRange1, re>::type
      +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_return<const SinglePassRange1, re>::type
      +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of find_first_of + that return an iterator, return an iterator to the first occurrence in + rng1 of any of the elements + in rng2. Equality is + determined by operator== + for non-predicate versions of find_first_of, + and by satisfying pred + in the predicate versions. +

      +

      + The versions of find_first_of + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/find_first_of.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +ForwardRange2 is a + model of the Forward Range + Concept. +
      • +
      • +SinglePassRange1's + value type is a model of the EqualityComparableConcept, + and can be compared for equality with ForwardRange2's + value type. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +ForwardRange2 is a + model of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +ForwardRange2's value + type is convertible to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + At most distance(rng1) * distance(rng2) comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html new file mode 100644 index 0000000..548c215 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html @@ -0,0 +1,133 @@ + + + +find_if + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange, class UnaryPredicate>
      +typename range_iterator<SinglePassRange>::type
      +find_if(SinglePassRange& rng, UnaryPredicate pred);
      +
      +template<class SinglePassRange, class UnaryPredicate>
      +typename range_iterator<const SinglePassRange>::type
      +find_if(const SinglePassRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange,
      +    class UnaryPredicate
      +    >
      +typename range_return<SinglePassRange, re>::type
      +find_if(SinglePassRange& rng, UnaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class SinglePassRange,
      +    class UnaryPredicate
      +    >
      +typename range_return<const SinglePassRange, re>::type
      +find_if(const SinglePassRange& rng, UnaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of find_if + that return an iterator, returns the first iterator in the range rng such that pred(*i) is true. + end(rng) + is returned if no such iterator exists. +

      +

      + The versions of find_if + that return a range_return, + defines found in the same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/find_if.hpp +

      +
      + + Requirements +
      +
        +
      • +SinglePassRange is + a model of the Single + Pass Range Concept. +
      • +
      • +UnaryPredicate is a + model of the PredicateConcept. +
      • +
      • + The value type of SinglePassRange + is convertible to the argument type of UnaryPredicate. +
      • +
      +
      + + Precondition: +
      +

      + For each iterator i in + rng, *i is in the domain of UnaryPredicate. +

      +
      + + Complexity +
      +

      + Linear. At most distance(rng) invocations of pred. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html new file mode 100644 index 0000000..80aceea --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html @@ -0,0 +1,113 @@ + + + +for_each + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange,
      +    class UnaryFunction
      +    >
      +UnaryFunction for_each(SinglePassRange& rng, UnaryFunction fun);
      +
      +template<
      +    class SinglePassRange,
      +    class UnaryFunction
      +    >
      +UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun);    
      +
      +

      +

      +
      + + Description +
      +

      + for_each traverses forward + through rng and for each + element x it invokes + fun(x). +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/for_each.hpp +

      +
      + + Requirements +
      +
        +
      • +SinglePassRange is + a model of the Single + Pass Range Concept. +
      • +
      • +UnaryFunction is a + model of the UnaryFunctionConcept. +
      • +
      • +UnaryFunction does + not apply any non-constant operation through its argument. +
      • +
      • +SinglePassRange's value + type is convertible to UnaryFunction's + argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. Exactly distance(rng) applications of UnaryFunction. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html new file mode 100644 index 0000000..469333a --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html @@ -0,0 +1,170 @@ + + + +lexicographical_compare + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2
      +    >
      +bool lexicographical_compare(const SinglePassRange1& rng1,
      +                             const SinglePassRange2& rng2);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +    >
      +bool lexicographical_compare(const SinglePassRange1& rng1,
      +                             const SinglePassRange2& rng2,
      +                             BinaryPredicate pred);    
      +
      +

      +

      +
      + + Description +
      +

      + lexicographical_compare + compares element by element rng1 + against rng2. If the + element from rng1 is + less than the element from rng2 + then true is returned. If + the end of rng1 without + reaching the end of rng2 + this also causes the return value to be true. + The return value is false + in all other circumstances. The elements are compared using operator< + in the non-predicate versions of lexicographical_compare + and using pred in the + predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/lexicographical_compare.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions of lexicographical_compare: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange1's + value type is a model of the LessThanComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the LessThanComparableConcept. +
      • +
      • + Let x be an object + of SinglePassRange1's + value type. Let y be + an obect of SinglePassRange2's + value type. x < + y must be valid. y < + x must be valid. +
      • +
      +

      + For the predicate versions of lexicographical_compare: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + Linear. At most 2 * + min(distance(rng1), distance(rng2)) + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html new file mode 100644 index 0000000..686416f --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html @@ -0,0 +1,188 @@ + + + +lower_bound + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class Value>
      +typename range_iterator<ForwardRange>::type
      +lower_bound(ForwardRange& rng, Value val);
      +
      +template<class ForwardRange, class Value>
      +typename range_iterator<const ForwardRange>::type
      +lower_bound(const ForwardRange& rng, Value val);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_return<ForwardRange, re>::type
      +lower_bound(ForwardRange& rng, Value val);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_return<const ForwardRange, re>::type
      +lower_bound(const ForwardRange& rng, Value val);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of lower_bound + that return an iterator, returns the first iterator in the range rng such that: without predicate - + *i + < value + is false, with predicate + - pred(*i, value) + is false. +

      +

      + end(rng) + is returned if no such iterator exists. +

      +

      + The versions of lower_bound + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/lower_bound.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +Value is a model of + the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type Value + is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      • +ForwardRange's value + type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng is sorted in ascending + order according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng is sorted in ascending + order according to pred. +

      +
      + + Complexity +
      +

      + For ranges that model the Random + Access Range concept the complexity is O(log N), + where N is distance(rng). +

      +

      + For all other range types the complexity is O(N). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html new file mode 100644 index 0000000..07fca98 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html @@ -0,0 +1,166 @@ + + + +max_element + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange>
      +typename range_iterator<ForwardRange>::type
      +max_element(ForwardRange& rng);
      +
      +template<class ForwardRange>
      +typename range_iterator<const ForwardRange>::type
      +max_element(const ForwardRange& rng);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_iterator<ForwardRange>::type
      +max_element(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_iterator<const ForwardRange>::type
      +max_element(const ForwardRange& rng, BinaryPredicate pred);
      +
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange
      +    >
      +typename range_return<ForwardRange, re>::type
      +max_element(ForwardRange& rng);
      +
      +template<
      +    range_return_value_re,
      +    class ForwardRange
      +    >
      +typename range_return<const ForwardRange, re>::type
      +max_element(const ForwardRange& rng);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class BinaryPredicate
      +    >
      +typename range_return<ForwardRange, re>::type
      +max_element(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class BinaryPredicate
      +    >
      +typename range_return<const ForwardRange, re>::type
      +max_element(const ForwardRange& rng, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of max_element + that return an iterator, return the iterator to the maximum value as + determined by using operator< if a predicate is not supplied. Otherwise + the predicate pred is + used to determine the maximum value. The versions of max_element + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/max_element.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange's value + type is a model of the LessThanComparableConcept. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +ForwardRange's value + type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Linear. Zero comparisons if empty(rng), otherwise distance(rng) - 1 + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html new file mode 100644 index 0000000..90a0a22 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html @@ -0,0 +1,166 @@ + + + +min_element + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange>
      +typename range_iterator<ForwardRange>::type
      +min_element(ForwardRange& rng);
      +
      +template<class ForwardRange>
      +typename range_iterator<const ForwardRange>::type
      +min_element(const ForwardRange& rng);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_iterator<ForwardRange>::type
      +min_element(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<class ForwardRange, class BinaryPredicate>
      +typename range_iterator<const ForwardRange>::type
      +min_element(const ForwardRange& rng, BinaryPredicate pred);
      +
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange
      +    >
      +typename range_return<ForwardRange, re>::type
      +min_element(ForwardRange& rng);
      +
      +template<
      +    range_return_value_re,
      +    class ForwardRange
      +    >
      +typename range_return<const ForwardRange, re>::type
      +min_element(const ForwardRange& rng);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class BinaryPredicate
      +    >
      +typename range_return<ForwardRange, re>::type
      +min_element(ForwardRange& rng, BinaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class BinaryPredicate
      +    >
      +typename range_return<const ForwardRange, re>::type
      +min_element(const ForwardRange& rng, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of min_element + that return an iterator, return the iterator to the minimum value as + determined by using operator< if a predicate is not supplied. Otherwise + the predicate pred is + used to determine the minimum value. The versions of min_element + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/min_element.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +ForwardRange's value + type is a model of the LessThanComparableConcept. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +ForwardRange's value + type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Complexity +
      +

      + Linear. Zero comparisons if empty(rng), otherwise distance(rng) - 1 + comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html new file mode 100644 index 0000000..d783d9a --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html @@ -0,0 +1,222 @@ + + + +mismatch + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange1, class SinglePassRange2>
      +std::pair<
      +    typename range_iterator<SinglePassRange1>::type,
      +    typename range_iterator<const SinglePassRange2>::type >
      +mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2);
      +
      +template<class SinglePassRange1, class SinglePassRange2>
      +std::pair<
      +    typename range_iterator<const SinglePassRange1>::type,
      +    typename range_iterator<const SinglePassRange2>::type >
      +mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2);
      +
      +template<class SinglePassRange1, class SinglePassRange2>
      +std::pair<
      +    typename range_iterator<SinglePassRange1>::type,
      +    typename range_iterator<SinglePassRange2>::type >
      +mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2);
      +
      +template<class SinglePassRange1, class SinglePassRange2>
      +std::pair<
      +    typename range_iterator<const SinglePassRange1>::type,
      +    typename range_iterator<SinglePassRange2>::type >
      +mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2);
      +
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +    >
      +std::pair<
      +    typename range_iterator<SinglePassRange1>::type,
      +    typename range_iterator<const SinglePassRange2>::type >
      +mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2,
      +         BinaryPredicate pred);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +    >
      +std::pair<
      +    typename range_iterator<const SinglePassRange1>::type,
      +    typename range_iterator<const SinglePassRange2>::type >
      +mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2,
      +         BinaryPredicate pred);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +    >
      +std::pair<
      +    typename range_iterator<SinglePassRange1>::type,
      +    typename range_iterator<SinglePassRange2>::type >
      +mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2,
      +         BinaryPredicate pred);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +    >
      +std::pair<
      +    typename range_iterator<const SinglePassRange1>::type,
      +    typename range_iterator<SinglePassRange2>::type >
      +mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2,
      +         BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of mismatch + that return an iterator, return an iterator to the first position where + rng1 and rng2 differ. +

      +

      + Equality is determined by operator== for non-predicate versions of mismatch, and by satisfying pred in the predicate versions. +

      +

      + The versions of mismatch + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/mismatch.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange1's + value type is a model of the EqualityComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the EqualityComparableConcept. +
      • +
      • +SinglePassRange1s value + type can be compared for equality with SinglePassRange2's + value type. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument type. +
      • +
      +
      + + Precondition: +
      +

      + distance(rng2) >= distance(rng1) +

      +
      + + Complexity +
      +

      + Linear. At most distance(rng1) comparisons. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html new file mode 100644 index 0000000..891d51d --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html @@ -0,0 +1,206 @@ + + + +search + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange1, class ForwardRange2>
      +typename range_iterator<ForwardRange1>::type
      +search(ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<class ForwardRange1, class ForwardRange2>
      +typename range_iterator<const ForwardRange1>::type
      +search(const ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_iterator<ForwardRange1>::type,
      +search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +template<
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_iterator<const ForwardRange1>::type
      +search(const ForwardRange1& rng1, ForwardRange2& rng2, BinaryPredicate pred);
      +
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2
      +    >
      +typename range_return<ForwardRange1, re>::type
      +search(ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2
      +    >
      +typename range_return<const ForwardRange1, re>::type
      +search(const ForwardRange1& rng1, const ForwardRange2& rng2);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_return<ForwardRange1, re>::type,
      +search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange1,
      +    class ForwardRange2,
      +    class BinaryPredicate
      +    >
      +typename range_return<const ForwardRange1, re>::type
      +search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of search + that return an iterator, return an iterator to the start of the first + subsequence in rng1 that + is equal to the subsequence rng2. + The end(rng1) + is returned if no such subsequence exists in rng1. + Equality is determined by operator== for non-predicate versions of search, and by satisfying pred in the predicate versions. +

      +

      + The versions of search + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/search.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange1 is a + model of the Forward Range + Concept. +
      • +
      • +ForwardRange2 is a + model of the Forward Range + Concept. +
      • +
      • +ForwardRange1's value + type is a model of the EqualityComparableConcept. +
      • +
      • +ForwardRange2's value + type is a model of the EqualityComparableConcept. +
      • +
      • +ForwardRange1s value + type can be compared for equality with ForwardRange2's + value type. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange1 is a + model of the Forward Range + Concept. +
      • +
      • +ForwardRange2 is a + model of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the BinaryPredicateConcept. +
      • +
      • +ForwardRange1's value + type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +ForwardRange2's value + type is convertible to BinaryPredicate's + second argument type. +
      • +
      +
      + + Complexity +
      +

      + Average complexity is Linear. Worst-case complexity is quadratic. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html new file mode 100644 index 0000000..40bd80e --- /dev/null +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html @@ -0,0 +1,185 @@ + + + +upper_bound + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class ForwardRange, class Value>
      +typename range_iterator<ForwardRange>::type
      +upper_bound(ForwardRange& rng, Value val);
      +
      +template<class ForwardRange, class Value>
      +typename range_iterator<const ForwardRange>::type
      +upper_bound(const ForwardRange& rng, Value val);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_return<ForwardRange, re>::type
      +upper_bound(ForwardRange& rng, Value val);
      +
      +template<
      +    range_return_value re,
      +    class ForwardRange,
      +    class Value
      +    >
      +typename range_return<const ForwardRange, re>::type
      +upper_bound(const ForwardRange& rng, Value val);
      +
      +

      +

      +
      + + Description +
      +

      + The versions of upper_bound + that return an iterator, returns the first iterator in the range rng such that: without predicate - + val < + *i + is true, with predicate + - pred(val, *i) is true. +

      +

      + end(rng) + is returned if no such iterator exists. +

      +

      + The versions of upper_bound + that return a range_return, + defines found in the + same manner as the returned iterator described above. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/upper_bound.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +Value is a model of + the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type Value + is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +ForwardRange is a model + of the Forward Range + Concept. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +ForwardRange's value + type is the same type as Value. +
      • +
      • +ForwardRange's value + type is convertible to both of BinaryPredicate's + argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng is sorted in ascending + order according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng is sorted in ascending + order according to pred. +

      +
      + + Complexity +
      +

      + For ranges that model the Random + Access Range Concept the complexity is O(log N), + where N is distance(rng). + For all other range types the complexity is O(N). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_numeric.html b/doc/html/range/reference/algorithms/range_numeric.html new file mode 100644 index 0000000..c6c6767 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_numeric.html @@ -0,0 +1,54 @@ + + + +Numeric algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_numeric/accumulate.html b/doc/html/range/reference/algorithms/range_numeric/accumulate.html new file mode 100644 index 0000000..8f19f51 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_numeric/accumulate.html @@ -0,0 +1,157 @@ + + + +accumulate + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange,
      +    class Value
      +    >
      +Value accumulate(const SinglePassRange& source_rng,
      +                 Value init);
      +
      +template<
      +    class SinglePassRange,
      +    class Value,
      +    class BinaryOperation
      +    >
      +Value accumulate(const SinglePassRange& source_rng,
      +                 Value init,
      +                 BinaryOperation op);
      +
      +

      +

      +
      + + Description +
      +

      + accumulate is a generalisation + of summation. It computes a binary operation (operator+ in the non-predicate version) of init and all of the elements in rng. +

      +

      + The return value is the resultant value of the above algorithm. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/numeric.hpp +

      +
      + + Requirements +
      +
      + + For + the first version +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +Value is a model of + the AssignableConcept. +
      4. +
      5. + An operator+ + is defined for a left-hand operand of type Value + and a right-hand operance of the SinglePassRange + value type. +
      6. +
      7. + The return type of the above operator is convertible to Value. +
      8. +
      +
      + + For + the second version +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +Value is a model of + the AssignableConcept. +
      4. +
      5. +BinaryOperation is + a model of the BinaryFunctionConcept. +
      6. +
      7. +Value is convertible + to BinaryOperation's + first argument type. +
      8. +
      9. +SinglePassRange's value + type is convertible to BinaryOperation's + second argument type. +
      10. +
      11. + The return type of BinaryOperation + is convertible to Value. +
      12. +
      +
      + + Complexity +
      +

      + Linear. Exactly distance(source_rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html b/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html new file mode 100644 index 0000000..23fed4f --- /dev/null +++ b/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html @@ -0,0 +1,179 @@ + + + +adjacent_difference + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange,
      +    class OutputIterator
      +    >
      +OutputIterator adjacent_difference(
      +    const SinglePassRange& source_rng,
      +    OutputIterator out_it);
      +
      +template<
      +    class SinglePassRange,
      +    class OutputIterator,
      +    class BinaryOperation
      +    >
      +OutputIterator adjacent_difference(
      +    const SinglePassRange& source_rng,
      +    OutputIterator out_it,
      +    BinaryOperation op);
      +
      +

      +

      +
      + + Description +
      +

      + adjacent_difference calculates + the differences of adjacent_elements in rng. +

      +

      + The first version of adjacent_difference + uses operator-() + to calculate the differences. The second version uses BinaryOperation + instead of operator-(). +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/numeric.hpp +

      +
      + + Requirements +
      +
      + + For + the first version +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +OutputIterator is a + model of the OutputIteratorConcept. +
      4. +
      5. + If x and y are objects of SinglePassRange's + value type, then x - y + is defined. +
      6. +
      7. + The value type of SinglePassRange + is convertible to a type in OutputIterator's + set of value types. +
      8. +
      9. + The return type of x - y + is convertible to a type in OutputIterator's + set of value types. +
      10. +
      +
      + + For + the second version +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +OutputIterator is a + model of the OutputIteratorConcept. +
      4. +
      5. +BinaryOperation is + a model of the BinaryFunctionConcept. +
      6. +
      7. + The value type of SinglePassRange + is convertible to BinaryOperation's + first and second argument types. +
      8. +
      9. + The value type of SinglePassRange + is convertible to a type in OutputIterator's + set of value types. +
      10. +
      11. + The result type of BinaryOperation + is convertible to a type in OutputIterator's + set of value types. +
      12. +
      +
      + + Precondition: +
      +

      + [result, result + + distance(rng)) is a valid range. +

      +
      + + Complexity +
      +

      + Linear. If empty(rng) + then zero applications, otherwise distance(rng) - 1 + applications are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_numeric/inner_product.html b/doc/html/range/reference/algorithms/range_numeric/inner_product.html new file mode 100644 index 0000000..273fe4e --- /dev/null +++ b/doc/html/range/reference/algorithms/range_numeric/inner_product.html @@ -0,0 +1,192 @@ + + + +inner_product + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange1,
      +         class SinglePassRange2,
      +         class Value>
      +    Value inner_product( const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         Value                   init);
      +
      +template<class SinglePassRange1,
      +         class SinglePassRange2,
      +         class Value,
      +         class BinaryOperation1,
      +         class BinaryOperation2>
      +    Value inner_product( const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         Value                   init,
      +                         BinaryOperation1        op1,
      +
      +

      +

      +
      + + Description +
      +

      + inner_product calculates + a generalised inner product of the range rng1 + and rng2. +

      +

      + For further information on the inner_product + algorithm please see inner_product. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/numeric.hpp +

      +
      + + Requirements +
      +
      + + For + the first version +
      +
        +
      1. +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      2. +
      3. +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      4. +
      5. +Value is a model of + the AssignableConcept. +
      6. +
      7. + If x is an object of + type Value, y is an object of SinglePassRange1's + value type, and z is + an object of SinglePassRange2's + value type, then x + y * z + is defined. +
      8. +
      9. + The result type of the expression x + + y + * z + is convertible to Value. +
      10. +
      +
      + + For + the second version +
      +
        +
      1. +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      2. +
      3. +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      4. +
      5. +Value is a model of + the AssignableConcept. +
      6. +
      7. +BinaryOperation1 is + a model of the BinaryFunctionConcept. +
      8. +
      9. +BinaryOperation2 is + a model of the BinaryFunctionConcept. +
      10. +
      11. + The value type of SinglePassRange1 + is convertible to the first argument type of BinaryOperation2. +
      12. +
      13. + The value type of SinglePassRange2 + is convertible to the second argument type of BinaryOperation2. +
      14. +
      15. +Value is convertible + to the value type of BinaryOperation1. +
      16. +
      17. + The return type of BinaryOperation2 + is convertible to the second argument type of BinaryOperation1. +
      18. +
      19. + The return type of BinaryOperation1 + is convertible to Value. +
      20. +
      +
      + + Precondition: +
      +

      + distance(rng2) >= distance(rng1) is a valid range. +

      +
      + + Complexity +
      +

      + Linear. Exactly distance(rng). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_numeric/irange.html b/doc/html/range/reference/algorithms/range_numeric/irange.html new file mode 100644 index 0000000..a23253d --- /dev/null +++ b/doc/html/range/reference/algorithms/range_numeric/irange.html @@ -0,0 +1,105 @@ + + + +irange + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class Integer>
      +integer_range< range_detail::integer_iterator<Integer> >
      +irange(Integer first, Integer  last);
      +
      +template<class Integer, class StepSize>
      +integer_range< range_detail::integer_iterator_with_step<Integer, StepSize> >
      +irange(Integer first, Integer last, StepSize step_size);
      +
      +

      +

      +
      + + Description +
      +

      + irange is a function + to generate an Integer Range. +

      +

      + irange allows treating + integers as a model of the Random + Access Range Concept. It should be noted that the first and last + parameters denoted a half-open range. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/irange.hpp +

      +
      + + Requirements +
      +
        +
      1. +Integer is a model + of the Integer Concept. +
      2. +
      3. +StepSize is a model + of the SignedInteger + Concept. +
      4. +
      +
      + + Complexity +
      +

      + Constant. Since this function generates a new range the most significant + performance cost is incurred through the iteration of the generated range. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/range_numeric/partial_sum.html b/doc/html/range/reference/algorithms/range_numeric/partial_sum.html new file mode 100644 index 0000000..6b52687 --- /dev/null +++ b/doc/html/range/reference/algorithms/range_numeric/partial_sum.html @@ -0,0 +1,161 @@ + + + +partial_sum + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange,
      +         class OutputIterator>
      +OutputIterator partial_sum(const SinglePassRange& rng,
      +                           OutputIterator out_it);
      +
      +template<class SinglePassRange,
      +         class OutputIterator,
      +         class BinaryOperation>
      +OutputIterator partial_sum(const SinglePassRange& rng,
      +                           OutputIterator out_it,
      +                           BinaryOperation op);
      +
      +

      +

      +
      + + Description +
      +

      + partial_sum calculates + a generalised partial sum of rng + in the same manner as std::partial_sum(boost::begin(rng), boost::end(rng), out_it). See partial_sum. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/numeric.hpp +

      +
      + + Requirements +
      +
      + + For + the first version +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +OutputIterator is a + model of the OutputIteratorConcept. +
      4. +
      5. + If x and y are objects of SinglePassRange's + value type, then x + y + is defined. +
      6. +
      7. + The return type of x + y + is convertible to the value type of SinglePassRange. +
      8. +
      9. + The value type of SinglePassRange + is convertible to a type in OutputIterator's + set of value types. +
      10. +
      +
      + + For + the second version +
      +
        +
      1. +SinglePassRange is + a model of the Single + Pass Range Concept. +
      2. +
      3. +OutputIterator is a + model of the OutputIteratorConcept. +
      4. +
      5. +BinaryOperation is + a model of the BinaryFunctionConcept. +
      6. +
      7. + The result type of BinaryOperation + is convertible to the value type of SinglePassRange. +
      8. +
      9. + The value type of SinglePassRange + is convertible to a type in OutputIterator's + set of value types. +
      10. +
      +
      + + Precondition: +
      +

      + [result, result + + distance(rng)) is a valid range. +

      +
      + + Complexity +
      +

      + Linear. If empty(rng) + then zero applications, otherwise distance(rng) - 1 + applications are performed. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/set_algorithms.html b/doc/html/range/reference/algorithms/set_algorithms.html new file mode 100644 index 0000000..b9888f5 --- /dev/null +++ b/doc/html/range/reference/algorithms/set_algorithms.html @@ -0,0 +1,55 @@ + + + +Set algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/set_algorithms/includes.html b/doc/html/range/reference/algorithms/set_algorithms/includes.html new file mode 100644 index 0000000..e7eedb3 --- /dev/null +++ b/doc/html/range/reference/algorithms/set_algorithms/includes.html @@ -0,0 +1,187 @@ + + + +includes + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class SinglePassRange1, class SinglePassRange2>
      +bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class BinaryPredicate
      +    >
      +bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2,
      +              BinaryPredicate pred);    
      +
      +

      +

      +
      + + Description +
      +

      + includes returns true if and only if, for every element + in rng2, an equivalent + element is also present in rng1. + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/set_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +SinglePassRange1's + value type is a model of the LessThanComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type SinglePassRange1's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • + The ordering of objects of type SinglePassRange2's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to pred. +

      +
      + + Complexity +
      +

      + Linear. O(N), + where N is distance(rng1) + distance(rng2). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_difference.html b/doc/html/range/reference/algorithms/set_algorithms/set_difference.html new file mode 100644 index 0000000..a8f32c6 --- /dev/null +++ b/doc/html/range/reference/algorithms/set_algorithms/set_difference.html @@ -0,0 +1,206 @@ + + + +set_difference + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator
      +    >
      +OutputIterator set_difference(const SinglePassRange1& rng1,
      +                              const SinglePassRange2& rng2,
      +                              OutputIterator          out);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator,
      +    class BinaryPredicate
      +    >
      +OutputIterator set_difference(const SinglePassRange1& rng1,
      +                              const SinglePassRange2& rng2,
      +                              OutputIterator          out,
      +                              BinaryPredicate         pred);
      +
      +

      +

      +
      + + Description +
      +

      + set_difference constructs + a sorted range that is the set difference of the sorted ranges rng1 and rng2. + The return value is the end of the output range. +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/set_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +SinglePassRange1's + value type is a model of the LessThanComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type SinglePassRange1's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • + The ordering of objects of type SinglePassRange2's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to pred. +

      +
      + + Complexity +
      +

      + Linear. O(N), + where N is distance(rng1) + distance(rng2). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html b/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html new file mode 100644 index 0000000..5ead92b --- /dev/null +++ b/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html @@ -0,0 +1,206 @@ + + + +set_intersection + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator
      +    >
      +OutputIterator set_intersection(const SinglePassRange1& rng1,
      +                                const SinglePassRange2& rng2,
      +                                OutputIterator          out);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator,
      +    class BinaryPredicate
      +    >
      +OutputIterator set_intersection(const SinglePassRange1& rng1,
      +                                const SinglePassRange2& rng2,
      +                                OutputIterator          out,
      +                                BinaryPredicate         pred);    
      +
      +

      +

      +
      + + Description +
      +

      + set_intersection constructs + a sorted range that is the intersection of the sorted ranges rng1 and rng2. + The return value is the end of the output range. +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/set_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +SinglePassRange1's + value type is a model of the LessThanComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type SinglePassRange1's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • + The ordering of objects of type SinglePassRange2's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to pred. +

      +
      + + Complexity +
      +

      + Linear. O(N), + where N is distance(rng1) + distance(rng2). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html b/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html new file mode 100644 index 0000000..738d029 --- /dev/null +++ b/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html @@ -0,0 +1,210 @@ + + + +set_symmetric_difference + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator
      +    >
      +OutputIterator
      +set_symmetric_difference(const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         OutputIterator          out);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator,
      +    class BinaryPredicate
      +    >
      +OutputIterator
      +set_symmetric_difference(const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         OutputIterator          out,
      +                         BinaryPredicate         pred);    
      +
      +

      +

      +
      + + Description +
      +

      + set_symmetric_difference + constructs a sorted range that is the set symmetric difference of the + sorted ranges rng1 and + rng2. The return value + is the end of the output range. +

      +

      + The ordering relationship is determined by using operator< in the non-predicate versions, and + by evaluating pred in + the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/set_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +SinglePassRange1's + value type is a model of the LessThanComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type SinglePassRange1's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • + The ordering of objects of type SinglePassRange2's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to pred. +

      +
      + + Complexity +
      +

      + Linear. O(N), + where N is distance(rng1) + distance(rng2). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_union.html b/doc/html/range/reference/algorithms/set_algorithms/set_union.html new file mode 100644 index 0000000..02dfe3f --- /dev/null +++ b/doc/html/range/reference/algorithms/set_algorithms/set_union.html @@ -0,0 +1,205 @@ + + + +set_union + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator
      +    >
      +OutputIterator set_union(const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         OutputIterator          out);
      +
      +template<
      +    class SinglePassRange1,
      +    class SinglePassRange2,
      +    class OutputIterator,
      +    class BinaryPredicate
      +    >
      +OutputIterator set_union(const SinglePassRange1& rng1,
      +                         const SinglePassRange2& rng2,
      +                         OutputIterator          out,
      +                         BinaryPredicate         pred);    
      + 
      +

      +

      +
      + + Description +
      +

      + set_union constructs + a sorted range that is the union of the sorted ranges rng1 + and rng2. The return + value is the end of the output range. The ordering relationship is determined + by using operator< + in the non-predicate versions, and by evaluating pred + in the predicate versions. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/algorithm/set_algorithm.hpp +

      +
      + + Requirements +
      +

      + For the non-predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +SinglePassRange1's + value type is a model of the LessThanComparableConcept. +
      • +
      • +SinglePassRange2's + value type is a model of the LessThanComparableConcept. +
      • +
      • + The ordering of objects of type SinglePassRange1's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      • + The ordering of objects of type SinglePassRange2's + value type is a strict weak ordering, + as defined in the LessThanComparableConcept + requirements. +
      • +
      +

      + For the predicate versions: +

      +
        +
      • +SinglePassRange1 is + a model of the Single + Pass Range Concept. +
      • +
      • +SinglePassRange2 is + a model of the Single + Pass Range Concept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • +SinglePassRange1 and + SinglePassRange2 have + the same value type. +
      • +
      • +BinaryPredicate is + a model of the StrictWeakOrderingConcept. +
      • +
      • +SinglePassRange1's + value type is convertible to BinaryPredicate's + first argument type. +
      • +
      • +SinglePassRange2's + value type is convertible to BinaryPredicate's + second argument types. +
      • +
      +
      + + Precondition: +
      +

      + For the non-predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to operator<. +

      +

      + For the predicate versions: +

      +

      + rng1 and rng2 are sorted in ascending order + according to pred. +

      +
      + + Complexity +
      +

      + Linear. O(N), + where N is distance(rng1) + distance(rng2). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/extending.html b/doc/html/range/reference/extending.html new file mode 100644 index 0000000..fc32e83 --- /dev/null +++ b/doc/html/range/reference/extending.html @@ -0,0 +1,51 @@ + + + +Extending the library + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/extending/method_1.html b/doc/html/range/reference/extending/method_1.html new file mode 100644 index 0000000..3283d10 --- /dev/null +++ b/doc/html/range/reference/extending/method_1.html @@ -0,0 +1,161 @@ + + + +Method 1: provide member functions and nested types + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +

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

      +
      ++++ + + + + + + + + + + + + + + +
      +

      + Member function +

      +
      +

      + Related concept +

      +
      +

      + begin() +

      +
      +

      + Single Pass + Range +

      +
      +

      + end() +

      +
      +

      + Single Pass + Range +

      +
      +

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

      +

      + The required member types are: +

      +
      ++++ + + + + + + + + + + + + + + +
      +

      + Member type +

      +
      +

      + Related concept +

      +
      +

      + iterator +

      +
      +

      + Single Pass + Range +

      +
      +

      + const_iterator +

      +
      +

      + Single Pass + Range +

      +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/extending/method_2.html b/doc/html/range/reference/extending/method_2.html new file mode 100644 index 0000000..cdda356 --- /dev/null +++ b/doc/html/range/reference/extending/method_2.html @@ -0,0 +1,265 @@ + + + +Method 2: provide free-standing functions and specialize metafunctions + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +

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

      +
      ++++ + + + + + + + + + + + + + + +
      +

      + Function +

      +
      +

      + Related concept +

      +
      +

      + range_begin(x) +

      +
      +

      + Single Pass + Range +

      +
      +

      + range_end(x) +

      +
      +

      + Single Pass + Range +

      +
      +

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

      +

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

      +
      ++++ + + + + + + + + + + + + + + +
      +

      + Metafunction +

      +
      +

      + Related concept +

      +
      +

      + boost::range_mutable_iterator +

      +
      +

      + Single Pass + Range +

      +
      +

      + boost::range_const_iterator +

      +
      +

      + Single Pass + Range +

      +
      +

      + A complete example is given here: +

      +

      + +

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

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/extending/method_3.html b/doc/html/range/reference/extending/method_3.html new file mode 100644 index 0000000..f841237 --- /dev/null +++ b/doc/html/range/reference/extending/method_3.html @@ -0,0 +1,50 @@ + + + +Method 3: provide range adaptor implementations + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/extending/method_3/method_3_1.html b/doc/html/range/reference/extending/method_3/method_3_1.html new file mode 100644 index 0000000..d45ef05 --- /dev/null +++ b/doc/html/range/reference/extending/method_3/method_3_1.html @@ -0,0 +1,100 @@ + + + +Method 3.1: Implement a Range Adaptor without arguments + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + To implement a Range Adaptor without arguments (e.g. reversed) you need + to: +

      +
        +
      1. + Provide a range for your return type, for example: +
        #include <boost/range/iterator_range.hpp>
        +#include <boost/iterator/reverse_iterator.hpp>
        +
        +template< typename R >
        +struct reverse_range :
        +    boost::iterator_range<
        +        boost::reverse_iterator<
        +            typename boost::range_iterator<R>::type> >
        +{
        +private:
        +    typedef boost::iterator_range<
        +        boost::reverse_iterator<
        +            typename boost::range_iterator<R>::type> > base;
        +            
        +public:
        +    typedef boost::reverse_iterator<
        +        typename boost::range_iterator<R>::type > iterator;
        +        
        +    reverse_range(R& r)
        +        : base(iterator(boost::end(r)), iterator(boost::begin(r)))
        +    { }
        +};
        +
        +
      2. +
      3. + Provide a tag to uniquely identify your adaptor in the operator| + function overload set +
        namespace detail {
        +    struct reverse_forwarder {};
        +}
        +
        +
      4. +
      5. + Implement operator|
        template< class BidirectionalRng >
        +inline reverse_range<BidirectionalRng> 
        +operator|( BidirectionalRng& r, detail::reverse_forwarder )
        +{
        +	return reverse_range<BidirectionalRng>( r );   
        +}
        +
        +template< class BidirectionalRng >
        +inline reverse_range<const BidirectionalRng> 
        +operator|( const BidirectionalRng& r, detail::reverse_forwarder )
        +{
        +	return reverse_range<const BidirectionalRng>( r );   
        +}
        +
        +
      6. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/extending/method_3/method_3_2.html b/doc/html/range/reference/extending/method_3/method_3_2.html new file mode 100644 index 0000000..58d6bc8 --- /dev/null +++ b/doc/html/range/reference/extending/method_3/method_3_2.html @@ -0,0 +1,155 @@ + + + +Method 3.2: Implement a Range Adaptor with arguments + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
        +
      1. + Provide a range for your return type, for example: +
        #include <boost/range/adaptor/argument_fwd.hpp>
        +#include <boost/range/iterator_range.hpp>
        +#include <boost/iterator/transform_iterator.hpp>
        +
        +template<typename Value>
        +class replace_value
        +{
        +public:
        +    typedef const Value& result_type;
        +    typedef const Value& argument_type;
        +    
        +    replace_value(const Value& from, const Value& to)
        +        : m_from(from), m_to(to)
        +    {
        +    }
        +    
        +    const Value& operator()(const Value& x) const
        +    {
        +        return (x == m_from) ? m_to : x;
        +    }
        +private:
        +    Value m_from;
        +    Value m_to;
        +};
        +
        +template<typename Range>
        +class replace_range
        +: public boost::iterator_range<
        +    boost::transform_iterator<
        +        replace_value<typename boost::range_value<Range>::type>,
        +        typename boost::range_iterator<Range>::type> >
        +{
        +private:
        +    typedef typename boost::range_value<Range>::type value_type;
        +    typedef typename boost::range_iterator<Range>::type iterator_base;
        +    typedef replace_value<value_type> Fn;
        +    typedef boost::transform_iterator<Fn, iterator_base> replaced_iterator;
        +    typedef boost::iterator_range<replaced_iterator> base_t;
        +    
        +public:
        +    replace_range(Range& rng, value_type from, value_type to)
        +        : base_t(replaced_iterator(boost::begin(rng), Fn(from,to)),
        +                 replaced_iterator(boost::end(rng), Fn(from,to)))
        +     {
        +     }
        + };
        +
        +
      2. +
      3. + Implement a holder class to hold the arguments required to construct + the RangeAdaptor. +
      4. +
      +

      + The holder combines multiple parameters into one that can be passed as + the right operand of operator|(). +

      +

      + +

      +
      template<typename T>
      +class replace_holder : public boost::range_detail::holder2<T>
      +{
      +public:
      +    replace_holder(const T& from, const T& to)
      +        : boost::range_detail::holder2<T>(from, to)
      +    { }
      +private:
      +    void operator=(const replace_holder&);
      +};
      +
      +

      +

      +
      1. + Define an instance of the holder with the name of the adaptor +
      +

      + +

      +
      static boost::range_detail::forwarder2<replace_holder>
      +replaced = boost::range_detail::forwarder2<replace_holder>();
      +
      +

      +

      +
      1. + Define operator| +
      +

      + +

      +
      template<typename SinglePassRange>
      +inline replace_range<SinglePassRange>
      +operator|(SinglePassRange& rng,
      +          const replace_holder<typename boost::range_value<SinglePassRange>::type>& f)
      +{
      +    return replace_range<SinglePassRange>(rng, f.val1, f.val2);
      +}
      +
      +template<typename SinglePassRange>
      +inline replace_range<const SinglePassRange>
      +operator|(const SinglePassRange& rng,
      +          const replace_holder<typename boost::range_value<SinglePassRange>::type>& f)
      +{
      +    return replace_range<const SinglePassRange>(rng, f.val1, f.val2);
      +}
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/overview.html b/doc/html/range/reference/overview.html new file mode 100644 index 0000000..63c4433 --- /dev/null +++ b/doc/html/range/reference/overview.html @@ -0,0 +1,68 @@ + + + +Overview + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
        +
      • + standard-like containers +
      • +
      • std::pair<iterator,iterator>
      • +
      • + built-in arrays +
      • +
      +

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

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

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

      +

      + +

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

      +

      +

      + instead of +

      +

      + +

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

      +

      +

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

      +

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

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

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

      +

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

      +

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

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

      +

      +

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

      +
      ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Expression +

      +
      +

      + Return +

      +
      +

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

      +
      +

      + returns a single iterator like std::unique +

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

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

      +
      +

      + returns the entire original range. +

      +
      +

      + This functionality has the following advantages: +

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

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

      +

      + +

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

      +

      +

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

      +

      + +

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

      +

      +

      + The same task may be accomplished simply with +

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

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

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

      + +

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

      +

      +
      + + Description +
      +

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

      +
      + + Definition +
      +

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

      +
      + + Requirements +
      +
        +
      • +SinglePassRange is + a model of the SinglePassRangeConcept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • + The value_type of + SinglePassRange is + convertible to a type in OutputIterator's + set of value types. +
      • +
      +
      + + Precondition: +
      +
        +
      • +out_it is not an iterator + within the source_rng. +
      • +
      • +[out_it, out_it + + distance(source_rng)) is a valid range. +
      • +
      +
      + + Complexity +
      +

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

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

      + +

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

      +

      +
      + + Description +
      +

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

      +

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

      +

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

      +
      + + Definition +
      +

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

      +
      + + Requirements +
      +
        +
      • +BidirectionalRange + is a model of the SinglePassRangeConcept. +
      • +
      • +OutputIterator is a + model of the OutputIteratorConcept. +
      • +
      • + The value_type of + SinglePassRange is + convertible to a type in OutputIterator's + set of value types. +
      • +
      +
      + + Precondition: +
      +
        +
      • +out_it is not an iterator + within the source_rng. +
      • +
      • +[out_it, out_it + + distance(source_rng)) is a valid range. +
      • +
      +
      + + Complexity +
      +

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

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

      +??? +

      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html b/doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html new file mode 100644 index 0000000..9974a92 --- /dev/null +++ b/doc/html/range/reference/range_algorithm/range_algorithm_non_mutating_algorithms.html @@ -0,0 +1,42 @@ + + + +Non-mutating algorithms + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges.html b/doc/html/range/reference/ranges.html new file mode 100644 index 0000000..2e16372 --- /dev/null +++ b/doc/html/range/reference/ranges.html @@ -0,0 +1,48 @@ + + + +Provided Ranges + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/counting_range.html b/doc/html/range/reference/ranges/counting_range.html new file mode 100644 index 0000000..4a3fae5 --- /dev/null +++ b/doc/html/range/reference/ranges/counting_range.html @@ -0,0 +1,90 @@ + + + +counting_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template< class Incrementable > inline
      +iterator_range< counting_iterator<Incrementable> >
      +counting_range(Incrementable first, Incrementable last);
      +
      +template< class SinglePassRange > inline
      +iterator_range< counting_iterator<typename range_iterator<SinglePassRange>::type >
      +counting_range(const SinglePassRange& rng);
      +
      +template< class SinglePassRange > inline
      +iterator_range< counting_iterator<typename range_iterator<SinglePassRange>::type >
      +counting_range(SinglePassRange& rng);
      +
      +

      +

      +
      + + Description +
      +

      + counting_range is a function + to generator that generates an iterator_range + wrapping a counting_iterator + (from Boost.Iterator). +

      +
      + + Definition +
      +

      + Defined in header file boost/range/counting_range.hpp +

      +
      + + Requirements +
      +
      1. +Incrementable is a model + of the Incrementable + Concept. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/introduction.html b/doc/html/range/reference/ranges/introduction.html new file mode 100644 index 0000000..f0080c6 --- /dev/null +++ b/doc/html/range/reference/ranges/introduction.html @@ -0,0 +1,46 @@ + + + +Introduction + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + The Boost.Range library provides some of the more commonly required ranges. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/irange.html b/doc/html/range/reference/ranges/irange.html new file mode 100644 index 0000000..18aaeca --- /dev/null +++ b/doc/html/range/reference/ranges/irange.html @@ -0,0 +1,103 @@ + + + +irange + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class Integer>
      +integer_range< range_detail::integer_iterator<Integer> >
      +irange(Integer first, Integer  last);
      +
      +template<class Integer, class StepSize>
      +integer_range< range_detail::integer_iterator_with_step<Integer, StepSize> >
      +irange(Integer first, Integer last, StepSize step_size);
      +
      +

      +

      +
      + + Description +
      +

      + irange is a function to + generate an Integer Range. +

      +

      + irange allows treating + integers as a model of the Random + Access Range Concept. It should be noted that the first and last + parameters denoted a half-open range. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/irange.hpp +

      +
      + + Requirements +
      +
        +
      1. +Integer is a model of + the Integer Concept. +
      2. +
      3. +StepSize is a model of + the SignedInteger Concept. +
      4. +
      +
      + + Complexity +
      +

      + Constant. Since this function generates a new range the most significant + performance cost is incurred through the iteration of the generated range. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/istream_range.html b/doc/html/range/reference/ranges/istream_range.html new file mode 100644 index 0000000..599d368 --- /dev/null +++ b/doc/html/range/reference/ranges/istream_range.html @@ -0,0 +1,72 @@ + + + +istream_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template< class Type, class Elem, class Traits > inline
      +iterator_range< std::istream_iterator<Type, Elem, Traits> >
      +istream_range(std::basic_istream<Elem, Traits>& in);
      +
      +

      +

      +
      + + Description +
      +

      + istream_range is a function + to generator that generates an iterator_range + wrapping a std::istream_iterator. +

      +
      + + Definition +
      +

      + Defined in header file boost/range/istream_range.hpp +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/reference.html b/doc/html/range/reference/ranges/reference.html new file mode 100644 index 0000000..edaf8fa --- /dev/null +++ b/doc/html/range/reference/ranges/reference.html @@ -0,0 +1,50 @@ + + + +Reference + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/reference/counting_range.html b/doc/html/range/reference/ranges/reference/counting_range.html new file mode 100644 index 0000000..68fa72c --- /dev/null +++ b/doc/html/range/reference/ranges/reference/counting_range.html @@ -0,0 +1,91 @@ + + + +counting_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template< class Incrementable > inline
      +iterator_range< counting_iterator<Incrementable> >
      +counting_range(Incrementable first, Incrementable last);
      +
      +template< class SinglePassRange > inline
      +iterator_range< counting_iterator<typename range_iterator<SinglePassRange>::type >
      +counting_range(const SinglePassRange& rng);
      +
      +template< class SinglePassRange > inline
      +iterator_range< counting_iterator<typename range_iterator<SinglePassRange>::type >
      +counting_range(SinglePassRange& rng);
      +
      +

      +

      +
      + + Description +
      +

      + counting_range is a function + to generator that generates an iterator_range + wrapping a counting_iterator + (from Boost.Iterator). +

      +
      + + Definition +
      +

      + Defined in header file boost/range/counting_range.hpp +

      +
      + + Requirements +
      +
      1. +Incrementable is a + model of the Incrementable + Concept. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/reference/irange.html b/doc/html/range/reference/ranges/reference/irange.html new file mode 100644 index 0000000..d827097 --- /dev/null +++ b/doc/html/range/reference/ranges/reference/irange.html @@ -0,0 +1,104 @@ + + + +irange + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template<class Integer>
      +integer_range< range_detail::integer_iterator<Integer> >
      +irange(Integer first, Integer  last);
      +
      +template<class Integer, class StepSize>
      +integer_range< range_detail::integer_iterator_with_step<Integer, StepSize> >
      +irange(Integer first, Integer last, StepSize step_size);
      +
      +

      +

      +
      + + Description +
      +

      + irange is a function + to generate an Integer Range. +

      +

      + irange allows treating + integers as a model of the Random + Access Range Concept. It should be noted that the first and last + parameters denoted a half-open range. +

      +
      + + Definition +
      +

      + Defined in the header file boost/range/irange.hpp +

      +
      + + Requirements +
      +
        +
      1. +Integer is a model + of the Integer Concept. +
      2. +
      3. +StepSize is a model + of the SignedInteger + Concept. +
      4. +
      +
      + + Complexity +
      +

      + Constant. Since this function generates a new range the most significant + performance cost is incurred through the iteration of the generated range. +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/ranges/reference/istream_range.html b/doc/html/range/reference/ranges/reference/istream_range.html new file mode 100644 index 0000000..7552ec7 --- /dev/null +++ b/doc/html/range/reference/ranges/reference/istream_range.html @@ -0,0 +1,73 @@ + + + +istream_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      + + Prototype +
      +

      + +

      +
      template< class Type, class Elem, class Traits > inline
      +iterator_range< std::istream_iterator<Type, Elem, Traits> >
      +istream_range(std::basic_istream<Elem, Traits>& in);
      +
      +

      +

      +
      + + Description +
      +

      + istream_range is a function + to generator that generates an iterator_range + wrapping a std::istream_iterator. +

      +
      + + Definition +
      +

      + Defined in header file boost/range/istream_range.hpp +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/semantics.html b/doc/html/range/reference/semantics.html new file mode 100644 index 0000000..dafb2d9 --- /dev/null +++ b/doc/html/range/reference/semantics.html @@ -0,0 +1,163 @@ + + + +Semantics + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +
      + + 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* +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/semantics/functions.html b/doc/html/range/reference/semantics/functions.html new file mode 100644 index 0000000..232b680 --- /dev/null +++ b/doc/html/range/reference/semantics/functions.html @@ -0,0 +1,408 @@ + + + +Functions + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Expression +

      +
      +

      + Return type +

      +
      +

      + Returns +

      +
      +

      + Complexity +

      +
      +

      + begin(x) +

      +
      +

      + range_iterator<X>::type +

      +
      +

      + p.first if p + is of type std::pair<T> a + if a is an array + range_begin(x) + if that expression would invoke a function found by ADL t.begin() + otherwise +

      +
      +

      + constant time +

      +
      +

      + end(x) +

      +
      +

      + range_iterator<X>::type +

      +
      +

      + p.second if p + is of type std::pair<T> a + + sz + if a is an array + of size sz range_end(x) + if that expression would invoke a function found by ADL t.end() + otherwise +

      +
      +

      + constant time +

      +
      +

      + empty(x) +

      +
      +

      + bool +

      +
      +

      + 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_difference<X>::type +

      +
      +

      + boost::end(x) + - boost::begin(x) +

      +
      +

      + constant time +

      +
      +

      + rbegin(x) +

      +
      +

      + range_reverse_iterator<X>::type +

      +
      +

      + range_reverse_iterator<X>::type(boost::end(x)) +

      +
      +

      + constant time +

      +
      +

      + rend(x) +

      +
      +

      + range_reverse_iterator<X>::type +

      +
      +

      + range_reverse_iterator<X>::type(boost::begin(x)) +

      +
      +

      + constant time +

      +
      +

      + const_begin(x) +

      +
      +

      + range_iterator<const + X>::type +

      +
      +

      + range_iterator<const + X>::type(boost::begin(x)) +

      +
      +

      + constant time +

      +
      +

      + const_end(x) +

      +
      +

      + range_iterator<const + X>::type +

      +
      +

      + range_iterator<const + X>::type(boost::end(x)) +

      +
      +

      + constant time +

      +
      +

      + const_rbegin(x) +

      +
      +

      + range_reverse_iterator<const + X>::type +

      +
      +

      + range_reverse_iterator<const + X>::type(boost::rbegin(x)) +

      +
      +

      + constant time +

      +
      +

      + const_rend(x) +

      +
      +

      + range_reverse_iterator<const + X>::type +

      +
      +

      + range_reverse_iterator<const + X>::type(boost::rend(x)) +

      +
      +

      + constant time +

      +
      +

      + as_literal(x) +

      +
      +

      + iterator_range<U> where U + is Char* + if x is a pointer + to a string and U + is range_iterator<X>::type + otherwise +

      +
      +

      + [s,s + + std::char_traits<X>::length(s)) if s + is a Char* + or an array of Char + [boost::begin(x),boost::end(x)) otherwise +

      +
      +

      + linear time for pointers to a string or arrays of Char, constant time otherwise +

      +
      +

      + as_array(x) +

      +
      +

      + iterator_range<X> +

      +
      +

      + [boost::begin(x),boost::end(x)) +

      +
       
      +

      + 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 libraries 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). +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/semantics/metafunctions.html b/doc/html/range/reference/semantics/metafunctions.html new file mode 100644 index 0000000..6df4902 --- /dev/null +++ b/doc/html/range/reference/semantics/metafunctions.html @@ -0,0 +1,236 @@ + + + +Metafunctions + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +
      +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +

      + Expression +

      +
      +

      + Return type +

      +
      +

      + Complexity +

      +
      +

      + range_iterator<X>::type +

      +
      +

      + +

      +
      T::iterator
      +P::first_type
      +A*
      +
      +

      +

      +
      +

      + compile time +

      +
      +

      + range_iterator<const + X>::type +

      +
      +

      + +

      +
      T::const_iterator
      +P::first_type
      +const A*
      +
      +

      +

      +
      +

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

      +
      +

      + boost::iterator_category<range_iterator<X>::type>::type +

      +
      +

      + compile time +

      +
      +

      + range_reverse_iterator<X>::type +

      +
      +

      + boost::reverse_iterator<range_iterator<X>::type> +

      +
      +

      + compile time +

      +
      +

      + range_reverse_iterator<const + X>::type +

      +
      +

      + boost::reverse_iterator<range_iterator<const X>::type +

      +
      +

      + compile time +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/reference/synopsis.html b/doc/html/range/reference/synopsis.html new file mode 100644 index 0000000..248e8c1 --- /dev/null +++ b/doc/html/range/reference/synopsis.html @@ -0,0 +1,185 @@ + + + +Synopsis + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + +

      +
      namespace boost
      +{
      +    //
      +    // Single Pass Range metafunctions
      +    //
      +
      +    template< class T >
      +    struct range_iterator;
      +
      +    template< class T >
      +    struct range_value;
      +
      +    template< class T >
      +    struct range_reference;
      +    
      +    template< class T >
      +    struct range_pointer;
      +    
      +    template< class T >
      +    struct range_category;
      +
      +    //
      +    // Forward Range metafunctions
      +    //
      +
      +    template< class T >
      +    struct range_difference;
      +
      +    //
      +    // Bidirectional Range metafunctions
      +    //
      +
      +    template< class T >
      +    struct range_reverse_iterator;
      +
      +    //
      +    // Single Pass Range functions
      +    //
      +
      +    template< class T >
      +    typename range_iterator<T>::type
      +    begin( T& r );
      +
      +    template< class T >
      +    typename range_iterator<const T>::type
      +    begin( const T& r );
      +
      +    template< class T >
      +    typename range_iterator<T>::type
      +    end( T& r );
      +
      +    template< class T >
      +    typename range_iterator<const T>::type
      +    end( const T& r );
      +
      +    template< class T >
      +    bool
      +    empty( const T& r );
      +
      +    //
      +    // Forward Range functions
      +    //
      +
      +    template< class T >
      +    typename range_difference<T>::type
      +    distance( const T& r );
      +
      +    //
      +    // Bidirectional Range functions
      +    //
      +
      +    template< class T >
      +    typename range_reverse_iterator<T>::type
      +    rbegin( T& r );
      +
      +    template< class T >
      +    typename range_reverse_iterator<const T>::type
      +    rbegin( const T& r );
      +
      +    template< class T >
      +    typename range_reverse_iterator<T>::type
      +    rend( T& r );
      +
      +    template< class T >
      +    typename range_reverse_iterator<const T>::type
      +    rend( const T& r );
      +    
      +    //
      +    // Random Access Range functions
      +    //
      +    
      +    template< class T >
      +    typename range_difference<T>::type
      +    size( const T& r );
      +
      +    //
      +    // Special const Range functions
      +    //
      +
      +    template< class T >
      +    typename range_iterator<const T>::type 
      +    const_begin( const T& r );
      +
      +    template< class T >
      +    typename range_iterator<const T>::type 
      +    const_end( const T& r );
      +
      +    template< class T >
      +    typename range_reverse_iterator<const T>::type 
      +    const_rbegin( const T& r );
      +
      +    template< class T >
      +    typename range_reverse_iterator<const T>::type 
      +    const_rend( const T& r );
      +    
      +    //
      +    // String utilities
      +    //
      +    
      +    template< class T >
      +    iterator_range< ... see below ... >
      +    as_literal( T& r );
      +    
      +    template< class T >
      +    iterator_range< ... see below ... >
      +    as_literal( const T& r );
      +    
      +    template< class T >
      +    iterator_range< typename range_iterator<T>::type >
      +    as_array( T& r );
      +    
      +    template< class T >
      +    iterator_range< typename range_iterator<const T>::type >
      +    as_array( const T& r );
      +
      +} // namespace 'boost' 
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/style_guide.html b/doc/html/range/style_guide.html new file mode 100644 index 0000000..f064884 --- /dev/null +++ b/doc/html/range/style_guide.html @@ -0,0 +1,141 @@ + + + +Terminology and style guidelines + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

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

      +
        +
      • + Random Access Readable Writeable Range +
      • +
      • + Forward Lvalue Range +
      • +
      +

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

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/upgrade.html b/doc/html/range/upgrade.html new file mode 100644 index 0000000..ad53c37 --- /dev/null +++ b/doc/html/range/upgrade.html @@ -0,0 +1,49 @@ + + + +Upgrade version of Boost.Range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      + + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/upgrade/upgrade_1_34_to_1_35.html b/doc/html/range/upgrade/upgrade_1_34_to_1_35.html new file mode 100644 index 0000000..252ec93 --- /dev/null +++ b/doc/html/range/upgrade/upgrade_1_34_to_1_35.html @@ -0,0 +1,77 @@ + + + +Upgrade from version 1.34 + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + Boost version 1.35 introduced some larger refactorings of the library: +

      +
        +
      1. + Direct support for character arrays was abandoned in favor of uniform treatment + of all arrays. Instead string algorithms can use the new function as_literal(). +
      2. +
      3. +size + now requires a Random + Access Range. The old behavior is provided as distance(). +
      4. +
      5. +range_size<T>::type has been completely removed in favor + of range_difference<T>::type +
      6. +
      7. +boost_range_begin() + and boost_range_end() + have been renamed range_begin() and range_end() respectively. +
      8. +
      9. +range_result_iterator<T>::type and range_reverse_result_iterator<T>::type + have been renamed range_iterator<T>::type + and range_reverse_iterator<T>::type. +
      10. +
      11. + The procedure that makes a custom type work with the library has been greatly + simplified. See Extending the + library for UDTs for details. +
      12. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/upgrade/upgrade_from_1_34.html b/doc/html/range/upgrade/upgrade_from_1_34.html new file mode 100644 index 0000000..dfc4c52 --- /dev/null +++ b/doc/html/range/upgrade/upgrade_from_1_34.html @@ -0,0 +1,77 @@ + + + +Upgrade from version 1.34 + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + Boost version 1.35 introduced some larger refactorings of the library: +

      +
        +
      1. + Direct support for character arrays was abandoned in favor of uniform treatment + of all arrays. Instead string algorithms can use the new function as_literal(). +
      2. +
      3. +size + now requires a Random + Access Range. The old behavior is provided as distance(). +
      4. +
      5. +range_size<T>::type has been completely removed in favor + of range_difference<T>::type +
      6. +
      7. +boost_range_begin() + and boost_range_end() + have been renamed range_begin() and range_end() respectively. +
      8. +
      9. +range_result_iterator<T>::type and range_reverse_result_iterator<T>::type + have been renamed range_iterator<T>::type + and range_reverse_iterator<T>::type. +
      10. +
      11. + The procedure that makes a custom type work with the library has been greatly + simplified. See Extending the + library for UDTs for details. +
      12. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/upgrade/upgrade_from_1_42.html b/doc/html/range/upgrade/upgrade_from_1_42.html new file mode 100644 index 0000000..3fbc2d2 --- /dev/null +++ b/doc/html/range/upgrade/upgrade_from_1_42.html @@ -0,0 +1,64 @@ + + + +Upgrade from version 1.42 + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + New features: +

      + +

      + Removed: +

      +
      1. +iterator_range no longer + has a is_singular member + function. The singularity restrictions have been removed from the iterator_range class since this added + restrictions to ranges of iterators whose default constructors were not + singular. Previously the is_singular + member function always returned false + in release build configurations, hence it is not anticipated that this + interface change will produce difficulty in upgrading. +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/utilities.html b/doc/html/range/utilities.html new file mode 100644 index 0000000..d9caa5f --- /dev/null +++ b/doc/html/range/utilities.html @@ -0,0 +1,82 @@ + + + +Utilities + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + + +

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

      +
        +
      • + Class iterator_range +
      • +
      • + Class sub_range +
      • +
      • + Function join +
      • +
      +

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

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/utilities/iterator_range.html b/doc/html/range/utilities/iterator_range.html new file mode 100644 index 0000000..f7d7b4a --- /dev/null +++ b/doc/html/range/utilities/iterator_range.html @@ -0,0 +1,322 @@ + + + +Class iterator_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + The intention of the iterator_range + class is to encapsulate two iterators so they fulfill the Forward + Range concept. A few other functions are also provided for convenience. +

      +

      + If the template argument is not a model of Forward + Traversal Iterator, one can still use a subset of the interface. + In particular, size() + requires Random Access 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 design decision avoids + the iterator_range imposing + limitations upon ranges of iterators that are not singular. Any singularity + limitation is simply propogated from the underlying iterator type. +

      +
      + + Synopsis +
      +

      + +

      +
      namespace boost
      +{
      +    template< class ForwardTraversalIterator >
      +    class iterator_range
      +    {
      +    public: // Forward Range types
      +        typedef ForwardTraversalIterator   iterator;
      +        typedef ForwardTraversalIterator   const_iterator;
      +        typedef iterator_difference<iterator>::type difference_type;
      +
      +    public: // construction, assignment
      +        template< class ForwardTraversalIterator2 >
      +        iterator_range( ForwardTraversalIterator2 Begin, ForwardTraversalIterator2 End );
      +                    
      +        template< class ForwardRange >
      +        iterator_range( ForwardRange& r );
      +  
      +        template< class ForwardRange >
      +        iterator_range( const ForwardRange& r );
      +        
      +        template< class ForwardRange >
      +        iterator_range& operator=( ForwardRange& r );
      +
      +        template< class ForwardRange >
      +        iterator_range& operator=( const ForwardRange& r );
      +    
      +    public: // Forward Range functions
      +        iterator  begin() const;
      +        iterator  end() const;
      +        
      +    public: // convenience
      +        operator    unspecified_bool_type() const;
      +        bool        equal( const iterator_range& ) const;
      +        value_type& front() const;
      +        value_type& back() const;
      +        iterator_range& advance_begin(difference_type n);
      +        iterator_range& advance_end(difference_type n);
      +        bool      empty() const;
      +        // for Random Access Range only: 
      +        reference operator[]( difference_type at ) const;
      +        value_type operator()( difference_type at ) const;
      +        size_type size() const;
      +    };
      +    
      +    // stream output
      +    template< class ForwardTraversalIterator, class T, class Traits >
      +    std::basic_ostream<T,Traits>& 
      +    operator<<( std::basic_ostream<T,Traits>& Os,
      +                const iterator_range<ForwardTraversalIterator>& r );
      +
      +    // comparison
      +    template< class ForwardTraversalIterator, class ForwardTraversalIterator2 >
      +    bool operator==( const iterator_range<ForwardTraversalIterator>& l, 
      +                     const iterator_range<ForwardTraversalIterator2>& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardRange >
      +    bool operator==( const iterator_range<ForwardTraversalIterator>& l, 
      +                     const ForwardRange& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardRange >
      +    bool operator==( const ForwardRange& l,
      +                     const iterator_range<ForwardTraversalIterator>& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardTraversalIterator2 >
      +    bool operator!=( const iterator_range<ForwardTraversalIterator>& l, 
      +                     const iterator_range<ForwardTraversalIterator2>& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardRange >
      +    bool operator!=( const iterator_range<ForwardTraversalIterator>& l, 
      +                     const ForwardRange& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardRange >
      +    bool operator!=( const ForwardRange& l,
      +                     const iterator_range<ForwardTraversalIterator>& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardTraversalIterator2 >
      +    bool operator<( const iterator_range<ForwardTraversalIterator>& l, 
      +                    const iterator_range<ForwardTraversalIterator2>& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardRange >
      +    bool operator<( const iterator_range<ForwardTraversalIterator>& l, 
      +                    const ForwardRange& r );
      +
      +    template< class ForwardTraversalIterator, class ForwardRange >
      +    bool operator<( const ForwardRange& l,
      +                    const iterator_range<ForwardTraversalIterator>& r );
      + 
      +    // external construction
      +    template< class ForwardTraversalIterator >
      +    iterator_range< ForwardTraversalIterator >
      +    make_iterator_range( ForwardTraversalIterator Begin, 
      +                         ForwardTraversalIterator End );
      +       
      +    template< class ForwardRange >
      +    iterator_range< typename range_iterator<ForwardRange>::type >
      +    make_iterator_range( ForwardRange& r );
      +
      +    template< class ForwardRange >
      +    iterator_range< typename range_iterator<const ForwardRange>::type >
      +    make_iterator_range( const ForwardRange& r );
      +    
      +    template< class Range >
      +    iterator_range< typename range_iterator<Range>::type >
      +    make_iterator_range( Range& r,
      +                         typename range_difference<Range>::type advance_begin,
      +                         typename range_difference<Range>::type advance_end );
      +    
      +    template< class Range >
      +    iterator_range< typename range_iterator<const Range>::type >
      +    make_iterator_range( const Range& r, 
      +                         typename range_difference<const Range>::type advance_begin,
      +                         typename range_difference<const 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) ); +

      +

      +

      +
      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/utilities/join.html b/doc/html/range/utilities/join.html new file mode 100644 index 0000000..2902714 --- /dev/null +++ b/doc/html/range/utilities/join.html @@ -0,0 +1,89 @@ + + + +Function join + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + The intention of the join + function is to join two ranges into one longer range. +

      +

      + The resultant range will have the lowest common traversal of the two ranges + supplied as parameters. +

      +

      + Note that the joined range incurs a performance cost due to the need to check + if the end of a range has been reached internally during traversal. +

      +
      + + Synposis +
      +

      + +

      +
      template<typename SinglePassRange1, typename SinglePassRange2>
      +iterator_range<range_detail::join_iterator<
      +    typename range_iterator<const SinglePassRange1>::type,
      +    typename range_iterator<const SinglePassRange2>::type,
      +    typename add_const<
      +        typename range_value<const SinglePassRange1>::type>::type>
      +>
      +join(const SinglePassRange1& rng1, const SinglePassRange2& rng2)
      +
      +template<typename SinglePassRange1, typename SinglePassRange2>
      +iterator_range<range_detail::join_iterator<
      +    typename range_iterator<SinglePassRange1>::type,
      +    typename range_iterator<SinglePassRange2>::type,
      +    typename range_value<SinglePassRange1>::type>
      +>
      +join(SinglePassRange1& rng1, SinglePassRange2& rng2);
      +
      +

      +

      +
      + + Example +
      +

      + The expression join(irange(0,5), irange(5,10)) would + evaluate to a range representing an integer range [0,10) +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/range/utilities/sub_range.html b/doc/html/range/utilities/sub_range.html new file mode 100644 index 0000000..7e1dd1b --- /dev/null +++ b/doc/html/range/utilities/sub_range.html @@ -0,0 +1,122 @@ + + + +Class sub_range + + + + + + + + + + + + + + + +
      Boost C++ LibrariesHomeLibrariesPeopleFAQMore
      +
      +
      +PrevUpHomeNext +
      +
      + +

      + The sub_range class inherits + all its functionality from the iterator_range class. The sub_range class is often easier to use + because one must specify the Forward + Range template argument instead of an iterator. Moreover, the sub_range class can propagate constness + since it knows what a corresponding const_iterator + is. +

      +
      + + Synopsis +
      +

      + +

      +
      namespace boost
      +{
      +    template< class ForwardRange >
      +    class sub_range : public iterator_range< typename range_iterator<ForwardRange>::type >
      +    {
      +    public: 
      +        typedef typename range_iterator<ForwardRange>::type iterator;
      +        typedef typename range_iterator<const ForwardRange>::type  const_iterator;
      +        typedef typename iterator_difference<iterator>::type difference_type;
      +    
      +    public: // construction, assignment
      +        template< class ForwardTraversalIterator >
      +        sub_range( ForwardTraversalIterator Begin, ForwardTraversalIterator End );
      +
      +        template< class ForwardRange2 >
      +        sub_range( ForwardRange2& r );
      +         
      +        template< class ForwardRange2 >
      +        sub_range( const 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" );
      +
      +

      +

      +
      + + + +
      +
      +
      +PrevUpHomeNext +
      + + diff --git a/doc/html/standalone_HTML.manifest b/doc/html/standalone_HTML.manifest new file mode 100644 index 0000000..e9d38e8 --- /dev/null +++ b/doc/html/standalone_HTML.manifest @@ -0,0 +1,19 @@ +index.html +range/concepts.html +range/concepts/single_pass_range.html +range/concepts/forward_range.html +range/concepts/bidirectional_range.html +range/concepts/random_access_range.html +range/concepts/concept_checking.html +range/reference.html +range/reference/synopsis.html +range/reference/semantics.html +range/reference/extending.html +range/utilities.html +range/utilities/sub_range.html +range/style_guide.html +range/library_headers.html +range/examples.html +range/portability.html +range/faq.html +range/history_ack.html diff --git a/doc/introduction.qbk b/doc/introduction.qbk new file mode 100644 index 0000000..4529d92 --- /dev/null +++ b/doc/introduction.qbk @@ -0,0 +1,73 @@ +[section 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 + +* simpler implementation and specification of generic range algorithms +* more flexible, compact and maintainable client code +* safe use of built-in arrays (for legacy code; why else would you use built-in arrays?) + +Below are given a small example (the complete example can be found [@http://www.boost.org/libs/range/test/algorithm_example.cpp here] ): + +`` + // + // example: extracting bounds in a generic algorithm + // + template< class ForwardReadableRange, class T > + inline typename boost::range_iterator< ForwardReadableRange >::type + find( ForwardReadableRange& c, const T& value ) + { + return std::find( boost::begin( c ), boost::end( c ), value ); + } + + template< class ForwardReadableRange, class T > + inline typename boost::range_iterator< const ForwardReadableRange >::type + find( const ForwardReadableRange& c, const T& value ) + { + return std::find( boost::begin( c ), boost::end( c ), value ); + } + + // + // replace first value and return its index + // + template< class ForwardReadableWriteableRange, class T > + inline typename boost::range_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 my_vector; + int values[] = { 1,2,3,4,5,6,7,8,9 }; + + my_vector.assign( values, boost::end( values ) ); + 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; + + std::cout << my_generic_replace( my_vector, 4, 2 ); + std::cout << my_generic_replace( my_view, 4, 2 ); + std::cout << my_generic_replace( str, 'a', 'b' ); + + // prints '3', '5' and '0' +`` + +By using the free-standing functions and __metafunctions__, the code automatically works for all the types supported by this library; now and in the future. Notice that we have to provide two versions of `find()` since we cannot forward a non-const rvalue with reference arguments (see this article about __the_forwarding_problem__ ). + +[endsect] + diff --git a/doc/istream_range.html b/doc/istream_range.html new file mode 100755 index 0000000..8f41fc4 --- /dev/null +++ b/doc/istream_range.html @@ -0,0 +1,64 @@ + + + + + + Boost.Range Utilities + + + + + + + + + +

      Boost.Range

      +

      Function istream_range

      +

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

      + +

      Synopsis

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

      + © Copyright Neil Groves 2009. +

      + +

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

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + + + diff --git a/doc/mfc_atl.qbk b/doc/mfc_atl.qbk new file mode 100644 index 0000000..2a7bb9c --- /dev/null +++ b/doc/mfc_atl.qbk @@ -0,0 +1,139 @@ +[def __mfc_collections__ [@http://msdn.microsoft.com/en-us/library/942860sh.aspx MFC Collection Classes]] +[def __atl_collections__ [@http://msdn.microsoft.com/en-us/library/15e672bd.aspx ATL Collection Classes]] + +[section:mfc_atl MFC/ATL (courtesy of Shunsuke Sogame)] + +[h4 Introduction] +This implementation was kindly donated by Shunsuke Sogame. This header adapts MFC and ATL containers to the appropriate Range concepts. + +[table + [] + [[[*Author:]] [Shunsuke Sogame]] + [[[*Contact:]] [mb2act@yahoo.co.jp]] + [[[*Date:]] [26th of May 2006]] + [[[*Copyright:]] [Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0]] +] + +[h4 Overview] + +Boost.Range MFC/ATL Extension provides Boost.Range support for MFC/ATL collection and string types. + +`` +CTypedPtrArray *> myArray; +... +BOOST_FOREACH (CList *theList, myArray) +{ + BOOST_FOREACH (CString& str, *theList) + { + boost::to_upper(str); + std::sort(boost::begin(str), boost::end(str)); + ... + } +} +`` + +[section:requirements Requirements] + +* Boost C++ Libraries Version 1.34.0 or later (no compilation required) +* Visual C++ 7.1 or later (for MFC and ATL) + +[endsect] + +[section:mfc_ranges MFC Ranges] +If the `` 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. + +[table + [[Range] [Traversal Category] [`range_reference::type`]] + [[`CArray`] [__random_access_range__] [`T&`]] + [[`CList`] [__bidirectional_range__] [`T&`]] + [[`CMap`] [__forward_range__] [`Range::CPair&`]] + [[`CTypedPtrArray`] [__random_access_range__] [`T* const`]] + [[`CTypedPtrList`] [__bidirectional_range__] [`T* const`]] + [[`CTypedPtrMap`] [__forward_range__] [`std::pair const`]] + [[`CByteArray`] [__random_access_range__] [`BYTE&`]] + [[`CDWordArray`] [__random_access_range__] [`DWORD&`]] + [[`CObArray`] [__random_access_range__] [`CObject*&`]] + [[`CPtrArray`] [__random_access_range__] [`void*&`]] + [[`CStringArray`] [__random_access_range__] [`CString&`]] + [[`CUIntArray`] [__random_access_range__] [`UINT&`]] + [[`CWordArray`] [__random_access_range__] [`WORD&`]] + [[`CObList`] [__bidirectional_range__] [`CObject*&`]] + [[`CPtrList`] [__bidirectional_range__] [`void*&`]] + [[`CStringList`] [__bidirectional_range__] [`CString&`]] + [[`CMapPtrToWord`] [__forward_range__] [`std::pair const`]] + [[`CMapPtrToPtr`] [__forward_range__] [`std::pair const`]] + [[`CMapStringToOb`] [__forward_range__] [`std::pair const`]] + [[`CMapStringToString`] [__forward_range__] [`Range::CPair&`]] + [[`CMapWordToOb`] [__forward_range__] [`std::pair const`]] + [[`CMapWordToPtr`] [__forward_range__] [`std::pair const`]] +] + +Other Boost.Range metafunctions are defined by the following. Let `Range` be any type listed above and `Ref` be the same as `range_reference::type`. `range_value::type` is the same as `remove_reference::type>::type`, `range_difference::type` is the same as `std::ptrdiff_t`, and `range_pointer::type` is the same as `add_pointer::type>::type`. As for `const Range`, see below. +[endsect] + +[section:atl_ranges ATL Ranges] + +If the `` 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. + +[table + [[Range] [Traversal Category] [`range_reference::type`]] + [[`CAtlArray`] [__random_access_range__] [`E&`]] + [[`CAutoPtrArray`] [__random_access_range__] [`E&`]] + [[`CInterfaceArray`] [__random_access_range__] [`CComQIPtr&`]] + [[`CAtlList`] [__bidirectional_range__] [`E&`]] + [[`CAutoPtrList`] [__bidirectional_range__] [`E&`]] + [[`CHeapPtrList`] [__bidirectional_range__] [`E&`]] + [[`CInterfaceList`] [__bidirectional_range__] [`CComQIPtr&`]] + [[`CAtlMap`] [__forward_range__] [`Range::CPair&`]] + [[`CRBTree`] [__bidirectional_range__] [`Range::CPair&`]] + [[`CRBMap`] [__bidirectional_range__] [`Range::CPair&`]] + [[`CRBMultiMap`] [__bidirectional_range__] [`Range::CPair&`]] + [[`CSimpleStringT`] [__random_access_range__] [`B&`]] + [[`CStringT`] [__random_access_range__] [`B&`]] + [[`CFixedStringT`] [__random_access_range__] [`range_reference::type`]] + [[`CComBSTR`] [__random_access_range__] [`OLECHAR&`]] + [[`CSimpleArray`] [__random_access_range__] [`T&`]] +] + +Other __boost_range_home__ metafunctions are defined by the following. Let `Range` be any type listed above and `Ref` be the same as `range_reference::type`. `range_value::type` is the same as `remove_reference::type`, `range_difference::type` is the same as `std::ptrdiff_t`, and `range_pointer::type` is the same as `add_pointer::type>::type`. As for `const Range`, see below. + +[endsect] + +[section:const_ranges const Ranges] + +`range_reference::type` is defined by the following algorithm. Let `Range` be any type listed above and `Ref` be the same as `range_reference::type`. + +`` +if (Range is CObArray || Range is CObList) + return CObject const * & +else if (Range is CPtrArray || Range is CPtrList) + return void const * & +else if (there is a type X such that X& is the same as Ref) + return X const & +else if (there is a type X such that X* const is the same as Ref) + return X const * const +else + return Ref +`` + + +Other Boost.Range metafunctions are defined by the following. + +[table + [[Range metafunction] [Result]] + [[`range_value::type`] [`range_value::type`]] + [[`range_difference::type`] [`std::ptrdiff_t`]] + [[`range_pointer::type`] [`add_pointer::type>::type>::type`]] +] + +[endsect] + +[section:references References] + +# __boost_range_home__ +# __mfc_collections__ +# __atl_collections__ + +[endsect] + +[endsect] diff --git a/doc/portability.qbk b/doc/portability.qbk new file mode 100644 index 0000000..b4aadbb --- /dev/null +++ b/doc/portability.qbk @@ -0,0 +1,22 @@ +[section 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_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: + +# do not use built-in arrays, +# do not pass rvalues to __begin__`()`, __end__`()` and __iterator_range__ Range constructors and assignment operators, +# use __const_begin__`()` and __const_end__`()` whenever your code by intention is read-only; this will also solve most rvalue problems, +# do not rely on ADL: + * if you overload functions, include that header before the headers in this library, + * put all overloads in namespace boost. + + + +[endsect] + diff --git a/doc/reference.qbk b/doc/reference.qbk new file mode 100644 index 0000000..037495e --- /dev/null +++ b/doc/reference.qbk @@ -0,0 +1,11 @@ +[section Reference] + +[include reference/overview.qbk] +[include reference/synopsis.qbk] +[include reference/semantics.qbk] +[include reference/adaptors.qbk] +[include reference/algorithms.qbk] +[include reference/ranges.qbk] +[include reference/extending.qbk] + +[endsect] diff --git a/doc/reference/adaptors.qbk b/doc/reference/adaptors.qbk new file mode 100644 index 0000000..9de7fc5 --- /dev/null +++ b/doc/reference/adaptors.qbk @@ -0,0 +1,205 @@ +[section:adaptors Range Adaptors] + +[section:adaptors_introduction Introduction and motivation] + +A [*Range Adaptor] is a class that wraps an existing Range to provide a new Range with different behaviour. Since the behaviour of Ranges is determined by their associated iterators, a Range Adaptor simply wraps the underlying iterators with new special iterators. In this example + +`` +#include +#include +#include +#include + +std::vector vec; +boost::copy( vec | boost::adaptors::reversed, + std::ostream_iterator(std::cout) ); +`` + +the iterators from `vec` are wrapped `reverse_iterator`s. The type of the underlying Range Adapter is not documented because you do not need to know it. All that is relevant is that the expression + +`` +vec | boost::adaptors::reversed +`` + +returns a Range Adaptor where the iterator type is now the iterator type of the range `vec` wrapped in `reverse_iterator`. The expression `boost::adaptors::reversed` is called an *Adaptor Generator*. + +There are two ways of constructing a range adaptor. The first is by using `operator|()`. This is my preferred technique, however while discussing range adaptors with others it became clear that some users of the library strongly prefer a more familiar function syntax, so equivalent functions of the present tense form have been added as an alternative syntax. The equivalent to `rng | reversed` is `adaptors::reverse(rng)` for example. + +Why do I prefer the `operator|` syntax? The answer is readability: + +`` +std::vector vec; +boost::copy( boost::adaptors::reverse(vec), + std::ostream_iterator(std::cout) ); +`` + +This might not look so bad, but when we apply several adaptors, it becomes much worse. Just compare + +`` +std::vector vec; +boost::copy( boost::adaptors::unique( boost::adaptors::reverse( vec ) ), + std::ostream_iterator(std::cout) ); +`` + +to + +`` +std::vector vec; +boost::copy( vec | boost::adaptors::reversed + | boost::adaptors::uniqued, + std::ostream_iterator(std::cout) ); +`` + +Furthermore, some of the adaptor generators take arguments themselves and these arguments are expressed with function call notation too. In those situations, you will really appreciate the succinctness of `operator|()`. + +[heading Composition of Adaptors] + +Range Adaptors are a powerful complement to Range algorithms. The reason is that adaptors are ['*orthogonal*] to algorithms. For example, consider these Range algorithms: + +* `boost::copy( rng, out )` +* `boost::count( rng, pred )` + +What should we do if we only want to copy an element `a` if it satisfies some predicate, say `pred(a)`? And what if we only want to count the elements that satisfy the same predicate? The naive answer would be to use these algorithms: + +* `boost::copy_if( rng, pred, out )` +* `boost::count_if( rng, pred )` + +These algorithms are only defined to maintain a one to one relationship with the standard library algorithms. This approach of adding algorithm suffers a combinatorial explosion. Inevitably many algorithms are missing `_if` variants and there is redundant development overhead for each new algorithm. The Adaptor Generator is the design solution to this problem. + +[heading Range Adaptor alternative to copy_if algorithm] +`` +boost::copy_if( rng, pred, out ); +`` +can be expressed as +`` +boost::copy( rng | boost::adaptors::filtered(pred), out ); +`` + +[heading Range Adaptor alternative to count_if algorithm] +`` +boost::count_if( rng, pred ); +`` +can be expressed as +`` +boost::count( rng | boost::adaptors::filtered(pred), out ); +`` + +What this means is that ['*no*] algorithm with the `_if` suffix is needed. Furthermore, it turns out that algorithms with the `_copy` suffix are not needed either. Consider the somewhat misdesigned `replace_copy_if()` which may be used as + +`` +std::vector vec; +boost::replace_copy_if( rng, std::back_inserter(vec), pred ); +`` + +With adaptors and algorithms we can express this as + +`` +std::vector vec; +boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value)); +`` + +The latter code has several benefits: + +1. it is more ['*efficient*] because we avoid extra allocations as might happen with `std::back_inserter` + +2. it is ['*flexible*] as we can subsequently apply even more adaptors, for example: `` +boost::push_back(vec, rng | boost::adaptors::replaced_if(pred, new_value) + | boost::adaptors::reversed); +`` + +3. it is ['*safer*] because there is no use of an unbounded output iterator. + +In this manner, the ['*composition*] of Range Adaptors has the following consequences: + +1. we no longer need `_if`, `_copy`, `_copy_if` and `_n` variants of algorithms. + +2. we can generate a multitude of new algorithms on the fly, for example, above we generated `reverse_replace_copy_if()` + +In other words: + +[*Range Adaptors are to algorithms what algorithms are to containers] + +[endsect] + +[section:adaptors_synopsis Synopsis] + +The library provides the following Adapter Generator expressions: + +`` +rng | boost::adaptors::adjacent_filtered(bi_pred) +rng | boost::adaptors::copied(n,m) +rng | boost::adaptors::filtered(pred) +rng | boost::adaptors::indexed +rng | boost::adaptors::indirected +rng | boost::adaptors::map_keys +rng | boost::adaptors::map_values +rng | boost::adaptors::replaced(new_value, old_value) +rng | boost::adaptors::replaced_if(pred, new_value) +rng | boost::adaptors::reversed +rng | boost::adaptors::sliced(n, m) +rng | boost::adaptors::strided(n) +rng | boost::adaptors::tokenized( ) +rng | boost::adaptors::transformed(fun) +rng | boost::adaptors::uniqued +`` + +[endsect] + +[section:adaptors_general_requirements General Requirements] + +In the description of generator expressions, the following notation is used: + +* `fwdRng` is an expression of a type `R` that models `ForwardRange` +* `biRng` is an expression of a type `R` that models `BidirectionalRange` +* `rndRng` is an expression of a type `R` that models `RandomAccessRange` +* `pred` is an expression of a type that models `UnaryPredicate` +* `bi_pred` is an expression of a type that models `BinaryPredicate` +* `fun` is an expression of a type that models `UnaryFunction` +* `value`, `new_value` and `old_value` are objects convertible to `boost::range_value::type` +* `n,m` are integer expressions convertible to `range_difference::type` + +Also note that `boost::range_value::type` must be implicitly convertible to the type arguments to `pred`, `bi_pred` and `fun`. + +Range Category in the following adaptor descriptions refers to the minimum range concept required by the range passed to the adaptor. The resultant range is a model of the same range concept as the input range unless specified otherwise. + +Returned Range Category is the concept of the returned range. In some cases the returned range is of a lesser category than the range passed to the adaptor. For example, the `filtered` adaptor returns only a `ForwardRange` regardless of the input. + +Furthermore, the following rules apply to any expression of the form +`` +rng | boost::adaptors::adaptor_generator +`` + +1. Applying `operator|()` to a range `R` (always left argument) and a range adapter `RA` (always right argument) yields a new range type which may not conform to the same range concept as `R`. + +2. The return-type of `operator|()` is otherwise unspecified. + +3. `operator|()` is found by Argument Dependent Lookup (ADL) because a range adaptor is implemented in namespace `boost::adaptors`. + +4. `operator|()` is used to add new behaviour ['*lazily*] and never modifies its left argument. + +5. All iterators extracted from the left argument are extracted using qualified calls to `boost::begin()` and `boost::end()`. + +6. In addition to the `throw`-clauses below, `operator|()` may throw exceptions as a result of copying iterators. If such copying cannot throw an exception, then neither can the whole expression. + +[endsect] + +[section:adaptors_reference Reference] +[include adaptors/adjacent_filtered.qbk] +[include adaptors/copied.qbk] +[include adaptors/filtered.qbk] +[include adaptors/indexed.qbk] +[include adaptors/indirected.qbk] +[include adaptors/map_keys.qbk] +[include adaptors/map_values.qbk] +[include adaptors/replaced.qbk] +[include adaptors/replaced_if.qbk] +[include adaptors/reversed.qbk] +[include adaptors/sliced.qbk] +[include adaptors/strided.qbk] +[include adaptors/tokenized.qbk] +[include adaptors/transformed.qbk] +[include adaptors/uniqued.qbk] +[endsect] + +[endsect] + diff --git a/doc/reference/adaptors/adjacent_filtered.html b/doc/reference/adaptors/adjacent_filtered.html new file mode 100755 index 0000000..a5da75a --- /dev/null +++ b/doc/reference/adaptors/adjacent_filtered.html @@ -0,0 +1,101 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      adjacent_filtered

      +
      +
                  rng | boost::adaptors::adjacent_filtered( bi_pred )
      +        
      +
                  boost::make_adjacent_filtered_range( rng, bi_pred )
      +        
      +
      +
        +
      • + Precondition: + The value-type of the range is convertible to both argument types + of bi_pred. +
      • +
      • + Postcondition: + For all adjacent elements [x,y] in the returned range, + bi_pred(x,y) is true. +
      • +
      • + Throws: + Whatever the copy-constructor of bi_pred might throw. +
      • +
      • + Range Category: + SinglePassRange +
      • +
      + +
      +

      Example

      +
      +        #include <boost/range/adaptor/adjacent_filtered.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <functional>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::assign;
      +            using namespace boost::adaptors;
      +            
      +            std::vector<int> input;
      +            input += 1,1,2,2,2,3,4,5,6;
      +            
      +            boost::copy(
      +                input | adjacent_filtered(std::not_equal_to<int>()),
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This would produce the output:
      + 1,2,3,4,5,6
      +

      +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/adjacent_filtered.qbk b/doc/reference/adaptors/adjacent_filtered.qbk new file mode 100644 index 0000000..933536d --- /dev/null +++ b/doc/reference/adaptors/adjacent_filtered.qbk @@ -0,0 +1,47 @@ +[section:adjacent_filtered adjacent_filtered] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::adjacent_filtered(bi_pred)`]] + [[Function] [`boost::adaptors::adjacent_filter(rng, bi_pred)`]] +] + +* [*Precondition:] The `value_type` of the range is convertible to both argument types of `bi_pred`. +* [*Postcondition:] For all adjacent elements `[x,y]` in the returned range, `bi_pred(x,y)` is `true`. +* [*Throws:] Whatever the copy constructor of `bi_pred` might throw. +* [*Range Category:] `SinglePassRange` + +[section:adjacent_filtered_example adjacent_filtered example] +`` +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,1,2,2,2,3,4,5,6; + + boost::copy( + input | adjacent_filtered(std::not_equal_to()), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +1,2,3,4,5,6 +`` +[endsect] + + diff --git a/doc/reference/adaptors/copied.html b/doc/reference/adaptors/copied.html new file mode 100755 index 0000000..12b3351 --- /dev/null +++ b/doc/reference/adaptors/copied.html @@ -0,0 +1,93 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      copied

      +
      +
      rng | boost::adaptors::copied( n, m )
      +
      boost::make_copied_range( rng, n, m )
      +
      +
        +
      • + Precondition: + 0 <= n && n <= m && m < distance(rng) +
      • +
      • + Returns: + A new iterator_range that holds the sliced range + [n,m) of the original range. +
      • +
      • + Range Category: + RandomAccessRange +
      • +
      + +
      +

      Example

      +
      +    #include <boost/range/adaptor/copied.hpp>
      +    #include <boost/range/algorithm/copy.hpp>
      +    #include <boost/assign.hpp>
      +    #include <algorithm>
      +    #include <iostream>
      +    #include <vector>
      +
      +    int main(int argc, const char* argv[])
      +    {
      +        using namespace boost::assign;
      +        using namespace boost::adaptors;
      +
      +        std::vector<int> input;
      +        input += 1,2,3,4,5,6,7,8,9,10;
      +
      +        boost::copy(
      +            input | copied(1, 5),
      +            std::ostream_iterator<int>(std::cout, ","));
      +
      +        return 0;
      +    }
      +    
      +

      + This would produce the output: + 2,3,4,5 +

      +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/copied.qbk b/doc/reference/adaptors/copied.qbk new file mode 100644 index 0000000..263286c --- /dev/null +++ b/doc/reference/adaptors/copied.qbk @@ -0,0 +1,45 @@ +[section:copied copied] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::copied(n, m)`]] + [[Function] [`boost::adaptors::copy(rng, n, m)`]] +] + +* [*Precondition:] `0 <= n && n <= m && m < distance(rng)` +* [*Returns:] A new `iterator_range` that holds the sliced range `[n,m)` of the original range. +* [*Range Category:] `RandomAccessRange` + +[section:copied_example copied example] +`` +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | copied(1, 5), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +2,3,4,5 +`` +[endsect] + + diff --git a/doc/reference/adaptors/examples/adjacent_filtered.cpp b/doc/reference/adaptors/examples/adjacent_filtered.cpp new file mode 100644 index 0000000..70923f8 --- /dev/null +++ b/doc/reference/adaptors/examples/adjacent_filtered.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,1,2,2,2,3,4,5,6; + + boost::copy( + input | adjacent_filtered(std::not_equal_to()), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/copied.cpp b/doc/reference/adaptors/examples/copied.cpp new file mode 100644 index 0000000..0ab0ca2 --- /dev/null +++ b/doc/reference/adaptors/examples/copied.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | copied(1, 5), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/filtered.cpp b/doc/reference/adaptors/examples/filtered.cpp new file mode 100644 index 0000000..65242f3 --- /dev/null +++ b/doc/reference/adaptors/examples/filtered.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include +#include + +struct is_even +{ + bool operator()(int x) const { return x % 2 == 0; } +}; + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | filtered(is_even()), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/indexed.cpp b/doc/reference/adaptors/examples/indexed.cpp new file mode 100644 index 0000000..3dc31d1 --- /dev/null +++ b/doc/reference/adaptors/examples/indexed.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include + +template +void display_element_and_index(Iterator first, Iterator last) +{ + for (Iterator it = first; it != last; ++it) + { + std::cout << "Element = " << *it + << " Index = " << it.index() << std::endl; + } +} + +template +void display_element_and_index(const SinglePassRange& rng) +{ + display_element_and_index(boost::begin(rng), boost::end(rng)); +} + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 10,20,30,40,50,60,70,80,90; + + display_element_and_index( input | indexed(0) ); + + return 0; +] + diff --git a/doc/reference/adaptors/examples/indirected.cpp b/doc/reference/adaptors/examples/indirected.cpp new file mode 100644 index 0000000..47cf493 --- /dev/null +++ b/doc/reference/adaptors/examples/indirected.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + + std::vector > input; + + for (int i = 0; i < 10; ++i) + input.push_back(boost::shared_ptr(new int(i))); + + boost::copy( + input | indirected, + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/map_keys.cpp b/doc/reference/adaptors/examples/map_keys.cpp new file mode 100644 index 0000000..6c5fc44 --- /dev/null +++ b/doc/reference/adaptors/examples/map_keys.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); + + boost::copy( + input | map_keys, + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/map_values.cpp b/doc/reference/adaptors/examples/map_values.cpp new file mode 100644 index 0000000..9442612 --- /dev/null +++ b/doc/reference/adaptors/examples/map_values.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); + + boost::copy( + input | map_values, + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/replaced.cpp b/doc/reference/adaptors/examples/replaced.cpp new file mode 100644 index 0000000..7c8926b --- /dev/null +++ b/doc/reference/adaptors/examples/replaced.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,2,5,2,7,2,9; + + boost::copy( + input | replaced(2, 10), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/replaced_if.cpp b/doc/reference/adaptors/examples/replaced_if.cpp new file mode 100644 index 0000000..fedd364 --- /dev/null +++ b/doc/reference/adaptors/examples/replaced_if.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include + +struct is_even +{ + bool operator()(int x) const { return x % 2 == 0; } +}; + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | replaced_if(is_even(), 10), + std::ostream_iterator(std::cout, ",")); + + return 0; +} diff --git a/doc/reference/adaptors/examples/reversed.cpp b/doc/reference/adaptors/examples/reversed.cpp new file mode 100644 index 0000000..e2aa80c --- /dev/null +++ b/doc/reference/adaptors/examples/reversed.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | reversed, + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/sliced.cpp b/doc/reference/adaptors/examples/sliced.cpp new file mode 100644 index 0000000..6ce4b12 --- /dev/null +++ b/doc/reference/adaptors/examples/sliced.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | sliced(2, 5), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/strided.cpp b/doc/reference/adaptors/examples/strided.cpp new file mode 100644 index 0000000..4509758 --- /dev/null +++ b/doc/reference/adaptors/examples/strided.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | strided(2), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/tokenized.cpp b/doc/reference/adaptors/examples/tokenized.cpp new file mode 100644 index 0000000..b4e6371 --- /dev/null +++ b/doc/reference/adaptors/examples/tokenized.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + + std::string input = " a b c d e f g hijklmnopqrstuvwxyz"; + std::vector< boost::sub_match< std::string::iterator > > result; + boost::push_back(result, input | tokenized(boost::regex("\\b"))); + + BOOST_ASSERT( boost::size(result) == 16u ); + + return 0; +} diff --git a/doc/reference/adaptors/examples/transformed.cpp b/doc/reference/adaptors/examples/transformed.cpp new file mode 100644 index 0000000..1508969 --- /dev/null +++ b/doc/reference/adaptors/examples/transformed.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include + +struct double_int +{ + typedef int result_type; + int operator()(int x) const { return x * 2; } +}; + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | transformed(double_int()), + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/examples/uniqued.cpp b/doc/reference/adaptors/examples/uniqued.cpp new file mode 100644 index 0000000..0511ade --- /dev/null +++ b/doc/reference/adaptors/examples/uniqued.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,1,2,2,2,3,4,5,6; + + boost::copy( + input | uniqued, + std::ostream_iterator(std::cout, ",")); + + return 0; +} + diff --git a/doc/reference/adaptors/filtered.html b/doc/reference/adaptors/filtered.html new file mode 100755 index 0000000..055c826 --- /dev/null +++ b/doc/reference/adaptors/filtered.html @@ -0,0 +1,108 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      filtered

      +
      +
      rng | boost::adaptors::filtered( pred )
      +
      boost::make_filtered_range( rng, pred )
      +
      +
        +
      • + Precondition: + The value-type of the range is convertible to the argument type of + pred. +
      • +
      • + Postcondition: + For all elements x in the returned range, + pred(x) is true +
      • +
      • + Throws: + Whatever the copy-constructor of pred might throw. +
      • +
      • + Range Category: + ForwardRange +
      • +
      • + Returned Range Category: + ForwardRange +
      • +
      + +
      +

      Example

      +
      +        #include <boost/range/adaptor/filtered.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +
      +        struct is_even
      +        {
      +            bool operator()(int x) const { return x % 2 == 0; }
      +        };
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::assign;
      +            using namespace boost::adaptors;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,4,5,6,7,8,9;
      +
      +            boost::copy(
      +                input | filtered(is_even()),
      +                std::ostream_iterator<int>(std::cout, ","));
      +
      +            return 0;
      +        }
      +    
      +

      + This would produce the output:
      + 2,4,6,8 +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/filtered.qbk b/doc/reference/adaptors/filtered.qbk new file mode 100644 index 0000000..2a6dc33 --- /dev/null +++ b/doc/reference/adaptors/filtered.qbk @@ -0,0 +1,50 @@ +[section:filtered filtered] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::filtered(pred)`]] + [[Function] [`boost::adaptors::filter(rng, pred)`]] +] + +* [*Precondition:] The `value_type` of the range is convertible to the argument type of `pred`. +* [*Postcondition:] For all adjacent elements `[x]` in the returned range, `pred(x)` is `true`. +* [*Throws:] Whatever the copy constructor of `pred` might throw. +* [*Range Category:] `ForwardRange` +* [*Returned Range Category:] `ForwardRange` + +[section:filtered_example filtered example] +`` +#include +#include +#include +#include +#include +#include + +struct is_even +{ + bool operator()( int x ) const { return x % 2 == 0; } +}; + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | filtered(is_even()), + std::ostream_iterator(std::cout, ",")); +} +`` +[endsect] + +This would produce the output: +`` +2,4,6,8 +`` +[endsect] + + diff --git a/doc/reference/adaptors/indexed.html b/doc/reference/adaptors/indexed.html new file mode 100755 index 0000000..74e0d04 --- /dev/null +++ b/doc/reference/adaptors/indexed.html @@ -0,0 +1,117 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      indexed

      +
      +
      rng | boost::adaptors::indexed
      +
      boost::make_indexed_range( rng )
      +
      +
        +
      • + Returns: + A range adapted to return both the element and the associated + index. + The returned range consists of iterators that have in addition + to the usual iterator member functions an + index() member function that returns the appropriate + index for the element in the sequence corresponding with the + iterator. +
      • +
      • + Range Category: + SinglePassRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/indexed.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        template<class Iterator>
      +        void display_element_and_index(Iterator first, Iterator last)
      +        {
      +            for (Iterator it = first; it != last; ++it)
      +            {
      +                std::cout << "Element = " << *it
      +                          << " Index = " << it.index() << std::endl;
      +            }
      +        }
      +        
      +        template<class SinglePassRange>
      +        void display_element_and_index(const SinglePassRange& rng)
      +        {
      +            display_element_and_index(boost::begin(rng), boost::end(rng));
      +        }
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::assign;
      +            using namespace boost::adaptors;
      +            
      +            std::vector<int> input;
      +            input += 10,20,30,40,50,60,70,80,90;
      +            
      +            display_element_and_index( input | indexed(0) );
      +            
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + Element = 10 Index = 0
      + Element = 20 Index = 1
      + Element = 30 Index = 2
      + Element = 40 Index = 3
      + Element = 50 Index = 4
      + Element = 60 Index = 5
      + Element = 70 Index = 6
      + Element = 80 Index = 7
      + Element = 90 Index = 8
      +
      +

      +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/indexed.qbk b/doc/reference/adaptors/indexed.qbk new file mode 100644 index 0000000..36dfd88 --- /dev/null +++ b/doc/reference/adaptors/indexed.qbk @@ -0,0 +1,86 @@ +[section:indexed indexed] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::indexed`]] + [[Function] [`boost::adaptors::index(rng)`]] +] + +* [*Returns:] A range adapted to return both the element and the associated index. The returned range consists of iterators that have in addition to the usual iterator member functions an `index()` member function that returns the appropriate index for the element in the sequence corresponding with the iterator. +* [*Range Category:] `SinglePassRange` + +[section:indexed_example indexed example] +`` +#include +#include +#include +#include +#include +#include + +template +void display_element_and_index(Iterator first, Iterator last) +{ + for (Iterator it = first; it != last; ++it) + { + std::cout << "Element = " << *it << " Index = " << it.index() << std::endl; + } +} + +template +void display_element_and_index(const SinglePassRange& rng) +{ + display_element_and_index(boost::begin(rng), boost::end(rng)); +} + +template +void check_element_and_index( + Iterator1 test_first, + Iterator1 test_last, + Iterator2 reference_first, + Iterator2 reference_last) +{ + BOOST_CHECK_EQUAL( std::distance(test_first, test_last), + std::distance(reference_first, reference_last) ); + + int reference_index = 0; + + Iterator1 test_it = test_first; + Iterator2 reference_it = reference_first; + for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index) + { + BOOST_CHECK_EQUAL( *test_it, *reference_it ); + BOOST_CHECK_EQUAL( test_it.index(), reference_index ); + } +} + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 10,20,30,40,50,60,70,80,90; + + display_element_and_index( input | indexed(0) ); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +Element = 10 Index = 0 +Element = 20 Index = 1 +Element = 30 Index = 2 +Element = 40 Index = 3 +Element = 50 Index = 4 +Element = 60 Index = 5 +Element = 70 Index = 6 +Element = 80 Index = 7 +Element = 90 Index = 8 +`` +[endsect] + + diff --git a/doc/reference/adaptors/indirected.html b/doc/reference/adaptors/indirected.html new file mode 100755 index 0000000..0a56e32 --- /dev/null +++ b/doc/reference/adaptors/indirected.html @@ -0,0 +1,95 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      indirected

      +
      +
      rng | boost::adaptors::indirected
      +
      boost::make_indirected_range( rng )
      +
      +
        +
      • + Precondition: + The value-type of the range defines unary operator*() +
      • +
      • + Postcondition: + For all elements x in the returned range, + x is the result of *y where + y is the corresponding element in the original range. +
      • +
      • + Range Category: + SinglePassRange +
      • +
      + +
      +

      Example

      +
      +        #include <boost/range/adaptor/indirected.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/shared_ptr.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            
      +            std::vector<boost::shared_ptr<int> > input;
      +            
      +            for (int i = 0; i < 10; ++i)
      +                input.push_back(boost::shared_ptr<int>(new int(i)));
      +                
      +            boost::copy(
      +                input | indirected,
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + 0,1,2,3,4,5,6,7,8,9 +

      +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/indirected.qbk b/doc/reference/adaptors/indirected.qbk new file mode 100644 index 0000000..f0cbd7a --- /dev/null +++ b/doc/reference/adaptors/indirected.qbk @@ -0,0 +1,46 @@ +[section:indirected indirected] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::indirected`]] + [[Function] [`boost::adaptors::indirect(rng)`]] +] + +* [*Precondition:] The `value_type` of the range defines unary `operator*()` +* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `*y` where `y` is the corresponding element in the original range. +* [*Range Category:] `SinglePassRange` + +[section:indirected_example indirected example] +`` +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + + std::vector > input; + + for (int i = 0; i < 10; ++i) + input.push_back(boost::shared_ptr(new int(i))); + + boost::copy( + input | indirected, + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +0,1,2,3,4,5,6,7,8,9 +`` +[endsect] + + diff --git a/doc/reference/adaptors/map_keys.html b/doc/reference/adaptors/map_keys.html new file mode 100755 index 0000000..a1eec17 --- /dev/null +++ b/doc/reference/adaptors/map_keys.html @@ -0,0 +1,99 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      map_keys

      +
      +
      rng | boost::adaptors::map_keys
      +
      boost::make_map_key_range( rng )
      +
      +
        +
      • + Precondition: + The value-type of the range is an instantiation of std::pair. +
      • +
      • + Postcondition: + For all elements x in the returned range, + x is the result of y.first where + y is the corresponding element in the original range. +
      • +
      • + Range Category: + SinglePassRange +
      • +
      + +
      +

      Example

      +
      +        #include <boost/range/adaptor/map.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <map>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::assign;
      +            using namespace boost::adaptors;
      +            
      +            std::map<int,int> input;
      +            for (int i = 0; i < 10; ++i)
      +                input.insert(std::make_pair(i, i * 10));
      +                
      +            boost::copy(
      +                input | map_keys,
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + 0,1,2,3,4,5,6,7,8,9 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/map_keys.qbk b/doc/reference/adaptors/map_keys.qbk new file mode 100644 index 0000000..7b29013 --- /dev/null +++ b/doc/reference/adaptors/map_keys.qbk @@ -0,0 +1,47 @@ +[section:map_keys map_keys] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::map_keys`]] + [[Function] [`boost::adaptors::keys(rng)`]] +] + +* [*Precondition:] The `value_type` of the range is an instantiation of `std::pair`. +* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.first` where `y` is the corresponding element in the original range. +* [*Range Category:] `SinglePassRange` + +[section:map_keys_example map_keys example] +`` +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); + + boost::copy( + input | map_keys, + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +0,1,2,3,4,5,6,7,8,9 +`` +[endsect] + + diff --git a/doc/reference/adaptors/map_values.html b/doc/reference/adaptors/map_values.html new file mode 100755 index 0000000..bc3c165 --- /dev/null +++ b/doc/reference/adaptors/map_values.html @@ -0,0 +1,98 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      map_values

      +
      +
      rng | boost::adaptors::map_values
      +
      boost::make_map_value_range( rng )
      +
      +
        +
      • + Precondition: + The value-type of the range is an instantiation of std::pair. +
      • +
      • + Postcondition: + For all elements x in the returned range, + x is the result of y.second where + y is the corresponding element in the original range. +
      • +
      • + Range Category: + SinglePassRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/map.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <map>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::assign;
      +            using namespace boost::adaptors;
      +            
      +            std::map<int,int> input;
      +            for (int i = 0; i < 10; ++i)
      +                input.insert(std::make_pair(i, i * 10));
      +                
      +            boost::copy(
      +                input | map_values,
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + 0,10,20,30,40,50,60,70,80,90 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/map_values.qbk b/doc/reference/adaptors/map_values.qbk new file mode 100644 index 0000000..28f75c8 --- /dev/null +++ b/doc/reference/adaptors/map_values.qbk @@ -0,0 +1,47 @@ +[section:map_values map_values] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::map_values`]] + [[Function] [`boost::adaptors::values(rng)`]] +] + +* [*Precondition:] The `value_type` of the range is an instantiation of `std::pair`. +* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.second` where `y` is the corresponding element in the original range. +* [*Range Category:] `SinglePassRange` + +[section:map_values_example map_values example] +`` +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); + + boost::copy( + input | map_values, + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +0,10,20,30,40,50,60,70,80,90 +`` +[endsect] + + diff --git a/doc/reference/adaptors/replaced.html b/doc/reference/adaptors/replaced.html new file mode 100755 index 0000000..861277f --- /dev/null +++ b/doc/reference/adaptors/replaced.html @@ -0,0 +1,107 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      replaced

      +
      +
      rng | boost::adaptors::replaced( new_value, old_value )
      +
      boost::make_replaced_range( rng, new_value, old_value )
      +
      +
        +
      • + Precondition: +
          +
        • + new_value is convertible to the value-type of + the range. +
        • +
        • + old_value is convertible to the value-type of + the range. +
        • +
        +
      • +
      • + Postcondition: + For all elements x in the returned range, the value + x is equal to the value of + (y == old_value) ? new_value : y + where y is the corresponding element in the original + range. +
      • +
      • + Range Category: + ForwardRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/replaced.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            using namespace boost::assign;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,2,5,2,7,2,9;
      +            
      +            boost::copy(
      +                input | replaced(2, 10),
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + 1,10,3,10,5,10,7,10,9 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/replaced.qbk b/doc/reference/adaptors/replaced.qbk new file mode 100644 index 0000000..92a673b --- /dev/null +++ b/doc/reference/adaptors/replaced.qbk @@ -0,0 +1,47 @@ +[section:replaced replaced] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::replaced(new_value, old_value)`]] + [[Function] [`boost::adaptors::replace(rng, new_value, old_value)`]] +] + +* [*Precondition:] + * `new_value` is convertible to the `value_type` of the range. + * `old_value` is convertible to the `value_type` of the range. +* [*Postcondition:] For all elements `x` in the returned range, the value `x` is equal to the value of `(y == old_value) ? new_value : y` where `y` is the corresponding element in the original range. +* [*Range Category:] `ForwardRange` + +[section:replaced_example replaced example] +`` +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,2,5,2,7,2,9; + + boost::copy( + input | replaced(2, 10), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +1,10,3,10,5,10,7,10,9 +`` +[endsect] + + diff --git a/doc/reference/adaptors/replaced_if.html b/doc/reference/adaptors/replaced_if.html new file mode 100755 index 0000000..cde3678 --- /dev/null +++ b/doc/reference/adaptors/replaced_if.html @@ -0,0 +1,114 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      replaced_if

      +
      +
      rng | boost::adaptors::replaced_if( pred, new_value )
      +
      boost::make_replaced_if_range( rng, pred, new_value )
      +
      +
        +
      • + Precondition: +
          +
        • + The range value-type is convertible to the argument type + of pred. +
        • +
        • + new_value is convertible to the value-type + of the range. +
        • +
        +
      • +
      • + Postconditions: + For all elements [x] in the returned range, the value + x is equal to the value of + pred(y) ? new_value : y + where y is the corresponding element in the original + range. +
      • +
      • + Range Category: + ForwardRange +
      • +
      + +
      +

      Example

      +
      +        #include <boost/range/adaptor/replaced_if.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        struct is_even
      +        {
      +            bool operator()(int x) const { return x % 2 == 0; }
      +        };
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            using namespace boost::assign;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,4,5,6,7,8,9;
      +            
      +            boost::copy(
      +                input | replaced_if(is_even(), 10),
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +        
      +    
      +

      + This produces the output:
      + + 1,10,3,10,5,10,7,10,9 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/replaced_if.qbk b/doc/reference/adaptors/replaced_if.qbk new file mode 100644 index 0000000..b7b7e57 --- /dev/null +++ b/doc/reference/adaptors/replaced_if.qbk @@ -0,0 +1,52 @@ +[section:replaced_if replaced_if] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::replaced_if(pred, new_value)`]] + [[Function] [`boost::adaptors::replace_if(rng, pred, new_value)`]] +] + +* [*Precondition:] + * The range `value_type` is convertible to the argument type of `pred`. + * `new_value` is convertible to the `value_type` of the range. +* [*Postconditions:] For all elements `x` in the returned range, the value `x` is equal to the value of `pred(y) ? new_value : y` where `y` is the corresponding element in the original range. +* [*Range Category:] `ForwardRange` + +[section:replaced_if_example replaced_if example] +`` +#include +#include +#include +#include +#include +#include + +struct is_even +{ + bool operator()(int x) const { return x % 2 == 0; } +}; + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | replaced_if(is_even(), 10), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +1,10,3,10,5,10,7,10,9 +`` +[endsect] + + diff --git a/doc/reference/adaptors/reversed.html b/doc/reference/adaptors/reversed.html new file mode 100755 index 0000000..0aea1ee --- /dev/null +++ b/doc/reference/adaptors/reversed.html @@ -0,0 +1,91 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      reversed

      +
      +
      rng | boost::adaptors::reversed
      +
      boost::make_reversed_range( rng )
      +
      +
        +
      • + Returns: + A range whose iterators behave as if they were the original + iterators wrapped in reverse_iterator. +
      • +
      • + Range Category: + BidirectionalRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/reversed.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            using namespace boost::assign;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,4,5,6,7,8,9;
      +            
      +            boost::copy(
      +                input | reversed,
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + 9,8,7,6,5,4,3,2,1 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/reversed.qbk b/doc/reference/adaptors/reversed.qbk new file mode 100644 index 0000000..4ad623b --- /dev/null +++ b/doc/reference/adaptors/reversed.qbk @@ -0,0 +1,44 @@ +[section:reversed reversed] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::reversed`]] + [[Function] [`boost::adaptors::reverse(rng)`]] +] + +* [*Returns:] A range whose iterators behave as if they were the original iterators wrapped in `reverse_iterator`. +* [*Range Category:] `BidirectionalRange` + +[section:reversed_example reversed example] +`` +#include +#include +#include +#include +#include +#include + +void reversed_example_test() +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | reversed, + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +9,8,7,6,5,4,3,2,1 +`` +[endsect] + + diff --git a/doc/reference/adaptors/sliced.html b/doc/reference/adaptors/sliced.html new file mode 100755 index 0000000..d979392 --- /dev/null +++ b/doc/reference/adaptors/sliced.html @@ -0,0 +1,94 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      sliced

      +
      +
      rng | boost::adaptors::sliced( n, m )
      +
      boost::make_sliced_range( rng, n, m )
      +
      +
        +
      • + Precondition: + 0 <= n && n <= m && m < distance(rng) +
      • +
      • + Returns: + make_range(rng, n, m) +
      • +
      • + Range Category: + RandomAccessRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/sliced.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            using namespace boost::assign;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,4,5,6,7,8,9;
      +            
      +            boost::copy(
      +                input | sliced(2, 5),
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + 3,4,5 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/sliced.qbk b/doc/reference/adaptors/sliced.qbk new file mode 100644 index 0000000..e424ddc --- /dev/null +++ b/doc/reference/adaptors/sliced.qbk @@ -0,0 +1,45 @@ +[section:sliced sliced] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::sliced(n, m)`]] + [[Function] [`boost::adaptors::slice(rng, n, m)`]] +] + +* [*Precondition:] `0 <= n && n <= m && m < distance(rng)` +* [*Returns:] `make_range(rng, n, m)` +* [*Range Category:] `RandomAccessRange` + +[section:sliced_example sliced example] +`` +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | sliced(2, 5), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +3,4,5 +`` +[endsect] + + diff --git a/doc/reference/adaptors/strided.html b/doc/reference/adaptors/strided.html new file mode 100755 index 0000000..3e23af5 --- /dev/null +++ b/doc/reference/adaptors/strided.html @@ -0,0 +1,94 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      strided

      +
      +
      rng | boost::adaptors::strided( n )
      +
      boost::make_strided_range( rng, n )
      +
      +
        +
      • + Precondition: + 0 <= n && n <= distance(rng) +
      • +
      • + Returns: + A new range based on rng where traversal is performed in steps of n. +
      • +
      • + Range Category: + RandomAccessRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/strided.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            using namespace boost::assign;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,4,5,6,7,8,9,10;
      +            
      +            boost::copy(
      +                input | strided(2),
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output: + + 1,3,5,7,9 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/strided.qbk b/doc/reference/adaptors/strided.qbk new file mode 100644 index 0000000..cf2f09f --- /dev/null +++ b/doc/reference/adaptors/strided.qbk @@ -0,0 +1,45 @@ +[section:strided strided] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::strided(n)`]] + [[Function] [`boost::adaptors::stride(rng, n)`]] +] + +* [*Precondition:] `0 <= n && n < distance(rng)` +* [*Returns:] A new range based on `rng` where traversal is performed in steps of `n`. +* [*Range Category:] `RandomAccessRange` + +[section:strided_example strided example] +`` +#include +#include +#include +#include +#include +#include + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | strided(2), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +1,3,5,7,9 +`` +[endsect] + + diff --git a/doc/reference/adaptors/tokenized.html b/doc/reference/adaptors/tokenized.html new file mode 100755 index 0000000..304e91d --- /dev/null +++ b/doc/reference/adaptors/tokenized.html @@ -0,0 +1,118 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      tokenized

      +
      +
      rng | boost::adaptors::tokenized( regex )
      +
      rng | boost::adaptors::tokenized( regex, i )
      +
      rng | boost::adaptors::tokenized( regex, rndRng )
      +
      rng | boost::adaptors::tokenized( regex, i, flags )
      +
      rng | boost::adaptors::tokenized( regex, rndRng, flags )
      +
      boost::make_tokenized_range( rng, regex, i, flags )
      +
      boost::make_tokenized_range( rng, regex, rngRng, flags )
      +
      +
        +
      • + Precondition: +
          +
        • + Let T denote + typename range_value< decltype(rng) >::type, + then regex has the type + basic_regex<T> or is + implicitly convertible to one of these types. +
        • +
        • + i has the type int. +
        • +
        • + the value-type of rndRng is int. +
        • +
        • + flags has the type + regex_constants::syntax_option_type. +
        • +
        +
      • +
      • + Returns: + A range whose iterators behave as if they were the + original iterators wrapped in regex_token_iterator. + The first iterator in the range would be constructed by + forwarding all the arguments of tokenized() to the + regex_token_iterator constructor. +
      • +
      • + Throws: + Whatever constructing and copying equivalent + regex_token_iterators might throw. +
      • +
      • + Range Category: + RandomAccessRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/tokenized.hpp>
      +        #include <boost/range/algorithm_ext/push_back.hpp>
      +        #include <boost/assert.hpp>
      +        #include <algorithm>
      +        #include <string>
      +        #include <vector>
      +        
      +        int main(int argc, const char* argv)
      +        {
      +            using namespace boost::adaptors;
      +            
      +            std::string input = "a b c d e f g hijklmnopqrstuvwxyz";
      +            std::vector< boost::sub_match< std::string::iterator > > result;
      +            boost::push_back(result, input | tokenized(boost::regex("\\b")));
      +            
      +            BOOST_ASSERT( boost::size(result) == 16u );
      +            
      +            return 0;
      +        }
      +    
      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/tokenized.qbk b/doc/reference/adaptors/tokenized.qbk new file mode 100644 index 0000000..7b7504c --- /dev/null +++ b/doc/reference/adaptors/tokenized.qbk @@ -0,0 +1,42 @@ +[section:tokenized tokenized] + +[table + [[Syntax] [Code]] + [ + [Pipe] + [ + `` + rng | boost::adaptors::tokenized(regex) + rng | boost::adaptors::tokenized(regex, i) + rng | boost::adaptors::tokenized(regex, rndRng) + rng | boost::adaptors::tokenized(regex, i, flags) + rng | boost::adaptors::tokenized(regex, rndRng, flags) + `` + ] + ] + [ + [Function] + [ + `` + boost::adaptors::tokenize(rng, regex) + boost::adaptors::tokenize(rng, regex, i) + boost::adaptors::tokenize(rng, regex, rndRng) + boost::adaptors::tokenize(rng, regex, i, flags) + boost::adaptors::tokenize(rng, regex, rndRng, flags) + `` + ] + ] +] + +* [*Precondition:] + * Let `T` denote `typename range_value::type`, then `regex` has the type `basic_regex` or is implicitly convertible to one of these types. + * `i` has the type `int`. + * the `value_type` of `rndRng` is `int`. + * `flags` has the type `regex_constants::syntax_option_type`. +* [*Returns:] A range whose iterators behave as if they were the original iterators wrapped in `regex_token_iterator`. The first iterator in the range would be constructed by forwarding all the arguments of `tokenized()` to the `regex_token_iterator` constructor. +* [*Throws:] Whatever constructing and copying equivalent `regex_token_iterator`s might throw. +* [*Range Category:] `RandomAccessRange` + +[endsect] + + diff --git a/doc/reference/adaptors/transformed.html b/doc/reference/adaptors/transformed.html new file mode 100755 index 0000000..4069f9a --- /dev/null +++ b/doc/reference/adaptors/transformed.html @@ -0,0 +1,107 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      transformed

      +
      +
      rng | boost::adaptors::transformed( fun )
      +
      boost::make_transformed_range( rng, fun )
      +
      +
        +
      • + Precondition: + The value-type of the range is convertible to the argument type + of fun. +
      • +
      • + Postcondition: + For all elements x in the returned range, + x is the result of fun(y) where + y is the corresponding element in the original range. +
      • +
      • + Throws: + Whatever the copy-constructor of fun might throw. +
      • +
      • + Range Category: + SinglePassRange +
      • +
      +
      +

      Example

      +
      +        #include <boost/range/adaptor/transformed.hpp>
      +        #include <boost/range/algorithm/copy.hpp>
      +        #include <boost/range/assign.hpp>
      +        #include <algorithm>
      +        #include <iostream>
      +        #include <vector>
      +        
      +        struct double_int
      +        {
      +            typedef int result_type;
      +            int operator()(int x) const { return x * 2; }
      +        };
      +        
      +        int main(int argc, const char* argv[])
      +        {
      +            using namespace boost::adaptors;
      +            using namespace boost::assign;
      +            
      +            std::vector<int> input;
      +            input += 1,2,3,4,5,6,7,8,9,10;
      +            
      +            boost::copy(
      +                input | transformed(double_int()),
      +                std::ostream_iterator<int>(std::cout, ","));
      +                
      +            return 0;
      +        }
      +    
      +

      + This produces the output:
      + + 2,4,6,8,10,12,14,16,18,20 + +

      + +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/transformed.qbk b/doc/reference/adaptors/transformed.qbk new file mode 100644 index 0000000..3b64768 --- /dev/null +++ b/doc/reference/adaptors/transformed.qbk @@ -0,0 +1,52 @@ +[section:transformed transformed] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::transformed(fun)`]] + [[Function] [`boost::adaptors::transform(rng, fun)`]] +] + +* [*Precondition:] The `value_type` of the range is convertible to the argument type of `fun`. +* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `fun(y)` where `y` is the corresponding element in the original range. +* [*Throws:] Whatever the copy-constructor of `fun` might throw. +* [*Range Category:] `SinglePassRange` + +[section:transformed_example transformed example] +`` +#include +#include +#include +#include +#include +#include + +struct double_int +{ + typedef int result_type; + int operator()(int x) const { return x * 2; } +}; + +int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | transformed(double_int()), + std::ostream_iterator(std::cout, ",")); + + return 0; +} +`` +[endsect] + +This would produce the output: +`` +2,4,6,8,10,12,14,16,18,20 +`` +[endsect] + + diff --git a/doc/reference/adaptors/uniqued.html b/doc/reference/adaptors/uniqued.html new file mode 100755 index 0000000..43ca130 --- /dev/null +++ b/doc/reference/adaptors/uniqued.html @@ -0,0 +1,95 @@ + + + + + + Boost.Range Range Adaptors + + + + + + + + + + +

      Boost.Range

      + +

      Range Adaptors

      + +
      + +

      uniqued

      +
      +
      rng | boost::adaptors::uniqued
      +
      boost::make_uniqued_range( rng )
      +
      +
        +
      • + Precondition: + The value-type of the range is comparable with + operator==(). +
      • +
      • + Postcondition: + For all adjacent elements [x,y] in the returned range, + x==y is false. +
      • +
      • + Range Category: + ForwardRange +
      • +
      + +
      +

      Example

      + +
      +    #include <boost/range/adaptor/uniqued.hpp>
      +    #include <boost/range/algorithm/copy.hpp>
      +    #include <boost/assign.hpp>
      +    #include <algorithm>
      +    #include <iostream>
      +    #include <vector>
      +    
      +    int main(int argc, const char* argv)
      +    {
      +        using namespace boost::assign;
      +        using namespace boost::adaptors;
      +        
      +        std::vector<int> input;
      +	input += 1,1,2,2,2,3,4,5,6;
      +        
      +	boost::copy(
      +	    input | uniqued,
      +            std::ostream_iterator<int>(std::cout, ",") );
      +         
      +        return 0;
      +    }
      +   
      +

      + This would produce the output:
      + 1,2,3,4,5,6
      +

      +
      +

      + (C) Copyright Neil Groves 2009 + (C) Copyright Thorsten Ottosen 2003-2004 +

      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      + + + diff --git a/doc/reference/adaptors/uniqued.qbk b/doc/reference/adaptors/uniqued.qbk new file mode 100644 index 0000000..a90cdde --- /dev/null +++ b/doc/reference/adaptors/uniqued.qbk @@ -0,0 +1,43 @@ +[section:uniqued uniqued] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::uniqued`]] + [[Function] [`boost::adaptors::unique(rng)`]] +] + +* [*Precondition:] The `value_type` of the range is comparable with `operator==()`. +* [*Postcondition:] For all adjacent elements `[x,y]` in the returned range, `x==y` is false. +* [*Range Category:] `ForwardRange` + +[section:uniqued_example uniqued example] +`` +#include +#include +#include +#include +#include +#include + +void uniqued_example_test() +{ + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,1,2,2,2,3,4,5,6; + + boost::copy( + input | uniqued, + std::ostream_iterator(std::cout, ",")); +} +`` +[endsect] + +This would produce the output: +`` +1,2,3,4,5,6 +`` +[endsect] + + diff --git a/doc/reference/algorithm/adjacent_find.qbk b/doc/reference/algorithm/adjacent_find.qbk new file mode 100644 index 0000000..32c881e --- /dev/null +++ b/doc/reference/algorithm/adjacent_find.qbk @@ -0,0 +1,80 @@ +[section:adjacent_find Range Algorithm - adjacent_find] + +[heading Prototype] + +`` +template +typename range_iterator::type +adjacent_find(ForwardRange& rng); + +template +typename range_iterator::type +adjacent_find(const ForwardRange& rng); + +template +typename range_iterator::type +adjacent_find(ForwardRange& rng, BinaryPred pred); + +template +typename range_iterator::type +adjacent_find(const ForwardRange& rng, BinaryPred pred); + +template +typename range_return::type +adjacent_find(ForwardRange& rng); + +template +typename range_return::type +adjacent_find(const ForwardRange& rng); + +template< + range_return_value re, + class ForwardRange, + class BinaryPredicate + > +typename range_return::type +adjacent_find(ForwardRange& rng, BinaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class BinaryPredicate + > +typename range_return::type +adjacent_find(const ForwardRange& rng, BinaryPredicate pred); +`` + +[heading Description] + +[*Non-predicate versions:] + +`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `x == y` + +[*Predicate versions:] + +`adjacent_find` finds the first adjacent elements `[x,y]` in `rng` where `pred(x,y)` is `true`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/adjacent_find.hpp` + +[heading Requirements] + +[*For the non-predicate versions of adjacent_find:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange`'s value type is a model of the `EqualityComparableConcept`. + +[*For the predicate versions of adjacent_find:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +Linear. If `empty(rng)` then no comparisons are performed; otherwise, at most `distance(rng) - 1` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/binary_search.qbk b/doc/reference/algorithm/binary_search.qbk new file mode 100644 index 0000000..542906f --- /dev/null +++ b/doc/reference/algorithm/binary_search.qbk @@ -0,0 +1,55 @@ +[section:binary_search binary_search] + +[heading Prototype] + +`` +template +bool binary_search(const ForwardRange& rng, const Value& val); + +template +bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred); +`` + +[heading Description] + +`binary_search` returns `true` if and only if the value `val` exists in the range `rng`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/binary_search.hpp` + +[heading Requirements] + +[*For the non-predicate versions of binary_search:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `Value` is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* `ForwardRange`'s value type is the same type as `Value`. + +[*For the predicate versions of binary_search:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `ForwardRange`'s value type is the same type as `Value`. +* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s argument type. + +[heading Precondition:] + +[*For the non-predicate version:] + +`rng` is ordered in ascending order according to `operator<`. + +[*For the predicate version:] + +`rng` is ordered in ascending order according to the function object `pred`. + +[heading Complexity] + +For non-random-access ranges, the complexity is `O(N)` where `N` is `distance(rng)`. + +For random-access ranges, the complexity is `O(log N)` where `N` is `distance(rng)`. + +[endsect] + + diff --git a/doc/reference/algorithm/copy.qbk b/doc/reference/algorithm/copy.qbk new file mode 100644 index 0000000..70dd3a3 --- /dev/null +++ b/doc/reference/algorithm/copy.qbk @@ -0,0 +1,36 @@ +[section:copy Range Algorithm - copy] + +[heading Prototype] + +`` +template +OutputIterator copy(const SinglePassRange& source_rng, OutputIterator out_it); +`` + +[heading Description] + +`copy` copies all elements from `source_rng` to the range `[out_it, out_it + distance(source_rng))`. +The return value is `out_it + distance(source_rng)` + +[heading Definition] + +Defined in the header file `boost/range/algorithm/copy.hpp` + +[heading Requirements] + +* `SinglePassRange` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* The `value_type` of __single_pass_range__ Concept is convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +* `out_it` is not an iterator within the `source_rng`. +* `[out_it, out_it + distance(source_rng))` is a valid range. + +[heading Complexity] + +Linear. Exactly `distance(source_rng)` assignments are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/copy_backward.qbk b/doc/reference/algorithm/copy_backward.qbk new file mode 100644 index 0000000..f6aa444 --- /dev/null +++ b/doc/reference/algorithm/copy_backward.qbk @@ -0,0 +1,41 @@ +[section:copy_backward Range Algorithm - copy_backward] + +[heading Prototype] + +`` +template + BidirectionalOutputIterator + copy_backward(const BidirectionalRange& source_rng, + BidirectionalOutputIterator out_it); +`` + +[heading Description] + +`copy_backward` copies all elements from `source_rng` to the range `[out_it - distance(source_rng), out_it)`. + +The values are copied in reverse order. The return value is `out_it - distance(source_rng)`. + +Note well that unlike all other standard algorithms `out_it` denotes the *end* of the output sequence. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/copy_backward.hpp` + +[heading Requirements] + +* `BidirectionalRange` is a model of __bidirectional_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* The `value_type` of __bidirectional_range__ Concept is convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +* `out_it` is not an iterator within the `source_rng`. +* `[out_it, out_it + distance(source_rng))` is a valid range. + +[heading Complexity] + +Linear. Exactly `distance(source_rng)` assignments are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/count.qbk b/doc/reference/algorithm/count.qbk new file mode 100644 index 0000000..3a41ec8 --- /dev/null +++ b/doc/reference/algorithm/count.qbk @@ -0,0 +1,36 @@ +[section:count count] + +[heading Prototype] + +`` +template +typename range_difference::type +count(SinglePassRange& rng, const Value& val); + +template +typename range_difference::type +count(const SinglePassRange& rng, const Value& val); +`` + +[heading Description] + +`count` returns the number of elements `x` in `rng` where `x == val` is `true`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/count.hpp` + +[heading Requirements] + +* `SinglePassRange` is a model of the __single_pass_range__ Concept. +* `Value` is a model of the `EqualityComparableConcept`. +* `SinglePassRange`'s value type is a model of the `EqualityComparableConcept`. +* An object of `SinglePassRange`'s value type can be compared for equality with an object of type `Value`. + +[heading Complexity] + +Linear. Exactly `distance(rng)` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/equal.qbk b/doc/reference/algorithm/equal.qbk new file mode 100644 index 0000000..278fe45 --- /dev/null +++ b/doc/reference/algorithm/equal.qbk @@ -0,0 +1,59 @@ +[section:equal equal] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2 +> +bool equal(const SinglePassRange1& rng1, + const SinglePassRange2& rng2); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate +> +bool equal(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryPredicate pred); +`` + +[heading Description] + +`equal` returns `true` if `distance(rng1)` is equal to the `distance(rng2)` and for each element `x` in `rng1`, the corresponding element `y` in `rng2` is equal. Otherwise `false` is returned. + +In this range version of `equal` it is perfectly acceptable to pass in two ranges of unequal lengths. + +Elements are considered equal in the non-predicate version if `operator==` returns `true`. Elements are considered equal in the predicate version if `pred(x,y)` is `true`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/equal.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`. +* `SinglePassRange1`'s value type can be compared for equality with `SinglePassRange2`'s value type. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +Linear. At most `min(distance(rng1), distance(rng2))` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/equal_range.qbk b/doc/reference/algorithm/equal_range.qbk new file mode 100644 index 0000000..6d9650a --- /dev/null +++ b/doc/reference/algorithm/equal_range.qbk @@ -0,0 +1,78 @@ +[section:equal_range equal_range] + +[heading Prototype] + +`` +template< + class ForwardRange, + class Value + > +std::pair::type, + typename range_iterator::type> +equal_range(ForwardRange& rng, const Value& val); + +template< + class ForwardRange, + class Value + > +std::pair::type, + typename range_iterator::type> +equal_range(const ForwardRange& rng, const Value& val); + +template< + class ForwardRange, + class Value, + class SortPredicate + > +std::pair::type, + typename range_iterator::type> +equal_range(ForwardRange& rng, const Value& val, SortPredicate pred); + +template< + class ForwardRange, + class Value, + class SortPredicate + > +std::pair::type, + typename range_iterator::type> +equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred); + `` + +[heading Description] + +`equal_range` returns a range in the form of a pair of iterators where all of the elements are equal to `val`. If no values are found that are equal to `val`, then an empty range is returned, hence `result.first == result.second`. For the non-predicate versions of `equal_range` the equality of elements is determined by `operator<`. +For the predicate versions of `equal_range` the equality of elements is determined by `pred`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/equal_range.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `Value` is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* `ForwardRange`'s value type is the same type as `Value`. + +[*For the predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `SortPredicate` is a model of the `StrictWeakOrderingConcept`. +* `ForwardRange`'s value type is the same as `Value`. +* `ForwardRange`'s value type is convertible to both of `SortPredicate`'s argument types. + +[heading Precondition:] + +For the non-predicate versions: `rng` is ordered in ascending order according to `operator<`. + +For the predicate versions: `rng` is ordered in ascending order according to `pred`. + +[heading Complexity] + +For random-access ranges, the complexity is `O(log N)`, otherwise the complexity is `O(N)`. + +[endsect] + + diff --git a/doc/reference/algorithm/fill.qbk b/doc/reference/algorithm/fill.qbk new file mode 100644 index 0000000..e8419ab --- /dev/null +++ b/doc/reference/algorithm/fill.qbk @@ -0,0 +1,34 @@ +[section:fill Range Algorithm - fill] + +[heading Prototype] + +`` +template +void fill( ForwardRange& rng, const Value& val ); + +template +void fill( const ForwardRange& rng, const Value& val ); +`` + +[heading Description] + +`fill` assigns the value `val` to every element in the range `rng`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/fill.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `Value` is a model of the `AssignableConcept`. +* `Value` is convertible to `ForwardRange`'s value type. + +[heading Complexity] + +Linear. Exactly `distance(rng)` assignments are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/find.qbk b/doc/reference/algorithm/find.qbk new file mode 100644 index 0000000..50b47c0 --- /dev/null +++ b/doc/reference/algorithm/find.qbk @@ -0,0 +1,52 @@ +[section:find find] + +[heading Prototype] + +`` +template +typename range_iterator::type +find(SinglePassRange& rng, Value val); + +template +typename range_iterator::type +find(const SinglePassRange& rng, Value val); + +template< + range_return_value re, + class SinglePassRange, + class Value + > +typename range_return::type +find(SinglePassRange& rng, Value val); + +template< + range_return_value re, + class SinglePassRange, + class Value + > +typename range_return::type +find(const SinglePassRange& rng, Value val); +`` + +[heading Description] + +The versions of `find` that return an iterator, returns the first iterator in the range `rng` such that `*i == value`. `end(rng)` is returned if no such iterator exists. +The versions of find that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/find.hpp` + +[heading Requirements] + +* `SinglePassRange` is a model of the __single_pass_range__ Concept. +* `Value` is a model of the `EqualityComparableConcept`. +* The `operator==` is defined for type `Value` to be compared with the `SinglePassRange`'s value type. + +[heading Complexity] + +Linear. At most `distance(rng)` comparisons for equality. + +[endsect] + + diff --git a/doc/reference/algorithm/find_end.qbk b/doc/reference/algorithm/find_end.qbk new file mode 100644 index 0000000..237f21a --- /dev/null +++ b/doc/reference/algorithm/find_end.qbk @@ -0,0 +1,99 @@ +[section:find_end find_end] + +[heading Prototype] + +`` +template +typename range_iterator::type +find_end(ForwardRange1& rng1, const ForwardRange2& rng2); + +template +typename range_iterator::type +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2); + +template< + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_iterator::type +find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + +template< + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_iterator::type +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2 + > +typename range_return::type +find_end(ForwardRange1& rng1, const ForwardRange2& rng2); + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2 + > +typename range_return::type +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2); + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_return::type +find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_return::type +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); +`` + +[heading Description] + +The versions of `find_end` that return an iterator, return an iterator to the beginning of the last sub-sequence equal to `rng2` within `rng1`. +Equality is determined by `operator==` for non-predicate versions of `find_end`, and by satisfying `pred` in the predicate versions. The versions of `find_end` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/find_end.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange1` is a model of the __forward_range__ Concept. +* `ForwardRange2` is a model of the __forward_range__ Concept. +* `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`. +* `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`. +* Objects of `ForwardRange1`'s value type can be compared for equality with objects of `ForwardRange2`'s value type. + +[*For the predicate versions:] + +* `ForwardRange1` is a model of the __forward_range__ Concept. +* `ForwardRange2` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +The number of comparisons is proportional to `distance(rng1) * distance(rng2)`. If both `ForwardRange1` and `ForwardRange2` are models of `BidirectionalRangeConcept` then the average complexity is linear and the worst case is `distance(rng1) * distance(rng2)`. + +[endsect] + + diff --git a/doc/reference/algorithm/find_first_of.qbk b/doc/reference/algorithm/find_first_of.qbk new file mode 100644 index 0000000..bd8b856 --- /dev/null +++ b/doc/reference/algorithm/find_first_of.qbk @@ -0,0 +1,99 @@ +[section:find_first_of find_first_of] + +[heading Prototype] + +`` +template +typename range_iterator::type +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2); + +template +typename range_iterator::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2); + +template< + class SinglePassRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_iterator::type +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + +template< + class SinglePassRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_iterator::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + + +template< + range_return_value re, + class SinglePassRange1, + class ForwardRange2 + > +typename range_return::type +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2); + +template< + range_return_value re, + class SinglePassRange1, + class ForwardRange2 + > +typename range_return::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2); + +template< + range_return_value re, + class SinglePassRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_return::type +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + +template< + range_return_value re, + class SinglePassRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_return::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); +`` + +[heading Description] + +The versions of `find_first_of` that return an iterator, return an iterator to the first occurrence in `rng1` of any of the elements in `rng2`. +Equality is determined by `operator==` for non-predicate versions of `find_first_of`, and by satisfying `pred` in the predicate versions. + +The versions of `find_first_of` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/find_first_of.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `ForwardRange2` is a model of the __forward_range__ Concept. +* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`, and can be compared for equality with `ForwardRange2`'s value type. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `ForwardRange2` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +At most `distance(rng1) * distance(rng2)` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/find_if.qbk b/doc/reference/algorithm/find_if.qbk new file mode 100644 index 0000000..81ba4c3 --- /dev/null +++ b/doc/reference/algorithm/find_if.qbk @@ -0,0 +1,57 @@ +[section:find_if find_if] + +[heading Prototype] + +`` +template +typename range_iterator::type +find_if(SinglePassRange& rng, UnaryPredicate pred); + +template +typename range_iterator::type +find_if(const SinglePassRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class SinglePassRange, + class UnaryPredicate + > +typename range_return::type +find_if(SinglePassRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class SinglePassRange, + class UnaryPredicate + > +typename range_return::type +find_if(const SinglePassRange& rng, UnaryPredicate pred); +`` + +[heading Description] + +The versions of `find_if` that return an iterator, returns the first iterator in the range `rng` such that `pred(*i)` is `true`. `end(rng)` is returned if no such iterator exists. + +The versions of `find_if` that return a `range_return`, defines found in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/find_if.hpp` + +[heading Requirements] + +* `SinglePassRange` is a model of the __single_pass_range__ Concept. +* `UnaryPredicate` is a model of the `PredicateConcept`. +* The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`. + +[heading Precondition:] + +For each iterator `i` in `rng`, `*i` is in the domain of `UnaryPredicate`. + +[heading Complexity] + +Linear. At most `distance(rng)` invocations of `pred`. + +[endsect] + + diff --git a/doc/reference/algorithm/for_each.qbk b/doc/reference/algorithm/for_each.qbk new file mode 100644 index 0000000..a11530c --- /dev/null +++ b/doc/reference/algorithm/for_each.qbk @@ -0,0 +1,40 @@ +[section:for_each for_each] + +[heading Prototype] + +`` +template< + class SinglePassRange, + class UnaryFunction + > +UnaryFunction for_each(SinglePassRange& rng, UnaryFunction fun); + +template< + class SinglePassRange, + class UnaryFunction + > +UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun); +`` + +[heading Description] + +`for_each` traverses forward through `rng` and for each element `x` it invokes `fun(x)`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/for_each.hpp` + +[heading Requirements] + +* `SinglePassRange` is a model of the __single_pass_range__ Concept. +* `UnaryFunction` is a model of the `UnaryFunctionConcept`. +* `UnaryFunction` does not apply any non-constant operation through its argument. +* `SinglePassRange`'s value type is convertible to `UnaryFunction`'s argument type. + +[heading Complexity] + +Linear. Exactly `distance(rng)` applications of `UnaryFunction`. + +[endsect] + + diff --git a/doc/reference/algorithm/generate.qbk b/doc/reference/algorithm/generate.qbk new file mode 100644 index 0000000..adc85af --- /dev/null +++ b/doc/reference/algorithm/generate.qbk @@ -0,0 +1,39 @@ +[section:generate Range Algorithm - generate] + +[heading Prototype] + +`` +template +ForwardRange& generate( ForwardRange& rng, Generator gen ); + +template +const ForwardRange& generate( const ForwardRange& rng, Generator gen ); +`` + +[heading Description] + +`generate` assigns the result of `gen()` to each element in range `rng`. Returns the resultant range. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/generate.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `Generator` is a model of the `GeneratorConcept`. +* The `value_type` of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +* `out_it` is not an iterator within `rng`. +* `[out_it, out_it + distance(rng))` is a valid range. + +[heading Complexity] + +Linear. Exactly `distance(rng)` assignments are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/includes.qbk b/doc/reference/algorithm/includes.qbk new file mode 100644 index 0000000..5b7eb84 --- /dev/null +++ b/doc/reference/algorithm/includes.qbk @@ -0,0 +1,64 @@ +[section:includes includes] + +[heading Prototype] + +`` +template +bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate + > +bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2, + BinaryPredicate pred); +`` + +[heading Description] + +`includes` returns `true` if and only if, for every element in `rng2`, an equivalent element is also present in `rng1`. +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/set_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `pred`. + +[heading Complexity] + +Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`. + +[endsect] + + diff --git a/doc/reference/algorithm/inplace_merge.qbk b/doc/reference/algorithm/inplace_merge.qbk new file mode 100644 index 0000000..a393423 --- /dev/null +++ b/doc/reference/algorithm/inplace_merge.qbk @@ -0,0 +1,72 @@ +[section:inplace_merge Range Algorithm - inplace_merge] + +[heading Prototype] + +`` +template +BidirectionalRange& +inplace_merge( BidirectionalRange& rng, + typename range_iterator::type middle ); + +template +const BidirectionalRange& +inplace_merge( const BidirectionalRange& rng, + typename range_iterator::type middle ); + +template +BidirectionalRange& +inplace_merge( BidirectionalRange& rng, + typename range_iterator::type middle, + BinaryPredicate pred ); + +template +const BidirectionalRange& +inplace_merge( const BidirectionalRange& rng, + typename range_iterator::type middle, + BinaryPredicate pred ); +`` + +[heading Description] + +`inplace_merge` combines two consecutive sorted ranges `[begin(rng), middle)` and `[middle, end(rng))` into a single sorted range `[begin(rng), end(rng))`. That is, it starts with a range `[begin(rng), end(rng))` that consists of two pieces each of which is in ascending order, and rearranges it so that the entire range is in ascending order. `inplace_merge` is stable, meaning both that the relative order of elements within each input range is preserved. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/inplace_merge.hpp` + +[heading Requirements] + +[*For the non-predicate version:] + +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. +* `range_value::type` is a model of `LessThanComparableConcept` +* The ordering on objects of `range_type::type` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate version:] +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `BidirectionalRange`'s value type is convertible to both `BinaryPredicate`'s argument types. + +[heading Precondition:] + +[heading For the non-predicate version:] + +* `middle` is in the range `rng`. +* `[begin(rng), middle)` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `y < x` is `false`. +* `[middle, end(rng))` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `y < x` is `false`. + +[heading For the predicate version:] + +* `middle` is in the range `rng`. +* `[begin(rng), middle)` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `pred(y,x) == false`. +* `[middle, end(rng))` is in ascending order. That is for each pair of adjacent elements `[x,y]`, `pred(y,x) == false`. + +[heading Complexity] + +Worst case: `O(N log(N))` + +[endsect] + + diff --git a/doc/reference/algorithm/lexicographical_compare.qbk b/doc/reference/algorithm/lexicographical_compare.qbk new file mode 100644 index 0000000..16d155d --- /dev/null +++ b/doc/reference/algorithm/lexicographical_compare.qbk @@ -0,0 +1,55 @@ +[section:lexicographical_compare lexicographical_compare] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2 + > +bool lexicographical_compare(const SinglePassRange1& rng1, + const SinglePassRange2& rng2); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate + > +bool lexicographical_compare(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryPredicate pred); +`` + +[heading Description] + +`lexicographical_compare` compares element by element `rng1` against `rng2`. If the element from `rng1` is less than the element from `rng2` then `true` is returned. If the end of `rng1` without reaching the end of `rng2` this also causes the return value to be `true`. The return value is `false` in all other circumstances. The elements are compared using `operator<` in the non-predicate versions of `lexicographical_compare` and using `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/lexicographical_compare.hpp` + +[heading Requirements] + +[*For the non-predicate versions of lexicographical_compare:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. +* Let `x` be an object of `SinglePassRange1`'s value type. Let `y` be an obect of `SinglePassRange2`'s value type. `x < y` must be valid. `y < x` must be valid. + +[*For the predicate versions of lexicographical_compare:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +Linear. At most `2 * min(distance(rng1), distance(rng2))` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/lower_bound.qbk b/doc/reference/algorithm/lower_bound.qbk new file mode 100644 index 0000000..26b5ab1 --- /dev/null +++ b/doc/reference/algorithm/lower_bound.qbk @@ -0,0 +1,80 @@ +[section:lower_bound lower_bound] + +[heading Prototype] + +`` +template +typename range_iterator::type +lower_bound(ForwardRange& rng, Value val); + +template +typename range_iterator::type +lower_bound(const ForwardRange& rng, Value val); + +template< + range_return_value re, + class ForwardRange, + class Value + > +typename range_return::type +lower_bound(ForwardRange& rng, Value val); + +template< + range_return_value re, + class ForwardRange, + class Value + > +typename range_return::type +lower_bound(const ForwardRange& rng, Value val); +`` + +[heading Description] + +The versions of `lower_bound` that return an iterator, returns the first iterator in the range `rng` such that: +without predicate - `*i < value` is `false`, +with predicate - `pred(*i, value)` is `false`. + +`end(rng)` is returned if no such iterator exists. + +The versions of `lower_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/lower_bound.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `Value` is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* `ForwardRange`'s value type is the same type as `Value`. + +[*For the predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `ForwardRange`'s value type is the same type as `Value`. +* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng` is sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng` is sorted in ascending order according to `pred`. + +[heading Complexity] + +For ranges that model the __random_access_range__ concept the complexity is `O(log N)`, where `N` is `distance(rng)`. + +For all other range types the complexity is `O(N)`. + + +[endsect] + + diff --git a/doc/reference/algorithm/make_heap.qbk b/doc/reference/algorithm/make_heap.qbk new file mode 100644 index 0000000..6f54a15 --- /dev/null +++ b/doc/reference/algorithm/make_heap.qbk @@ -0,0 +1,51 @@ +[section:make_heap make_heap] + +[heading Prototype] + +`` +template +void make_heap(RandomAccessRange& rng); + +template +void make_heap(const RandomAccessRange& rng); + +template +void make_heap(RandomAccessRange& rng, Compare pred); + +template +void make_heap(const RandomAccessRange& rng, Compare pred); +`` + +[heading Description] + +`make_heap` turns `rng` into a heap. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/heap_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `Compare` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types. + +[heading Complexity] + +Linear. At most `3 * distance(rng)` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/max_element.qbk b/doc/reference/algorithm/max_element.qbk new file mode 100644 index 0000000..35cc0ed --- /dev/null +++ b/doc/reference/algorithm/max_element.qbk @@ -0,0 +1,81 @@ +[section:max_element max_element] + +[heading Prototype] + +`` +template +typename range_iterator::type +max_element(ForwardRange& rng); + +template +typename range_iterator::type +max_element(const ForwardRange& rng); + +template +typename range_iterator::type +max_element(ForwardRange& rng, BinaryPredicate pred); + +template +typename range_iterator::type +max_element(const ForwardRange& rng, BinaryPredicate pred); + + +template< + range_return_value re, + class ForwardRange + > +typename range_return::type +max_element(ForwardRange& rng); + +template< + range_return_value_re, + class ForwardRange + > +typename range_return::type +max_element(const ForwardRange& rng); + +template< + range_return_value re, + class ForwardRange, + class BinaryPredicate + > +typename range_return::type +max_element(ForwardRange& rng, BinaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class BinaryPredicate + > +typename range_return::type +max_element(const ForwardRange& rng, BinaryPredicate pred); +`` + +[heading Description] + +The versions of `max_element` that return an iterator, return the iterator to the maximum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the maximum value. The versions of `max_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/max_element.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`. + +[*For the predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + +[heading Complexity] + +Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/merge.qbk b/doc/reference/algorithm/merge.qbk new file mode 100644 index 0000000..2f538bc --- /dev/null +++ b/doc/reference/algorithm/merge.qbk @@ -0,0 +1,83 @@ +[section:merge Range Algorithm - merge] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator + > +OutputIterator merge(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out); + +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryPredicate + > +OutputIterator merge(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred); +`` + +[heading Description] + +`merge` combines two sorted ranges `rng1` and `rng2` into a single sorted range by copying elements. `merge` is stable. The return value is `out + distance(rng1) + distance(rng2)`. + +The two versions of `merge` differ by how they compare the elements. + +The non-predicate version uses the `operator<()` for the range value type. The predicate version uses the predicate instead of `operator<()`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/merge.hpp` + +[heading Requirements] + +[*For the non-predicate version:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `range_value::type` is the same as `range_value::type`. +* `range_value::type` is a model of the `LessThanComparableConcept`. +* The ordering on objects of `range_value::type` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* `range_value::type` is convertible to a type in `OutputIterator`'s set of value types. + +[*For the predicate version:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `range_value::type` is the same as `range_value::type`. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `SinglePassRange1`'s value type is convertible to both `BinaryPredicate`'s argument types. +* `range_value::type` is convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +[heading For the non-predicate version:] + +* The elements of `rng1` are in ascending order. That is, for each adjacent element pair `[x,y]` of `rng1`, `y < x == false`. +* The elements of `rng2` are in ascending order. That is, for each adjacent element pair `[x,y]` of `rng2`, `y < x == false`. +* The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap. +* The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap. +* `[out, out + distance(rng1) + distance(rng2))` is a valid range. + +[heading For the predicate version:] + +* The elements of `rng1` is in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng1`, `pred(y, x) == false`. +* The elements of `rng2` is in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng2`, `pred(y, x) == false`. +* The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap. +* The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap. +* `[out, out + distance(rng1) + distance(rng2))` is a valid range. + +[heading Complexity] + +Linear. There are no comparisons if both `rng1` and `rng2` are empty, otherwise at most `distance(rng1) + distance(rng2) - 1` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/min_element.qbk b/doc/reference/algorithm/min_element.qbk new file mode 100644 index 0000000..3977f09 --- /dev/null +++ b/doc/reference/algorithm/min_element.qbk @@ -0,0 +1,81 @@ +[section:min_element min_element] + +[heading Prototype] + +`` +template +typename range_iterator::type +min_element(ForwardRange& rng); + +template +typename range_iterator::type +min_element(const ForwardRange& rng); + +template +typename range_iterator::type +min_element(ForwardRange& rng, BinaryPredicate pred); + +template +typename range_iterator::type +min_element(const ForwardRange& rng, BinaryPredicate pred); + + +template< + range_return_value re, + class ForwardRange + > +typename range_return::type +min_element(ForwardRange& rng); + +template< + range_return_value_re, + class ForwardRange + > +typename range_return::type +min_element(const ForwardRange& rng); + +template< + range_return_value re, + class ForwardRange, + class BinaryPredicate + > +typename range_return::type +min_element(ForwardRange& rng, BinaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class BinaryPredicate + > +typename range_return::type +min_element(const ForwardRange& rng, BinaryPredicate pred); +`` + +[heading Description] + +The versions of `min_element` that return an iterator, return the iterator to the minimum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the minimum value. The versions of `min_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/min_element.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`. + +[*For the predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + +[heading Complexity] + +Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/mismatch.qbk b/doc/reference/algorithm/mismatch.qbk new file mode 100644 index 0000000..f470092 --- /dev/null +++ b/doc/reference/algorithm/mismatch.qbk @@ -0,0 +1,116 @@ +[section:mismatch mismatch] + +[heading Prototype] + +`` +template +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2); + +template +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2); + +template +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2); + +template +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2); + + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate + > +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, + BinaryPredicate pred); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate + > +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, + BinaryPredicate pred); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate + > +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, + BinaryPredicate pred); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryPredicate + > +std::pair< + typename range_iterator::type, + typename range_iterator::type > +mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, + BinaryPredicate pred); +`` + +[heading Description] + +The versions of `mismatch` that return an iterator, return an iterator to the first position where `rng1` and `rng2` differ. + +Equality is determined by `operator==` for non-predicate versions of `mismatch`, and by satisfying `pred` in the predicate versions. + +The versions of `mismatch` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/mismatch.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `SinglePassRange1`'s value type is a model of the `EqualityComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `EqualityComparableConcept`. +* `SinglePassRange1`s value type can be compared for equality with `SinglePassRange2`'s value type. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. + +[heading Precondition:] + +`distance(rng2) >= distance(rng1)` + +[heading Complexity] + +Linear. At most `distance(rng1)` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/next_permutation.qbk b/doc/reference/algorithm/next_permutation.qbk new file mode 100644 index 0000000..37b901a --- /dev/null +++ b/doc/reference/algorithm/next_permutation.qbk @@ -0,0 +1,51 @@ +[section:next_permutation next_permutation] + +[heading Prototype] + +`` +template +void next_permutation(BidirectionalRange& rng); + +template +void next_permutation(const BidirectionalRange& rng); + +template +void next_permutation(BidirectionalRange& rng, Compare pred); + +template +void next_permutation(const BidirectionalRange& rng, Compare pred); +`` + +[heading Description] + +`next_permutation` transforms the range of elements `rng` into the lexicographically next greater permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically smallest permutation and `false` is returned. `true` is returned when the next greater permutation is successfully generated. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/permutation.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. +* `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. +* `Compare` is a model of the `StrictWeakOrderingConcept`. +* `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types. + +[heading Complexity] + +Linear. At most `distance(rng) / 2` swaps. + +[endsect] + + diff --git a/doc/reference/algorithm/nth_element.qbk b/doc/reference/algorithm/nth_element.qbk new file mode 100644 index 0000000..69c87a8 --- /dev/null +++ b/doc/reference/algorithm/nth_element.qbk @@ -0,0 +1,58 @@ +[section:nth_element Range Algorithm - nth_element] + +[heading Prototype] + +`` +template +void nth_element(RandomAccessRange& rng, + typename range_iterator::type nth); + +template +void nth_element(const RandomAccessRange& rng, + typename range_iterator::type nth); + +template +void nth_element(RandomAccessRange& rng, + typename range_iterator::type nth, + BinaryPredicate sort_pred); + +template +void nth_element(const RandomAccessRange& rng, + typename range_iterator::type nth, + BinaryPredicate sort_pred); +`` + +[heading Description] + +`nth_element` partially orders a range of elements. `nth_element` arranges the range `rng` such that the element corresponding with the iterator `nth` is the same as the element that would be in that position if `rng` has been sorted. + + +[heading Definition] + +Defined in the header file `boost/range/algorithm/nth_element.hpp` + +[heading Requirements] + +[*For the non-predicate version:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering relation on `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + + +[*For the predicate version:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + + +[heading Complexity] + +On average, linear in `distance(rng)`. + +[endsect] + + diff --git a/doc/reference/algorithm/partial_sort.qbk b/doc/reference/algorithm/partial_sort.qbk new file mode 100644 index 0000000..298c16f --- /dev/null +++ b/doc/reference/algorithm/partial_sort.qbk @@ -0,0 +1,60 @@ +[section:partial_sort Range Algorithm - partial_sort] + +[heading Prototype] + +`` +template +void partial_sort(RandomAccessRange& rng, + typename range_iterator::type middle); + +template +void partial_sort(const RandomAccessRange& rng, + typename range_iterator::type middle); + +template +void partial_sort(RandomAccessRange& rng, + typename range_iterator::type middle, + BinaryPredicate sort_pred); + +template +void partial_sort(const RandomAccessRange& rng, + typename range_iterator::type middle, + BinaryPredicate sort_pred); +`` + +[heading Description] + +`partial_sort` rearranges the elements in `rng`. It places the smallest `distance(begin(rng), middle)` elements, sorted in ascending order, into the range `[begin(rng), middle)`. The remaining elements are placed in an unspecified order into `[middle, last)`. + +The non-predicative versions of this function specify that one element is less than another by using `operator<()`. The predicate versions use the predicate instead. + + +[heading Definition] + +Defined in the header file `boost/range/algorithm/partial_sort.hpp` + +[heading Requirements] + +[*For the non-predicate version:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering relation on `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + + +[*For the predicate version:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + + +[heading Complexity] + +Approximately `distance(rng) * log(distance(begin(rng), middle))` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/partition.qbk b/doc/reference/algorithm/partition.qbk new file mode 100644 index 0000000..cd17db7 --- /dev/null +++ b/doc/reference/algorithm/partition.qbk @@ -0,0 +1,58 @@ +[section:partition Range Algorithm - partition] + +[heading Prototype] + +`` +template< + class ForwardRange, + class UnaryPredicate + > +typename range_iterator::type +partition(ForwardRange& rng, UnaryPredicate pred); + +template< + class ForwardRange, + class UnaryPredicate + > +typename range_iterator::type +partition(const ForwardRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class UnaryPredicate + > +typename range_return::type +partition(ForwardRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class UnaryPredicate + > +typename range_return::type +partition(const ForwardRange& rng, UnaryPredicate pred); +`` + +[heading Description] + +`partition` orders the elements in `rng` based on `pred`, such that the elements that satisfy `pred` precede the elements that do not. In the versions that return a single iterator, the return value is the middle iterator. In the versions that have a configurable range_return, `found` corresponds to the middle iterator. + + +[heading Definition] + +Defined in the header file `boost/range/algorithm/partition.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `UnaryPredicate` is a model of the `PredicateConcept`. +* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type. + +[heading Complexity] + +Linear. Exactly `distance(rng)` applications of `pred`, and at most `distance(rng) / 2` swaps. + +[endsect] + + diff --git a/doc/reference/algorithm/pop_heap.qbk b/doc/reference/algorithm/pop_heap.qbk new file mode 100644 index 0000000..4479d46 --- /dev/null +++ b/doc/reference/algorithm/pop_heap.qbk @@ -0,0 +1,56 @@ +[section:pop_heap pop_heap] + +[heading Prototype] + +`` +template +void pop_heap(RandomAccessRange& rng); + +template +void pop_heap(const RandomAccessRange& rng); + +template +void pop_heap(RandomAccessRange& rng, Compare pred); + +template +void pop_heap(const RandomAccessRange& rng, Compare pred); +`` + +[heading Description] + +`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/heap_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `Compare` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types. + +[heading Precondition:] + +* `!empty(rng)` +* `rng` is a heap. + +[heading Complexity] + +Logarithmic. At most `2 * log(distance(rng))` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/prev_permutation.qbk b/doc/reference/algorithm/prev_permutation.qbk new file mode 100644 index 0000000..11642a4 --- /dev/null +++ b/doc/reference/algorithm/prev_permutation.qbk @@ -0,0 +1,51 @@ +[section:prev_permutation prev_permutation] + +[heading Prototype] + +`` +template +void prev_permutation(BidirectionalRange& rng); + +template +void prev_permutation(const BidirectionalRange& rng); + +template +void prev_permutation(BidirectionalRange& rng, Compare pred); + +template +void prev_permutation(const BidirectionalRange& rng, Compare pred); +`` + +[heading Description] + +`prev_permutation` transforms the range of elements `rng` into the lexicographically next smaller permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically largest permutation and `false` is returned. `true` is returned when the next smaller permutation is successfully generated. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/permutation.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. +* `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. +* `Compare` is a model of the `StrictWeakOrderingConcept`. +* `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types. + +[heading Complexity] + +Linear. At most `distance(rng) / 2` swaps. + +[endsect] + + diff --git a/doc/reference/algorithm/push_heap.qbk b/doc/reference/algorithm/push_heap.qbk new file mode 100644 index 0000000..eae2466 --- /dev/null +++ b/doc/reference/algorithm/push_heap.qbk @@ -0,0 +1,56 @@ +[section:push_heap push_heap] + +[heading Prototype] + +`` +template +void push_heap(RandomAccessRange& rng); + +template +void push_heap(const RandomAccessRange& rng); + +template +void push_heap(RandomAccessRange& rng, Compare pred); + +template +void push_heap(const RandomAccessRange& rng, Compare pred); +`` + +[heading Description] + +`push_heap` adds an element to a heap. It is assumed that `begin(rng)`, `prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/heap_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `Compare` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types. + +[heading Precondition:] + +* `!empty(rng)` +* `[begin(rng), prior(end(rng)))` is a heap. + +[heading Complexity] + +Logarithmic. At most `log(distance(rng))` comparisons. + +[endsect] + + diff --git a/doc/reference/algorithm/random_shuffle.qbk b/doc/reference/algorithm/random_shuffle.qbk new file mode 100644 index 0000000..e2d10b7 --- /dev/null +++ b/doc/reference/algorithm/random_shuffle.qbk @@ -0,0 +1,50 @@ +[section:random_shuffle Range Algorithm - random_shuffle] + +[heading Prototype] + +`` +template +RandomAccessRange& random_shuffle(RandomAccessRange& rng); + +template +const RandomAccessRange& random_shuffle(const RandomAccessRange& rng); + +template +RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen); + +template +const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen); +`` + +[heading Description] + +`random_shuffle` randomly rearranges the elements in `rng`. The versions of `random_shuffle` that do not specify a `Generator` use an internal random number generator. The versions of `random_shuffle` that do specify a `Generator` use this instead. Returns the shuffles range. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/random_shuffle.hpp` + +[heading Requirements] + +[*For the version without a Generator:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. + +[*For the version with a Generator:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `Generator` is a model of the `RandomNumberGeneratorConcept`. +* `RandomAccessRange`'s distance type is convertible to `Generator`'s argument type. + +[heading Precondition:] + +* `distance(rng)` is less than `gen`'s maximum value. + + +[heading Complexity] + +Linear. If `!empty(rng)`, exactly `distance(rng) - 1` swaps are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/remove.qbk b/doc/reference/algorithm/remove.qbk new file mode 100644 index 0000000..5c609aa --- /dev/null +++ b/doc/reference/algorithm/remove.qbk @@ -0,0 +1,58 @@ +[section:remove Range Algorithm - remove] + +[heading Prototype] + +`` +template< + class ForwardRange, + class Value + > +typename range_iterator::type +remove(ForwardRange& rng, const Value& val); + +template< + class ForwardRange, + class Value + > +typename range_iterator::type +remove(const ForwardRange& rng, const Value& val); + +template< + range_return_value re, + class ForwardRange, + class Value + > +typename range_return::type +remove(ForwardRange& rng, const Value& val); + +template< + range_return_value re, + class ForwardRange, + class Value + > +typename range_return::type +remove(const ForwardRange& rng, const Value& val); +`` + +[heading Description] + +`remove` removes from `rng` all of the elements `x` for which `x == val` is `true`. The versions of `remove` that return an iterator, return an iterator `new_last` such that the range `[begin(rng), new_last)` contains no elements equal to `val`. The `range_return` versions of `remove` defines `found` as the new last element. The iterators in the range `[new_last, end(rng))` are dereferenceable, but the elements are unspecified. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/remove.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `Value` is a model of the `EqualityComparableConcept`. +* Objects of type `Value` can be compared for equality with objects of `ForwardRange`'s value type. + +[heading Complexity] + +Linear. `remove` performs exactly `distance(rng)` comparisons for equality. + +[endsect] + + diff --git a/doc/reference/algorithm/remove_if.qbk b/doc/reference/algorithm/remove_if.qbk new file mode 100644 index 0000000..475e965 --- /dev/null +++ b/doc/reference/algorithm/remove_if.qbk @@ -0,0 +1,58 @@ +[section:remove_if Range Algorithm - remove_if] + +[heading Prototype] + +`` +template< + class ForwardRange, + class UnaryPredicate + > +typename range_iterator::type +remove(ForwardRange& rng, UnaryPredicate pred); + +template< + class ForwardRange, + class UnaryPredicate + > +typename range_iterator::type +remove(const ForwardRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class UnaryPredicate + > +typename range_return::type +remove(ForwardRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class UnaryPredicate + > +typename range_return::type +remove(const ForwardRange& rng, UnaryPredicate pred); +`` + +[heading Description] + +`remove_if` removes from `rng` all of the elements `x` for which `pred(x)` is `true`. The versions of `remove_if` that return an iterator, return an iterator `new_last` such that the range `[begin(rng), new_last)` contains no elements where `pred(x)` is `true`. The iterators in the range `[new_last, end(rng))` are dereferenceable, but the elements are unspecified. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/remove_if.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `UnaryPredicate` is a model of the `PredicateConcept`. +* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type. + +[heading Complexity] + +Linear. `remove_if` performs exactly `distance(rng)` applications of `pred`. + +[endsect] + + diff --git a/doc/reference/algorithm/replace.qbk b/doc/reference/algorithm/replace.qbk new file mode 100644 index 0000000..a173a56 --- /dev/null +++ b/doc/reference/algorithm/replace.qbk @@ -0,0 +1,41 @@ +[section:replace Range Algorithm - replace] + +[heading Prototype] + +`` +template< + class ForwardRange, + class Value + > +ForwardRange& replace(ForwardRange& rng, const Value& what, const Value& with_what); + +template< + class ForwardRange, + class UnaryPredicate + > +const ForwardRange& replace(const ForwardRange& rng, const Value& what, const Value& with_what); +`` + +[heading Description] + +`replace` every element in `rng` equal to `what` with `with_what`. Return a reference to `rng`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/replace.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `Value` is convertible to `ForwardRange`'s value type. +* `Value` is a model of the `AssignableConcept`. +* `Value` is a model of the `EqualityComparableConcept`, and may be compared for equality with objects of `ForwardRange`'s value type. + +[heading Complexity] + +Linear. `replace` performs exactly `distance(rng)` comparisons for equality and at most `distance(rng)` assignments. + +[endsect] + + diff --git a/doc/reference/algorithm/replace_if.qbk b/doc/reference/algorithm/replace_if.qbk new file mode 100644 index 0000000..2546395 --- /dev/null +++ b/doc/reference/algorithm/replace_if.qbk @@ -0,0 +1,36 @@ +[section:replace_if Range Algorithm - replace_if] + +[heading Prototype] + +`` +template +ForwardRange& replace_if(ForwardRange& rng, UnaryPredicate pred, const Value& with_what); + +template +const ForwardRange& replace_if(const ForwardRange& rng, UnaryPredicate pred, const Value& with_what); +`` + +[heading Description] + +`replace_if` replaces every element `x` in `rng` for which `pred(x) == true` with `with_what`. Returns a reference to `rng`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/replace_if.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `UnaryPredicate` is a model of the `PredicateConcept` +* `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type. +* `Value` is convertible to `ForwardRange`'s value type. +* `Value` is a model of the `AssignableConcept`. + +[heading Complexity] + +Linear. `replace_if` performs exactly `distance(rng)` applications of `pred`, and at most `distance(rng)` assignments. + +[endsect] + + diff --git a/doc/reference/algorithm/reverse.qbk b/doc/reference/algorithm/reverse.qbk new file mode 100644 index 0000000..7d678ef --- /dev/null +++ b/doc/reference/algorithm/reverse.qbk @@ -0,0 +1,32 @@ +[section:reverse Range Algorithm - reverse] + +[heading Prototype] + +`` +template +BidirectionalRange& reverse(BidirectionalRange& rng); + +template +const BidirectionalRange& reverse(const BidirectionalRange& rng); +`` + +[heading Description] + +`reverse` reverses a range. Returns a reference to the reversed range. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/reverse.hpp` + +[heading Requirements] + +* `BidirectionalRange` is a model of the __bidirectional_range__ Concept. +* `BidirectionalRange` is mutable. + +[heading Complexity] + +Linear. `reverse` makes `distance(rng)/2` calls to `iter_swap`. + +[endsect] + + diff --git a/doc/reference/algorithm/rotate.qbk b/doc/reference/algorithm/rotate.qbk new file mode 100644 index 0000000..9fa1b90 --- /dev/null +++ b/doc/reference/algorithm/rotate.qbk @@ -0,0 +1,39 @@ +[section:rotate Range Algorithm - rotate] + +[heading Prototype] + +`` +template +ForwardRange& rotate(ForwardRange& rng, + typename range_iterator::type middle); + +template +const ForwardRange& rotate(const ForwardRange& rng, + typename range_iterator::type middle); +`` + +[heading Description] + +`rotate` rotates the elements in a range. It exchanges the two ranges `[begin(rng), middle)` and `[middle, end(rng))`. Returns a reference to `rng`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/rotate.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. + +[heading Precondition:] + +* `[begin(rng), middle)` is a valid range. +* `[middle, end(rng))` is a valid range. + +[heading Complexity] + +Linear. At most `distance(rng)` swaps are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/search.qbk b/doc/reference/algorithm/search.qbk new file mode 100644 index 0000000..e6c0a85 --- /dev/null +++ b/doc/reference/algorithm/search.qbk @@ -0,0 +1,101 @@ +[section:search search] + +[heading Prototype] + +`` +template +typename range_iterator::type +search(ForwardRange1& rng1, const ForwardRange2& rng2); + +template +typename range_iterator::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2); + +template< + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_iterator::type, +search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + +template< + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_iterator::type +search(const ForwardRange1& rng1, ForwardRange2& rng2, BinaryPredicate pred); + + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2 + > +typename range_return::type +search(ForwardRange1& rng1, const ForwardRange2& rng2); + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2 + > +typename range_return::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2); + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_return::type, +search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); + +template< + range_return_value re, + class ForwardRange1, + class ForwardRange2, + class BinaryPredicate + > +typename range_return::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); +`` + +[heading Description] + +The versions of `search` that return an iterator, return an iterator to the start of the first subsequence in `rng1` that is equal to the subsequence `rng2`. The `end(rng1)` is returned if no such subsequence exists in `rng1`. +Equality is determined by `operator==` for non-predicate versions of `search`, and by satisfying `pred` in the predicate versions. + +The versions of `search` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/search.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange1` is a model of the __forward_range__ Concept. +* `ForwardRange2` is a model of the __forward_range__ Concept. +* `ForwardRange1`'s value type is a model of the `EqualityComparableConcept`. +* `ForwardRange2`'s value type is a model of the `EqualityComparableConcept`. +* `ForwardRange1`s value type can be compared for equality with `ForwardRange2`'s value type. + +[*For the predicate versions:] + +* `ForwardRange1` is a model of the __forward_range__ Concept. +* `ForwardRange2` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `ForwardRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `ForwardRange2`'s value type is convertible to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +Average complexity is Linear. Worst-case complexity is quadratic. + +[endsect] + + diff --git a/doc/reference/algorithm/set_difference.qbk b/doc/reference/algorithm/set_difference.qbk new file mode 100644 index 0000000..cd9724d --- /dev/null +++ b/doc/reference/algorithm/set_difference.qbk @@ -0,0 +1,76 @@ +[section:set_difference set_difference] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator + > +OutputIterator set_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out); + +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryPredicate + > +OutputIterator set_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred); +`` + +[heading Description] + +`set_difference` constructs a sorted range that is the set difference of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/set_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `pred`. + +[heading Complexity] + +Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`. + +[endsect] + + diff --git a/doc/reference/algorithm/set_intersection.qbk b/doc/reference/algorithm/set_intersection.qbk new file mode 100644 index 0000000..3c4e984 --- /dev/null +++ b/doc/reference/algorithm/set_intersection.qbk @@ -0,0 +1,76 @@ +[section:set_intersection set_intersection] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator + > +OutputIterator set_intersection(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out); + +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryPredicate + > +OutputIterator set_intersection(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred); +`` + +[heading Description] + +`set_intersection` constructs a sorted range that is the intersection of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/set_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `pred`. + +[heading Complexity] + +Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`. + +[endsect] + + diff --git a/doc/reference/algorithm/set_symmetric_difference.qbk b/doc/reference/algorithm/set_symmetric_difference.qbk new file mode 100644 index 0000000..4c6ed3e --- /dev/null +++ b/doc/reference/algorithm/set_symmetric_difference.qbk @@ -0,0 +1,78 @@ +[section:set_symmetric_difference set_symmetric_difference] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator + > +OutputIterator +set_symmetric_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out); + +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryPredicate + > +OutputIterator +set_symmetric_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred); +`` + +[heading Description] + +`set_symmetric_difference` constructs a sorted range that is the set symmetric difference of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/set_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `pred`. + +[heading Complexity] + +Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`. + +[endsect] + + diff --git a/doc/reference/algorithm/set_union.qbk b/doc/reference/algorithm/set_union.qbk new file mode 100644 index 0000000..3788781 --- /dev/null +++ b/doc/reference/algorithm/set_union.qbk @@ -0,0 +1,75 @@ +[section:set_union set_union] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator + > +OutputIterator set_union(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out); + +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryPredicate + > +OutputIterator set_union(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred); + `` + +[heading Description] + +`set_union` constructs a sorted range that is the union of the sorted ranges `rng1` and `rng2`. The return value is the end of the output range. +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/set_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`. +* `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `SinglePassRange1`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* The ordering of objects of type `SinglePassRange2`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `SinglePassRange1` and `SinglePassRange2` have the same value type. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type. +* `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng1` and `rng2` are sorted in ascending order according to `pred`. + +[heading Complexity] + +Linear. `O(N)`, where `N` is `distance(rng1) + distance(rng2)`. + +[endsect] + + diff --git a/doc/reference/algorithm/sort.qbk b/doc/reference/algorithm/sort.qbk new file mode 100644 index 0000000..63fb8f8 --- /dev/null +++ b/doc/reference/algorithm/sort.qbk @@ -0,0 +1,53 @@ +[section:sort Range Algorithm - sort] + +[heading Prototype] + +`` +template +RandomAccessRange& sort(RandomAccessRange& rng); + +template +const RandomAccessRange& sort(const RandomAccessRange& rng); + +template +RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred); + +template +const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred); +`` + +[heading Description] + +`sort` sorts the elements in `rng` into ascending order. `sort` is not guaranteed to be stable. Returns the sorted range. + +For versions of the `sort` function without a predicate, ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`. + +For versions of the `sort` function with a predicate, ascending order is defined by `pred` such that for all adjacent elements `[x,y]`, `pred(y, x) == false`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/sort.hpp` + +[heading Requirements] + +[*For versions of sort without a predicate:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements. + +[*For versions of sort with a predicate] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + +[heading Complexity] + +`O(N log(N))` comparisons (both average and worst-case), where `N` is `distance(rng)`. + +[endsect] + + diff --git a/doc/reference/algorithm/sort_heap.qbk b/doc/reference/algorithm/sort_heap.qbk new file mode 100644 index 0000000..9a24887 --- /dev/null +++ b/doc/reference/algorithm/sort_heap.qbk @@ -0,0 +1,55 @@ +[section:sort_heap sort_heap] + +[heading Prototype] + +`` +template +void sort_heap(RandomAccessRange& rng); + +template +void sort_heap(const RandomAccessRange& rng); + +template +void sort_heap(RandomAccessRange& rng, Compare pred); + +template +void sort_heap(const RandomAccessRange& rng, Compare pred); +`` + +[heading Description] + +`sort_heap` turns a heap into a sorted range. + +The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/heap_algorithm.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `RandomAccessRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. + +[*For the predicate versions:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `Compare` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `Compare`'s argument types. + +[heading Precondition:] + +`rng` is a heap. + +[heading Complexity] + +At most `N * log(N)` comparisons, where `N` is `distance(rng)`. + +[endsect] + + diff --git a/doc/reference/algorithm/stable_partition.qbk b/doc/reference/algorithm/stable_partition.qbk new file mode 100644 index 0000000..30e9311 --- /dev/null +++ b/doc/reference/algorithm/stable_partition.qbk @@ -0,0 +1,56 @@ +[section:stable_partition Range Algorithm - stable_partition] + +[heading Prototype] + +`` +template +typename range_iterator::type +stable_partition(ForwardRange& rng, UnaryPredicate pred); + +template +typename range_iterator::type +stable_partition(const ForwardRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class UnaryPredicate +> +typename range_return::type +stable_partition(ForwardRange& rng, UnaryPredicate pred); + +template< + range_return_value re, + class ForwardRange, + class UnaryPredicate +> +typename range_return::type +stable_partition(const ForwardRange& rng, UnaryPredicate pred); +`` + +[heading Description] + +`stable_partition` reorders the elements in the range `rng` base on the function object `pred`. Once this function has completed all of the elements that satisfy `pred` appear before all of the elements that fail to satisfy it. `stable_partition` differs from `partition` because it preserves relative order. It is table. + +For the versions that return an iterator, the return value is the iterator to the first element that fails to satisfy `pred`. + +For versions that return a `range_return`, the `found` iterator is the iterator to the first element that fails to satisfy `pred`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/stable_partition.hpp` + +[heading Requirements] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `UnaryPredicate` is a model of the `PredicateConcept`. + +[heading Complexity] + +Best case: `O(N)` where `N` is `distance(rng)`. +Worst case: `N * log(N)` swaps, where `N` is `distance(rng)`. + +[endsect] + + diff --git a/doc/reference/algorithm/stable_sort.qbk b/doc/reference/algorithm/stable_sort.qbk new file mode 100644 index 0000000..11431b5 --- /dev/null +++ b/doc/reference/algorithm/stable_sort.qbk @@ -0,0 +1,54 @@ +[section:stable_sort Range Algorithm - stable_sort] + +[heading Prototype] + +`` +template +RandomAccessRange& stable_sort(RandomAccessRange& rng); + +template +const RandomAccessRange& stable_sort(const RandomAccessRange& rng); + +template +RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate pred); + +template +const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate pred); +`` + +[heading Description] + +`stable_sort` sorts the elements in `rng` into ascending order. `stable_sort` is guaranteed to be stable. The order is preserved for equivalent elements. + +For versions of the `stable_sort` function without a predicate ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`. + +For versions of the `stable_sort` function with a predicate, ascending order is designed by `pred` such that for all adjacent elements `[x,y]`, `pred(y,x) == false`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/stable_sort.hpp` + +[heading Requirements] + +[*For versions of stable_sort without a predicate] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. +* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements. + +[*For versions of stable_sort with a predicate:] + +* `RandomAccessRange` is a model of the __random_access_range__ Concept. +* `RandomAccessRange` is mutable. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + +[heading Complexity] + +Best case: `O(N)` where `N` is `distance(rng)`. +Worst case: `O(N log(N)^2)` comparisons, where `N` is `distance(rng)`. + +[endsect] + + diff --git a/doc/reference/algorithm/transform.qbk b/doc/reference/algorithm/transform.qbk new file mode 100644 index 0000000..0a9c68c --- /dev/null +++ b/doc/reference/algorithm/transform.qbk @@ -0,0 +1,83 @@ +[section:transform Range Algorithm - transform] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class OutputIterator, + class UnaryOperation +> +OutputIterator transform(const SinglePassRange1& rng, + OutputIterator out, + UnaryOperation fun); + +template< + class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryOperation +> +OutputIterator transform(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryOperation fun); +`` + +[heading Description] + +[*UnaryOperation version:] + +`transform` assigns the value `y` to each element `[out, out + distance(rng)), y = fun(x)` where `x` is the corresponding value to `y` in `rng1`. The return value is `out + distance(rng)`. + +[*BinaryOperation version:] + +`transform` assigns the value `z` to each element `[out, out + min(distance(rng1), distance(rng2))), z = fun(x,y)` where `x` is the corresponding value in `rng1` and `y` is the corresponding value in `rng2`. This version of `transform` stops upon reaching either the end of `rng1`, or the end of `rng2`. Hence there isn't a requirement for `distance(rng1) == distance(rng2)` since there is a safe guaranteed behaviour, unlike with the iterator counterpart in the standard library. + +The return value is `out + min(distance(rng1), distance(rng2))`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/transform.hpp` + +[heading Requirements] + +[*For the unary versions of transform:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `UnaryOperation` is a model of the `UnaryFunctionConcept`. +* `SinglePassRange1`'s value type must be convertible to `UnaryFunction`'s argument type. +* `UnaryFunction`'s result type must be convertible to a type in `OutputIterator`'s set of value types. + +[*For the binary versions of transform:] + +* `SinglePassRange1` is a model of the __single_pass_range__ Concept. +* `SinglePassRange2` is a model of the __single_pass_range__ Concept. +* `OutputIterator` is a model of the `OutputIteratorConcept`. +* `BinaryOperation` is a model of the `BinaryFunctionConcept`. +* `SinglePassRange1`'s value type must be convertible to `BinaryFunction`'s first argument type. +* `SinglePassRange2`'s value type must be convertible to `BinaryFunction`'s second argument type. +* `BinaryOperation`'s result type must be convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +[*For the unary version of transform:] + +* `out` is not an iterator within the range `[begin(rng1) + 1, end(rng1))`. +* `[out, out + distance(rng1))` is a valid range. + +[*For the binary version of transform:] + +* `out` is not an iterator within the range `[begin(rng1) + 1, end(rng1))`. +* `out` is not an iterator within the range `[begin(rng2) + 1, end(rng2))`. +* `[out, out + min(distance(rng1), distance(rng2)))` is a valid range. + + +[heading Complexity] + +Linear. The operation is applied exactly `distance(rng1)` for the unary version and `min(distance(rng1), distance(rng2))` for the binary version. + +[endsect] + + diff --git a/doc/reference/algorithm/unique.qbk b/doc/reference/algorithm/unique.qbk new file mode 100644 index 0000000..b5d55b4 --- /dev/null +++ b/doc/reference/algorithm/unique.qbk @@ -0,0 +1,72 @@ +[section:unique Range Algorithm - unique] + +[heading Prototype] + +`` +template +typename range_return::type +unique(ForwardRange& rng); + +template +typename range_return::type +unique(const ForwardRange& rng); + +template +typename range_return::type +unique(ForwardRange& rng, BinaryPredicate pred); + +template +typename range_return::type +unique(const ForwardRange& rng, BinaryPredicate pred); + +template +typename range_return::type +unique(ForwardRange& rng); + +template +typename range_return::type +unique(const ForwardRange& rng); + +template +typename range_return::type +unique(ForwardRange& rng, BinaryPredicate pred); + +template +typename range_return::type +unique(const ForwardRange& rng, BinaryPredicate pred); +`` + +[heading Description] + +`unique` removes all but the first element of each sequence of duplicate encountered in `rng`. + +Elements in the range `[new_last, end(rng))` are dereferenceable but undefined. + +Equality is determined by the predicate if one is supplied, or by `operator==()` for `ForwardRange`'s value type. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/unique.hpp` + +[heading Requirements] + +[*For the non-predicate versions of unique:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `ForwardRange`'s value type is a model of the `EqualityComparableConcept`. + +[*For the predicate versions of unique:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `ForwardRange` is mutable. +* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. +* `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type. + +[heading Complexity] + +Linear. `O(N)` where `N` is `distance(rng)`. Exactly `distance(rng)` comparisons are performed. + +[endsect] + + diff --git a/doc/reference/algorithm/upper_bound.qbk b/doc/reference/algorithm/upper_bound.qbk new file mode 100644 index 0000000..43ea642 --- /dev/null +++ b/doc/reference/algorithm/upper_bound.qbk @@ -0,0 +1,77 @@ +[section:upper_bound upper_bound] + +[heading Prototype] + +`` +template +typename range_iterator::type +upper_bound(ForwardRange& rng, Value val); + +template +typename range_iterator::type +upper_bound(const ForwardRange& rng, Value val); + +template< + range_return_value re, + class ForwardRange, + class Value + > +typename range_return::type +upper_bound(ForwardRange& rng, Value val); + +template< + range_return_value re, + class ForwardRange, + class Value + > +typename range_return::type +upper_bound(const ForwardRange& rng, Value val); +`` + +[heading Description] + +The versions of `upper_bound` that return an iterator, returns the first iterator in the range `rng` such that: +without predicate - `val < *i` is `true`, +with predicate - `pred(val, *i)` is `true`. + +`end(rng)` is returned if no such iterator exists. + +The versions of `upper_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. + +[heading Definition] + +Defined in the header file `boost/range/algorithm/upper_bound.hpp` + +[heading Requirements] + +[*For the non-predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `Value` is a model of the `LessThanComparableConcept`. +* The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. +* `ForwardRange`'s value type is the same type as `Value`. + +[*For the predicate versions:] + +* `ForwardRange` is a model of the __forward_range__ Concept. +* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. +* `ForwardRange`'s value type is the same type as `Value`. +* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. + +[heading Precondition:] + +[*For the non-predicate versions:] + +`rng` is sorted in ascending order according to `operator<`. + +[*For the predicate versions:] + +`rng` is sorted in ascending order according to `pred`. + +[heading Complexity] + +For ranges that model the __random_access_range__ Concept the complexity is `O(log N)`, where `N` is `distance(rng)`. For all other range types the complexity is `O(N)`. + +[endsect] + + diff --git a/doc/reference/algorithm_ext/erase.qbk b/doc/reference/algorithm_ext/erase.qbk new file mode 100644 index 0000000..64c48a8 --- /dev/null +++ b/doc/reference/algorithm_ext/erase.qbk @@ -0,0 +1,30 @@ +[section:erase erase] + +[heading Prototype] + +`` +template< + class Container, + class SinglePassRange + > +void erase(Container& target, + iterator_range to_erase); +`` + +[heading Description] + +`erase` the iterator range `to_erase` from the container `target`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/erase.hpp` + +[heading Requirements] + +# `Container` supports erase of an iterator range. + +[heading Complexity] + +Linear. Proprotional to `distance(to_erase)`. + +[endsect] diff --git a/doc/reference/algorithm_ext/for_each.qbk b/doc/reference/algorithm_ext/for_each.qbk new file mode 100644 index 0000000..47b5d40 --- /dev/null +++ b/doc/reference/algorithm_ext/for_each.qbk @@ -0,0 +1,68 @@ +[section:for_each for_each] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryFunction + > +BinaryFunction for_each(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryFunction fn); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryFunction + > +BinaryFunction for_each(const SinglePassRange1& rng1, + SinglePassRange2& rng2, + BinaryFunction fn); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryFunction + > +BinaryFunction for_each(SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryFunction fn); + +template< + class SinglePassRange1, + class SinglePassRange2, + class BinaryFunction + > +BinaryFunction for_each(SinglePassRange1& rng1, + SinglePassRange2& rng2, + BinaryFunction fn); +`` + +[heading Description] + +`for_each` traverses forward through `rng1` and `rng2` simultaneously. +For each iteration, the element `x` is used from `rng1` and the corresponding +element `y` is used from `rng2` to invoke `fn(x,y)`. + +Iteration is stopped upon reaching the end of the shorter of `rng1`, or `rng2`. +It is safe to call this function with unequal length ranges. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/for_each.hpp` + +[heading Requirements] + +# `SinglePassRange1` is a model of the __single_pass_range__ Concept. +# `SinglePassRange2` is a model of the __single_pass_range__ Concept. +# `BinaryFunction` is a model of the `BinaryFunctionConcept`. +# `SinglePassRange1`'s value type is convertible to `BinaryFunction`'s first argument type. +# `SinglepassRange2`'s value type is convertible to `BinaryFunction`'s second argument type. + +[heading Complexity] + +Linear. Exactly `min(distance(rng1), distance(rng2))` applications of `BinaryFunction`. + +[endsect] diff --git a/doc/reference/algorithm_ext/insert.qbk b/doc/reference/algorithm_ext/insert.qbk new file mode 100644 index 0000000..1d9c567 --- /dev/null +++ b/doc/reference/algorithm_ext/insert.qbk @@ -0,0 +1,33 @@ +[section:insert insert] + +[heading Prototype] + +`` +template< + class Container, + class SinglePassRange + > +void insert(Container& target, + typename Container::iterator before, + const SinglePassRange& from); +`` + +[heading Description] + +`insert` all of the elements in the range `from` before the `before` iterator into `target`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/insert.hpp` + +[heading Requirements] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `Container` supports insert at a specified position. +# `SinglePassRange`'s value type is convertible to `Container`'s value type. + +[heading Complexity] + +Linear. `distance(from)` assignments are performed. + +[endsect] diff --git a/doc/reference/algorithm_ext/overwrite.qbk b/doc/reference/algorithm_ext/overwrite.qbk new file mode 100644 index 0000000..b9307ff --- /dev/null +++ b/doc/reference/algorithm_ext/overwrite.qbk @@ -0,0 +1,34 @@ +[section:overwrite overwrite] + +[heading Prototype] + +`` +template< + class SinglePassRange1, + class SinglePassRange2 + > +void overwrite(const SinglePassRange1& from, + SinglePassRange2& to); +`` + +[heading Description] + +`overwrite` assigns the values from the range `from` into the range `to`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/overwrite.hpp` + +[heading Requirements] + +# `SinglePassRange1` is a model of the __single_pass_range__ Concept. +# `SinglePassRange2` is a model of the __single_pass_range__ Concept. +# `SinglePassRange2` is mutable. +# `distance(SinglePassRange1) <= distance(SinglePassRange2)` +# `SinglePassRange1`'s value type is convertible to `SinglePassRange2`'s value type. + +[heading Complexity] + +Linear. `distance(rng1)` assignments are performed. + +[endsect] diff --git a/doc/reference/algorithm_ext/push_back.qbk b/doc/reference/algorithm_ext/push_back.qbk new file mode 100644 index 0000000..f3c8952 --- /dev/null +++ b/doc/reference/algorithm_ext/push_back.qbk @@ -0,0 +1,32 @@ +[section:push_back push_back] + +[heading Prototype] + +`` +template< + class Container, + class SinglePassRange + > +void push_back(Container& target, + const SinglePassRange& from); +`` + +[heading Description] + +`push_back` all of the elements in the range `from` to the back of the container `target`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/push_back.hpp` + +[heading Requirements] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `Container` supports insert at `end()`. +# `SinglePassRange`'s value type is convertible to `Container`'s value type. + +[heading Complexity] + +Linear. `distance(from)` assignments are performed. + +[endsect] diff --git a/doc/reference/algorithm_ext/push_front.qbk b/doc/reference/algorithm_ext/push_front.qbk new file mode 100644 index 0000000..d827105 --- /dev/null +++ b/doc/reference/algorithm_ext/push_front.qbk @@ -0,0 +1,32 @@ +[section:push_front push_front] + +[heading Prototype] + +`` +template< + class Container, + class SinglePassRange + > +void push_front(Container& target, + const SinglePassRange& from); +`` + +[heading Description] + +`push_front` all of the elements in the range `from` to the front of the container `target`. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/push_front.hpp` + +[heading Requirements] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `Container` supports insert at `begin()`. +# `SinglePassRange`'s value type is convertible to `Container`'s value type. + +[heading Complexity] + +Linear. `distance(from)` assignments are performed. + +[endsect] diff --git a/doc/reference/algorithm_ext/remove_erase.qbk b/doc/reference/algorithm_ext/remove_erase.qbk new file mode 100644 index 0000000..0164768 --- /dev/null +++ b/doc/reference/algorithm_ext/remove_erase.qbk @@ -0,0 +1,31 @@ +[section:remove_erase remove_erase] + +[heading Prototype] + +`` +template< + class Container, + class T + > +void remove_erase(Container& target, + const T& val); +`` + +[heading Description] + +`remove_erase` actually eliminates the elements equal to `val` from the container. This +is in contrast to the `remove` algorithm which merely rearranges elements. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/erase.hpp` + +[heading Requirements] + +# `Container` supports erase of an iterator range. + +[heading Complexity] + +Linear. Proportional to `distance(target)`s. + +[endsect] diff --git a/doc/reference/algorithm_ext/remove_erase_if.qbk b/doc/reference/algorithm_ext/remove_erase_if.qbk new file mode 100644 index 0000000..f0ae749 --- /dev/null +++ b/doc/reference/algorithm_ext/remove_erase_if.qbk @@ -0,0 +1,32 @@ +[section:remove_erase_if remove_erase_if] + +[heading Prototype] + +`` +template< + class Container, + class Pred + > +void remove_erase(Container& target, + Pred pred); +`` + +[heading Description] + +`remove_erase_if` removes the elements `x` that satisfy `pred(x)` from the container. +This is in contrast to the `erase` algorithm which merely rearranges elements. + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/erase.hpp` + +[heading Requirements] + +# `Container` supports erase of an iterator range. +# `Pred` is a model of the `Predicate` Concept. + +[heading Complexity] + +Linear. Proportional to `distance(target)`s. + +[endsect] diff --git a/doc/reference/algorithms.qbk b/doc/reference/algorithms.qbk new file mode 100644 index 0000000..9bbce12 --- /dev/null +++ b/doc/reference/algorithms.qbk @@ -0,0 +1,162 @@ +[section:algorithms Range Algorithm] + +[section:range_algorithm_introduction Introduction and motivation] +In its most simple form a [*Range Algorithm] (or range-based algorithm) is simply an iterator-based algorithm where the /two/ iterator arguments have been replaced by /one/ range argument. For example, we may write + +`` +#include +#include + +std::vector vec = ...; +boost::sort(vec); +`` + +instead of + +`` +std::sort(vec.begin(), vec.end()); +`` + +However, the return type of range algorithms is almost always different from that of existing iterator-based algorithms. + +One group of algorithms, like `boost::sort()`, will simply return the same range so that we can continue to pass the range around and/or further modify it. Because of this we may write +`` +boost:unique(boost::sort(vec)); +`` +to first sort the range and then run `unique()` on the sorted range. + +Algorithms like `boost::unique()` fall into another group of algorithms that return (potentially) narrowed views of the original range. By default `boost::unique(rng)` returns the range `[boost::begin(rng), found)` where `found` denotes the iterator returned by `std::unique(boost::begin(rng), boost::end(rng))` + +Therefore exactly the unique values can be copied by writing +`` +boost::copy(boost::unique(boost::sort(vec)), + std::ostream_iterator(std::cout)); +`` + +Algorithms like `boost::unique` usually return the same range: `[boost::begin(rng), found)`. However, this behaviour may be changed by supplying the algorithms with a template argument: + +[table + [[Expression] [Return]] + [[`boost::unique(rng)`] [returns a single iterator like `std::unique`]] + [[`boost::unique(rng)`] [returns the range `[boost::begin(rng), found)` (this is the default)]] + [[`boost::unique(rng)`] [returns the range `[boost::begin(rng), boost::next(found))`]] + [[`boost::unique(rng)`] [returns the range `[found, boost::end(rng))`]] + [[`boost::unique(rng)`] [returns the range `[boost::next(found),boost::end(rng))`]] + [[`boost::unique(rng)`] [returns the entire original range.]] +] + +This functionality has the following advantages: + +# it allows for ['*seamless functional-style programming*] where you do not need to use named local variables to store intermediate results +# it is very ['*safe*] because the algorithm can verify out-of-bounds conditions and handle tricky conditions that lead to empty ranges + +For example, consider how easy we may erase the duplicates in a sorted container: + +`` +std::vector vec = ...; +boost::erase(vec, boost::unique(boost::sort(vec))); +`` + +Notice the use of `boost::return_found_end`. What if we wanted to erase all the duplicates except one of them? In old-fashined STL-programming we might write + +`` +// assume 'vec' is already sorted +std::vector::iterator i = std::unique(vec.begin(), vec.end()); + +// remember this check or you get into problems +if (i != vec.end()) + ++i; + +vec.erase(i, vec.end()); +`` + +The same task may be accomplished simply with +`` +boost::erase(vec, boost::unique(vec)); +`` +and there is no need to worry about generating an invalid range. Furthermore, if the container is complex, calling `vec.begin()` several times will be more expensive than using a range algorithm. + +[endsect] + +[section:range_algorithm_mutating_algorithms Mutating algorithms] +[include algorithm/copy.qbk] +[include algorithm/copy_backward.qbk] +[include algorithm/fill.qbk] +[include algorithm/generate.qbk] +[include algorithm/inplace_merge.qbk] +[include algorithm/merge.qbk] +[include algorithm/nth_element.qbk] +[include algorithm/partial_sort.qbk] +[include algorithm/partition.qbk] +[include algorithm/random_shuffle.qbk] +[include algorithm/remove.qbk] +[include algorithm/remove_if.qbk] +[include algorithm/replace.qbk] +[include algorithm/replace_if.qbk] +[include algorithm/rotate.qbk] +[include algorithm/sort.qbk] +[include algorithm/stable_partition.qbk] +[include algorithm/stable_sort.qbk] +[include algorithm/transform.qbk] +[include algorithm/unique.qbk] +[endsect] + +[section:range_algorithm_non_mutating_algorithms Non-mutating algorithms] +[include algorithm/adjacent_find.qbk] +[include algorithm/binary_search.qbk] +[include algorithm/count.qbk] +[include algorithm/equal.qbk] +[include algorithm/equal_range.qbk] +[include algorithm/for_each.qbk] +[include algorithm/find.qbk] +[include algorithm/find_end.qbk] +[include algorithm/find_first_of.qbk] +[include algorithm/find_if.qbk] +[include algorithm/lexicographical_compare.qbk] +[include algorithm/lower_bound.qbk] +[include algorithm/max_element.qbk] +[include algorithm/min_element.qbk] +[include algorithm/mismatch.qbk] +[include algorithm/search.qbk] +[include algorithm/upper_bound.qbk] +[endsect] + +[section:set_algorithms Set algorithms] +[include algorithm/includes.qbk] +[include algorithm/set_union.qbk] +[include algorithm/set_intersection.qbk] +[include algorithm/set_difference.qbk] +[include algorithm/set_symmetric_difference.qbk] +[endsect] + +[section:heap_algorithms Heap algorithms] +[include algorithm/push_heap.qbk] +[include algorithm/pop_heap.qbk] +[include algorithm/make_heap.qbk] +[endsect] + +[section:permutation_algorithms Permutation algorithms] +[include algorithm/next_permutation.qbk] +[include algorithm/prev_permutation.qbk] +[endsect] + +[section:range_algorithm_new_algorithms New algorithms] +[include algorithm_ext/erase.qbk] +[include algorithm_ext/for_each.qbk] +[include algorithm_ext/insert.qbk] +[include algorithm_ext/overwrite.qbk] +[include algorithm_ext/push_back.qbk] +[include algorithm_ext/push_front.qbk] +[include algorithm_ext/remove_erase.qbk] +[include algorithm_ext/remove_erase_if.qbk] +[endsect] + +[section:range_numeric Numeric algorithms] +[include numeric/accumulate.qbk] +[include numeric/adjacent_difference.qbk] +[include numeric/inner_product.qbk] +[include numeric/partial_sum.qbk] +[endsect] + +[endsect] + diff --git a/doc/reference/extending.qbk b/doc/reference/extending.qbk new file mode 100644 index 0000000..8cf6a74 --- /dev/null +++ b/doc/reference/extending.qbk @@ -0,0 +1,316 @@ +[section:extending Extending the library] + +[section:method_1 Method 1: provide member functions and nested types] + +This procedure assumes that you have control over the types that should be made conformant to a Range concept. If not, see [link range.reference.extending.method_2 method 2]. + +The primary templates in this library are implemented such that standard containers will work automatically and so will __boost_array__. Below is given an overview of which member functions and member types a class must specify to be useable as a certain Range concept. + +[table + [[Member function] [Related concept ]] + [[`begin()` ] [__single_pass_range__]] + [[`end()` ] [__single_pass_range__]] +] + +Notice that `rbegin()` and `rend()` member functions are not needed even though the container can support bidirectional iteration. + +The required member types are: + +[table + [[Member type ] [Related concept ]] + [[`iterator` ] [__single_pass_range__]] + [[`const_iterator`] [__single_pass_range__]] +] + +Again one should notice that member types `reverse_iterator` and `const_reverse_iterator` are not needed. + +[endsect] + +[section:method_2 Method 2: provide free-standing functions and specialize metafunctions] + +This procedure assumes that you cannot (or do not wish to) change the types that should be made conformant to a Range concept. If this is not true, see [link range.reference.extending.method_1 method 1]. + +The primary templates in this library are implemented such that certain functions are found via argument-dependent-lookup (ADL). Below is given an overview of which free-standing functions a class must specify to be useable as a certain Range concept. Let `x` be a variable (`const` or `mutable`) of the class in question. + +[table + [[Function ] [Related concept ]] + [[`range_begin(x)`] [__single_pass_range__]] + [[`range_end(x)` ] [__single_pass_range__]] +] + +`range_begin()` and `range_end()` must be overloaded for both `const` and `mutable` reference arguments. + +You must also specialize two metafunctions for your type `X`: + +[table + [[Metafunction ] [Related concept ]] + [[`boost::range_mutable_iterator`] [__single_pass_range__]] + [[`boost::range_const_iterator`] [__single_pass_range__]] +] + +A complete example is given here: + +`` + #include + #include // for std::iterator_traits, std::distance() + + namespace Foo + { + // + // Our sample UDT. A 'Pair' + // will work as a range when the stored + // elements are iterators. + // + template< class T > + struct Pair + { + T first, last; + }; + + } // namespace 'Foo' + + namespace boost + { + // + // Specialize metafunctions. We must include the range.hpp header. + // We must open the 'boost' namespace. + // + + template< class T > + struct range_mutable_iterator< Foo::Pair > + { + typedef T type; + }; + + template< class T > + struct range_const_iterator< Foo::Pair > + { + // + // Remark: this is defined similar to 'range_iterator' + // because the 'Pair' type does not distinguish + // between an iterator and a const_iterator. + // + typedef T type; + }; + + } // namespace 'boost' + + namespace Foo + { + // + // The required functions. These should be defined in + // the same namespace as 'Pair', in this case + // in namespace 'Foo'. + // + + template< class T > + inline T range_begin( Pair& x ) + { + return x.first; + } + + template< class T > + inline T range_begin( const Pair& x ) + { + return x.first; + } + + template< class T > + inline T range_end( Pair& x ) + { + return x.last; + } + + template< class T > + inline T range_end( const Pair& x ) + { + return x.last; + } + + } // namespace 'Foo' + + #include + + int main() + { + typedef std::vector::iterator iter; + std::vector vec; + Foo::Pair pair = { vec.begin(), vec.end() }; + const Foo::Pair& cpair = pair; + // + // Notice that we call 'begin' etc with qualification. + // + iter i = boost::begin( pair ); + iter e = boost::end( pair ); + i = boost::begin( cpair ); + e = boost::end( cpair ); + boost::range_difference< Foo::Pair >::type s = boost::size( pair ); + s = boost::size( cpair ); + boost::range_reverse_iterator< const Foo::Pair >::type + ri = boost::rbegin( cpair ), + re = boost::rend( cpair ); + } +`` + +[endsect] + +[section:method_3 Method 3: provide range adaptor implementations] + +[section:method_3_1 Method 3.1: Implement a Range Adaptor without arguments] + +To implement a Range Adaptor without arguments (e.g. reversed) you need to: + +# Provide a range for your return type, for example: +`` +#include +#include + +template< typename R > +struct reverse_range : + boost::iterator_range< + boost::reverse_iterator< + typename boost::range_iterator::type> > +{ +private: + typedef boost::iterator_range< + boost::reverse_iterator< + typename boost::range_iterator::type> > base; + +public: + typedef boost::reverse_iterator< + typename boost::range_iterator::type > iterator; + + reverse_range(R& r) + : base(iterator(boost::end(r)), iterator(boost::begin(r))) + { } +}; +`` + +# Provide a tag to uniquely identify your adaptor in the `operator|` function overload set +`` +namespace detail { + struct reverse_forwarder {}; +} +`` + +# Implement `operator|` +`` +template< class BidirectionalRng > +inline reverse_range +operator|( BidirectionalRng& r, detail::reverse_forwarder ) +{ + return reverse_range( r ); +} + +template< class BidirectionalRng > +inline reverse_range +operator|( const BidirectionalRng& r, detail::reverse_forwarder ) +{ + return reverse_range( r ); +} +`` + +[endsect] + +[section:method_3_2 Method 3.2: Implement a Range Adaptor with arguments] + +# Provide a range for your return type, for example: +`` +#include +#include +#include + +template +class replace_value +{ +public: + typedef const Value& result_type; + typedef const Value& argument_type; + + replace_value(const Value& from, const Value& to) + : m_from(from), m_to(to) + { + } + + const Value& operator()(const Value& x) const + { + return (x == m_from) ? m_to : x; + } +private: + Value m_from; + Value m_to; +}; + +template +class replace_range +: public boost::iterator_range< + boost::transform_iterator< + replace_value::type>, + typename boost::range_iterator::type> > +{ +private: + typedef typename boost::range_value::type value_type; + typedef typename boost::range_iterator::type iterator_base; + typedef replace_value Fn; + typedef boost::transform_iterator replaced_iterator; + typedef boost::iterator_range base_t; + +public: + replace_range(Range& rng, value_type from, value_type to) + : base_t(replaced_iterator(boost::begin(rng), Fn(from,to)), + replaced_iterator(boost::end(rng), Fn(from,to))) + { + } + }; +`` + +# Implement a holder class to hold the arguments required to construct the RangeAdaptor. + +The holder combines multiple parameters into one that can be passed as the right operand of `operator|()`. + +`` +template +class replace_holder : public boost::range_detail::holder2 +{ +public: + replace_holder(const T& from, const T& to) + : boost::range_detail::holder2(from, to) + { } +private: + void operator=(const replace_holder&); +}; +`` + +# Define an instance of the holder with the name of the adaptor + +`` +static boost::range_detail::forwarder2 +replaced = boost::range_detail::forwarder2(); +`` + +# Define `operator|` + +`` +template +inline replace_range +operator|(SinglePassRange& rng, + const replace_holder::type>& f) +{ + return replace_range(rng, f.val1, f.val2); +} + +template +inline replace_range +operator|(const SinglePassRange& rng, + const replace_holder::type>& f) +{ + return replace_range(rng, f.val1, f.val2); +} +`` + +[endsect] + +[endsect] + +[endsect] + diff --git a/doc/reference/numeric/accumulate.qbk b/doc/reference/numeric/accumulate.qbk new file mode 100644 index 0000000..e642305 --- /dev/null +++ b/doc/reference/numeric/accumulate.qbk @@ -0,0 +1,56 @@ +[section:accumulate accumulate] + +[heading Prototype] + +`` +template< + class SinglePassRange, + class Value + > +Value accumulate(const SinglePassRange& source_rng, + Value init); + +template< + class SinglePassRange, + class Value, + class BinaryOperation + > +Value accumulate(const SinglePassRange& source_rng, + Value init, + BinaryOperation op); +`` + +[heading Description] + +`accumulate` is a generalisation of summation. It computes a binary operation (`operator+` +in the non-predicate version) of `init` and all of the elements in `rng`. + +The return value is the resultant value of the above algorithm. + +[heading Definition] + +Defined in the header file `boost/range/numeric.hpp` + +[heading Requirements] + +[heading For the first version] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `Value` is a model of the `AssignableConcept`. +# An `operator+` is defined for a left-hand operand of type `Value` and a right-hand operance of the `SinglePassRange` value type. +# The return type of the above operator is convertible to `Value`. + +[heading For the second version] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `Value` is a model of the `AssignableConcept`. +# `BinaryOperation` is a model of the `BinaryFunctionConcept`. +# `Value` is convertible to `BinaryOperation`'s first argument type. +# `SinglePassRange`'s value type is convertible to `BinaryOperation`'s second argument type. +# The return type of `BinaryOperation` is convertible to `Value`. + +[heading Complexity] + +Linear. Exactly `distance(source_rng)`. + +[endsect] diff --git a/doc/reference/numeric/adjacent_difference.qbk b/doc/reference/numeric/adjacent_difference.qbk new file mode 100644 index 0000000..f7ea1f7 --- /dev/null +++ b/doc/reference/numeric/adjacent_difference.qbk @@ -0,0 +1,63 @@ +[section:adjacent_difference adjacent_difference] + +[heading Prototype] + +`` +template< + class SinglePassRange, + class OutputIterator + > +OutputIterator adjacent_difference( + const SinglePassRange& source_rng, + OutputIterator out_it); + +template< + class SinglePassRange, + class OutputIterator, + class BinaryOperation + > +OutputIterator adjacent_difference( + const SinglePassRange& source_rng, + OutputIterator out_it, + BinaryOperation op); +`` + +[heading Description] + +`adjacent_difference` calculates the differences of adjacent_elements in `rng`. + +The first version of `adjacent_difference` uses `operator-()` to calculate the differences. +The second version uses `BinaryOperation` instead of `operator-()`. + +[heading Definition] + +Defined in the header file `boost/range/numeric.hpp` + +[heading Requirements] + +[heading For the first version] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `OutputIterator` is a model of the `OutputIteratorConcept`. +# If `x` and `y` are objects of `SinglePassRange`'s value type, then `x - y` is defined. +# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. +# The return type of `x - y` is convertible to a type in `OutputIterator`'s set of value types. + +[heading For the second version] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `OutputIterator` is a model of the `OutputIteratorConcept`. +# `BinaryOperation` is a model of the `BinaryFunctionConcept`. +# The value type of `SinglePassRange` is convertible to `BinaryOperation`'s first and second argument types. +# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. +# The result type of `BinaryOperation` is convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +`[result, result + distance(rng))` is a valid range. + +[heading Complexity] + +Linear. If `empty(rng)` then zero applications, otherwise `distance(rng) - 1` applications are performed. + +[endsect] diff --git a/doc/reference/numeric/inner_product.qbk b/doc/reference/numeric/inner_product.qbk new file mode 100644 index 0000000..a56062a --- /dev/null +++ b/doc/reference/numeric/inner_product.qbk @@ -0,0 +1,67 @@ +[section:inner_product inner_product] + +[heading Prototype] + +`` +template + Value inner_product( const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + Value init); + +template + Value inner_product( const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + Value init, + BinaryOperation1 op1, +`` + +[heading Description] + +`inner_product` calculates a generalised inner product of the range `rng1` and `rng2`. + +For further information on the `inner_product` algorithm please see __sgi_inner_product__. + +[heading Definition] + +Defined in the header file `boost/range/numeric.hpp` + +[heading Requirements] + +[heading For the first version] + +# `SinglePassRange1` is a model of the __single_pass_range__ Concept. +# `SinglePassRange2` is a model of the __single_pass_range__ Concept. +# `Value` is a model of the `AssignableConcept`. +# If `x` is an object of type `Value`, `y` is an object of `SinglePassRange1`'s value +type, and `z` is an object of `SinglePassRange2`'s value type, then `x + y * z` +is defined. +# The result type of the expression `x + y * z` is convertible to `Value`. + +[heading For the second version] + +# `SinglePassRange1` is a model of the __single_pass_range__ Concept. +# `SinglePassRange2` is a model of the __single_pass_range__ Concept. +# `Value` is a model of the `AssignableConcept`. +# `BinaryOperation1` is a model of the `BinaryFunctionConcept`. +# `BinaryOperation2` is a model of the `BinaryFunctionConcept`. +# The value type of `SinglePassRange1` is convertible to the first argument type of `BinaryOperation2`. +# The value type of `SinglePassRange2` is convertible to the second argument type of `BinaryOperation2`. +# `Value` is convertible to the value type of `BinaryOperation1`. +# The return type of `BinaryOperation2` is convertible to the second argument type of `BinaryOperation1`. +# The return type of `BinaryOperation1` is convertible to `Value`. + +[heading Precondition:] + +`distance(rng2) >= distance(rng1)` is a valid range. + +[heading Complexity] + +Linear. Exactly `distance(rng)`. + +[endsect] diff --git a/doc/reference/numeric/partial_sum.qbk b/doc/reference/numeric/partial_sum.qbk new file mode 100644 index 0000000..aa556e2 --- /dev/null +++ b/doc/reference/numeric/partial_sum.qbk @@ -0,0 +1,55 @@ +[section:partial_sum partial_sum] + +[heading Prototype] + +`` +template +OutputIterator partial_sum(const SinglePassRange& rng, + OutputIterator out_it); + +template +OutputIterator partial_sum(const SinglePassRange& rng, + OutputIterator out_it, + BinaryOperation op); +`` + +[heading Description] + +`partial_sum` calculates a generalised partial sum of `rng` in the same manner as +`std::partial_sum(boost::begin(rng), boost::end(rng), out_it)`. See __sgi_partial_sum__. + + +[heading Definition] + +Defined in the header file `boost/range/numeric.hpp` + +[heading Requirements] + +[heading For the first version] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `OutputIterator` is a model of the `OutputIteratorConcept`. +# If `x` and `y` are objects of `SinglePassRange`'s value type, then `x + y` is defined. +# The return type of `x + y` is convertible to the value type of `SinglePassRange`. +# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. + +[heading For the second version] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `OutputIterator` is a model of the `OutputIteratorConcept`. +# `BinaryOperation` is a model of the `BinaryFunctionConcept`. +# The result type of `BinaryOperation` is convertible to the value type of `SinglePassRange`. +# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. + +[heading Precondition:] + +`[result, result + distance(rng))` is a valid range. + +[heading Complexity] + +Linear. If `empty(rng)` then zero applications, otherwise `distance(rng) - 1` applications are performed. + +[endsect] diff --git a/doc/reference/overview.qbk b/doc/reference/overview.qbk new file mode 100644 index 0000000..d171b9c --- /dev/null +++ b/doc/reference/overview.qbk @@ -0,0 +1,14 @@ +[section Overview] + +Four types of objects are currently supported by the library: + +* standard-like containers +* `std::pair` +* built-in arrays + +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. + +[endsect] + diff --git a/doc/reference/ranges.qbk b/doc/reference/ranges.qbk new file mode 100644 index 0000000..aaee7d8 --- /dev/null +++ b/doc/reference/ranges.qbk @@ -0,0 +1,8 @@ +[section:ranges Provided Ranges] + +[include ranges/counting_range.qbk] +[include ranges/istream_range.qbk] +[include ranges/irange.qbk] + +[endsect] + diff --git a/doc/reference/ranges/counting_range.qbk b/doc/reference/ranges/counting_range.qbk new file mode 100644 index 0000000..c9484b8 --- /dev/null +++ b/doc/reference/ranges/counting_range.qbk @@ -0,0 +1,31 @@ +[section:counting_range counting_range] + +[heading Prototype] + +`` +template< class Incrementable > inline +iterator_range< counting_iterator > +counting_range(Incrementable first, Incrementable last); + +template< class SinglePassRange > inline +iterator_range< counting_iterator::type > +counting_range(const SinglePassRange& rng); + +template< class SinglePassRange > inline +iterator_range< counting_iterator::type > +counting_range(SinglePassRange& rng); +`` + +[heading Description] + +`counting_range` is a function to generator that generates an `iterator_range` wrapping a `counting_iterator` (from Boost.Iterator). + +[heading Definition] + +Defined in header file `boost/range/counting_range.hpp` + +[heading Requirements] + +# `Incrementable` is a model of the `Incrementable` Concept. + +[endsect] diff --git a/doc/reference/ranges/irange.qbk b/doc/reference/ranges/irange.qbk new file mode 100644 index 0000000..bd9efc4 --- /dev/null +++ b/doc/reference/ranges/irange.qbk @@ -0,0 +1,35 @@ +[section:irange irange] + +[heading Prototype] + +`` +template +integer_range< range_detail::integer_iterator > +irange(Integer first, Integer last); + +template +integer_range< range_detail::integer_iterator_with_step > +irange(Integer first, Integer last, StepSize step_size); +`` + +[heading Description] + +`irange` is a function to generate an Integer Range. + +`irange` allows treating integers as a model of the __random_access_range__ Concept. It should be noted that the `first` and `last` parameters denoted a half-open range. + +[heading Definition] + +Defined in the header file `boost/range/irange.hpp` + +[heading Requirements] + +# `Integer` is a model of the `Integer` Concept. +# `StepSize` is a model of the `SignedInteger` Concept. + +[heading Complexity] + +Constant. Since this function generates a new range the most significant performance cost is incurred through the iteration of the generated range. + +[endsect] + diff --git a/doc/reference/ranges/istream_range.qbk b/doc/reference/ranges/istream_range.qbk new file mode 100644 index 0000000..2b195e7 --- /dev/null +++ b/doc/reference/ranges/istream_range.qbk @@ -0,0 +1,19 @@ +[section:istream_range istream_range] + +[heading Prototype] + +`` +template< class Type, class Elem, class Traits > inline +iterator_range< std::istream_iterator > +istream_range(std::basic_istream& in); +`` + +[heading Description] + +`istream_range` is a function to generator that generates an `iterator_range` wrapping a `std::istream_iterator`. + +[heading Definition] + +Defined in header file `boost/range/istream_range.hpp` + +[endsect] diff --git a/doc/reference/semantics.qbk b/doc/reference/semantics.qbk new file mode 100644 index 0000000..47d15c9 --- /dev/null +++ b/doc/reference/semantics.qbk @@ -0,0 +1,185 @@ +[section Semantics] + +[heading notation] + +[table + [[Type ] [Object] [Describes ]] + [[`X` ] [`x` ] [any type ]] + [[`T` ] [`t` ] [denotes behavior of the primary templates]] + [[`P` ] [`p` ] [denotes `std::pair` ]] + [[`A[sz]`] [`a` ] [denotes an array of type `A` of size `sz`]] + [[`Char*`] [`s` ] [denotes either `char*` or `wchar_t*` ]] +] + +[section Metafunctions] + +[table + [[Expression] [Return type] [Complexity]] + [ + [`range_iterator::type`] + [`` + T::iterator + P::first_type + A* + ``] + [compile time] + ] + [ + [`range_iterator::type`] + [`` + T::const_iterator + P::first_type + const A* + ``] + [compile time] + ] + [ + [`range_value::type`] + [`boost::iterator_value::type>::type`] + [compile time] + ] + [ + [`range_reference::type`] + [`boost::iterator_reference::type>::type`] + [compile time] + ] + [ + [`range_pointer::type`] + [`boost::iterator_pointer::type>::type`] + [compile time] + ] + [ + [`range_category::type`] + [`boost::iterator_category::type>::type`] + [compile time] + ] + [ + [`range_difference::type`] + [`boost::iterator_category::type>::type`] + [compile time] + ] + [ + [`range_reverse_iterator::type`] + [`boost::reverse_iterator::type>`] + [compile time] + ] + [ + [`range_reverse_iterator::type`] + [`boost::reverse_iterator::type`] + [compile time] + ] +] + +[endsect] + +[section Functions] + +[table + [[Expression] [Return type] [Returns] [Complexity]] + + [ + [`begin(x)`] + [`range_iterator::type`] + [ + `p.first` if `p` is of type `std::pair` + `a` if `a` is an array + `range_begin(x)` if that expression would invoke a function found by ADL + `t.begin()` otherwise + ] + [constant time] + ] + [ + [`end(x)`] + [`range_iterator::type`] + [ + `p.second` if `p` is of type `std::pair` + `a + sz` if `a` is an array of size `sz` + `range_end(x)` if that expression would invoke a function found by ADL + `t.end()` otherwise + ] + [constant time] + ] + [ + [`empty(x)`] + [`bool`] + [`boost::begin(x) == boost::end(x)`] + [constant time] + ] + [ + [`distance(x)`] + [`range_difference::type`] + [`std::distance(boost::begin(x),boost::end(x))`] + [-] + ] + [ + [`size(x)`] + [`range_difference::type`] + [`boost::end(x) - boost::begin(x)`] + [constant time] + ] + [ + [`rbegin(x)`] + [`range_reverse_iterator::type`] + [`range_reverse_iterator::type(boost::end(x))`] + [constant time] + ] + [ + [`rend(x)`] + [`range_reverse_iterator::type`] + [`range_reverse_iterator::type(boost::begin(x))`] + [constant time] + ] + [ + [`const_begin(x)`] + [`range_iterator::type`] + [`range_iterator::type(boost::begin(x))`] + [constant time] + ] + [ + [`const_end(x)`] + [`range_iterator::type`] + [`range_iterator::type(boost::end(x))`] + [constant time] + ] + [ + [`const_rbegin(x)`] + [`range_reverse_iterator::type`] + [`range_reverse_iterator::type(boost::rbegin(x))`] + [constant time] + ] + [ + [`const_rend(x)`] + [`range_reverse_iterator::type`] + [`range_reverse_iterator::type(boost::rend(x))`] + [constant time] + ] + [ + [`as_literal(x)`] + [`iterator_range` where `U` is `Char*` if `x` is a pointer to a string and `U` is `range_iterator::type` otherwise] + [ + `[s,s + std::char_traits::length(s))` if `s` is a `Char*` or an array of `Char` `[boost::begin(x),boost::end(x))` otherwise + ] + [ + linear time for pointers to a string or arrays of `Char`, constant time otherwise + ] + ] + [ + [`as_array(x)`] + [`iterator_range`] + [`[boost::begin(x),boost::end(x))`] + ] +] + +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 libraries 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). + +[endsect] + +[endsect] + + diff --git a/doc/reference/synopsis.qbk b/doc/reference/synopsis.qbk new file mode 100644 index 0000000..5848bd2 --- /dev/null +++ b/doc/reference/synopsis.qbk @@ -0,0 +1,143 @@ +[section Synopsis] + +`` +namespace boost +{ + // + // Single Pass Range metafunctions + // + + template< class T > + struct range_iterator; + + template< class T > + struct range_value; + + template< class T > + struct range_reference; + + template< class T > + struct range_pointer; + + template< class T > + struct range_category; + + // + // Forward Range metafunctions + // + + template< class T > + struct range_difference; + + // + // Bidirectional Range metafunctions + // + + template< class T > + struct range_reverse_iterator; + + // + // Single Pass Range functions + // + + template< class T > + typename range_iterator::type + begin( T& r ); + + template< class T > + typename range_iterator::type + begin( const T& r ); + + template< class T > + typename range_iterator::type + end( T& r ); + + template< class T > + typename range_iterator::type + end( const T& r ); + + template< class T > + bool + empty( const T& r ); + + // + // Forward Range functions + // + + template< class T > + typename range_difference::type + distance( const T& r ); + + // + // Bidirectional Range functions + // + + template< class T > + typename range_reverse_iterator::type + rbegin( T& r ); + + template< class T > + typename range_reverse_iterator::type + rbegin( const T& r ); + + template< class T > + typename range_reverse_iterator::type + rend( T& r ); + + template< class T > + typename range_reverse_iterator::type + rend( const T& r ); + + // + // Random Access Range functions + // + + template< class T > + typename range_difference::type + size( const T& r ); + + // + // Special const Range functions + // + + template< class T > + typename range_iterator::type + const_begin( const T& r ); + + template< class T > + typename range_iterator::type + const_end( const T& r ); + + template< class T > + typename range_reverse_iterator::type + const_rbegin( const T& r ); + + template< class T > + typename range_reverse_iterator::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::type > + as_array( T& r ); + + template< class T > + iterator_range< typename range_iterator::type > + as_array( const T& r ); + +} // namespace 'boost' +`` + +[endsect] + diff --git a/doc/style.qbk b/doc/style.qbk new file mode 100644 index 0000000..779fd5c --- /dev/null +++ b/doc/style.qbk @@ -0,0 +1,45 @@ +[section:style_guide 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: + +* [*/Value access/] category: + * Readable Range + * Writeable Range + * Swappable Range + * Lvalue Range +* [*/Traversal/] category: + * __single_pass_range__ + * __forward_range__ + * __bidirectional_range__ + * __random_access_range__ + +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 + +* Random Access Readable Writeable Range +* Forward Lvalue Range + +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 ); +`` + +[endsect] + diff --git a/doc/upgrade.qbk b/doc/upgrade.qbk new file mode 100644 index 0000000..016f89c --- /dev/null +++ b/doc/upgrade.qbk @@ -0,0 +1,30 @@ +[section:upgrade Upgrade version of Boost.Range] + +[section:upgrade_from_1_42 Upgrade from version 1.42] + +New features: + +# __range_adaptors__ +# __range_algorithms__ + +Removed: + +# `iterator_range` no longer has a `is_singular` member function. The singularity restrictions have been removed from the `iterator_range` class since this added restrictions to ranges of iterators whose default constructors were not singular. Previously the `is_singular` member function always returned `false` in release build configurations, hence it is not anticipated that this interface change will produce difficulty in upgrading. + + +[endsect] + +[section:upgrade_from_1_34 Upgrade from version 1.34] + +Boost version 1.35 introduced some larger refactorings of the library: + +# Direct support for character arrays was abandoned in favor of uniform treatment of all arrays. Instead string algorithms can use the new function __as_literal__`()`. +# __size__ now requires a __random_access_range__. The old behavior is provided as __distance__`()`. +# `range_size::type` has been completely removed in favor of `range_difference::type` +# `boost_range_begin()` and `boost_range_end()` have been renamed `range_begin()` and `range_end()` respectively. +# `range_result_iterator::type` and `range_reverse_result_iterator::type` have been renamed `range_iterator::type` and `range_reverse_iterator::type`. +# The procedure that makes a custom type work with the library has been greatly simplified. See __extending_for_udts__ for details. + +[endsect] + +[endsect] diff --git a/doc/utilities.qbk b/doc/utilities.qbk new file mode 100644 index 0000000..20ce6b6 --- /dev/null +++ b/doc/utilities.qbk @@ -0,0 +1,296 @@ +[section:utilities 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` is hardly self-documenting whereas more domain specific class names are. Therefore these two classes are provided: + +* Class `iterator_range` +* Class `sub_range` +* Function `join` + +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. + +[section:iterator_range Class `iterator_range`] + +The intention of the `iterator_range` class is to encapsulate two iterators so they fulfill the __forward_range__ concept. A few other functions are also provided for convenience. + +If the template argument is not a model of __forward_traversal_iterator__, one can still use a subset of the interface. In particular, `size()` requires Random Access 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 design decision avoids the `iterator_range` imposing limitations upon ranges of iterators that are not singular. Any singularity limitation is simply propogated from the underlying iterator type. + + +[h4 Synopsis] + +`` +namespace boost +{ + template< class ForwardTraversalIterator > + class iterator_range + { + public: // Forward Range types + typedef ForwardTraversalIterator iterator; + typedef ForwardTraversalIterator const_iterator; + typedef iterator_difference::type difference_type; + + public: // construction, assignment + template< class ForwardTraversalIterator2 > + iterator_range( ForwardTraversalIterator2 Begin, ForwardTraversalIterator2 End ); + + template< class ForwardRange > + iterator_range( ForwardRange& r ); + + template< class ForwardRange > + iterator_range( const ForwardRange& r ); + + template< class ForwardRange > + iterator_range& operator=( ForwardRange& r ); + + template< class ForwardRange > + iterator_range& operator=( const ForwardRange& r ); + + public: // Forward Range functions + iterator begin() const; + iterator end() const; + + public: // convenience + operator unspecified_bool_type() const; + bool equal( const iterator_range& ) const; + value_type& front() const; + value_type& back() const; + iterator_range& advance_begin(difference_type n); + iterator_range& advance_end(difference_type n); + bool empty() const; + // for Random Access Range only: + reference operator[]( difference_type at ) const; + value_type operator()( difference_type at ) const; + size_type size() const; + }; + + // stream output + template< class ForwardTraversalIterator, class T, class Traits > + std::basic_ostream& + operator<<( std::basic_ostream& Os, + const iterator_range& r ); + + // comparison + template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > + bool operator==( const iterator_range& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator==( const iterator_range& l, + const ForwardRange& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator==( const ForwardRange& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > + bool operator!=( const iterator_range& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator!=( const iterator_range& l, + const ForwardRange& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator!=( const ForwardRange& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardTraversalIterator2 > + bool operator<( const iterator_range& l, + const iterator_range& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator<( const iterator_range& l, + const ForwardRange& r ); + + template< class ForwardTraversalIterator, class ForwardRange > + bool operator<( const ForwardRange& l, + const iterator_range& r ); + + // external construction + template< class ForwardTraversalIterator > + iterator_range< ForwardTraversalIterator > + make_iterator_range( ForwardTraversalIterator Begin, + ForwardTraversalIterator End ); + + template< class ForwardRange > + iterator_range< typename range_iterator::type > + make_iterator_range( ForwardRange& r ); + + template< class ForwardRange > + iterator_range< typename range_iterator::type > + make_iterator_range( const ForwardRange& r ); + + template< class Range > + iterator_range< typename range_iterator::type > + make_iterator_range( Range& r, + typename range_difference::type advance_begin, + typename range_difference::type advance_end ); + + template< class Range > + iterator_range< typename range_iterator::type > + make_iterator_range( const Range& r, + typename range_difference::type advance_begin, + typename range_difference::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` to `iterator_range`. 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. + +[h4 Details member functions] + +`operator unspecified_bool_type() const;` + +[:['[*Returns]] `!empty();`] + +`bool equal( iterator_range& r ) const;` + +[:['[*Returns]] `begin() == r.begin() && end() == r.end();`] + +[h4 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::type advance_begin, + typename range_difference::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) );`] + +[endsect] + +[section:sub_range 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. + +[h4 Synopsis] + +`` +namespace boost +{ + template< class ForwardRange > + class sub_range : public iterator_range< typename range_iterator::type > + { + public: + typedef typename range_iterator::type iterator; + typedef typename range_iterator::type const_iterator; + typedef typename iterator_difference::type difference_type; + + public: // construction, assignment + template< class ForwardTraversalIterator > + sub_range( ForwardTraversalIterator Begin, ForwardTraversalIterator End ); + + template< class ForwardRange2 > + sub_range( ForwardRange2& r ); + + template< class ForwardRange2 > + sub_range( const 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 ir = find_first( str, "ll" ); +sub_range sub = find_first( str, "ll" ); +`` + +[endsect] + +[section:join Function join] + +The intention of the `join` function is to join two ranges into one longer range. + +The resultant range will have the lowest common traversal of the two ranges supplied as parameters. + +Note that the joined range incurs a performance cost due to the need to check if the end of a range has been reached internally during traversal. + +[h4 Synposis] +`` +template +iterator_range::type, + typename range_iterator::type, + typename add_const< + typename range_value::type>::type> +> +join(const SinglePassRange1& rng1, const SinglePassRange2& rng2) + +template +iterator_range::type, + typename range_iterator::type, + typename range_value::type> +> +join(SinglePassRange1& rng1, SinglePassRange2& rng2); +`` + +[h4 Example] + +The expression `join(irange(0,5), irange(5,10))` would evaluate to a range representing an integer range `[0,10)` + + +[endsect] + +[endsect] + diff --git a/include/boost/range/adaptor/adjacent_filtered.hpp b/include/boost/range/adaptor/adjacent_filtered.hpp new file mode 100644 index 0000000..944665b --- /dev/null +++ b/include/boost/range/adaptor/adjacent_filtered.hpp @@ -0,0 +1,255 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_ADJACENT_FILTER_IMPL_HPP +#define BOOST_RANGE_ADAPTOR_ADJACENT_FILTER_IMPL_HPP + +#include +#ifdef BOOST_MSVC +#pragma warning( push ) +#pragma warning( disable : 4355 ) +#endif + +#include +#include +#include +#include +#include +#include + + +namespace boost +{ + + namespace range_detail + { + template< class Iter, class R > + class skip_iterator + : public boost::iterator_adaptor< skip_iterator, Iter > + { + private: + typedef boost::iterator_adaptor< skip_iterator, Iter > + base_t; + + R* range; + + public: + typedef Iter wrapped_iter_t; + + // + // The iterators are bound to the lifetime of the + // range and may not exist on their own. Hence it makes no + // sense to e.g. wrap them in reverse_iterators + // (that can OTOH be done in advance). + // + typedef std::input_iterator_tag iterator_category; + + explicit skip_iterator( R* r, Iter i ) + : base_t(i), range(r) {} + + template< class OtherIter, class R2> + skip_iterator( const skip_iterator& other ) + : base_t( other.base() ) {} + + R* get_range() const { return range; } + + private: + friend class boost::iterator_core_access; + + void increment() + { + BOOST_ASSERT( range != 0 ); + range->increment_impl( this->base_reference() ); + } + + // + // Not needed ... just apply a reverse_iterator + // + void decrement() + { + BOOST_ASSERT( false && "you can't decrement an adjacent_filter_iterator" ); + } + + template< class D > + void advance( D n ) + { + BOOST_ASSERT( false ); + } + + }; + + template< class P, class R > + struct adjacent_filter_range + : iterator_range< skip_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type, + adjacent_filter_range + > + > + { + private: + typedef skip_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type, + adjacent_filter_range + > + skip_iter; + typedef iterator_range + base_range; + + typedef BOOST_DEDUCED_TYPENAME range_iterator::type raw_iterator; + + P bi_pred; + + // Get the first element in the half-open range that + // passes the filter predicate. + // The adjacent_filter_range must only contain values that pass + // through the filter. + static raw_iterator to_valid(raw_iterator it, raw_iterator last, const P& bi_pred, bool default_pass) + { + if (it != last) + { + if (default_pass) + { + raw_iterator nxt = next(it); + while (nxt != last && !bi_pred(*it, *nxt)) + { + ++it; + ++nxt; + } + } + else + { + raw_iterator nxt = next(it); + for(; nxt != last; ++it, ++nxt) + { + if (bi_pred(*it, *nxt)) + { + break; + } + } + if (nxt == last) + { + it = last; + } + } + } + return it; + } + + public: + adjacent_filter_range( const P& p, R& r, bool default_pass ) + : base_range( skip_iter( this, to_valid(boost::begin(r), boost::end(r), p, default_pass)), + skip_iter( this, boost::end(r) ) ), + bi_pred( p ), + _default_pass(default_pass) + { + } + + void increment_impl( raw_iterator& current ) + { + BOOST_ASSERT( current != this->end().base() ); + + current = to_valid(next(current), this->end().base(), bi_pred, _default_pass); + } + + private: + bool _default_pass; + }; + + template< class T > + struct adjacent_holder : holder + { + adjacent_holder( T r ) : holder(r) + { } + }; + + template< class T > + struct adjacent_excl_holder : holder + { + adjacent_excl_holder( T r ) : holder(r) + { } + }; + + template< class ForwardRng, class BinPredicate > + inline adjacent_filter_range + operator|( ForwardRng& r, + const adjacent_holder& f ) + { + return adjacent_filter_range( f.val, r, true ); + } + + template< class ForwardRng, class BinPredicate > + inline adjacent_filter_range + operator|( const ForwardRng& r, + const adjacent_holder& f ) + { + return adjacent_filter_range( f.val, r, true ); + } + + template< class ForwardRng, class BinPredicate > + inline adjacent_filter_range + operator|( ForwardRng& r, + const adjacent_excl_holder& f ) + { + return adjacent_filter_range( f.val, r, false ); + } + + template< class ForwardRng, class BinPredicate > + inline adjacent_filter_range + operator|( const ForwardRng& r, + const adjacent_excl_holder& f ) + { + return adjacent_filter_range( f.val, r, false ); + } + + } // 'range_detail' + + // Bring adjacent_filter_range into the boost namespace so that users of + // this library may specify the return type of the '|' operator and + // make_adjacent_filtered_range() + using range_detail::adjacent_filter_range; + + namespace adaptors + { + namespace + { + const range_detail::forwarder + adjacent_filtered = + range_detail::forwarder(); + + const range_detail::forwarder + adjacent_filtered_excl = + range_detail::forwarder(); + } + + template + inline adjacent_filter_range + adjacent_filter(ForwardRng& rng, BinPredicate filter_pred, bool default_pass = true) + { + return adjacent_filter_range(filter_pred, rng, default_pass); + } + + template + inline adjacent_filter_range + adjacent_filter(const ForwardRng& rng, BinPredicate filter_pred, bool default_pass = true) + { + return adjacent_filter_range(filter_pred, rng, default_pass); + } + + } // 'adaptors' + +} + +#ifdef BOOST_MSVC +#pragma warning( pop ) +#endif + +#endif diff --git a/include/boost/range/adaptor/argument_fwd.hpp b/include/boost/range/adaptor/argument_fwd.hpp new file mode 100755 index 0000000..357056b --- /dev/null +++ b/include/boost/range/adaptor/argument_fwd.hpp @@ -0,0 +1,80 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_ARGUMENT_FWD_HPP +#define BOOST_RANGE_ADAPTOR_ARGUMENT_FWD_HPP + +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4512) // assignment operator could not be generated +#endif + +namespace boost +{ + namespace range_detail + { + template< class T > + struct holder + { + T val; + holder( T t ) : val(t) + { } + }; + + template< class T > + struct holder2 + { + T val1, val2; + holder2( T t, T u ) : val1(t), val2(u) + { } + }; + + template< template class Holder > + struct forwarder + { + template< class T > + Holder operator()( T t ) const + { + return Holder(t); + } + }; + + template< template class Holder > + struct forwarder2 + { + template< class T > + Holder operator()( T t, T u ) const + { + return Holder(t,u); + } + }; + + template< template class Holder > + struct forwarder2TU + { + template< class T, class U > + Holder operator()( T t, U u ) const + { + return Holder(t, u); + } + }; + + + } + +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif diff --git a/include/boost/range/adaptor/copied.hpp b/include/boost/range/adaptor/copied.hpp new file mode 100755 index 0000000..72b2860 --- /dev/null +++ b/include/boost/range/adaptor/copied.hpp @@ -0,0 +1,68 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_COPIED_HPP +#define BOOST_RANGE_ADAPTOR_COPIED_HPP + +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class T > + struct copy_holder + : holder2 + { + copy_holder( std::size_t t, std::size_t u ) + : holder2(t,u) + { } + }; + + template< class CopyableRandomAccessRng, class Int > + inline CopyableRandomAccessRng + operator|( const CopyableRandomAccessRng& r, const copy_holder& f ) + { + iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > + temp( sliced_impl( r, f ) ); + return CopyableRandomAccessRng( temp.begin(), temp.end() ); + } + + } // 'range_detail' + + namespace adaptors + { + namespace + { + const range_detail::forwarder2 + copied = range_detail::forwarder2(); + } + + template + inline CopyableRandomAccessRange + copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u) + { + iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type> temp( + adaptors::slice(rng, t, u)); + + return CopyableRandomAccessRange( temp.begin(), temp.end() ); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptor/define_adaptor.hpp b/include/boost/range/adaptor/define_adaptor.hpp new file mode 100644 index 0000000..d68c64e --- /dev/null +++ b/include/boost/range/adaptor/define_adaptor.hpp @@ -0,0 +1,117 @@ +#ifndef BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED +#define BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED + +#include + +#define BOOST_DEFINE_RANGE_ADAPTOR( adaptor_name, range_adaptor ) \ + struct adaptor_name##_forwarder {}; \ + \ + template range_adaptor \ + operator|(Range& rng, adaptor_name##_forwarder) \ + { \ + return range_adaptor ( rng ); \ + } \ + \ + template range_adaptor \ + operator|(const Range& rng, adaptor_name##_forwarder) \ + { \ + return range_adaptor ( rng ); \ + } \ + \ + static adaptor_name##_forwarder adaptor_name = adaptor_name##_forwarder(); \ + \ + template \ + range_adaptor \ + make_##adaptor_name(Range& rng) \ + { \ + return range_adaptor (rng); \ + } \ + \ + template \ + range_adaptor \ + make_##adaptor_name(const Range& rng) \ + { \ + return range_adaptor (rng); \ + } + +#define BOOST_DEFINE_RANGE_ADAPTOR_1( adaptor_name, range_adaptor, adaptor_class ) \ + template range_adaptor \ + operator|(Range& rng, const adaptor_name & args) \ + { \ + return range_adaptor (rng, args.arg1); \ + } \ + template range_adaptor \ + operator|(const Range& rng, const adaptor_name & args) \ + { \ + return range_adaptor (rng, args.arg1); \ + } \ + template \ + range_adaptor \ + make_##adaptor_name(Range& rng, Arg1 arg1) \ + { \ + return range_adaptor(rng, arg1); \ + } + +#define BOOST_DEFINE_RANGE_ADAPTOR_1( adaptor_name, range_adaptor, arg1_type ) \ + struct adaptor_name \ + { \ + explicit adaptor_name (arg1_type arg1_) \ + : arg1(arg1_) {} \ + arg1_type arg1; \ + }; \ + \ + template range_adaptor \ + operator|(Range& rng, adaptor_name args) \ + { \ + return range_adaptor (rng, args.arg1); \ + } \ + \ + template range_adaptor \ + operator|(const Range& rng, adaptor_name args) \ + { \ + return range_adaptor (rng, args.arg1); \ + } \ + \ + template \ + range_adaptor \ + make_##adaptor_name(Range& rng, arg1_type arg1) \ + { \ + return range_adaptor (rng, arg1); \ + } \ + \ + template \ + range_adaptor \ + make_##adaptor_name(const Range& rng, arg1_type arg1) \ + { \ + return range_adaptor (rng, arg1); \ + } + +#define BOOST_RANGE_ADAPTOR_2( adaptor_name, range_adaptor, arg1_type, arg2_type ) \ + struct adaptor_name \ + { \ + explicit adaptor_name (arg1_type arg1_, arg2_type arg2_) \ + : arg1(arg1_), arg2(arg2_) {} \ + arg1_type arg1; \ + arg2_type arg2; \ + }; \ + \ + template range_adaptor \ + operator|(Range& rng, adaptor_name args) \ + { \ + return range_adaptor (rng, args.arg1, args.arg2); \ + } \ + template \ + range_adaptor \ + make_##adaptor_name(Range& rng, arg1_type arg1, arg2_type arg2) \ + { \ + return range_adaptor (rng, arg1, arg2); \ + } \ + template \ + range_adaptor \ + make_##adaptor_name(const Range& rng, arg1_type arg1, arg2_type arg2) \ + { \ + return range_adaptor (rng, arg1, arg2); \ + } + + +#endif // include guard diff --git a/include/boost/range/adaptor/filtered.hpp b/include/boost/range/adaptor/filtered.hpp new file mode 100755 index 0000000..c3e9ef5 --- /dev/null +++ b/include/boost/range/adaptor/filtered.hpp @@ -0,0 +1,102 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_FILTERED_HPP +#define BOOST_RANGE_ADAPTOR_FILTERED_HPP + +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class P, class R > + struct filter_range : + boost::iterator_range< + boost::filter_iterator< P, + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + { + private: + typedef boost::iterator_range< + boost::filter_iterator< P, + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + base; + public: + filter_range( P p, R& r ) + : base( make_filter_iterator( p, boost::begin(r), boost::end(r) ), + make_filter_iterator( p, boost::end(r), boost::end(r) ) ) + { } + }; + + template< class T > + struct filter_holder : holder + { + filter_holder( T r ) : holder(r) + { } + }; + + template< class InputRng, class Predicate > + inline filter_range + operator|( InputRng& r, + const filter_holder& f ) + { + return filter_range( f.val, r ); + } + + template< class InputRng, class Predicate > + inline filter_range + operator|( const InputRng& r, + const filter_holder& f ) + { + return filter_range( f.val, r ); + } + + } // 'range_detail' + + // Unusual use of 'using' is intended to bring filter_range into the boost namespace + // while leaving the mechanics of the '|' operator in range_detail and maintain + // argument dependent lookup. + // filter_range logically needs to be in the boost namespace to allow user of + // the library to define the return type for make_filtered_range() + using range_detail::filter_range; + + namespace adaptors + { + namespace + { + const range_detail::forwarder + filtered = + range_detail::forwarder(); + } + + template + inline filter_range + filter(InputRange& rng, Predicate filter_pred) + { + return range_detail::filter_range( filter_pred, rng ); + } + + template + inline filter_range + filter(const InputRange& rng, Predicate filter_pred) + { + return range_detail::filter_range( filter_pred, rng ); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptor/indexed.hpp b/include/boost/range/adaptor/indexed.hpp new file mode 100755 index 0000000..cab8e1d --- /dev/null +++ b/include/boost/range/adaptor/indexed.hpp @@ -0,0 +1,173 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_INDEXED_IMPL_HPP +#define BOOST_RANGE_ADAPTOR_INDEXED_IMPL_HPP + +#include +#ifdef BOOST_MSVC +#pragma warning( push ) +#pragma warning( disable : 4355 ) +#endif + +#include +#include +#include +#include +#include + + + +namespace boost +{ + + namespace range_detail + { + template< class Iter > + class indexed_iterator + : public boost::iterator_adaptor< indexed_iterator, Iter > + { + private: + typedef boost::iterator_adaptor< indexed_iterator, Iter > + base; + + typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type; + + index_type index_; + + public: + explicit indexed_iterator( Iter i, index_type index ) + : base(i), index_(index) + { + BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" ); + } + + index_type index() const + { + return index_; + } + + private: + friend class boost::iterator_core_access; + + void increment() + { + ++index_; + ++(this->base_reference()); + } + + + void decrement() + { + BOOST_ASSERT( index_ > 0 && "Indexed Iterator out of bounds" ); + --index_; + --(this->base_reference()); + } + + void advance( index_type n ) + { + index_ += n; + BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" ); + this->base_reference() += n; + } + }; + + template< class Rng > + struct indexed_range : + iterator_range< indexed_iterator::type> > + { + private: + typedef indexed_iterator::type> + iter_type; + typedef iterator_range + base; + public: + template< class Index > + indexed_range( Index i, Rng& r ) + : base( iter_type(boost::begin(r), i), iter_type(boost::end(r),i) ) + { } + }; + + + template< class T > + struct index_holder : holder + { + index_holder( T r ) : holder(r) + { } + }; + + struct index_forwarder + { + template< class T > + index_holder operator()( T r ) const + { + return r; + } + + index_holder operator()( int r = 0 ) const + { + return r; + } + }; + + template< class SinglePassRange > + inline indexed_range + operator|( SinglePassRange& r, + const index_holder::type>& f ) + { + return indexed_range( f.val, r ); + } + + template< class SinglePassRange > + inline indexed_range + operator|( const SinglePassRange& r, + const index_holder::type>& f ) + { + return indexed_range( f.val, r ); + } + + } // 'range_detail' + + // Make this available to users of this library. It will sometimes be + // required since it is the return type of operator '|' and + // make_indexed_range(). + using range_detail::indexed_range; + + namespace adaptors + { + namespace + { + const range_detail::forwarder + indexed = + range_detail::forwarder(); + } + + template + inline indexed_range + index(SinglePassRange& rng, Index index) + { + return indexed_range(index, rng); + } + + template + inline indexed_range + index(const SinglePassRange& rng, Index index) + { + return indexed_range(index, rng); + } + } // 'adaptors' + +} + +#ifdef BOOST_MSVC +#pragma warning( pop ) +#endif + +#endif diff --git a/include/boost/range/adaptor/indirected.hpp b/include/boost/range/adaptor/indirected.hpp new file mode 100644 index 0000000..47eeb85 --- /dev/null +++ b/include/boost/range/adaptor/indirected.hpp @@ -0,0 +1,88 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_INDIRECTED_HPP +#define BOOST_RANGE_ADAPTOR_INDIRECTED_HPP + +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class R > + struct indirect_range : + public boost::iterator_range< + boost::indirect_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + { + private: + typedef boost::iterator_range< + boost::indirect_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + base; + + public: + indirect_range( R& r ) + : base( r ) + { } + }; + + struct indirect_forwarder {}; + + template< class InputRng > + inline indirect_range + operator|( InputRng& r, indirect_forwarder ) + { + return indirect_range( r ); + } + + template< class InputRng > + inline indirect_range + operator|( const InputRng& r, indirect_forwarder ) + { + return indirect_range( r ); + } + + } // 'range_detail' + + using range_detail::indirect_range; + + namespace adaptors + { + namespace + { + const range_detail::indirect_forwarder indirected = + range_detail::indirect_forwarder(); + } + + template + inline indirect_range + indirect(InputRange& rng) + { + return indirect_range(rng); + } + + template + inline indirect_range + indirect(const InputRange& rng) + { + return indirect_range(rng); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptor/map.hpp b/include/boost/range/adaptor/map.hpp new file mode 100755 index 0000000..f790e1a --- /dev/null +++ b/include/boost/range/adaptor/map.hpp @@ -0,0 +1,188 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_MAP_HPP +#define BOOST_RANGE_ADAPTOR_MAP_HPP + +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + struct map_keys_forwarder {}; + struct map_values_forwarder {}; + + template< class Map > + struct select_first + { + typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t; + typedef const BOOST_DEDUCED_TYPENAME pair_t::first_type& + result_type; + + result_type operator()( const pair_t& r ) const + { + return r.first; + } + }; + + template< class Map > + struct select_second_mutable + { + typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t; + typedef BOOST_DEDUCED_TYPENAME pair_t::second_type& result_type; + + result_type operator()( pair_t& r ) const + { + return r.second; + } + }; + + template< class Map > + struct select_second_const + { + typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t; + typedef const BOOST_DEDUCED_TYPENAME pair_t::second_type& + result_type; + + result_type operator()( const pair_t& r ) const + { + return r.second; + } + }; + + template + class select_first_range + : public transform_range< + select_first, + const StdPairRng> + { + typedef transform_range, const StdPairRng> base; + public: + typedef select_first transform_fn_type; + typedef const StdPairRng source_range_type; + + select_first_range(transform_fn_type fn, source_range_type& rng) + : base(fn, rng) + { + } + + select_first_range(const base& other) : base(other) {} + }; + + template + class select_second_mutable_range + : public transform_range< + select_second_mutable, + StdPairRng> + { + typedef transform_range, StdPairRng> base; + public: + typedef select_second_mutable transform_fn_type; + typedef StdPairRng source_range_type; + + select_second_mutable_range(transform_fn_type fn, source_range_type& rng) + : base(fn, rng) + { + } + + select_second_mutable_range(const base& other) : base(other) {} + }; + + template + class select_second_const_range + : public transform_range< + select_second_const, + const StdPairRng> + { + typedef transform_range, const StdPairRng> base; + public: + typedef select_second_const transform_fn_type; + typedef const StdPairRng source_range_type; + + select_second_const_range(transform_fn_type fn, source_range_type& rng) + : base(fn, rng) + { + } + + select_second_const_range(const base& other) : base(other) {} + }; + + template< class StdPairRng > + inline select_first_range + operator|( const StdPairRng& r, map_keys_forwarder ) + { + return operator|( r, + boost::adaptors::transformed( select_first() ) ); + } + + template< class StdPairRng > + inline select_second_mutable_range + operator|( StdPairRng& r, map_values_forwarder ) + { + return operator|( r, + boost::adaptors::transformed( select_second_mutable() ) ); + } + + template< class StdPairRng > + inline select_second_const_range + operator|( const StdPairRng& r, map_values_forwarder ) + { + return operator|( r, + boost::adaptors::transformed( select_second_const() ) ); + } + + } // 'range_detail' + + using range_detail::select_first_range; + using range_detail::select_second_mutable_range; + using range_detail::select_second_const_range; + + namespace adaptors + { + namespace + { + const range_detail::map_keys_forwarder map_keys = + range_detail::map_keys_forwarder(); + + const range_detail::map_values_forwarder map_values = + range_detail::map_values_forwarder(); + } + + template + inline select_first_range + keys(const StdPairRange& rng) + { + return select_first_range( + range_detail::select_first(), rng ); + } + + template + inline select_second_const_range + values(const StdPairRange& rng) + { + return select_second_const_range( + range_detail::select_second_const(), rng ); + } + + template + inline select_second_mutable_range + values(StdPairRange& rng) + { + return select_second_mutable_range( + range_detail::select_second_mutable(), rng ); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptor/replaced.hpp b/include/boost/range/adaptor/replaced.hpp new file mode 100644 index 0000000..1690797 --- /dev/null +++ b/include/boost/range/adaptor/replaced.hpp @@ -0,0 +1,134 @@ +// Boost.Range library +// +// Copyright Neil Groves 2007. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_REPLACED_IMPL_HPP_INCLUDED +#define BOOST_RANGE_ADAPTOR_REPLACED_IMPL_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class Value > + class replace_value + { + public: + typedef const Value& result_type; + typedef const Value& first_argument_type; + + replace_value(const Value& from, const Value& to) + : _from(from), _to(to) + { + } + + const Value& operator()(const Value& x) const + { + return (x == _from) ? _to : x; + } + + private: + Value _from; + Value _to; + }; + + template< class R > + class replace_range : + public boost::iterator_range< + boost::transform_iterator< + replace_value< BOOST_DEDUCED_TYPENAME range_value::type >, + BOOST_DEDUCED_TYPENAME range_iterator::type > > + { + private: + typedef replace_value< BOOST_DEDUCED_TYPENAME range_value::type > Fn; + + typedef boost::iterator_range< + boost::transform_iterator< + replace_value< BOOST_DEDUCED_TYPENAME range_value::type >, + BOOST_DEDUCED_TYPENAME range_iterator::type > > base_t; + + public: + typedef BOOST_DEDUCED_TYPENAME range_value::type value_type; + + replace_range( R& r, value_type from, value_type to ) + : base_t( make_transform_iterator( boost::begin(r), Fn(from, to) ), + make_transform_iterator( boost::end(r), Fn(from, to) ) ) + { } + }; + + template< class T > + class replace_holder : public holder2 + { + public: + replace_holder( const T& from, const T& to ) + : holder2(from, to) + { } + private: + // not assignable + void operator=(const replace_holder&); + }; + + template< class InputRng > + inline replace_range + operator|( InputRng& r, + const replace_holder::type>& f ) + { + return replace_range(r, f.val1, f.val2); + } + + template< class InputRng > + inline replace_range + operator|( const InputRng& r, + const replace_holder::type>& f ) + { + return replace_range(r, f.val1, f.val2); + } + } // 'range_detail' + + using range_detail::replace_range; + + namespace adaptors + { + namespace + { + const range_detail::forwarder2 + replaced = + range_detail::forwarder2(); + } + + template + inline replace_range + replace(InputRange& rng, + BOOST_DEDUCED_TYPENAME range_value::type from, + BOOST_DEDUCED_TYPENAME range_value::type to) + { + return replace_range(rng, from, to); + } + + template + inline replace_range + replace(const InputRange& rng, + BOOST_DEDUCED_TYPENAME range_value::type from, + BOOST_DEDUCED_TYPENAME range_value::type to) + { + return replace_range(rng, from ,to); + } + + } // 'adaptors' +} // 'boost' + +#endif // include guard diff --git a/include/boost/range/adaptor/replaced_if.hpp b/include/boost/range/adaptor/replaced_if.hpp new file mode 100644 index 0000000..22264a2 --- /dev/null +++ b/include/boost/range/adaptor/replaced_if.hpp @@ -0,0 +1,136 @@ +// Boost.Range library +// +// Copyright Neil Groves 2007. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_REPLACED_IF_IMPL_HPP_INCLUDED +#define BOOST_RANGE_ADAPTOR_REPLACED_IF_IMPL_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class Pred, class Value > + class replace_value_if + { + public: + typedef const Value& result_type; + typedef const Value& first_argument_type; + + replace_value_if(const Pred& pred, const Value& to) + : m_pred(pred), m_to(to) + { + } + + const Value& operator()(const Value& x) const + { + return m_pred(x) ? m_to : x; + } + + private: + Pred m_pred; + Value m_to; + }; + + template< class Pred, class R > + class replace_if_range : + public boost::iterator_range< + boost::transform_iterator< + replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value::type >, + BOOST_DEDUCED_TYPENAME range_iterator::type > > + { + private: + typedef replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value::type > Fn; + + typedef boost::iterator_range< + boost::transform_iterator< + replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value::type >, + BOOST_DEDUCED_TYPENAME range_iterator::type > > base_t; + + public: + typedef BOOST_DEDUCED_TYPENAME range_value::type value_type; + + replace_if_range( R& r, const Pred& pred, value_type to ) + : base_t( make_transform_iterator( boost::begin(r), Fn(pred, to) ), + make_transform_iterator( boost::end(r), Fn(pred, to) ) ) + { } + }; + + template< class Pred, class T > + class replace_if_holder + { + public: + replace_if_holder( const Pred& pred, const T& to ) + : m_pred(pred), m_to(to) + { } + + const Pred& pred() const { return m_pred; } + const T& to() const { return m_to; } + + private: + Pred m_pred; + T m_to; + }; + + template< class Pred, class InputRng > + inline replace_if_range + operator|( InputRng& r, + const replace_if_holder::type>& f ) + { + return replace_if_range(r, f.pred(), f.to()); + } + + template< class Pred, class InputRng > + inline replace_if_range + operator|( const InputRng& r, + const replace_if_holder::type>& f ) + { + return replace_if_range(r, f.pred(), f.to()); + } + } // 'range_detail' + + using range_detail::replace_if_range; + + namespace adaptors + { + namespace + { + const range_detail::forwarder2TU + replaced_if = + range_detail::forwarder2TU(); + } + + template + inline replace_if_range + replace_if(InputRange& rng, Pred pred, + BOOST_DEDUCED_TYPENAME range_value::type to) + { + return range_detail::replace_if_range(rng, pred, to); + } + + template + inline replace_if_range + replace_if(const InputRange& rng, Pred pred, + BOOST_DEDUCED_TYPENAME range_value::type to) + { + return range_detail::replace_if_range(rng, pred, to); + } + } // 'adaptors' + +} // 'boost' + +#endif // include guard diff --git a/include/boost/range/adaptor/reversed.hpp b/include/boost/range/adaptor/reversed.hpp new file mode 100755 index 0000000..afe7517 --- /dev/null +++ b/include/boost/range/adaptor/reversed.hpp @@ -0,0 +1,90 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_REVERSED_HPP +#define BOOST_RANGE_ADAPTOR_REVERSED_HPP + +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class R > + struct reverse_range : + public boost::iterator_range< + boost::reverse_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + { + private: + typedef boost::iterator_range< + boost::reverse_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + base; + + public: + typedef boost::reverse_iterator::type> iterator; + + reverse_range( R& r ) + : base( iterator(boost::end(r)), iterator(boost::begin(r)) ) + { } + }; + + struct reverse_forwarder {}; + + template< class BidirectionalRng > + inline reverse_range + operator|( BidirectionalRng& r, reverse_forwarder ) + { + return reverse_range( r ); + } + + template< class BidirectionalRng > + inline reverse_range + operator|( const BidirectionalRng& r, reverse_forwarder ) + { + return reverse_range( r ); + } + + } // 'range_detail' + + using range_detail::reverse_range; + + namespace adaptors + { + namespace + { + const range_detail::reverse_forwarder reversed = + range_detail::reverse_forwarder(); + } + + template + inline reverse_range + reverse(BidirectionalRange& rng) + { + return reverse_range(rng); + } + + template + inline reverse_range + reverse(const BidirectionalRange& rng) + { + return reverse_range(rng); + } + } // 'adaptors' + +} // 'boost' + +#endif diff --git a/include/boost/range/adaptor/sliced.hpp b/include/boost/range/adaptor/sliced.hpp new file mode 100755 index 0000000..9629ce4 --- /dev/null +++ b/include/boost/range/adaptor/sliced.hpp @@ -0,0 +1,92 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_SLICED_HPP +#define BOOST_RANGE_ADAPTOR_SLICED_HPP + +#include +#include +#include + +namespace boost +{ + namespace adaptors + { + template< class RandomAccessRange > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + slice( RandomAccessRange& rng, std::size_t t, std::size_t u ) + { + BOOST_ASSERT( t <= u && "error in slice indices" ); + BOOST_ASSERT( static_cast(boost::size(rng)) >= u && + "second slice index out of bounds" ); + + return make_iterator_range( rng, t, u - boost::size(rng) ); + } + + template< class RandomAccessRange > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + slice( const RandomAccessRange& rng, std::size_t t, std::size_t u ) + { + BOOST_ASSERT( t <= u && "error in slice indices" ); + BOOST_ASSERT( static_cast(boost::size(rng)) >= u && + "second slice index out of bounds" ); + + return make_iterator_range( rng, t, u - boost::size(rng) ); + } + } // 'adaptors' + + namespace range_detail + { + template< class T > + struct slice_holder + : holder2 + { + slice_holder( std::size_t t, std::size_t u ) + : holder2(t,u) + { } + }; + + template + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + sliced_impl( R& r, const H& f) + { + return adaptors::slice(r, f.val1, f.val2); + } + + template< class RandomAccessRange, class Int > + inline iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > + operator|( RandomAccessRange& r, const slice_holder& f ) + { + return sliced_impl( r, f ); + } + + template< class RandomAccessRange, class Int > + inline iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > + operator|( const RandomAccessRange& r, const slice_holder& f ) + { + return sliced_impl( r, f ); + } + + } // 'range_detail' + + namespace adaptors + { + namespace + { + const range_detail::forwarder2 + sliced = range_detail::forwarder2(); + } + } + +} + +#endif diff --git a/include/boost/range/adaptor/strided.hpp b/include/boost/range/adaptor/strided.hpp new file mode 100755 index 0000000..0c394b2 --- /dev/null +++ b/include/boost/range/adaptor/strided.hpp @@ -0,0 +1,149 @@ +// Boost.Range library +// +// Copyright Neil Groves 2007. 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/ +// +#ifndef BOOST_RANGE_ADAPTOR_STRIDED_HPP_INCLUDED +#define BOOST_RANGE_ADAPTOR_STRIDED_HPP_INCLUDED + +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + + template + class strided_iterator + : public iterator_adaptor< + strided_iterator, + BaseIterator> + { + friend class iterator_core_access; + + typedef iterator_adaptor, BaseIterator> super_t; + + public: + typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::difference_type difference_type; + + strided_iterator() : m_stride() { } + + strided_iterator(const strided_iterator& other) + : super_t(other), m_stride(other.m_stride) { } + + explicit strided_iterator(BaseIterator base_it, difference_type stride) + : super_t(base_it), m_stride(stride) { } + + strided_iterator& + operator=(const strided_iterator& other) + { + super_t::operator=(other); + + // Is the interoperation of the stride safe? + m_stride = other.m_stride; + return *this; + } + + void increment() { std::advance(this->base_reference(), m_stride); } + + void decrement() { std::advance(this->base_reference(), -m_stride); } + + void advance(difference_type n) { std::advance(this->base_reference(), n * m_stride); } + + difference_type + distance_to(const strided_iterator& other) const + { + return std::distance(this->base_reference(), other.base_reference()) / m_stride; + } + + // Using the compiler generated copy constructor and + // and assignment operator + + private: + difference_type m_stride; + }; + + template inline + strided_iterator + make_strided_iterator( + const BaseIterator& first, + BOOST_DEDUCED_TYPENAME std::iterator_traits::difference_type stride) + { + return strided_iterator(first, stride); + } + + template< class Rng > + class strided_range + : public iterator_range::type> > + { + typedef range_detail::strided_iterator::type> iter_type; + typedef iterator_range super_t; + public: + template< typename Difference > + strided_range(Difference stride, Rng& rng) + : super_t(make_strided_iterator(boost::begin(rng), stride), + make_strided_iterator(boost::end(rng), stride)) + { + } + }; + + template + class strided_holder : public holder + { + public: + strided_holder(Difference value) : holder(value) {} + }; + + template + inline strided_range + operator|(Rng& rng, const strided_holder& stride) + { + return strided_range(stride.val, rng); + } + + template + inline strided_range + operator|(const Rng& rng, const strided_holder& stride) + { + return strided_range(stride.val, rng); + } + + } // namespace range_detail + + using range_detail::strided_range; + + namespace adaptors + { + + namespace + { + const range_detail::forwarder + strided = range_detail::forwarder(); + } + + template + inline strided_range + stride(Range& rng, Difference step) + { + return strided_range(step, rng); + } + + template + inline strided_range + stride(const Range& rng, Difference step) + { + return strided_range(step, rng); + } + + } // namespace 'adaptors' +} // namespace 'boost' + +#endif diff --git a/include/boost/range/adaptor/tokenized.hpp b/include/boost/range/adaptor/tokenized.hpp new file mode 100755 index 0000000..c81d515 --- /dev/null +++ b/include/boost/range/adaptor/tokenized.hpp @@ -0,0 +1,137 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_TOKENIZED_HPP +#define BOOST_RANGE_ADAPTOR_TOKENIZED_HPP + +#include +#include + +namespace boost +{ + namespace range_detail + { + + template< class R > + struct token_range : + public boost::iterator_range< + boost::regex_token_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + { + private: + typedef + boost::regex_token_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + regex_iter; + + typedef BOOST_DEDUCED_TYPENAME regex_iter::regex_type + regex_type; + + typedef boost::iterator_range + base; + + public: + template< class Regex, class Submatch, class Flag > + token_range( R& r, const Regex& re, const Submatch& sub, Flag f ) + : base( regex_iter( boost::begin(r), boost::end(r), + regex_type(re), sub, f ), + regex_iter() ) + { } + }; + + template< class T, class U, class V > + struct regex_holder + { + const T& re; + const U& sub; + V f; + + regex_holder( const T& rex, const U& subm, V flag ) : + re(rex), sub(subm), f(flag) + { } + private: + // Not assignable + void operator=(const regex_holder&); + }; + + struct regex_forwarder + { + template< class Regex > + regex_holder + operator()( const Regex& re, + int submatch = 0, + regex_constants::match_flag_type f = + regex_constants::match_default ) const + { + return regex_holder( re, submatch, f ); + } + + template< class Regex, class Submatch > + regex_holder + operator()( const Regex& re, + const Submatch& sub, + regex_constants::match_flag_type f = + regex_constants::match_default ) const + { + return regex_holder( re, sub, f ); + } + }; + + template< class BidirectionalRng, class R, class S, class F > + inline token_range + operator|( BidirectionalRng& r, + const regex_holder& f ) + { + return token_range( r, f.re, f.sub, f.f ); + } + + template< class BidirectionalRng, class R, class S, class F > + inline token_range + operator|( const BidirectionalRng& r, + const regex_holder& f ) + { + return token_range( r, f.re, f.sub, f.f ); + } + + } // 'range_detail' + + using range_detail::token_range; + + namespace adaptors + { + namespace + { + const range_detail::regex_forwarder tokenized = + range_detail::regex_forwarder(); + } + + template + inline token_range + tokenize(BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f) + { + return token_range(rng, reg, sub, f); + } + + template + inline token_range + tokenize(const BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f) + { + return token_range(rng, reg, sub, f); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptor/transformed.hpp b/include/boost/range/adaptor/transformed.hpp new file mode 100755 index 0000000..0eeaee7 --- /dev/null +++ b/include/boost/range/adaptor/transformed.hpp @@ -0,0 +1,103 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_TRANSFORMED_HPP +#define BOOST_RANGE_ADAPTOR_TRANSFORMED_HPP + +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + + template< class F, class R > + struct transform_range : + public boost::iterator_range< + boost::transform_iterator< F, + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + { + private: + typedef boost::iterator_range< + boost::transform_iterator< F, + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + base; + + public: + typedef F transform_fn_type; + typedef R source_range_type; + + transform_range( F f, R& r ) + : base( make_transform_iterator( boost::begin(r), f ), + make_transform_iterator( boost::end(r), f ) ) + + { } + }; + + template< class T > + struct transform_holder : holder + { + transform_holder( T r ) : holder(r) + { } + }; + + template< class InputRng, class UnaryFunction > + inline transform_range + operator|( InputRng& r, + const transform_holder& f ) + { + return transform_range( f.val, r ); + } + + template< class InputRng, class UnaryFunction > + inline transform_range + operator|( const InputRng& r, + const transform_holder& f ) + { + return transform_range( f.val, r ); + } + + } // 'range_detail' + + using range_detail::transform_range; + + namespace adaptors + { + namespace + { + const range_detail::forwarder + transformed = + range_detail::forwarder(); + } + + template + inline transform_range + transform(InputRange& rng, UnaryFunction fn) + { + return transform_range(fn, rng); + } + + template + inline transform_range + transform(const InputRange& rng, UnaryFunction fn) + { + return transform_range(fn, rng); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptor/uniqued.hpp b/include/boost/range/adaptor/uniqued.hpp new file mode 100755 index 0000000..28a30f2 --- /dev/null +++ b/include/boost/range/adaptor/uniqued.hpp @@ -0,0 +1,90 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP +#define BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP + +#include + +namespace boost +{ + + namespace range_detail + { + struct unique_forwarder { }; + + struct unique_not_equal_to + { + typedef bool result_type; + + template< class T > + bool operator()( const T& l, const T& r ) const + { + return !(l == r); + } + }; + + template + class unique_range : public adjacent_filter_range + { + typedef adjacent_filter_range base; + public: + explicit unique_range(ForwardRng& rng) + : base(unique_not_equal_to(), rng, true) + { + } + }; + + template< class ForwardRng > + inline unique_range + operator|( ForwardRng& r, + unique_forwarder ) + { + return unique_range(r); + } + + template< class ForwardRng > + inline unique_range + operator|( const ForwardRng& r, + unique_forwarder ) + { + return unique_range(r); + } + + } // 'range_detail' + + using range_detail::unique_range; + + namespace adaptors + { + namespace + { + const range_detail::unique_forwarder uniqued = + range_detail::unique_forwarder(); + } + + template + inline unique_range + unique(ForwardRange& rng) + { + return unique_range(rng); + } + + template + inline unique_range + unique(const ForwardRange& rng) + { + return unique_range(rng); + } + } // 'adaptors' + +} + +#endif diff --git a/include/boost/range/adaptors.hpp b/include/boost/range/adaptors.hpp new file mode 100755 index 0000000..a1fad4f --- /dev/null +++ b/include/boost/range/adaptors.hpp @@ -0,0 +1,29 @@ +// Boost.Range library +// +// Copyright Neil Groves 2007. +// Copyright Thorsten Ottosen 2006. +// 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/ +// + +#ifndef BOOST_RANGE_ADAPTORS_HPP +#define BOOST_RANGE_ADAPTORS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/boost/range/algorithm.hpp b/include/boost/range/algorithm.hpp new file mode 100755 index 0000000..b7d8dd7 --- /dev/null +++ b/include/boost/range/algorithm.hpp @@ -0,0 +1,104 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file algorithm.hpp +/// Includes the range-based versions of the algorithms in the +/// C++ standard header file +// +///////////////////////////////////////////////////////////////////////////// + +// Copyright 2009 Neil Groves. +// Distributed under 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) +// +// Acknowledgements: +// This code uses combinations of ideas, techniques and code snippets +// from: Thorsten Ottosen, Eric Niebler, Jeremy Siek, +// and Vladimir Prus' +// +// The original mutating algorithms that served as the first version +// were originally written by Vladimir Prus' +// code from Boost Wiki + +#if defined(_MSC_VER) && _MSC_VER >= 1000 +#pragma once +#endif + +#ifndef BOOST_RANGE_ALGORITHM_HPP_INCLUDED_01012009 +#define BOOST_RANGE_ALGORITHM_HPP_INCLUDED_01012009 + +#include +#include +#include +#include +#include +#include +#include + +// Non-mutating algorithms +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Mutating algorithms +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Binary search +#include +#include +#include +#include + +// Set operations of sorted ranges +#include + +// Heap operations +#include + +// Minimum and Maximum +#include +#include + +// Permutations +#include + +#endif // include guard + diff --git a/include/boost/range/algorithm/adjacent_find.hpp b/include/boost/range/algorithm/adjacent_find.hpp new file mode 100755 index 0000000..c84ecec --- /dev/null +++ b/include/boost/range/algorithm/adjacent_find.hpp @@ -0,0 +1,119 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function adjacent_find + /// + /// range-based version of the adjacent_find std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< typename ForwardRange > + inline typename range_iterator::type + adjacent_find(ForwardRange & rng) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::adjacent_find(boost::begin(rng),boost::end(rng)); + } + + /// \overload + template< typename ForwardRange > + inline typename range_iterator::type + adjacent_find(const ForwardRange& rng) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::adjacent_find(boost::begin(rng),boost::end(rng)); + } + + /// \overload + template< typename ForwardRange, typename BinaryPredicate > + inline typename range_iterator::type + adjacent_find(ForwardRange & rng, BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + typename range_value::type>)); + return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); + } + + /// \overload + template< typename ForwardRange, typename BinaryPredicate > + inline typename range_iterator::type + adjacent_find(const ForwardRange& rng, BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + typename range_value::type>)); + return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); + } + +// range_return overloads + + /// \overload + template< range_return_value re, typename ForwardRange > + inline typename range_return::type + adjacent_find(ForwardRange & rng) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), + rng); + } + + /// \overload + template< range_return_value re, typename ForwardRange > + inline typename range_return::type + adjacent_find(const ForwardRange& rng) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), + rng); + } + + /// \overload + template< range_return_value re, typename ForwardRange, typename BinaryPredicate > + inline typename range_return::type + adjacent_find(ForwardRange& rng, BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + typename range_value::type>)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), + rng); + } + + /// \overload + template< range_return_value re, typename ForwardRange, typename BinaryPredicate > + inline typename range_return::type + adjacent_find(const ForwardRange& rng, BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/binary_search.hpp b/include/boost/range/algorithm/binary_search.hpp new file mode 100755 index 0000000..666f19c --- /dev/null +++ b/include/boost/range/algorithm/binary_search.hpp @@ -0,0 +1,43 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_BINARY_SEARCH_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_BINARY_SEARCH_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function binary_search + /// + /// range-based version of the binary_search std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline bool binary_search(const ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + return std::binary_search(boost::begin(rng), boost::end(rng), val); + } + + /// \overload + template + inline bool binary_search(const ForwardRange& rng, const Value& val, + BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::binary_search(boost::begin(rng), boost::end(rng), val, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/copy.hpp b/include/boost/range/algorithm/copy.hpp new file mode 100644 index 0000000..27b88ab --- /dev/null +++ b/include/boost/range/algorithm/copy.hpp @@ -0,0 +1,35 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function copy + /// + /// range-based version of the copy std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + template< class SinglePassRange, class OutputIterator > + inline OutputIterator copy(const SinglePassRange& rng, OutputIterator out) + { + //BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::copy(boost::begin(rng),boost::end(rng),out); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/copy_backward.hpp b/include/boost/range/algorithm/copy_backward.hpp new file mode 100755 index 0000000..34dbebb --- /dev/null +++ b/include/boost/range/algorithm/copy_backward.hpp @@ -0,0 +1,37 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_COPY_BACKWARD_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_COPY_BACKWARD_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function copy_backward + /// + /// range-based version of the copy_backwards std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + /// \pre BidirectionalTraversalWriteableIterator is a model of the BidirectionalIteratorConcept + /// \pre BidirectionalTraversalWriteableIterator is a model of the WriteableIteratorConcept + template< class BidirectionalRange, class BidirectionalTraversalWriteableIterator > + inline BidirectionalTraversalWriteableIterator + copy_backward(const BidirectionalRange& rng, + BidirectionalTraversalWriteableIterator out) + { + boost::function_requires< BidirectionalRangeConcept >(); + return std::copy_backward(boost::begin(rng), boost::end(rng), out); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/count.hpp b/include/boost/range/algorithm/count.hpp new file mode 100755 index 0000000..e695a0c --- /dev/null +++ b/include/boost/range/algorithm/count.hpp @@ -0,0 +1,44 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function count + /// + /// range-based version of the count std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + template< class SinglePassRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_difference::type + count(SinglePassRange& rng, const Value& val) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::count(boost::begin(rng), boost::end(rng), val); + } + + /// \overload + template< class SinglePassRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_difference::type + count(const SinglePassRange& rng, const Value& val) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::count(boost::begin(rng), boost::end(rng), val); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/count_if.hpp b/include/boost/range/algorithm/count_if.hpp new file mode 100755 index 0000000..9f8b929 --- /dev/null +++ b/include/boost/range/algorithm/count_if.hpp @@ -0,0 +1,45 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_COUNT_IF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_COUNT_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function count_if + /// + /// range-based version of the count_if std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre UnaryPredicate is a model of the UnaryPredicateConcept + template< class SinglePassRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME boost::range_difference::type + count_if(SinglePassRange& rng, UnaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::count_if(boost::begin(rng), boost::end(rng), pred); + } + + /// \overload + template< class SinglePassRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME boost::range_difference::type + count_if(const SinglePassRange& rng, UnaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::count_if(boost::begin(rng), boost::end(rng), pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/equal.hpp b/include/boost/range/algorithm/equal.hpp new file mode 100755 index 0000000..a7be749 --- /dev/null +++ b/include/boost/range/algorithm/equal.hpp @@ -0,0 +1,182 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. +// 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED + +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + // An implementation of equality comparison that is optimized for iterator + // traversal categories less than RandomAccessTraversal. + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2, + class IteratorCategoryTag1, + class IteratorCategoryTag2 > + inline bool equal_impl( SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2, + IteratorCategoryTag1, + IteratorCategoryTag2 ) + { + do + { + // If we have reached the end of the left range then this is + // the end of the loop. They are equal if and only if we have + // simultaneously reached the end of the right range. + if (first1 == last1) + return first2 == last2; + + // If we have reached the end of the right range at this line + // it indicates that the right range is shorter than the left + // and hence the result is false. + if (first2 == last2) + return false; + + // continue looping if and only if the values are equal + } while(*first1++ == *first2++); + + // Reaching this line in the algorithm indicates that a value + // inequality has been detected. + return false; + } + + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2, + class IteratorCategoryTag1, + class IteratorCategoryTag2, + class BinaryPredicate > + inline bool equal_impl( SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2, + BinaryPredicate pred, + IteratorCategoryTag1, + IteratorCategoryTag2 ) + { + do + { + // If we have reached the end of the left range then this is + // the end of the loop. They are equal if and only if we have + // simultaneously reached the end of the right range. + if (first1 == last1) + return first2 == last2; + + // If we have reached the end of the right range at this line + // it indicates that the right range is shorter than the left + // and hence the result is false. + if (first2 == last2) + return false; + + // continue looping if and only if the values are equal + } while(pred(*first1++, *first2++)); + + // Reaching this line in the algorithm indicates that a value + // inequality has been detected. + return false; + } + + // An implementation of equality comparison that is optimized for + // random access iterators. + template< class RandomAccessTraversalReadableIterator1, + class RandomAccessTraversalReadableIterator2 > + inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1, + RandomAccessTraversalReadableIterator1 last1, + RandomAccessTraversalReadableIterator2 first2, + RandomAccessTraversalReadableIterator2 last2, + std::random_access_iterator_tag, + std::random_access_iterator_tag ) + { + return ((last1 - first1) == (last2 - first2)) + && std::equal(first1, last1, first2); + } + + template< class RandomAccessTraversalReadableIterator1, + class RandomAccessTraversalReadableIterator2, + class BinaryPredicate > + inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1, + RandomAccessTraversalReadableIterator1 last1, + RandomAccessTraversalReadableIterator2 first2, + RandomAccessTraversalReadableIterator2 last2, + BinaryPredicate pred ) + { + return ((last1 - first1) == (last2 - first2)) + && std::equal(first1, last1, first2, pred); + } + + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2 > + inline bool equal( SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2 ) + { + BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1; + BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2; + + return equal_impl(first1, last1, first2, last2, tag1, tag2); + } + + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2, + class BinaryPredicate > + inline bool equal( SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2, + BinaryPredicate pred ) + { + BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1; + BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2; + + return equal_impl(first1, last1, first2, last2, pred, tag1, tag2); + } + + } + + /// \brief template function equal + /// + /// range-based version of the equal std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class SinglePassRange1, class SinglePassRange2 > + inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 ) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::equal( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2) ); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > + inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2, + BinaryPredicate pred ) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::equal( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), + pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/equal_range.hpp b/include/boost/range/algorithm/equal_range.hpp new file mode 100755 index 0000000..235b9db --- /dev/null +++ b/include/boost/range/algorithm/equal_range.hpp @@ -0,0 +1,74 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EQUAL_RANGE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EQUAL_RANGE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function equal_range + /// + /// range-based version of the equal_range std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre SortPredicate is a model of the BinaryPredicateConcept + template + inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > + equal_range(ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + return std::equal_range(boost::begin(rng), boost::end(rng), val); + } + + /// \overload + template + inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > + equal_range(const ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + return std::equal_range(boost::begin(rng), boost::end(rng), val); + } + + /// \overload + template + inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > + equal_range(ForwardRange& rng, const Value& val, SortPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); + } + + /// \overload + template + inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > + equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/fill.hpp b/include/boost/range/algorithm/fill.hpp new file mode 100755 index 0000000..cc4b352 --- /dev/null +++ b/include/boost/range/algorithm/fill.hpp @@ -0,0 +1,34 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function fill + /// + /// range-based version of the fill std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class Value > + inline ForwardRange& fill(ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + std::fill(boost::begin(rng), boost::end(rng), val); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/fill_n.hpp b/include/boost/range/algorithm/fill_n.hpp new file mode 100755 index 0000000..2283e23 --- /dev/null +++ b/include/boost/range/algorithm/fill_n.hpp @@ -0,0 +1,36 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FILL_N_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FILL_N_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function fill_n + /// + /// range-based version of the fill_n std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class Size, class Value > + inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + BOOST_ASSERT( static_cast(std::distance(boost::begin(rng), boost::end(rng))) >= n ); + std::fill_n(boost::begin(rng), n, val); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/find.hpp b/include/boost/range/algorithm/find.hpp new file mode 100755 index 0000000..1f9c667 --- /dev/null +++ b/include/boost/range/algorithm/find.hpp @@ -0,0 +1,66 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function find + /// + /// range-based version of the find std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + template< class SinglePassRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find( SinglePassRange& rng, const Value& val ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::find(boost::begin(rng), boost::end(rng), val); + } + /// \overload + template< class SinglePassRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find( const SinglePassRange& rng, const Value& val ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::find(boost::begin(rng), boost::end(rng), val); + } + +// range_return overloads + + /// \overload + template< range_return_value re, class SinglePassRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + find( SinglePassRange& rng, const Value& val ) + { + boost::function_requires< SinglePassRangeConcept >(); + return range_return:: + pack(std::find(boost::begin(rng), boost::end(rng), val), + rng); + } + /// \overload + template< range_return_value re, class SinglePassRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + find( const SinglePassRange& rng, const Value& val ) + { + boost::function_requires< SinglePassRangeConcept >(); + return range_return:: + pack(std::find(boost::begin(rng), boost::end(rng), val), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/find_end.hpp b/include/boost/range/algorithm/find_end.hpp new file mode 100755 index 0000000..a16478a --- /dev/null +++ b/include/boost/range/algorithm/find_end.hpp @@ -0,0 +1,136 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function find_end + /// + /// range-based version of the find_end std algorithm + /// + /// \pre ForwardRange1 is a model of the ForwardRangeConcept + /// \pre ForwardRange2 is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type + find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template< class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); + } + + /// \overload + template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_end(ForwardRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_end(const ForwardRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred), + rng1); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred), + rng1); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/find_first_of.hpp b/include/boost/range/algorithm/find_first_of.hpp new file mode 100755 index 0000000..70d143c --- /dev/null +++ b/include/boost/range/algorithm/find_first_of.hpp @@ -0,0 +1,139 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FIND_FIRST_OF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FIND_FIRST_OF_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function find_first_of + /// + /// range-based version of the find_first_of std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre ForwardRange2 is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class SinglePassRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template< class SinglePassRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_first_of(SinglePassRange1 const & rng1, ForwardRange2 const & rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); + } + + /// \overload + template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); + } + +// range return overloads + /// \overload + template< range_return_value re, class SinglePassRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); + } + + /// \overload + template< range_return_value re, class SinglePassRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); + } + + /// \overload + template< range_return_value re, class SinglePassRange1, class ForwardRange2, + class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred), + rng1); + } + + /// \overload + template< range_return_value re, class SinglePassRange1, class ForwardRange2, + class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2),pred), + rng1); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/find_if.hpp b/include/boost/range/algorithm/find_if.hpp new file mode 100755 index 0000000..9d13f29 --- /dev/null +++ b/include/boost/range/algorithm/find_if.hpp @@ -0,0 +1,69 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FIND_IF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FIND_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function find_if + /// + /// range-based version of the find_if std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre UnaryPredicate is a model of the UnaryPredicateConcept + template< class SinglePassRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_if( SinglePassRange& rng, UnaryPredicate pred ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::find_if(boost::begin(rng), boost::end(rng), pred); + } + /// \overload + template< class SinglePassRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + find_if( const SinglePassRange& rng, UnaryPredicate pred ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::find_if(boost::begin(rng), boost::end(rng), pred); + } + +// range_return overloads + + /// \overload + template< range_return_value re, class SinglePassRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_if( SinglePassRange& rng, UnaryPredicate pred ) + { + boost::function_requires< SinglePassRangeConcept >(); + return range_return:: + pack(std::find_if(boost::begin(rng), boost::end(rng), pred), + rng); + } + /// \overload + template< range_return_value re, class SinglePassRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + find_if( const SinglePassRange& rng, UnaryPredicate pred ) + { + boost::function_requires< SinglePassRangeConcept >(); + return range_return:: + pack(std::find_if(boost::begin(rng), boost::end(rng), pred), + rng); + } + + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/for_each.hpp b/include/boost/range/algorithm/for_each.hpp new file mode 100755 index 0000000..689b3e4 --- /dev/null +++ b/include/boost/range/algorithm/for_each.hpp @@ -0,0 +1,42 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function for_each + /// + /// range-based version of the for_each std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre UnaryFunction is a model of the UnaryFunctionConcept + template< class SinglePassRange, class UnaryFunction > + inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun) + { + boost::function_requires< SinglePassRangeConcept< SinglePassRange > >(); + return std::for_each(boost::begin(rng),boost::end(rng),fun); + } + + /// \overload + template< class SinglePassRange, class UnaryFunction > + inline UnaryFunction for_each(SinglePassRange const & rng, UnaryFunction fun) + { + boost::function_requires< SinglePassRangeConcept< SinglePassRange > >(); + return std::for_each(boost::begin(rng),boost::end(rng),fun); + } +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/algorithm/generate.hpp b/include/boost/range/algorithm/generate.hpp new file mode 100755 index 0000000..48bdb70 --- /dev/null +++ b/include/boost/range/algorithm/generate.hpp @@ -0,0 +1,44 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_GENERATE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_GENERATE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function generate + /// + /// range-based version of the generate std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre Generator is a model of the UnaryFunctionConcept + template< class ForwardRange, class Generator > + inline ForwardRange& generate( ForwardRange& rng, Generator gen ) + { + boost::function_requires< ForwardRangeConcept >(); + std::generate(boost::begin(rng), boost::end(rng), gen); + return rng; + } + + /// \overload + template< class ForwardRange, class Generator > + inline const ForwardRange& generate(const ForwardRange& rng, Generator gen) + { + boost::function_requires< ForwardRangeConcept >(); + std::generate(boost::begin(rng), boost::end(rng), gen); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/heap_algorithm.hpp b/include/boost/range/algorithm/heap_algorithm.hpp new file mode 100755 index 0000000..411b1ab --- /dev/null +++ b/include/boost/range/algorithm/heap_algorithm.hpp @@ -0,0 +1,169 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function push_heap + /// + /// range-based version of the push_heap std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre Compare is a model of the BinaryPredicateConcept + template + inline void push_heap(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::push_heap(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline void push_heap(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::push_heap(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline void push_heap(RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \overload + template + inline void push_heap(const RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \brief template function pop_heap + /// + /// range-based version of the pop_heap std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre Compare is a model of the BinaryPredicateConcept + template + inline void pop_heap(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::pop_heap(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline void pop_heap(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::pop_heap(boost::begin(rng),boost::end(rng)); + } + + /// \overload + template + inline void pop_heap(RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \overload + template + inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \brief template function make_heap + /// + /// range-based version of the make_heap std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre Compare is a model of the BinaryPredicateConcept + template + inline void make_heap(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::make_heap(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline void make_heap(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::make_heap(boost::begin(rng),boost::end(rng)); + } + + /// \overload + template + inline void make_heap(RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \overload + template + inline void make_heap(const RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \brief template function sort_heap + /// + /// range-based version of the sort_heap std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre Compare is a model of the BinaryPredicateConcept + template + inline void sort_heap(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort_heap(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline void sort_heap(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort_heap(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline void sort_heap(RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); + } + + /// \overload + template + inline void sort_heap(const RandomAccessRange& rng, Compare comp_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/inplace_merge.hpp b/include/boost/range/algorithm/inplace_merge.hpp new file mode 100755 index 0000000..419dabf --- /dev/null +++ b/include/boost/range/algorithm/inplace_merge.hpp @@ -0,0 +1,68 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_INPLACE_MERGE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_INPLACE_MERGE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function inplace_merge + /// + /// range-based version of the inplace_merge std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle) + { + boost::function_requires< BidirectionalRangeConcept >(); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); + return rng; + } + + /// \overload + template + inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle) + { + boost::function_requires< BidirectionalRangeConcept >(); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); + return rng; + } + + /// \overload + template + inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, + BinaryPredicate pred) + { + boost::function_requires< BidirectionalRangeConcept >(); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); + return rng; + } + + /// \overload + template + inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, + BinaryPredicate pred) + { + boost::function_requires< BidirectionalRangeConcept >(); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/lexicographical_compare.hpp b/include/boost/range/algorithm/lexicographical_compare.hpp new file mode 100755 index 0000000..dc79d09 --- /dev/null +++ b/include/boost/range/algorithm/lexicographical_compare.hpp @@ -0,0 +1,52 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function lexicographic_compare + /// + /// range-based version of the lexicographic_compare std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + template + inline bool lexicographical_compare(const SinglePassRange1& rng1, + const SinglePassRange2& rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::lexicographical_compare( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + } + + /// \overload + template + inline bool lexicographical_compare(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::lexicographical_compare( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/lower_bound.hpp b/include/boost/range/algorithm/lower_bound.hpp new file mode 100755 index 0000000..3bd313e --- /dev/null +++ b/include/boost/range/algorithm/lower_bound.hpp @@ -0,0 +1,99 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function lower_bound + /// + /// range-based version of the lower_bound std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + lower_bound( ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::lower_bound(boost::begin(rng), boost::end(rng), val); + } + /// \overload + template< class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + lower_bound( const ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::lower_bound(boost::begin(rng), boost::end(rng), val); + } + /// \overload + template< class ForwardRange, class Value, class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); + } + /// \overload + template< class ForwardRange, class Value, class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + lower_bound( ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + lower_bound( const ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value, class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value, class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/max_element.hpp b/include/boost/range/algorithm/max_element.hpp new file mode 100755 index 0000000..8274ff3 --- /dev/null +++ b/include/boost/range/algorithm/max_element.hpp @@ -0,0 +1,109 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function max_element + /// + /// range-based version of the max_element std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + max_element(ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return std::max_element(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + max_element(const ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return std::max_element(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + max_element(ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::max_element(boost::begin(rng), boost::end(rng), pred); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + max_element(const ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::max_element(boost::begin(rng), boost::end(rng), pred); + } + +// range_return overloads + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + max_element(ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng)), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + max_element(const ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng)), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + max_element(ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng), pred), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + max_element(const ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng), pred), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/merge.hpp b/include/boost/range/algorithm/merge.hpp new file mode 100755 index 0000000..61bf7c2 --- /dev/null +++ b/include/boost/range/algorithm/merge.hpp @@ -0,0 +1,55 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_MERGE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_MERGE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function merge + /// + /// range-based version of the merge std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + /// + template + inline OutputIterator merge(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::merge(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); + } + + /// \overload + template + inline OutputIterator merge(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::merge(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/min_element.hpp b/include/boost/range/algorithm/min_element.hpp new file mode 100755 index 0000000..66f87f0 --- /dev/null +++ b/include/boost/range/algorithm/min_element.hpp @@ -0,0 +1,109 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function min_element + /// + /// range-based version of the min_element std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + min_element(ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return std::min_element(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + min_element(const ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return std::min_element(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + min_element(ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::min_element(boost::begin(rng), boost::end(rng), pred); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + min_element(const ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::min_element(boost::begin(rng), boost::end(rng), pred); + } + +// range_return overloads + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + min_element(ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng)), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + min_element(const ForwardRange& rng) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng)), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + min_element(ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng), pred), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + min_element(const ForwardRange& rng, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng), pred), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/mismatch.hpp b/include/boost/range/algorithm/mismatch.hpp new file mode 100755 index 0000000..71198c2 --- /dev/null +++ b/include/boost/range/algorithm/mismatch.hpp @@ -0,0 +1,182 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_MISMATCH_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_MISMATCH_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2 > + inline std::pair + mismatch_impl(SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2) + { + while (first1 != last1 && first2 != last2 && *first1 == *first2) + { + ++first1; + ++first2; + } + return std::pair(first1, first2); + } + + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2, + class BinaryPredicate > + inline std::pair + mismatch_impl(SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2, + BinaryPredicate pred) + { + while (first1 != last1 && first2 != last2 && pred(*first1, *first2)) + { + ++first1; + ++first2; + } + return std::pair(first1, first2); + } + } + + /// \brief template function mismatch + /// + /// range-based version of the mismatch std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class SinglePassRange1, class SinglePassRange2 > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2 > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2 > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2 > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + } + + + /// \overload + template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } + + /// \overload + template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > + inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > + mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + + return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/nth_element.hpp b/include/boost/range/algorithm/nth_element.hpp new file mode 100755 index 0000000..d082a6a --- /dev/null +++ b/include/boost/range/algorithm/nth_element.hpp @@ -0,0 +1,64 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_NTH_ELEMENT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_NTH_ELEMENT_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function nth_element + /// + /// range-based version of the nth_element std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline void nth_element(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::nth_element(boost::begin(rng), nth, boost::end(rng)); + } + + /// \overload + template + inline void nth_element(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::nth_element(boost::begin(rng),nth,boost::end(rng)); + } + + /// \overload + template + inline void nth_element(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth, + BinaryPredicate sort_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred); + } + + /// \overload + template + inline void nth_element(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth, + BinaryPredicate sort_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::nth_element(boost::begin(rng),nth,boost::end(rng), sort_pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/partial_sort.hpp b/include/boost/range/algorithm/partial_sort.hpp new file mode 100755 index 0000000..a80d544 --- /dev/null +++ b/include/boost/range/algorithm/partial_sort.hpp @@ -0,0 +1,65 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function partial_sort + /// + /// range-based version of the partial_sort std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline void partial_sort(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::partial_sort(boost::begin(rng), middle, boost::end(rng)); + } + + /// \overload + template + inline void partial_sort(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::partial_sort(boost::begin(rng), middle, boost::end(rng)); + } + + /// \overload + template + inline void partial_sort(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle, + BinaryPredicate sort_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::partial_sort(boost::begin(rng), middle, boost::end(rng), + sort_pred); + } + + /// \overload + template + inline void partial_sort(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle, + BinaryPredicate sort_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/partial_sort_copy.hpp b/include/boost/range/algorithm/partial_sort_copy.hpp new file mode 100755 index 0000000..5adf435 --- /dev/null +++ b/include/boost/range/algorithm/partial_sort_copy.hpp @@ -0,0 +1,58 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function partial_sort_copy + /// + /// range-based version of the partial_sort_copy std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre RandomAccessRange is a model of the Mutable_RandomAccessRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline typename range_iterator::type + partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2) + { + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); + BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); + BOOST_CONCEPT_ASSERT((LessThanComparableConcept::type>)); + + return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + } + + /// \overload + template + inline typename range_iterator::type + partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2, + BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); + BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); + + return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/partition.hpp b/include/boost/range/algorithm/partition.hpp new file mode 100755 index 0000000..779a32d --- /dev/null +++ b/include/boost/range/algorithm/partition.hpp @@ -0,0 +1,68 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_PARTITION__HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_PARTITION__HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function partition + /// + /// range-based version of the partition std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + partition(ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::partition(boost::begin(rng),boost::end(rng),pred); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + partition(const ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::partition(boost::begin(rng),boost::end(rng),pred); + } + +// range_return overloads + + /// \overload + template< range_return_value re, class ForwardRange, + class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + partition(ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return boost::range_return:: + pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); + } + + /// \overload + template< range_return_value re, class ForwardRange, + class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + partition(const ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return boost::range_return:: + pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/permutation.hpp b/include/boost/range/algorithm/permutation.hpp new file mode 100755 index 0000000..01dee35 --- /dev/null +++ b/include/boost/range/algorithm/permutation.hpp @@ -0,0 +1,117 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function next_permutation + /// + /// range-based version of the next_permutation std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + /// \pre Compare is a model of the BinaryPredicateConcept + template + inline bool next_permutation(BidirectionalRange& rng) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::next_permutation(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline bool next_permutation(const BidirectionalRange& rng) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::next_permutation(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::next_permutation(boost::begin(rng), boost::end(rng), + comp_pred); + } + + /// \overload + template + inline bool next_permutation(const BidirectionalRange& rng, + Compare comp_pred) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::next_permutation(boost::begin(rng), boost::end(rng), + comp_pred); + } + + /// \brief template function prev_permutation + /// + /// range-based version of the prev_permutation std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + /// \pre Compare is a model of the BinaryPredicateConcept + template + inline bool prev_permutation(BidirectionalRange& rng) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::prev_permutation(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline bool prev_permutation(const BidirectionalRange& rng) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::prev_permutation(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::prev_permutation(boost::begin(rng), boost::end(rng), + comp_pred); + } + + /// \overload + template + inline bool prev_permutation(const BidirectionalRange& rng, + Compare comp_pred) + { + boost::function_requires< + BidirectionalRangeConcept >(); + + return std::prev_permutation(boost::begin(rng), boost::end(rng), + comp_pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/random_shuffle.hpp b/include/boost/range/algorithm/random_shuffle.hpp new file mode 100755 index 0000000..dbc35b0 --- /dev/null +++ b/include/boost/range/algorithm/random_shuffle.hpp @@ -0,0 +1,62 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function random_shuffle + /// + /// range-based version of the random_shuffle std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre Generator is a model of the UnaryFunctionConcept + template + inline RandomAccessRange& random_shuffle(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::random_shuffle(boost::begin(rng), boost::end(rng)); + return rng; + } + + /// \overload + template + inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::random_shuffle(boost::begin(rng),boost::end(rng)); + return rng; + } + + /// \overload + template + inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::random_shuffle(boost::begin(rng), boost::end(rng), gen); + return rng; + } + + /// \overload + template + inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::random_shuffle(boost::begin(rng), boost::end(rng), gen); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/remove.hpp b/include/boost/range/algorithm/remove.hpp new file mode 100755 index 0000000..093d831 --- /dev/null +++ b/include/boost/range/algorithm/remove.hpp @@ -0,0 +1,70 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function remove + /// + /// range-based version of the remove std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + remove(ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + return std::remove(boost::begin(rng),boost::end(rng),val); + } + + /// \overload + template< class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + remove(const ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + return std::remove(boost::begin(rng),boost::end(rng),val); + } + +// range_return overloads + + /// \overload + template< range_return_value re, class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + remove(ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + + return range_return::pack( + std::remove(boost::begin(rng), boost::end(rng), val), + rng); + } + + /// \overload + template< range_return_value re, class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + remove(const ForwardRange& rng, const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + + return range_return::pack( + std::remove(boost::begin(rng), boost::end(rng), val), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/remove_copy.hpp b/include/boost/range/algorithm/remove_copy.hpp new file mode 100755 index 0000000..75b84cb --- /dev/null +++ b/include/boost/range/algorithm/remove_copy.hpp @@ -0,0 +1,38 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function remove_copy + /// + /// range-based version of the remove_copy std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + /// \pre Value is a model of the EqualityComparableConcept + /// \pre Objects of type Value can be compared for equality with objects of + /// InputIterator's value type. + template< class SinglePassRange, class OutputIterator, class Value > + inline OutputIterator + remove_copy(SinglePassRange& rng, OutputIterator out_it, const Value& val) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/remove_copy_if.hpp b/include/boost/range/algorithm/remove_copy_if.hpp new file mode 100755 index 0000000..665b359 --- /dev/null +++ b/include/boost/range/algorithm/remove_copy_if.hpp @@ -0,0 +1,38 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function remove_copy_if + /// + /// range-based version of the remove_copy_if std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + /// \pre Predicate is a model of the PredicateConcept + /// \pre InputIterator's value type is convertible to Predicate's argument type + /// \pre out_it is not an iterator in the range rng + template< class SinglePassRange, class OutputIterator, class Predicate > + inline OutputIterator + remove_copy_if(SinglePassRange& rng, OutputIterator out_it, Predicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/remove_if.hpp b/include/boost/range/algorithm/remove_if.hpp new file mode 100755 index 0000000..2c0bbe9 --- /dev/null +++ b/include/boost/range/algorithm/remove_if.hpp @@ -0,0 +1,70 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REMOVE_IF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REMOVE_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function remove_if + /// + /// range-based version of the remove_if std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre UnaryPredicate is a model of the UnaryPredicateConcept + template< class ForwardRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type + remove_if(ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::remove_if(boost::begin(rng), boost::end(rng), pred); + } + + /// \overload + template< class ForwardRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type + remove_if(const ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return std::remove_if(boost::begin(rng),boost::end(rng),pred); + } + +// range_return overloads + + /// \overload + template< range_return_value re, class ForwardRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + remove_if(ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::remove_if(boost::begin(rng), boost::end(rng), pred), + rng); + } + + /// \overload + template< range_return_value re, class ForwardRange, class UnaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + remove_if(const ForwardRange& rng, UnaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return::pack( + std::remove_if(boost::begin(rng), boost::end(rng), pred), + rng); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/replace.hpp b/include/boost/range/algorithm/replace.hpp new file mode 100755 index 0000000..ec105de --- /dev/null +++ b/include/boost/range/algorithm/replace.hpp @@ -0,0 +1,47 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REPLACE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REPLACE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function replace + /// + /// range-based version of the replace std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class Value > + inline ForwardRange& + replace(ForwardRange& rng, const Value& what, + const Value& with_what) + { + boost::function_requires< ForwardRangeConcept >(); + std::replace(boost::begin(rng), boost::end(rng), what, with_what); + return rng; + } + + /// \overload + template< class ForwardRange, class Value > + inline const ForwardRange& + replace(const ForwardRange& rng, const Value& what, + const Value& with_what) + { + boost::function_requires< ForwardRangeConcept >(); + std::replace(boost::begin(rng), boost::end(rng), what, with_what); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/replace_copy.hpp b/include/boost/range/algorithm/replace_copy.hpp new file mode 100755 index 0000000..f4250b1 --- /dev/null +++ b/include/boost/range/algorithm/replace_copy.hpp @@ -0,0 +1,36 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REPLACE_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function replace_copy + /// + /// range-based version of the replace_copy std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class OutputIterator, class Value > + inline OutputIterator + replace_copy(ForwardRange& rng, OutputIterator out_it, const Value& what, + const Value& with_what) + { + boost::function_requires< ForwardRangeConcept >(); + return std::replace_copy(boost::begin(rng), boost::end(rng), out_it, + what, with_what); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/replace_copy_if.hpp b/include/boost/range/algorithm/replace_copy_if.hpp new file mode 100755 index 0000000..c03cb95 --- /dev/null +++ b/include/boost/range/algorithm/replace_copy_if.hpp @@ -0,0 +1,40 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function replace_copy_if + /// + /// range-based version of the replace_copy_if std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre Predicate is a model of the PredicateConcept + /// \pre Value is convertible to Predicate's argument type + /// \pre Value is Assignable + /// \pre Value is convertible to a type in OutputIterator's set of value types. + template< class ForwardRange, class OutputIterator, class Predicate, class Value > + inline OutputIterator + replace_copy_if(ForwardRange& rng, OutputIterator out_it, Predicate pred, + const Value& with_what) + { + boost::function_requires< ForwardRangeConcept >(); + return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it, + pred, with_what); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/replace_if.hpp b/include/boost/range/algorithm/replace_if.hpp new file mode 100755 index 0000000..bbee464 --- /dev/null +++ b/include/boost/range/algorithm/replace_if.hpp @@ -0,0 +1,49 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REPLACE_IF_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REPLACE_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function replace_if + /// + /// range-based version of the replace_if std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre UnaryPredicate is a model of the UnaryPredicateConcept + template< class ForwardRange, class UnaryPredicate, class Value > + inline ForwardRange& + replace_if(ForwardRange& rng, UnaryPredicate pred, + const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + std::replace_if(boost::begin(rng), boost::end(rng), pred, val); + return rng; + } + + /// \overload + template< class ForwardRange, class UnaryPredicate, class Value > + inline const ForwardRange& + replace_if(const ForwardRange& rng, UnaryPredicate pred, + const Value& val) + { + boost::function_requires< ForwardRangeConcept >(); + std::replace_if(boost::begin(rng), boost::end(rng), pred, val); + return rng; + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/reverse.hpp b/include/boost/range/algorithm/reverse.hpp new file mode 100755 index 0000000..3015d1d --- /dev/null +++ b/include/boost/range/algorithm/reverse.hpp @@ -0,0 +1,44 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function reverse + /// + /// range-based version of the reverse std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + template + inline BidirectionalRange& reverse(BidirectionalRange& rng) + { + boost::function_requires< BidirectionalRangeConcept >(); + std::reverse(boost::begin(rng), boost::end(rng)); + return rng; + } + + /// \overload + template + inline const BidirectionalRange& reverse(const BidirectionalRange& rng) + { + boost::function_requires< BidirectionalRangeConcept >(); + std::reverse(boost::begin(rng), boost::end(rng)); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/reverse_copy.hpp b/include/boost/range/algorithm/reverse_copy.hpp new file mode 100755 index 0000000..817675a --- /dev/null +++ b/include/boost/range/algorithm/reverse_copy.hpp @@ -0,0 +1,42 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_REVERSE_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_REVERSE_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function reverse_copy + /// + /// range-based version of the reverse_copy std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + template + inline OutputIterator reverse_copy(BidirectionalRange& rng, OutputIterator out) + { + BOOST_CONCEPT_ASSERT((BidirectionalRangeConcept)); + return std::reverse_copy(boost::begin(rng), boost::end(rng), out); + } + + /// \overload + template + inline OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out) + { + BOOST_CONCEPT_ASSERT((BidirectionalRangeConcept)); + return std::reverse_copy(boost::begin(rng), boost::end(rng), out); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/rotate.hpp b/include/boost/range/algorithm/rotate.hpp new file mode 100755 index 0000000..27eb0c9 --- /dev/null +++ b/include/boost/range/algorithm/rotate.hpp @@ -0,0 +1,46 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_ROTATE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_ROTATE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function rotate + /// + /// range-based version of the rotate std algorithm + /// + /// \pre Rng meets the requirements for a Forward range + template + inline ForwardRange& rotate(ForwardRange& rng, + typename range_iterator::type middle) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + std::rotate(boost::begin(rng), middle, boost::end(rng)); + return rng; + } + + /// \overload + template + inline const ForwardRange& + rotate(const ForwardRange& rng, + typename range_iterator::type middle) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + std::rotate(boost::begin(rng), middle, boost::end(rng)); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/rotate_copy.hpp b/include/boost/range/algorithm/rotate_copy.hpp new file mode 100755 index 0000000..123ea04 --- /dev/null +++ b/include/boost/range/algorithm/rotate_copy.hpp @@ -0,0 +1,38 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function rotate + /// + /// range-based version of the rotate std algorithm + /// + /// \pre Rng meets the requirements for a Forward range + template + inline OutputIterator rotate_copy( + const ForwardRange& rng, + typename range_iterator::type middle, + OutputIterator target + ) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::rotate_copy(boost::begin(rng), middle, boost::end(rng), target); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/search.hpp b/include/boost/range/algorithm/search.hpp new file mode 100755 index 0000000..62f61e0 --- /dev/null +++ b/include/boost/range/algorithm/search.hpp @@ -0,0 +1,131 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function search + /// + /// range-based version of the search std algorithm + /// + /// \pre ForwardRange1 is a model of the ForwardRangeConcept + /// \pre ForwardRange2 is a model of the ForwardRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + search(ForwardRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template< class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + search(const ForwardRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); + } + + /// \overload + template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + search(const ForwardRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); + } + +// range_return overloads + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_return::type + search(ForwardRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)), + rng1); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2 > + inline BOOST_DEDUCED_TYPENAME range_return::type + search(const ForwardRange1& rng1, const ForwardRange2& rng2) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)), + rng1); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred), + rng1); + } + + /// \overload + template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + search(const ForwardRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< ForwardRangeConcept >(); + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred), + rng1); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/search_n.hpp b/include/boost/range/algorithm/search_n.hpp new file mode 100755 index 0000000..65f2510 --- /dev/null +++ b/include/boost/range/algorithm/search_n.hpp @@ -0,0 +1,140 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_SEARCH_N_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_SEARCH_N_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function search + /// + /// range-based version of the search std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + /// \pre Integer is an integral type + /// \pre Value is a model of the EqualityComparableConcept + /// \pre ForwardRange's value type is a model of the EqualityComparableConcept + /// \pre Object's of ForwardRange's value type can be compared for equality with Objects of type Value + template< typename ForwardRange, typename Integer, typename Value > + inline typename range_iterator::type + search_n(ForwardRange& rng, Integer count, const Value& value) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::search_n(boost::begin(rng),boost::end(rng), count, value); + } + + /// \overload + template< typename ForwardRange, typename Integer, typename Value > + inline typename range_iterator::type + search_n(const ForwardRange& rng, Integer count, const Value& value) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::search_n(boost::begin(rng), boost::end(rng), count, value); + } + + /// \overload + template< typename ForwardRange, typename Integer, class Value, + typename BinaryPredicate > + inline typename range_iterator::type + search_n(ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate binary_pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); + return std::search_n(boost::begin(rng), boost::end(rng), + count, value, binary_pred); + } + + /// \overload + template< typename ForwardRange, typename Integer, typename Value, + typename BinaryPredicate > + inline typename range_iterator::type + search_n(const ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate binary_pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); + return std::search_n(boost::begin(rng), boost::end(rng), + count, value, binary_pred); + } + +// range_return overloads + + /// \overload + template< range_return_value re, typename ForwardRange, typename Integer, + typename Value > + inline typename range_return::type + search_n(ForwardRange& rng, Integer count, const Value& value) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::search_n(boost::begin(rng),boost::end(rng), + count, value), + rng); + } + + /// \overload + template< range_return_value re, typename ForwardRange, typename Integer, + class Value > + inline typename range_return::type + search_n(const ForwardRange& rng, Integer count, const Value& value) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::search_n(boost::begin(rng), boost::end(rng), + count, value), + rng); + } + + /// \overload + template< range_return_value re, typename ForwardRange, typename Integer, + typename Value, typename BinaryPredicate > + inline typename range_return::type + search_n(ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + const Value&>)); + return range_return:: + pack(std::search_n(boost::begin(rng), boost::end(rng), + count, value, pred), + rng); + } + + /// \overload + template< range_return_value re, typename ForwardRange, typename Integer, + typename Value, typename BinaryPredicate > + inline typename range_return::type + search_n(const ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + const Value&>)); + return range_return:: + pack(std::search_n(boost::begin(rng), boost::end(rng), + count, value, pred), + rng); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/set_algorithm.hpp b/include/boost/range/algorithm/set_algorithm.hpp new file mode 100755 index 0000000..48580a9 --- /dev/null +++ b/include/boost/range/algorithm/set_algorithm.hpp @@ -0,0 +1,188 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function includes + /// + /// range-based version of the includes std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline bool includes(const SinglePassRange1& rng1, + const SinglePassRange2& rng2) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::includes(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); + } + + /// \overload + template + inline bool includes(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::includes(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); + } + + /// \brief template function set_union + /// + /// range-based version of the set_union std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline OutputIterator set_union(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_union(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); + } + + /// \overload + template + inline OutputIterator set_union(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_union(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); + } + + /// \brief template function set_intersection + /// + /// range-based version of the set_intersection std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline OutputIterator set_intersection(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_intersection(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); + } + + /// \overload + template + inline OutputIterator set_intersection(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_intersection(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), + out, pred); + } + + /// \brief template function set_difference + /// + /// range-based version of the set_difference std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline OutputIterator set_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_difference(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); + } + + /// \overload + template + inline OutputIterator set_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_difference( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); + } + + /// \brief template function set_symmetric_difference + /// + /// range-based version of the set_symmetric_difference std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline OutputIterator + set_symmetric_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); + } + + /// \overload + template + inline OutputIterator + set_symmetric_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return std::set_symmetric_difference( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/sort.hpp b/include/boost/range/algorithm/sort.hpp new file mode 100755 index 0000000..78669b0 --- /dev/null +++ b/include/boost/range/algorithm/sort.hpp @@ -0,0 +1,63 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_SORT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_SORT_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function sort + /// + /// range-based version of the sort std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline RandomAccessRange& sort(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort(boost::begin(rng), boost::end(rng)); + + return rng; + } + + /// \overload + template + inline const RandomAccessRange& sort(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort(boost::begin(rng),boost::end(rng)); + return rng; + } + + /// \overload + template + inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort(boost::begin(rng), boost::end(rng), pred); + return rng; + } + + /// \overload + template + inline const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::sort(boost::begin(rng), boost::end(rng), pred); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/stable_partition.hpp b/include/boost/range/algorithm/stable_partition.hpp new file mode 100755 index 0000000..b0c6cc8 --- /dev/null +++ b/include/boost/range/algorithm/stable_partition.hpp @@ -0,0 +1,68 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_STABLE_PARTITION_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_STABLE_PARTITION_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function stable_partition + /// + /// range-based version of the stable_partition std algorithm + /// + /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept + /// \pre UnaryPredicate is a model of the UnaryPredicateConcept + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + stable_partition(BidirectionalRange& rng, UnaryPredicate pred) + { + boost::function_requires< BidirectionalRangeConcept >(); + return std::stable_partition(boost::begin(rng), boost::end(rng), pred); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_iterator::type + stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) + { + boost::function_requires< BidirectionalRangeConcept >(); + return std::stable_partition(boost::begin(rng),boost::end(rng),pred); + } + +// range_return overloads + template + inline BOOST_DEDUCED_TYPENAME range_return::type + stable_partition(BidirectionalRange& rng, UnaryPredicate pred) + { + boost::function_requires< BidirectionalRangeConcept >(); + return range_return::pack( + std::stable_partition(boost::begin(rng), boost::end(rng), pred), + rng); + } + + /// \overload + template + inline BOOST_DEDUCED_TYPENAME range_return::type + stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) + { + boost::function_requires< BidirectionalRangeConcept >(); + return range_return::pack( + std::stable_partition(boost::begin(rng),boost::end(rng),pred), + rng); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm/stable_sort.hpp b/include/boost/range/algorithm/stable_sort.hpp new file mode 100755 index 0000000..fba48d9 --- /dev/null +++ b/include/boost/range/algorithm/stable_sort.hpp @@ -0,0 +1,62 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_STABLE_SORT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_STABLE_SORT_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function stable_sort + /// + /// range-based version of the stable_sort std algorithm + /// + /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template + inline RandomAccessRange& stable_sort(RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::stable_sort(boost::begin(rng), boost::end(rng)); + return rng; + } + + /// \overload + template + inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::stable_sort(boost::begin(rng), boost::end(rng)); + return rng; + } + + /// \overload + template + inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate sort_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); + return rng; + } + + /// \overload + template + inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate sort_pred) + { + boost::function_requires< RandomAccessRangeConcept >(); + std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); + return rng; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/swap_ranges.hpp b/include/boost/range/algorithm/swap_ranges.hpp new file mode 100755 index 0000000..0b64b9c --- /dev/null +++ b/include/boost/range/algorithm/swap_ranges.hpp @@ -0,0 +1,81 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template + void swap_ranges_impl(Iterator1 it1, Iterator1 last1, + Iterator2 it2, Iterator2 last2, + single_pass_traversal_tag, + single_pass_traversal_tag) + { + ignore_unused_variable_warning(last2); + for (; it1 != last1; ++it1, ++it2) + { + BOOST_ASSERT( it2 != last2 ); + std::iter_swap(it1, it2); + } + } + + template + void swap_ranges_impl(Iterator1 it1, Iterator1 last1, + Iterator2 it2, Iterator2 last2, + random_access_traversal_tag, + random_access_traversal_tag) + { + ignore_unused_variable_warning(last2); + BOOST_ASSERT( last2 - it2 >= last1 - it1 ); + std::swap_ranges(it1, last1, it2); + } + + template + void swap_ranges_impl(Iterator1 first1, Iterator1 last1, + Iterator2 first2, Iterator2 last2) + { + swap_ranges_impl(first1, last1, first2, last2, + typename iterator_traversal::type(), + typename iterator_traversal::type()); + } + } // namespace range_detail + + /// \brief template function swap_ranges + /// + /// range-based version of the swap_ranges std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + template< typename SinglePassRange1, typename SinglePassRange2 > + inline SinglePassRange2& + swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2) + { + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + + boost::range_detail::swap_ranges_impl( + boost::begin(range1), boost::end(range1), + boost::begin(range2), boost::end(range2)); + + return range2; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/transform.hpp b/include/boost/range/algorithm/transform.hpp new file mode 100755 index 0000000..ca3e956 --- /dev/null +++ b/include/boost/range/algorithm/transform.hpp @@ -0,0 +1,85 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function transform + /// + /// range-based version of the transform std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + /// \pre UnaryOperation is a model of the UnaryFunctionConcept + /// \pre BinaryOperation is a model of the BinaryFunctionConcept + template< class SinglePassRange1, + class OutputIterator, + class UnaryOperation > + inline OutputIterator + transform(const SinglePassRange1& rng, + OutputIterator out, + UnaryOperation fun) + { + return std::transform(boost::begin(rng),boost::end(rng),out,fun); + } + + namespace range_detail + { + template< class SinglePassTraversalReadableIterator1, + class SinglePassTraversalReadableIterator2, + class OutputIterator, + class BinaryFunction > + inline OutputIterator + transform_impl(SinglePassTraversalReadableIterator1 first1, + SinglePassTraversalReadableIterator1 last1, + SinglePassTraversalReadableIterator2 first2, + SinglePassTraversalReadableIterator2 last2, + OutputIterator out, + BinaryFunction fn) + { + for (; first1 != last1; ++first1, ++first2) + { + BOOST_ASSERT( first2 != last2 ); + *out = fn(*first1, *first2); + ++out; + } + return out; + } + } + + /// \overload + template< class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryOperation > + inline OutputIterator + transform(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryOperation fun) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + return range_detail::transform_impl( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), + out, fun); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/unique.hpp b/include/boost/range/algorithm/unique.hpp new file mode 100755 index 0000000..8d8ee1a --- /dev/null +++ b/include/boost/range/algorithm/unique.hpp @@ -0,0 +1,101 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_UNIQUE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_UNIQUE_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function unique + /// + /// range-based version of the unique std algorithm + /// + /// \pre Rng meets the requirements for a Forward range + template< range_return_value re, class ForwardRange > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( ForwardRange& rng ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack( std::unique( boost::begin(rng), + boost::end(rng)), rng ); + } + + /// \overload + template< range_return_value re, class ForwardRange > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( const ForwardRange& rng ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack( std::unique( boost::begin(rng), + boost::end(rng)), rng ); + } + /// \overload + template< range_return_value re, class ForwardRange, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( ForwardRange& rng, BinaryPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::unique(boost::begin(rng), boost::end(rng), pred), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( const ForwardRange& rng, BinaryPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::unique(boost::begin(rng), boost::end(rng), pred), + rng); + } + + /// \overload + template< class ForwardRange > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( ForwardRange& rng ) + { + boost::function_requires< ForwardRangeConcept >(); + return boost::unique(rng); + } + /// \overload + template< class ForwardRange > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( const ForwardRange& rng ) + { + boost::function_requires< ForwardRangeConcept >(); + return boost::unique(rng); + } + /// \overload + template< class ForwardRange, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + unique( ForwardRange& rng, BinaryPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return boost::unique(rng); + } + /// \overload + template< class ForwardRange, class BinaryPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + unique( const ForwardRange& rng, BinaryPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return boost::unique(rng, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/unique_copy.hpp b/include/boost/range/algorithm/unique_copy.hpp new file mode 100755 index 0000000..4d2a3f2 --- /dev/null +++ b/include/boost/range/algorithm/unique_copy.hpp @@ -0,0 +1,45 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_UNIQUE_COPY_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_UNIQUE_COPY_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function unique_copy + /// + /// range-based version of the unique_copy std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class SinglePassRange, class OutputIterator > + inline OutputIterator + unique_copy( const SinglePassRange& rng, OutputIterator out_it ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::unique_copy(boost::begin(rng), boost::end(rng), out_it); + } + /// \overload + template< class SinglePassRange, class OutputIterator, class BinaryPredicate > + inline OutputIterator + unique_copy( const SinglePassRange& rng, OutputIterator out_it, + BinaryPredicate pred ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm/upper_bound.hpp b/include/boost/range/algorithm/upper_bound.hpp new file mode 100755 index 0000000..8d17abf --- /dev/null +++ b/include/boost/range/algorithm/upper_bound.hpp @@ -0,0 +1,101 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_UPPER_BOUND_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_UPPER_BOUND_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function upper_bound + /// + /// range-based version of the upper_bound std algorithm + /// + /// \pre ForwardRange is a model of the ForwardRangeConcept + template< class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + upper_bound( ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::upper_bound(boost::begin(rng), boost::end(rng), val); + } + /// \overload + template< class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + upper_bound( const ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::upper_bound(boost::begin(rng), boost::end(rng), val); + } + /// \overload + template< class ForwardRange, class Value, class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); + } + /// \overload + template< class ForwardRange, class Value, class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_iterator::type + upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + upper_bound( ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value > + inline BOOST_DEDUCED_TYPENAME range_return::type + upper_bound( const ForwardRange& rng, Value val ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value, + class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); + } + /// \overload + template< range_return_value re, class ForwardRange, class Value, + class SortPredicate > + inline BOOST_DEDUCED_TYPENAME range_return::type + upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) + { + boost::function_requires< ForwardRangeConcept >(); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext.hpp b/include/boost/range/algorithm_ext.hpp new file mode 100755 index 0000000..002e791 --- /dev/null +++ b/include/boost/range/algorithm_ext.hpp @@ -0,0 +1,27 @@ +// Boost.Range library +// +// Copyright Neil Groves 2007. 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) +// +// Copyright Thorsten Ottosen 2006. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_HPP +#define BOOST_RANGE_ALGORITHM_EXT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/boost/range/algorithm_ext/copy_n.hpp b/include/boost/range/algorithm_ext/copy_n.hpp new file mode 100755 index 0000000..39b7d3e --- /dev/null +++ b/include/boost/range/algorithm_ext/copy_n.hpp @@ -0,0 +1,47 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + /// \brief template function copy + /// + /// range-based version of the copy std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + /// \pre 0 <= n < distance(rng) + template< class SinglePassRange, class Size, class OutputIterator > + inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out) + { + boost::function_requires< SinglePassRangeConcept >(); + BOOST_ASSERT( n < static_cast(boost::distance(rng)) ); + BOOST_ASSERT( n >= static_cast(0) ); + + BOOST_DEDUCED_TYPENAME range_const_iterator::type source = boost::begin(rng); + + for (Size i = 0; i < n; ++i, ++out, ++source) + *out = *source; + + return out; + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/erase.hpp b/include/boost/range/algorithm_ext/erase.hpp new file mode 100755 index 0000000..c57d14d --- /dev/null +++ b/include/boost/range/algorithm_ext/erase.hpp @@ -0,0 +1,45 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + template< class Container > + inline void erase( Container& on, + iterator_range to_erase ) + { + on.erase( boost::begin(to_erase), boost::end(to_erase) ); + } + + template< class Container, class T > + inline void remove_erase( Container& on, const T& val ) + { + on.erase( + std::remove(boost::begin(on), boost::end(on), val), + boost::end(on)); + } + + template< class Container, class Pred > + inline void remove_erase_if( Container& on, Pred pred ) + { + on.erase( + std::remove_if(boost::begin(on), boost::end(on), pred), + boost::end(on)); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/for_each.hpp b/include/boost/range/algorithm_ext/for_each.hpp new file mode 100755 index 0000000..d18f548 --- /dev/null +++ b/include/boost/range/algorithm_ext/for_each.hpp @@ -0,0 +1,65 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_FOR_EACH_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_FOR_EACH_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template + inline Fn2 for_each_impl(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + Fn2 fn) + { + for (; first1 != last1 && first2 != last2; ++first1, ++first2) + { + fn(*first1, *first2); + } + return fn; + } + } + + template + inline Fn2 for_each(const SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn) + { + return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), fn); + } + + template + inline Fn2 for_each(const SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn) + { + return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), fn); + } + + template + inline Fn2 for_each(SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn) + { + return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), fn); + } + + template + inline Fn2 for_each(SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn) + { + return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), fn); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/insert.hpp b/include/boost/range/algorithm_ext/insert.hpp new file mode 100755 index 0000000..4b18fea --- /dev/null +++ b/include/boost/range/algorithm_ext/insert.hpp @@ -0,0 +1,32 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + template< class Container, class Range > + inline void insert( Container& on, + BOOST_DEDUCED_TYPENAME Container::iterator before, + const Range& from ) + { + BOOST_ASSERT( (void*)&on != (void*)&from && + "cannot copy from a container to itself" ); + on.insert( before, boost::begin(from), boost::end(from) ); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/is_sorted.hpp b/include/boost/range/algorithm_ext/is_sorted.hpp new file mode 100755 index 0000000..fc7b522 --- /dev/null +++ b/include/boost/range/algorithm_ext/is_sorted.hpp @@ -0,0 +1,65 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_IS_SORTED_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_IS_SORTED_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template + inline bool is_sorted(ForwardIterator first, ForwardIterator last) + { + for (ForwardIterator next = first; first != last && ++next != last; ++first) + if (*next < *first) + return false; + return true; + } + + template + inline bool is_sorted(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) + { + for (ForwardIterator next = first; first != last && ++next != last; ++first) + if (pred(*next, *first)) + return false; + return true; + } + } + + /// \brief template function count + /// + /// range-based version of the count std algorithm + /// + /// \pre SinglePassRange is a model of the SinglePassRangeConcept + template + inline bool is_sorted(const SinglePassRange& rng) + { + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((LessThanComparableConcept::type>)); + return range_detail::is_sorted(boost::begin(rng), boost::end(rng)); + } + + /// \overload + template + inline bool is_sorted(const SinglePassRange& rng, BinaryPredicate pred) + { + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); + return range_detail::is_sorted(boost::begin(rng), boost::end(rng), pred); + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/overwrite.hpp b/include/boost/range/algorithm_ext/overwrite.hpp new file mode 100755 index 0000000..8035968 --- /dev/null +++ b/include/boost/range/algorithm_ext/overwrite.hpp @@ -0,0 +1,46 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + template< class SinglePassRange1, class SinglePassRange2 > + inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to ) + { + BOOST_DEDUCED_TYPENAME range_iterator::type + i = boost::begin(from), e = boost::end(from); + + BOOST_DEDUCED_TYPENAME range_iterator::type + out = boost::begin(to); + +#ifndef NDEBUG + BOOST_DEDUCED_TYPENAME range_iterator::type + last_out = boost::end(to); +#endif + + for( ; i != e; ++out, ++i ) + { +#ifndef NDEBUG + BOOST_ASSERT( out != last_out + && "out of bounds in boost::overwrite()" ); +#endif + *out = *i; + } + } +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/push_back.hpp b/include/boost/range/algorithm_ext/push_back.hpp new file mode 100755 index 0000000..8178f5b --- /dev/null +++ b/include/boost/range/algorithm_ext/push_back.hpp @@ -0,0 +1,31 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_PUSH_BACK_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_PUSH_BACK_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + template< class Container, class Range > + inline void push_back( Container& on, const Range& from ) + { + BOOST_ASSERT( (void*)&on != (void*)&from && + "cannot copy from a container to itself" ); + on.insert( on.end(), boost::begin(from), boost::end(from) ); + } + +} + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/push_front.hpp b/include/boost/range/algorithm_ext/push_front.hpp new file mode 100755 index 0000000..eb82cf2 --- /dev/null +++ b/include/boost/range/algorithm_ext/push_front.hpp @@ -0,0 +1,30 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_PUSH_FRONT_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_PUSH_FRONT_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + template< class Container, class Range > + inline void push_front( Container& on, const Range& from ) + { + BOOST_ASSERT( (void*)&on != (void*)&from && + "cannot copy from a container to itself" ); + on.insert( on.begin(), boost::begin(from), boost::end(from) ); + } +} + +#endif // include guard diff --git a/include/boost/range/combine.hpp b/include/boost/range/combine.hpp new file mode 100755 index 0000000..31a540b --- /dev/null +++ b/include/boost/range/combine.hpp @@ -0,0 +1,310 @@ +#ifndef BOOST_RANGE_COMBINE_HPP +#define BOOST_RANGE_COMBINE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace detail + { + struct void_ { typedef void_ type; }; + } + + template<> struct range_iterator + { + typedef tuples::null_type type; + }; + + namespace detail + { + inline tuples::null_type range_begin( void_& ) + { return tuples::null_type(); } + + inline tuples::null_type range_end( void_& ) + { return tuples::null_type(); } + + template< class T > + struct tuple_iter + { + typedef typename mpl::eval_if_c< is_same::value, + mpl::identity, + range_iterator >::type + type; + }; + + template< class Rng1, class Rng2 > + struct tuple_range + { + typedef typename mpl::eval_if_c< is_same::value, + void_, + mpl::identity >::type + type; + }; + + template + < + class R1, + class R2, + class R3, + class R4, + class R5, + class R6 + > + struct generate_tuple + { + typedef boost::tuple< typename tuple_iter::type, + typename tuple_iter::type, + typename tuple_iter::type, + typename tuple_iter::type, + typename tuple_iter::type, + typename tuple_iter::type > + type; + + static type begin( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 ) + { + return make_tuple( boost::begin(r1), + boost::begin(r2), + boost::begin(r3), + boost::begin(r4), + boost::begin(r5), + boost::begin(r6) ); + } + + static type end( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 ) + { + return make_tuple( boost::end(r1), + boost::end(r2), + boost::end(r3), + boost::end(r4), + boost::end(r5), + boost::end(r6) ); + } + }; + + template + < + class R1, + class R2 = void_, + class R3 = void_, + class R4 = void_, + class R5 = void_, + class R6 = void_ + > + struct zip_rng + : iterator_range< + zip_iterator< typename generate_tuple::type > + > + { + private: + typedef generate_tuple + generator; + typedef typename generator::type + tuple; + typedef zip_iterator + zip_iter; + typedef iterator_range + base; + + public: + zip_rng( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 ) + : base( zip_iter( generator::begin(r1,r2,r3,r4,r5,r6) ), + zip_iter( generator::end(r1,r2,r3,r4,r5,r6) ) ) + { + BOOST_ASSERT(boost::distance(r1) <= boost::distance(r2)); + BOOST_ASSERT(boost::distance(r1) <= boost::distance(r3)); + BOOST_ASSERT(boost::distance(r1) <= boost::distance(r4)); + BOOST_ASSERT(boost::distance(r1) <= boost::distance(r5)); + BOOST_ASSERT(boost::distance(r1) <= boost::distance(r6)); + } + + template< class Zip, class Rng > + zip_rng( Zip& z, Rng& r ) + : base( zip_iter( generator::begin( z, r ) ), + zip_iter( generator::end( z, r ) ) ) + { + + // @todo: tuple::begin( should be overloaded for this situation + } + + struct tuple_length : tuples::length + { }; + + template< unsigned N > + struct get + { + template< class Z, class R > + static typename tuples::element::type begin( Z& z, R& ) + { + return get( z.begin().get_iterator_tuple() ); + } + + template< class Z, class R > + static typename tuples::element::type end( Z& z, R& r ) + { + return get( z.end().get_iterator_tuple() ); + } + }; + + }; + + template< class Rng1, class Rng2 > + struct zip_range + : iterator_range< + zip_iterator< + tuple< typename range_iterator::type, + typename range_iterator::type > + > > + { + private: + typedef zip_iterator< + tuple< typename range_iterator::type, + typename range_iterator::type > + > + zip_iter; + typedef iterator_range + base; + + public: + zip_range( Rng1& r1, Rng2& r2 ) + : base( zip_iter( make_tuple(boost::begin(r1), + boost::begin(r2)) ), + zip_iter( make_tuple(boost::end(r1), + boost::end(r2)) ) ) + { + BOOST_ASSERT(boost::distance(r1) <= boost::distance(r2)); + } + }; + + template< class Rng1, class Rng2, class Rng3 > + struct zip_range3 + : iterator_range< + zip_iterator< + tuple< typename range_iterator::type, + typename range_iterator::type, + typename range_iterator::type > + > > + { + private: + typedef zip_iterator< + tuple< typename range_iterator::type, + typename range_iterator::type, + typename range_iterator::type > + > + zip_iter; + typedef iterator_range + base; + + public: + zip_range3( Rng1& r1, Rng2& r2, Rng3& r3 ) + : base( zip_iter( make_tuple(boost::begin(r1), + boost::begin(r2), + boost::begin(r3)) ), + zip_iter( make_tuple(boost::end(r1), + boost::end(r2), + boost::end(r3)) ) + ) + { + BOOST_ASSERT(distance(r1) <= distance(r2)); + BOOST_ASSERT(distance(r1) <= distance(r3)); + } + }; + + + struct combine_tag {}; + + template< class Rng > + inline zip_rng + operator&( combine_tag, Rng& r ) + { + return zip_rng(r); + } + + template< class Rng > + inline iterator_range + operator&( combine_tag, const Rng& r ) + { + return iterator_range(r); + } + + template + < + class R1, + class R2, + class R3, + class R4, + class R5, + class Rng + > + inline typename zip_rng::next + operator&( const zip_rng& zip, + Rng& r ) + { + return zip_rng::next( zip, r ); + } + + // + // This one should be able to be made generic + // + // template + // < + // class R1, + // class R2 = void, + // class R3 = void, + // class R4 = void, + // class R5 = void, + // class R6 = void + // > + // inline zip_range::type + // x + // + // + /* + template< class Rng1, class Rng2, class Rng3 > + inline zip_range3 + operator&( const zip_range& r1, const Rng3& r3 ) + { + return zip_range3( + }*/ + + } // namespace 'detail' + + template< class Rng1, class Rng2 > + inline detail::zip_range combine( Rng1& r1, Rng2& r2 ) + { + return detail::zip_range(r1,r2); + } + + template< class Rng1, class Rng2 > + inline detail::zip_range combine( const Rng1& r1, Rng2& r2 ) + { + return detail::zip_range(r1,r2); + } + + template< class Rng1, class Rng2 > + inline detail::zip_range combine( Rng1& r1, const Rng2& r2 ) + { + return detail::zip_range(r1,r2); + } + + template< class Rng1, class Rng2 > + inline detail::zip_range combine( const Rng1& r1, const Rng2& r2 ) + { + return detail::zip_range(r1,r2); + } + + // + // @todo: find a solution that scales better + // instead of adding 6 overloads! + // +} + +#endif diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp old mode 100755 new mode 100644 index 53a88dc..b70c586 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -1,5 +1,10 @@ // Boost.Range library concept checks // +// Copyright Neil Groves 2009. Use, modification and distribution +// are 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) +// // Copyright Daniel Walker 2006. Use, modification and distribution // are subject to the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -15,6 +20,9 @@ #include #include #include +#include +#include +#include /*! * \file @@ -29,20 +37,15 @@ * concept. * * \code - * function_requires >(); + * BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); * \endcode * - * An additional concept check is required for the value access - * property of the range. For example to check for a - * ForwardReadableRange, the following code is required. + * A different concept check is required to ensure writeable value + * access. For example to check for a ForwardRange that can be written + * to, the following code is required. * * \code - * function_requires >(); - * function_requires< - * ReadableIteratorConcept< - * typename range_iterator::type - * > - * >(); + * BOOST_CONCEPT_ASSERT((WriteableForwardRangeConcept)); * \endcode * * \see http://www.boost.org/libs/range/doc/range.html for details @@ -55,84 +58,218 @@ namespace boost { + namespace range_detail { + + // Rationale for the inclusion of redefined iterator concept + // classes: + // + // The Range algorithms often do not require that the iterators are + // Assignable, but the correct standard conformant iterators + // do require the iterators to be a model of the Assignable concept. + // Iterators that contains a functor that is not assignable therefore + // are not correct models of the standard iterator concepts, + // despite being adequate for most algorithms. An example of this + // use case is the combination of the boost::adaptors::filtered + // class with a boost::lambda::bind generated functor. + // Ultimately modeling the range concepts using composition + // with the Boost.Iterator concepts would render the library + // incompatible with many common Boost.Lambda expressions. + template + struct IncrementableIteratorConcept : CopyConstructible + { + typedef typename iterator_traversal::type traversal_category; + + BOOST_CONCEPT_ASSERT(( + Convertible< + traversal_category, + incrementable_traversal_tag + >)); + + BOOST_CONCEPT_USAGE(IncrementableIteratorConcept) + { + ++i; + (void)i++; + } + private: + Iterator i; + }; + + template + struct SinglePassIteratorConcept + : IncrementableIteratorConcept + , EqualityComparable + { + BOOST_CONCEPT_ASSERT(( + Convertible< + typename SinglePassIteratorConcept::traversal_category, + single_pass_traversal_tag + >)); + }; + + template + struct ForwardIteratorConcept + : SinglePassIteratorConcept + , DefaultConstructible + { + typedef typename boost::detail::iterator_traits::difference_type difference_type; + + BOOST_MPL_ASSERT((is_integral)); + BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); + + BOOST_CONCEPT_ASSERT(( + Convertible< + typename ForwardIteratorConcept::traversal_category, + forward_traversal_tag + >)); + }; + + template + struct BidirectionalIteratorConcept + : ForwardIteratorConcept + { + BOOST_CONCEPT_ASSERT(( + Convertible< + typename BidirectionalIteratorConcept::traversal_category, + bidirectional_traversal_tag + >)); + + BOOST_CONCEPT_USAGE(BidirectionalIteratorConcept) + { + --i; + (void)i--; + } + private: + Iterator i; + }; + + template + struct RandomAccessIteratorConcept + : BidirectionalIteratorConcept + { + BOOST_CONCEPT_ASSERT(( + Convertible< + typename RandomAccessIteratorConcept::traversal_category, + random_access_traversal_tag + >)); + + BOOST_CONCEPT_USAGE(RandomAccessIteratorConcept) + { + i += n; + i = i + n; + i = n + i; + i -= n; + i = i - n; + n = i - j; + } + private: + typename RandomAccessIteratorConcept::difference_type n; + Iterator i; + Iterator j; + }; + + } // namespace range_detail + //! Check if a type T models the SinglePassRange range concept. template - struct SinglePassRangeConcept + struct SinglePassRangeConcept { - typedef typename range_iterator::type range_const_iterator; - typedef typename range_iterator::type range_iterator; + typedef typename range_iterator::type const_iterator; + typedef typename range_iterator::type iterator; - void constraints() - { - function_requires< - boost_concepts::SinglePassIteratorConcept< - range_iterator - > - >(); - i = boost::begin(a); - i = boost::end(a); - const_constraints(a); + BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); + BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); + + BOOST_CONCEPT_USAGE(SinglePassRangeConcept) + { + // This has been modified from assigning to this->i + // (where i was a member variable) to improve + // compatibility with Boost.Lambda + iterator i1 = boost::begin(*m_range); + iterator i2 = boost::end(*m_range); + + ignore_unused_variable_warning(i1); + ignore_unused_variable_warning(i2); + + const_constraints(*m_range); } - - void const_constraints(const T& a) + + private: + void const_constraints(const T& const_range) { - ci = boost::begin(a); - ci = boost::end(a); + const_iterator ci1 = boost::begin(const_range); + const_iterator ci2 = boost::end(const_range); + + ignore_unused_variable_warning(ci1); + ignore_unused_variable_warning(ci2); } - T a; - range_iterator i; - range_const_iterator ci; + + // Rationale: + // The type of m_range is T* rather than T because it allows + // T to be an abstract class. The other obvious alternative of + // T& produces a warning on some compilers. + T* m_range; }; //! Check if a type T models the ForwardRange range concept. template - struct ForwardRangeConcept + struct ForwardRangeConcept : SinglePassRangeConcept { - void constraints() + BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); + BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); + }; + + template + struct WriteableRangeConcept + { + typedef typename range_iterator::type iterator; + + BOOST_CONCEPT_USAGE(WriteableRangeConcept) { - function_requires< - SinglePassRangeConcept - >(); - function_requires< - boost_concepts::ForwardTraversalConcept< - typename range_iterator::type - > - >(); + *i = v; } + private: + iterator i; + typename range_value::type v; + }; + + //! Check if a type T models the WriteableForwardRange range concept. + template + struct WriteableForwardRangeConcept + : ForwardRangeConcept + , WriteableRangeConcept + { }; //! Check if a type T models the BidirectionalRange range concept. template - struct BidirectionalRangeConcept + struct BidirectionalRangeConcept : ForwardRangeConcept + { + BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); + BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); + }; + + //! Check if a type T models the WriteableBidirectionalRange range concept. + template + struct WriteableBidirectionalRangeConcept + : BidirectionalRangeConcept + , WriteableRangeConcept { - void constraints() - { - function_requires< - ForwardRangeConcept - >(); - function_requires< - boost_concepts::BidirectionalTraversalConcept< - typename range_iterator::type - > - >(); - } }; //! Check if a type T models the RandomAccessRange range concept. template - struct RandomAccessRangeConcept + struct RandomAccessRangeConcept : BidirectionalRangeConcept + { + BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); + BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); + }; + + //! Check if a type T models the WriteableRandomAccessRange range concept. + template + struct WriteableRandomAccessRangeConcept + : RandomAccessRangeConcept + , WriteableRangeConcept { - void constraints() - { - function_requires< - BidirectionalRangeConcept - >(); - function_requires< - boost_concepts::RandomAccessTraversalConcept< - typename range_iterator::type - > - >(); - } }; } // namespace boost diff --git a/include/boost/range/const_iterator.hpp b/include/boost/range/const_iterator.hpp old mode 100755 new mode 100644 index 195f9d4..875320f --- a/include/boost/range/const_iterator.hpp +++ b/include/boost/range/const_iterator.hpp @@ -21,6 +21,7 @@ #include #else +#include #include #include #include @@ -31,11 +32,13 @@ namespace boost // default ////////////////////////////////////////////////////////////////////////// + namespace range_detail { + BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( const_iterator ) + } + template< typename C > - struct range_const_iterator - { - typedef BOOST_DEDUCED_TYPENAME C::const_iterator type; - }; + struct range_const_iterator : range_detail::extract_const_iterator + {}; ////////////////////////////////////////////////////////////////////////// // pair diff --git a/include/boost/range/counting_range.hpp b/include/boost/range/counting_range.hpp new file mode 100755 index 0000000..c1ca5ec --- /dev/null +++ b/include/boost/range/counting_range.hpp @@ -0,0 +1,69 @@ +// Boost.Range library +// +// Copyright Neil Groves 2008. Use, modification and +// distribution is subject to the Boost Software Licence, 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 +// + +#ifndef BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED +#define BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED + +#include +#if BOOST_MSVC >= 1400 +#pragma warning(push) +#pragma warning(disable : 4244) +#endif + +#include +#include +#include +#include + +namespace boost +{ + + template + inline iterator_range > + counting_range(Value first, Value last) + { + typedef counting_iterator counting_iterator_t; + typedef iterator_range result_t; + return result_t(counting_iterator_t(first), + counting_iterator_t(last)); + } + + template + inline iterator_range::type> > + counting_range(const Range& rng) + { + typedef counting_iterator::type> counting_iterator_t; + typedef iterator_range result_t; + return boost::empty(rng) + ? result_t() + : result_t( + counting_iterator_t(*boost::begin(rng)), + counting_iterator_t(*boost::prior(boost::end(rng)))); + } + + template + inline iterator_range::type> > + counting_range(Range& rng) + { + typedef counting_iterator::type> counting_iterator_t; + typedef iterator_range result_t; + return boost::empty(rng) + ? result_t() + : result_t( + counting_iterator_t(*boost::begin(rng)), + counting_iterator_t(*boost::prior(boost::end(rng)))); + } +} // namespace boost + +#if BOOST_MSVC >= 1400 +#pragma warning(pop) +#endif + +#endif // include guard diff --git a/include/boost/range/detail/demote_iterator_traversal_tag.hpp b/include/boost/range/detail/demote_iterator_traversal_tag.hpp new file mode 100755 index 0000000..4351c85 --- /dev/null +++ b/include/boost/range/detail/demote_iterator_traversal_tag.hpp @@ -0,0 +1,79 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_DETAIL_DEMOTE_ITERATOR_TRAVERSAL_TAG_HPP_INCLUDED +#define BOOST_RANGE_DETAIL_DEMOTE_ITERATOR_TRAVERSAL_TAG_HPP_INCLUDED + +#include + +namespace boost +{ + namespace range_detail + { + +template +struct demote_iterator_traversal_tag +{ +}; + +#define BOOST_DEMOTE_TRAVERSAL_TAG( Tag1, Tag2, ResultTag ) \ +template<> struct demote_iterator_traversal_tag< Tag1 , Tag2 > \ +{ \ + typedef ResultTag type; \ +}; + +BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, no_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, incrementable_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, single_pass_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, forward_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, bidirectional_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, random_access_traversal_tag, no_traversal_tag ) + +BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, no_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, single_pass_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, forward_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, bidirectional_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, random_access_traversal_tag, incrementable_traversal_tag ) + +BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, no_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, forward_traversal_tag, single_pass_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, bidirectional_traversal_tag, single_pass_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, random_access_traversal_tag, single_pass_traversal_tag ) + +BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, no_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, forward_traversal_tag, forward_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, bidirectional_traversal_tag, forward_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, random_access_traversal_tag, forward_traversal_tag ) + +BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, no_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, forward_traversal_tag, forward_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, bidirectional_traversal_tag, bidirectional_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, random_access_traversal_tag, bidirectional_traversal_tag ) + +BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, no_traversal_tag, no_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, forward_traversal_tag, forward_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, bidirectional_traversal_tag, bidirectional_traversal_tag ) +BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal_tag, random_access_traversal_tag ) + +#undef BOOST_DEMOTE_TRAVERSAL_TAG + + } // namespace range_detail +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/detail/extract_optional_type.hpp b/include/boost/range/detail/extract_optional_type.hpp new file mode 100755 index 0000000..8292e34 --- /dev/null +++ b/include/boost/range/detail/extract_optional_type.hpp @@ -0,0 +1,52 @@ +// Boost.Range library +// +// Copyright Arno Schoedl & Neil Groves 2009. +// 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/ +// +#ifndef BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED +#define BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include + +#ifdef BOOST_NO_PARTIAL_TEMPLATE_SPECIALIZATION + +#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \ + template< typename C > \ + struct extract_ ## a_typedef \ + { \ + typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \ + }; + +#else + +namespace boost { + namespace range_detail { + template< typename T > struct exists { typedef void type; }; + } +} + +// Defines extract_some_typedef which exposes T::some_typedef as +// extract_some_typedef::type if T::some_typedef exists. Otherwise +// extract_some_typedef is empty. +#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \ + template< typename C, typename Enable=void > \ + struct extract_ ## a_typedef \ + {}; \ + template< typename C > \ + struct extract_ ## a_typedef< C \ + , BOOST_DEDUCED_TYPENAME boost::range_detail::exists< BOOST_DEDUCED_TYPENAME C::a_typedef >::type \ + > { \ + typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \ + }; + +#endif + +#endif // include guard diff --git a/include/boost/range/detail/join_iterator.hpp b/include/boost/range/detail/join_iterator.hpp new file mode 100644 index 0000000..792f834 --- /dev/null +++ b/include/boost/range/detail/join_iterator.hpp @@ -0,0 +1,357 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED +#define BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + +template +struct join_iterator_link +{ +private: + class reference_count_t + { + public: + reference_count_t() : m_count(0u) {} + reference_count_t(const reference_count_t&) : m_count(0u) {} + reference_count_t& operator=(const reference_count_t&) { return *this; } + + void increment() { ++m_count; } + bool decrement() { return --m_count ? false : true; } + + private: + unsigned int m_count; + }; + +public: + join_iterator_link(Iterator1 last1, Iterator2 first2) + : last1(last1) + , first2(first2) + { + } + + void add_reference() const + { + count.increment(); + } + + bool release_reference() const + { + return count.decrement(); + } + + Iterator1 last1; + Iterator2 first2; + +private: + join_iterator_link() /* = delete */ ; + + mutable reference_count_t count; +}; + +} // range_detail + +template +inline void intrusive_ptr_add_ref(const range_detail::join_iterator_link* p) +{ + p->add_reference(); +} + +template +inline void intrusive_ptr_release(const range_detail::join_iterator_link* p) +{ + if (p->release_reference()) + delete p; +} + +namespace range_detail +{ + +class join_iterator_begin_tag {}; +class join_iterator_end_tag {}; + +template +class join_iterator_union +{ +public: + typedef Iterator1 iterator1_t; + typedef Iterator2 iterator2_t; + + join_iterator_union() {} + join_iterator_union(unsigned int /*selected*/, const iterator1_t& it1, const iterator2_t& it2) : m_it1(it1), m_it2(it2) {} + + iterator1_t& it1() { return m_it1; } + const iterator1_t& it1() const { return m_it1; } + + iterator2_t& it2() { return m_it2; } + const iterator2_t& it2() const { return m_it2; } + + Reference dereference(unsigned int selected) const + { + return selected ? *m_it2 : *m_it1; + } + + bool equal(const join_iterator_union& other, unsigned int selected) const + { + return selected + ? m_it2 == other.m_it2 + : m_it1 == other.m_it1; + } + +private: + iterator1_t m_it1; + iterator2_t m_it2; +}; + +template +class join_iterator_union +{ +public: + typedef Iterator iterator1_t; + typedef Iterator iterator2_t; + + join_iterator_union() {} + + join_iterator_union(unsigned int selected, const iterator1_t& it1, const iterator2_t& it2) + : m_it(selected ? it2 : it1) + { + } + + iterator1_t& it1() { return m_it; } + const iterator1_t& it1() const { return m_it; } + + iterator2_t& it2() { return m_it; } + const iterator2_t& it2() const { return m_it; } + + Reference dereference(unsigned int) const + { + return *m_it; + } + + bool equal(const join_iterator_union& other, unsigned int selected) const + { + return m_it == other.m_it; + } + +private: + iterator1_t m_it; +}; + +template::type + , typename Reference = typename iterator_reference::type + , typename Traversal = typename demote_iterator_traversal_tag< + typename iterator_traversal::type + , typename iterator_traversal::type>::type +> +class join_iterator + : public iterator_facade, ValueType, Traversal, Reference> +{ + typedef join_iterator_link link_t; + typedef join_iterator_union iterator_union; +public: + typedef Iterator1 iterator1_t; + typedef Iterator2 iterator2_t; + + join_iterator() : m_section(0u) {} + + join_iterator(unsigned int section, Iterator1 current1, Iterator1 last1, Iterator2 first2, Iterator2 current2) + : m_section(section) + , m_it(section, current1, current2) + , m_link(new link_t(last1, first2)) + { + } + + template + join_iterator(Range1& r1, Range2& r2, join_iterator_begin_tag) + : m_section(boost::empty(r1) ? 1u : 0u) + , m_it(boost::empty(r1) ? 1u : 0u, boost::begin(r1), boost::begin(r2)) + , m_link(new link_t(boost::end(r1), boost::begin(r2))) + { + } + + template + join_iterator(const Range1& r1, const Range2& r2, join_iterator_begin_tag) + : m_section(boost::empty(r1) ? 1u : 0u) + , m_it(boost::empty(r1) ? 1u : 0u, boost::const_begin(r1), boost::const_begin(r2)) + , m_link(new link_t(boost::const_end(r1), boost::const_begin(r2))) + { + } + + template + join_iterator(Range1& r1, Range2& r2, join_iterator_end_tag) + : m_section(1u) + , m_it(1u, boost::end(r1), boost::end(r2)) + , m_link(new link_t(boost::end(r1), boost::begin(r2))) + { + } + + template + join_iterator(const Range1& r1, const Range2& r2, join_iterator_end_tag) + : m_section(1u) + , m_it(1u, boost::const_end(r1), boost::const_end(r2)) + , m_link(new link_t(boost::const_end(r1), boost::const_begin(r2))) + { + } + +private: + void increment() + { + if (m_section) + ++m_it.it2(); + else + { + ++m_it.it1(); + if (m_it.it1() == m_link->last1) + { + m_it.it2() = m_link->first2; + m_section = 1u; + } + } + } + + void decrement() + { + if (m_section) + { + if (m_it.it2() == m_link->first2) + { + m_it.it1() = boost::prior(m_link->last1); + m_section = 0u; + } + else + --m_it.it2(); + } + else + --m_it.it1(); + } + + typename join_iterator::reference dereference() const + { + return m_it.dereference(m_section); + } + + bool equal(const join_iterator& other) const + { + return m_section == other.m_section + && m_it.equal(other.m_it, m_section); + } + + void advance(typename join_iterator::difference_type offset) + { + if (m_section) + advance_from_range2(offset); + else + advance_from_range1(offset); + } + + typename join_iterator::difference_type distance_to(const join_iterator& other) const + { + typename join_iterator::difference_type result; + if (m_section) + { + if (other.m_section) + result = other.m_it.it2() - m_it.it2(); + else + { + result = (m_link->first2 - m_it.it2()) + + (other.m_it.it1() - m_link->last1); + + BOOST_ASSERT( result <= 0 ); + } + } + else + { + if (other.m_section) + { + result = (m_link->last1 - m_it.it1()) + + (other.m_it.it2() - m_link->first2); + } + else + result = other.m_it.it1() - m_it.it1(); + } + return result; + } + + void advance_from_range2(typename join_iterator::difference_type offset) + { + typedef typename join_iterator::difference_type difference_t; + BOOST_ASSERT( m_section == 1u ); + if (offset < 0) + { + difference_t r2_dist = m_link->first2 - m_it.it2(); + BOOST_ASSERT( r2_dist <= 0 ); + if (offset >= r2_dist) + std::advance(m_it.it2(), offset); + else + { + difference_t r1_dist = offset - r2_dist; + BOOST_ASSERT( r1_dist <= 0 ); + m_it.it1() = m_link->last1 + r1_dist; + m_section = 0u; + } + } + else + std::advance(m_it.it2(), offset); + } + + void advance_from_range1(typename join_iterator::difference_type offset) + { + typedef typename join_iterator::difference_type difference_t; + BOOST_ASSERT( m_section == 0u ); + if (offset > 0) + { + difference_t r1_dist = m_link->last1 - m_it.it1(); + BOOST_ASSERT( r1_dist >= 0 ); + if (offset < r1_dist) + std::advance(m_it.it1(), offset); + else + { + difference_t r2_dist = offset - r1_dist; + BOOST_ASSERT( r2_dist >= 0 ); + m_it.it2() = m_link->first2 + r2_dist; + m_section = 1u; + } + } + else + std::advance(m_it.it1(), offset); + } + + unsigned int m_section; + iterator_union m_it; + intrusive_ptr m_link; + + friend class ::boost::iterator_core_access; +}; + + } // namespace range_detail + +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/detail/misc_concept.hpp b/include/boost/range/detail/misc_concept.hpp new file mode 100755 index 0000000..74cb919 --- /dev/null +++ b/include/boost/range/detail/misc_concept.hpp @@ -0,0 +1,33 @@ +// Boost.Range library concept checks +// +// Copyright Neil Groves 2009. Use, modification and distribution +// are 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) +// +#ifndef BOOST_RANGE_DETAIL_MISC_CONCEPT_HPP_INCLUDED +#define BOOST_RANGE_DETAIL_MISC_CONCEPT_HPP_INCLUDED + +#include + +namespace boost +{ + namespace range_detail + { + template + class SameTypeConcept + { + public: + BOOST_CONCEPT_USAGE(SameTypeConcept) + { + same_type(a,b); + } + private: + template void same_type(T,T) {} + T1 a; + T2 b; + }; + } +} + +#endif // include guard diff --git a/include/boost/range/detail/range_return.hpp b/include/boost/range/detail/range_return.hpp new file mode 100755 index 0000000..52a6073 --- /dev/null +++ b/include/boost/range/detail/range_return.hpp @@ -0,0 +1,180 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_DETAIL_RANGE_RETURN_HPP_INCLUDED +#define BOOST_RANGE_DETAIL_RANGE_RETURN_HPP_INCLUDED + +#include +#include +#include + +namespace boost +{ + enum range_return_value + { + // (*) indicates the most common values + return_found, // only the found resulting iterator (*) + return_next, // next(found) iterator + return_prior, // prior(found) iterator + return_begin_found, // [begin, found) range (*) + return_begin_next, // [begin, next(found)) range + return_begin_prior, // [begin, prior(found)) range + return_found_end, // [found, end) range (*) + return_next_end, // [next(found), end) range + return_prior_end, // [prior(found), end) range + return_begin_end // [begin, end) range + }; + + template< class SinglePassRange, range_return_value > + struct range_return + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + SinglePassRange& rng) + { + return type(found, boost::end(rng)); + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_found > + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type type; + + static type pack(type found, SinglePassRange&) + { + return found; + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_next > + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type type; + + static type pack(type found, SinglePassRange& rng) + { + return found == boost::end(rng) + ? found + : boost::next(found); + } + }; + + template< class BidirectionalRange > + struct range_return< BidirectionalRange, return_prior > + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type type; + + static type pack(type found, BidirectionalRange& rng) + { + return found == boost::begin(rng) + ? found + : boost::prior(found); + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_begin_found > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + SinglePassRange& rng) + { + return type(boost::begin(rng), found); + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_begin_next > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + SinglePassRange& rng) + { + return type( boost::begin(rng), + found == boost::end(rng) ? found : boost::next(found) ); + } + }; + + template< class BidirectionalRange > + struct range_return< BidirectionalRange, return_begin_prior > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + BidirectionalRange& rng) + { + return type( boost::begin(rng), + found == boost::begin(rng) ? found : boost::prior(found) ); + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_found_end > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + SinglePassRange& rng) + { + return type(found, boost::end(rng)); + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_next_end > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + SinglePassRange& rng) + { + return type( found == boost::end(rng) ? found : boost::next(found), + boost::end(rng) ); + } + }; + + template< class BidirectionalRange > + struct range_return< BidirectionalRange, return_prior_end > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + BidirectionalRange& rng) + { + return type( found == boost::begin(rng) ? found : boost::prior(found), + boost::end(rng) ); + } + }; + + template< class SinglePassRange > + struct range_return< SinglePassRange, return_begin_end > + { + typedef boost::iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > type; + + static type pack(BOOST_DEDUCED_TYPENAME range_iterator::type found, + SinglePassRange& rng) + { + return type(boost::begin(rng), boost::end(rng)); + } + }; + +} + +#endif // include guard diff --git a/include/boost/range/irange.hpp b/include/boost/range/irange.hpp new file mode 100644 index 0000000..486be6e --- /dev/null +++ b/include/boost/range/irange.hpp @@ -0,0 +1,202 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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/ +// +#ifndef BOOST_RANGE_IRANGE_HPP_INCLUDED +#define BOOST_RANGE_IRANGE_HPP_INCLUDED + +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + // integer_iterator is an iterator over an integer sequence that + // is bounded only by the limits of the underlying integer + // representation. + // + // This is useful for implementing the irange(first, last) + // function. + // + // Note: + // This use of this iterator and irange is appreciably less + // performant than the corresponding hand-written integer + // loop on many compilers. + template + class integer_iterator + : public boost::iterator_facade< + integer_iterator, + Integer, + boost::random_access_traversal_tag, + const Integer& + > + { + typedef boost::iterator_facade< + integer_iterator, + Integer, + boost::random_access_traversal_tag, + const Integer& + > base_t; + public: + typedef typename base_t::value_type value_type; + typedef typename base_t::difference_type difference_type; + typedef typename base_t::reference reference; + + integer_iterator() : m_value() {} + explicit integer_iterator(value_type x) : m_value(x) {} + + private: + void increment() + { + ++m_value; + } + + void decrement() + { + --m_value; + } + + void advance(difference_type offset) + { + m_value += offset; + } + + difference_type distance_to(const integer_iterator& other) const + { + return other.m_value - m_value; + } + + bool equal(const integer_iterator& other) const + { + return m_value == other.m_value; + } + + reference dereference() const + { + return m_value; + } + + friend class ::boost::iterator_core_access; + value_type m_value; + }; + + // integer_iterator_with_step is similar in nature to the + // integer_iterator but provides the ability to 'move' in + // a number of steps specified at construction time. + // + // The three variable implementation provides the best guarantees + // of loop termination upon various combinations of input. + // + // While this design is less performant than some less + // safe alternatives, the use of ranges and iterators to + // perform counting will never be optimal anyhow, hence + // if optimal performance is desired a handcoded loop + // is the solution. + template + class integer_iterator_with_step + : public boost::iterator_facade< + integer_iterator_with_step, + Integer, + boost::random_access_traversal_tag, + Integer, + std::ptrdiff_t + > + { + typedef boost::iterator_facade< + integer_iterator_with_step, + Integer, + boost::random_access_traversal_tag, + Integer, + std::ptrdiff_t + > base_t; + public: + typedef typename base_t::value_type value_type; + typedef typename base_t::difference_type difference_type; + typedef typename base_t::reference reference; + + integer_iterator_with_step(value_type first, value_type step, difference_type step_size) + : m_first(first) + , m_step(step) + , m_step_size(step_size) + { + BOOST_ASSERT( step >= 0 ); + BOOST_ASSERT( step_size != 0 ); + } + + private: + void increment() + { + ++m_step; + } + + void decrement() + { + --m_step; + } + + void advance(difference_type offset) + { + m_step += offset; + } + + difference_type distance_to(const integer_iterator_with_step& other) const + { + return other.m_step - m_step; + } + + bool equal(const integer_iterator_with_step& other) const + { + return m_step == other.m_step; + } + + reference dereference() const + { + return m_first + (m_step * m_step_size); + } + + friend class ::boost::iterator_core_access; + value_type m_first; + value_type m_step; + difference_type m_step_size; + }; + + } // namespace range_detail + + template + iterator_range< range_detail::integer_iterator > + irange(Integer first, Integer last) + { + BOOST_ASSERT( first <= last ); + return boost::iterator_range< range_detail::integer_iterator >( + range_detail::integer_iterator(first), + range_detail::integer_iterator(last)); + } + + template + iterator_range< range_detail::integer_iterator_with_step > + irange(Integer first, Integer last, StepSize step_size) + { + BOOST_ASSERT( step_size != 0 ); + BOOST_ASSERT( (step_size > 0) ? (last >= first) : (last <= first) ); + typedef typename range_detail::integer_iterator_with_step iterator_t; + + const std::ptrdiff_t last_step + = (static_cast(last) - static_cast(first)) + / (static_cast(step_size)); + + return boost::iterator_range< iterator_t >( + iterator_t(first, 0, step_size), + iterator_t(first, last_step, step_size)); + } + +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/istream_range.hpp b/include/boost/range/istream_range.hpp new file mode 100755 index 0000000..fac17a4 --- /dev/null +++ b/include/boost/range/istream_range.hpp @@ -0,0 +1,34 @@ +// Boost.Range library +// +// Copyright Neil Groves 2008. Use, modification and +// distribution is subject to the Boost Software Licence, 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 +// + +#ifndef BOOST_RANGE_ISTREAM_RANGE_HPP_INCLUDED +#define BOOST_RANGE_ISTREAM_RANGE_HPP_INCLUDED + +/*! + * \file istream_range.hpp + */ + +#include +#include +#include + +namespace boost +{ + template inline + range > + istream_range(std::basic_istream& in) + { + return range >( + std::istream_iterator(in), + std::istream_iterator()); + } +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index d118224..dfcd4d2 100644 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -1,659 +1,16 @@ // Boost.Range library // -// Copyright Thorsten Ottosen & Pavol Droba 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 +// Copyright Neil Groves 2009. +// 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/ // +#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP_INCLUDED +#define BOOST_RANGE_ITERATOR_RANGE_HPP_INCLUDED -#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP -#define BOOST_RANGE_ITERATOR_RANGE_HPP - -#include // Define __STL_CONFIG_H, if appropriate. -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) - #pragma warning( push ) - #pragma warning( disable : 4996 ) -#endif - -// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch. -#ifndef BOOST_OLD_IOSTREAMS -# if defined(__STL_CONFIG_H) && \ - !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ - /**/ -# define BOOST_OLD_IOSTREAMS -# endif -#endif // #ifndef BOOST_OLD_IOSTREAMS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _STLP_NO_IOSTREAMS -# ifndef BOOST_OLD_IOSTREAMS -# include -# else -# include -# endif -#endif // _STLP_NO_IOSTREAMS -#include - -/*! \file - Defines the \c iterator_class and related functions. - \c iterator_range is a simple wrapper of iterator pair idiom. It provides - a rich subset of Container interface. -*/ - - -namespace boost -{ - namespace iterator_range_detail - { - // - // The functions adl_begin and adl_end are implemented in a separate - // class for gcc-2.9x - // - template - struct iterator_range_impl { - template< class ForwardRange > - static IteratorT adl_begin( ForwardRange& r ) - { - return IteratorT( boost::begin( r ) ); - } - - template< class ForwardRange > - static IteratorT adl_end( ForwardRange& r ) - { - return IteratorT( boost::end( r ) ); - } - }; - - template< class Left, class Right > - inline bool equal( const Left& l, const Right& r ) - { - typedef BOOST_DEDUCED_TYPENAME boost::range_difference::type sz_type; - - sz_type l_size = boost::distance( l ), - r_size = boost::distance( r ); - - if( l_size != r_size ) - return false; - - return std::equal( boost::begin(l), boost::end(l), - boost::begin(r) ); - } - - template< class Left, class Right > - inline bool less_than( const Left& l, const Right& r ) - { - return std::lexicographical_compare( boost::begin(l), - boost::end(l), - boost::begin(r), - boost::end(r) ); - } - - struct range_tag { }; - struct const_range_tag { }; - - } - -// iterator range template class -----------------------------------------// - - //! iterator_range class - /*! - An \c iterator_range delimits a range in a sequence by beginning and ending iterators. - An iterator_range can be passed to an algorithm which requires a sequence as an input. - For example, the \c toupper() function may be used most frequently on strings, - but can also be used on iterator_ranges: - - \code - boost::tolower( find( s, "UPPERCASE STRING" ) ); - \endcode - - Many algorithms working with sequences take a pair of iterators, - delimiting a working range, as an arguments. The \c iterator_range class is an - encapsulation of a range identified by a pair of iterators. - It provides a collection interface, - so it is possible to pass an instance to an algorithm requiring a collection as an input. - */ - template - class iterator_range - { - protected: // Used by sub_range - //! implementation class - typedef iterator_range_detail::iterator_range_impl impl; - public: - - //! this type - typedef iterator_range type; - //BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type); - - //! Encapsulated value type - typedef BOOST_DEDUCED_TYPENAME - iterator_value::type value_type; - - //! Difference type - typedef BOOST_DEDUCED_TYPENAME - iterator_difference::type difference_type; - - //! Size type - typedef std::size_t size_type; // note: must be unsigned - - //! This type - typedef iterator_range this_type; - - //! Refence type - // - // Needed because value-type is the same for - // const and non-const iterators - // - typedef BOOST_DEDUCED_TYPENAME - iterator_reference::type reference; - - //! const_iterator type - /*! - There is no distinction between const_iterator and iterator. - These typedefs are provides to fulfill container interface - */ - typedef IteratorT const_iterator; - //! iterator type - typedef IteratorT iterator; - - private: // for return value of operator()() - typedef BOOST_DEDUCED_TYPENAME - boost::mpl::if_< boost::is_abstract, - reference, value_type >::type abstract_value_type; - - public: - iterator_range() : m_Begin( iterator() ), m_End( iterator() ) - #ifndef NDEBUG - , singular( true ) - #endif - { } - - //! Constructor from a pair of iterators - template< class Iterator > - iterator_range( Iterator Begin, Iterator End ) : - m_Begin(Begin), m_End(End) - #ifndef NDEBUG - , singular(false) - #endif - {} - - //! Constructor from a Range - template< class Range > - iterator_range( const Range& r ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG - , singular(false) - #endif - {} - - //! Constructor from a Range - template< class Range > - iterator_range( Range& r ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG - , singular(false) - #endif - {} - - //! Constructor from a Range - template< class Range > - iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG - , singular(false) - #endif - {} - - //! Constructor from a Range - template< class Range > - iterator_range( Range& r, iterator_range_detail::range_tag ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG - , singular(false) - #endif - {} - - #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - this_type& operator=( const this_type& r ) - { - m_Begin = r.begin(); - m_End = r.end(); - - #ifndef NDEBUG - singular = r.singular; - #endif - return *this; - } - #endif - - template< class Iterator > - iterator_range& operator=( const iterator_range& r ) - { - m_Begin = r.begin(); - m_End = r.end(); - #ifndef NDEBUG - singular = r.is_singular(); - #endif - return *this; - } - - template< class ForwardRange > - iterator_range& operator=( ForwardRange& r ) - { - m_Begin = impl::adl_begin( r ); - m_End = impl::adl_end( r ); - #ifndef NDEBUG - singular = false; - #endif - return *this; - } - - template< class ForwardRange > - iterator_range& operator=( const ForwardRange& r ) - { - m_Begin = impl::adl_begin( r ); - m_End = impl::adl_end( r ); - #ifndef NDEBUG - singular = false; - #endif - return *this; - } - - IteratorT begin() const - { - BOOST_ASSERT( !is_singular() ); - return m_Begin; - } - - IteratorT end() const - { - BOOST_ASSERT( !is_singular() ); - return m_End; - } - - difference_type size() const - { - BOOST_ASSERT( !is_singular() ); - return m_End - m_Begin; - } - - bool empty() const - { - BOOST_ASSERT( !is_singular() ); - return m_Begin == m_End; - } - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - operator bool() const - { - return !empty(); - } -#else - typedef iterator (iterator_range::*unspecified_bool_type) () const; - operator unspecified_bool_type() const - { - return empty() ? 0: &iterator_range::end; - } -#endif - - bool equal( const iterator_range& r ) const - { - BOOST_ASSERT( !is_singular() ); - return m_Begin == r.m_Begin && m_End == r.m_End; - } - - -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - bool operator==( const iterator_range& r ) const - { - BOOST_ASSERT( !is_singular() ); - return iterator_range_detail::equal( *this, r ); - } - - bool operator!=( const iterator_range& r ) const - { - BOOST_ASSERT( !is_singular() ); - return !operator==(r); - } - - bool operator<( const iterator_range& r ) const - { - BOOST_ASSERT( !is_singular() ); - return iterator_range_detail::less_than( *this, r ); - } - -#endif - - public: // convenience - reference front() const - { - BOOST_ASSERT( !empty() ); - return *m_Begin; - } - - reference back() const - { - BOOST_ASSERT( !empty() ); - IteratorT last( m_End ); - return *--last; - } - - reference operator[]( difference_type at ) const - { - BOOST_ASSERT( at >= 0 && at < size() ); - return m_Begin[at]; - } - - // - // When storing transform iterators, operator[]() - // fails because it returns by reference. Therefore - // operator()() is provided for these cases. - // - abstract_value_type operator()( difference_type at ) const - { - BOOST_ASSERT( at >= 0 && at < size() ); - return m_Begin[at]; - } - - iterator_range& advance_begin( difference_type n ) - { - BOOST_ASSERT( !is_singular() ); - std::advance( m_Begin, n ); - return *this; - } - - iterator_range& advance_end( difference_type n ) - { - BOOST_ASSERT( !is_singular() ); - std::advance( m_End, n ); - return *this; - } - - private: - // begin and end iterators - IteratorT m_Begin; - IteratorT m_End; - - #ifndef NDEBUG - bool singular; - #endif - - public: - bool is_singular() const - { - #ifndef NDEBUG - return singular; - #else - return false; - #endif - } - - protected: - // - // Allow subclasses an easy way to access the - // base type - // - typedef iterator_range iterator_range_; - }; - -// iterator range free-standing operators ---------------------------// - -#ifndef _STLP_NO_IOSTREAMS -# ifndef BOOST_OLD_IOSTREAMS - - //! iterator_range output operator - /*! - Output the range to an ostream. Elements are outputed - in a sequence without separators. - */ - template< typename IteratorT, typename Elem, typename Traits > - inline std::basic_ostream& operator<<( - std::basic_ostream& Os, - const iterator_range& r ) - { - std::copy( r.begin(), r.end(), - std::ostream_iterator< BOOST_DEDUCED_TYPENAME - iterator_value::type, - Elem, Traits>(Os) ); - return Os; - } - -# else - - //! iterator_range output operator - /*! - Output the range to an ostream. Elements are outputed - in a sequence without separators. - */ - template< typename IteratorT > - inline std::ostream& operator<<( - std::ostream& Os, - const iterator_range& r ) - { - std::copy( r.begin(), r.end(), std::ostream_iterator(Os)); - return Os; - } - -# endif -#endif // _STLP_NO_IOSTREAMS - - ///////////////////////////////////////////////////////////////////// - // comparison operators - ///////////////////////////////////////////////////////////////////// - - template< class IteratorT, class ForwardRange > - inline bool operator==( const ForwardRange& l, - const iterator_range& r ) - { - return iterator_range_detail::equal( l, r ); - } - - template< class IteratorT, class ForwardRange > - inline bool operator!=( const ForwardRange& l, - const iterator_range& r ) - { - return !iterator_range_detail::equal( l, r ); - } - - template< class IteratorT, class ForwardRange > - inline bool operator<( const ForwardRange& l, - const iterator_range& r ) - { - return iterator_range_detail::less_than( l, r ); - } - -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -#else - template< class Iterator1T, class Iterator2T > - inline bool operator==( const iterator_range& l, - const iterator_range& r ) - { - return iterator_range_detail::equal( l, r ); - } - - template< class IteratorT, class ForwardRange > - inline bool operator==( const iterator_range& l, - const ForwardRange& r ) - { - return iterator_range_detail::equal( l, r ); - } - - - template< class Iterator1T, class Iterator2T > - inline bool operator!=( const iterator_range& l, - const iterator_range& r ) - { - return !iterator_range_detail::equal( l, r ); - } - - template< class IteratorT, class ForwardRange > - inline bool operator!=( const iterator_range& l, - const ForwardRange& r ) - { - return !iterator_range_detail::equal( l, r ); - } - - - template< class Iterator1T, class Iterator2T > - inline bool operator<( const iterator_range& l, - const iterator_range& r ) - { - return iterator_range_detail::less_than( l, r ); - } - - template< class IteratorT, class ForwardRange > - inline bool operator<( const iterator_range& l, - const ForwardRange& r ) - { - return iterator_range_detail::less_than( l, r ); - } - -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - -// iterator range utilities -----------------------------------------// - - //! iterator_range construct helper - /*! - Construct an \c iterator_range from a pair of iterators - - \param Begin A begin iterator - \param End An end iterator - \return iterator_range object - */ - template< typename IteratorT > - inline iterator_range< IteratorT > - make_iterator_range( IteratorT Begin, IteratorT End ) - { - return iterator_range( Begin, End ); - } - -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - template< typename Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( Range& r ) - { - return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - ( boost::begin( r ), boost::end( r ) ); - } - -#else - //! iterator_range construct helper - /*! - Construct an \c iterator_range from a \c Range containing the begin - and end iterators. - */ - template< class ForwardRange > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( ForwardRange& r ) - { - return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - ( r, iterator_range_detail::range_tag() ); - } - - template< class ForwardRange > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( const ForwardRange& r ) - { - return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - ( r, iterator_range_detail::const_range_tag() ); - } - -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - namespace iterator_range_detail - { - template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_range_impl( Range& r, - BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, - BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) - { - // - // Not worth the effort - // - //if( advance_begin == 0 && advance_end == 0 ) - // return make_iterator_range( r ); - // - - BOOST_DEDUCED_TYPENAME range_iterator::type - new_begin = boost::begin( r ), - new_end = boost::end( r ); - std::advance( new_begin, advance_begin ); - std::advance( new_end, advance_end ); - return make_iterator_range( new_begin, new_end ); - } - } - -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( Range& r, - BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, - BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) - { - //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" ); - return iterator_range_detail::make_range_impl( r, advance_begin, advance_end ); - } - -#else - - template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( Range& r, - BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, - BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) - { - //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" ); - return iterator_range_detail::make_range_impl( r, advance_begin, advance_end ); - } - - template< class Range > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( const Range& r, - BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, - BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) - { - //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" ); - return iterator_range_detail::make_range_impl( r, advance_begin, advance_end ); - } - -#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - - //! copy a range into a sequence - /*! - Construct a new sequence of the specified type from the elements - in the given range - - \param Range An input range - \return New sequence - */ - template< typename SeqT, typename Range > - inline SeqT copy_range( const Range& r ) - { - return SeqT( boost::begin( r ), boost::end( r ) ); - } - -} // namespace 'boost' - -#undef BOOST_OLD_IOSTREAMS - -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) - #pragma warning( pop ) -#endif - -#endif +#include "boost/range/iterator_range_core.hpp" +#include "boost/range/iterator_range_io.hpp" +#endif // include guard diff --git a/include/boost/range/iterator_range_core.hpp b/include/boost/range/iterator_range_core.hpp new file mode 100755 index 0000000..7514c81 --- /dev/null +++ b/include/boost/range/iterator_range_core.hpp @@ -0,0 +1,540 @@ +// Boost.Range library +// +// Copyright Neil Groves & Thorsten Ottosen & Pavol Droba 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/ +// +#ifndef BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED +#define BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED + +#include // Define __STL_CONFIG_H, if appropriate. +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning( push ) + #pragma warning( disable : 4996 ) +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! \file + Defines the \c iterator_class and related functions. + \c iterator_range is a simple wrapper of iterator pair idiom. It provides + a rich subset of Container interface. +*/ + + +namespace boost +{ + namespace iterator_range_detail + { + // + // The functions adl_begin and adl_end are implemented in a separate + // class for gcc-2.9x + // + template + struct iterator_range_impl { + template< class ForwardRange > + static IteratorT adl_begin( ForwardRange& r ) + { + return IteratorT( boost::begin( r ) ); + } + + template< class ForwardRange > + static IteratorT adl_end( ForwardRange& r ) + { + return IteratorT( boost::end( r ) ); + } + }; + + template< class Left, class Right > + inline bool less_than( const Left& l, const Right& r ) + { + return std::lexicographical_compare( boost::begin(l), + boost::end(l), + boost::begin(r), + boost::end(r) ); + } + + // This version is maintained since it is used in other boost libraries + // such as Boost.Assign + template< class Left, class Right > + inline bool equal(const Left& l, const Right& r) + { + return boost::equal(l, r); + } + + struct range_tag { }; + struct const_range_tag { }; + + } + +// iterator range template class -----------------------------------------// + + //! iterator_range class + /*! + An \c iterator_range delimits a range in a sequence by beginning and ending iterators. + An iterator_range can be passed to an algorithm which requires a sequence as an input. + For example, the \c toupper() function may be used most frequently on strings, + but can also be used on iterator_ranges: + + \code + boost::tolower( find( s, "UPPERCASE STRING" ) ); + \endcode + + Many algorithms working with sequences take a pair of iterators, + delimiting a working range, as an arguments. The \c iterator_range class is an + encapsulation of a range identified by a pair of iterators. + It provides a collection interface, + so it is possible to pass an instance to an algorithm requiring a collection as an input. + */ + template + class iterator_range + { + protected: // Used by sub_range + //! implementation class + typedef iterator_range_detail::iterator_range_impl impl; + public: + + //! this type + typedef iterator_range type; + //BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type); + + //! Encapsulated value type + typedef BOOST_DEDUCED_TYPENAME + iterator_value::type value_type; + + //! Difference type + typedef BOOST_DEDUCED_TYPENAME + iterator_difference::type difference_type; + + //! Size type + typedef std::size_t size_type; // note: must be unsigned + + //! This type + typedef iterator_range this_type; + + //! Reference type + // + // Needed because value-type is the same for + // const and non-const iterators + // + typedef BOOST_DEDUCED_TYPENAME + iterator_reference::type reference; + + //! const_iterator type + /*! + There is no distinction between const_iterator and iterator. + These typedefs are provides to fulfill container interface + */ + typedef IteratorT const_iterator; + //! iterator type + typedef IteratorT iterator; + + private: // for return value of operator()() + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::if_< boost::is_abstract, + reference, value_type >::type abstract_value_type; + + public: + iterator_range() : m_Begin( iterator() ), m_End( iterator() ) + { } + + //! Constructor from a pair of iterators + template< class Iterator > + iterator_range( Iterator Begin, Iterator End ) : + m_Begin(Begin), m_End(End) + {} + + //! Constructor from a Range + template< class Range > + iterator_range( const Range& r ) : + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + {} + + //! Constructor from a Range + template< class Range > + iterator_range( Range& r ) : + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + {} + + //! Constructor from a Range + template< class Range > + iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + {} + + //! Constructor from a Range + template< class Range > + iterator_range( Range& r, iterator_range_detail::range_tag ) : + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + {} + + #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + this_type& operator=( const this_type& r ) + { + m_Begin = r.begin(); + m_End = r.end(); + return *this; + } + #endif + + template< class Iterator > + iterator_range& operator=( const iterator_range& r ) + { + m_Begin = r.begin(); + m_End = r.end(); + return *this; + } + + template< class ForwardRange > + iterator_range& operator=( ForwardRange& r ) + { + m_Begin = impl::adl_begin( r ); + m_End = impl::adl_end( r ); + return *this; + } + + template< class ForwardRange > + iterator_range& operator=( const ForwardRange& r ) + { + m_Begin = impl::adl_begin( r ); + m_End = impl::adl_end( r ); + return *this; + } + + IteratorT begin() const + { + return m_Begin; + } + + IteratorT end() const + { + return m_End; + } + + difference_type size() const + { + return m_End - m_Begin; + } + + bool empty() const + { + return m_Begin == m_End; + } + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + operator bool() const + { + return !empty(); + } +#else + typedef iterator (iterator_range::*unspecified_bool_type) () const; + operator unspecified_bool_type() const + { + return empty() ? 0: &iterator_range::end; + } +#endif + + bool equal( const iterator_range& r ) const + { + return m_Begin == r.m_Begin && m_End == r.m_End; + } + + +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + bool operator==( const iterator_range& r ) const + { + return boost::equal( *this, r ); + } + + bool operator!=( const iterator_range& r ) const + { + return !operator==(r); + } + + bool operator<( const iterator_range& r ) const + { + return iterator_range_detail::less_than( *this, r ); + } + +#endif + + public: // convenience + reference front() const + { + BOOST_ASSERT( !empty() ); + return *m_Begin; + } + + reference back() const + { + BOOST_ASSERT( !empty() ); + IteratorT last( m_End ); + return *--last; + } + + reference operator[]( difference_type at ) const + { + BOOST_ASSERT( at >= 0 && at < size() ); + return m_Begin[at]; + } + + // + // When storing transform iterators, operator[]() + // fails because it returns by reference. Therefore + // operator()() is provided for these cases. + // + abstract_value_type operator()( difference_type at ) const + { + BOOST_ASSERT( at >= 0 && at < size() ); + return m_Begin[at]; + } + + iterator_range& advance_begin( difference_type n ) + { + std::advance( m_Begin, n ); + return *this; + } + + iterator_range& advance_end( difference_type n ) + { + std::advance( m_End, n ); + return *this; + } + + private: + // begin and end iterators + IteratorT m_Begin; + IteratorT m_End; + + protected: + // + // Allow subclasses an easy way to access the + // base type + // + typedef iterator_range iterator_range_; + }; + +// iterator range free-standing operators ---------------------------// + + ///////////////////////////////////////////////////////////////////// + // comparison operators + ///////////////////////////////////////////////////////////////////// + + template< class IteratorT, class ForwardRange > + inline bool operator==( const ForwardRange& l, + const iterator_range& r ) + { + return boost::equal( l, r ); + } + + template< class IteratorT, class ForwardRange > + inline bool operator!=( const ForwardRange& l, + const iterator_range& r ) + { + return !boost::equal( l, r ); + } + + template< class IteratorT, class ForwardRange > + inline bool operator<( const ForwardRange& l, + const iterator_range& r ) + { + return iterator_range_detail::less_than( l, r ); + } + +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +#else + template< class Iterator1T, class Iterator2T > + inline bool operator==( const iterator_range& l, + const iterator_range& r ) + { + return boost::equal( l, r ); + } + + template< class IteratorT, class ForwardRange > + inline bool operator==( const iterator_range& l, + const ForwardRange& r ) + { + return boost::equal( l, r ); + } + + + template< class Iterator1T, class Iterator2T > + inline bool operator!=( const iterator_range& l, + const iterator_range& r ) + { + return !boost::equal( l, r ); + } + + template< class IteratorT, class ForwardRange > + inline bool operator!=( const iterator_range& l, + const ForwardRange& r ) + { + return !boost::equal( l, r ); + } + + + template< class Iterator1T, class Iterator2T > + inline bool operator<( const iterator_range& l, + const iterator_range& r ) + { + return iterator_range_detail::less_than( l, r ); + } + + template< class IteratorT, class ForwardRange > + inline bool operator<( const iterator_range& l, + const ForwardRange& r ) + { + return iterator_range_detail::less_than( l, r ); + } + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +// iterator range utilities -----------------------------------------// + + //! iterator_range construct helper + /*! + Construct an \c iterator_range from a pair of iterators + + \param Begin A begin iterator + \param End An end iterator + \return iterator_range object + */ + template< typename IteratorT > + inline iterator_range< IteratorT > + make_iterator_range( IteratorT Begin, IteratorT End ) + { + return iterator_range( Begin, End ); + } + +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + template< typename Range > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_iterator_range( Range& r ) + { + return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + ( boost::begin( r ), boost::end( r ) ); + } + +#else + //! iterator_range construct helper + /*! + Construct an \c iterator_range from a \c Range containing the begin + and end iterators. + */ + template< class ForwardRange > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_iterator_range( ForwardRange& r ) + { + return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + ( r, iterator_range_detail::range_tag() ); + } + + template< class ForwardRange > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_iterator_range( const ForwardRange& r ) + { + return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + ( r, iterator_range_detail::const_range_tag() ); + } + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + namespace iterator_range_detail + { + template< class Range > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_range_impl( Range& r, + BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, + BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) + { + // + // Not worth the effort + // + //if( advance_begin == 0 && advance_end == 0 ) + // return make_iterator_range( r ); + // + + BOOST_DEDUCED_TYPENAME range_iterator::type + new_begin = boost::begin( r ), + new_end = boost::end( r ); + std::advance( new_begin, advance_begin ); + std::advance( new_end, advance_end ); + return make_iterator_range( new_begin, new_end ); + } + } + +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + template< class Range > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_iterator_range( Range& r, + BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, + BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) + { + //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" ); + return iterator_range_detail::make_range_impl( r, advance_begin, advance_end ); + } + +#else + + template< class Range > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_iterator_range( Range& r, + BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, + BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) + { + //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" ); + return iterator_range_detail::make_range_impl( r, advance_begin, advance_end ); + } + + template< class Range > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + make_iterator_range( const Range& r, + BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, + BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) + { + //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" ); + return iterator_range_detail::make_range_impl( r, advance_begin, advance_end ); + } + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + //! copy a range into a sequence + /*! + Construct a new sequence of the specified type from the elements + in the given range + + \param Range An input range + \return New sequence + */ + template< typename SeqT, typename Range > + inline SeqT copy_range( const Range& r ) + { + return SeqT( boost::begin( r ), boost::end( r ) ); + } + +} // namespace 'boost' + +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning( pop ) +#endif + +#endif + diff --git a/include/boost/range/iterator_range_io.hpp b/include/boost/range/iterator_range_io.hpp new file mode 100755 index 0000000..51e3a4f --- /dev/null +++ b/include/boost/range/iterator_range_io.hpp @@ -0,0 +1,93 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. +// 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/ +// +#ifndef BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED +#define BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED + +#include +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning( push ) + #pragma warning( disable : 4996 ) +#endif + +// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch. +#ifndef BOOST_OLD_IOSTREAMS +# if defined(__STL_CONFIG_H) && \ + !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ + /**/ +# define BOOST_OLD_IOSTREAMS +# endif +#endif // #ifndef BOOST_OLD_IOSTREAMS + +#ifndef _STLP_NO_IOSTREAMS +# ifndef BOOST_OLD_IOSTREAMS +# include +# else +# include +# endif +#endif // _STLP_NO_IOSTREAMS + +#include +#include +#include +#include + +namespace boost +{ + +#ifndef _STLP_NO_IOSTREAMS +# ifndef BOOST_OLD_IOSTREAMS + + //! iterator_range output operator + /*! + Output the range to an ostream. Elements are outputed + in a sequence without separators. + */ + template< typename IteratorT, typename Elem, typename Traits > + inline std::basic_ostream& operator<<( + std::basic_ostream& Os, + const iterator_range& r ) + { + std::copy( r.begin(), r.end(), + std::ostream_iterator< BOOST_DEDUCED_TYPENAME + iterator_value::type, + Elem, Traits>(Os) ); + return Os; + } + +# else + + //! iterator_range output operator + /*! + Output the range to an ostream. Elements are outputed + in a sequence without separators. + */ + template< typename IteratorT > + inline std::ostream& operator<<( + std::ostream& Os, + const iterator_range& r ) + { + std::copy( r.begin(), r.end(), std::ostream_iterator(Os)); + return Os; + } + +# endif +#endif // _STLP_NO_IOSTREAMS + +} // namespace boost + +#undef BOOST_OLD_IOSTREAMS + +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning(pop) +#endif + +#endif // include guard diff --git a/include/boost/range/join.hpp b/include/boost/range/join.hpp new file mode 100644 index 0000000..5e8f064 --- /dev/null +++ b/include/boost/range/join.hpp @@ -0,0 +1,68 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_JOIN_HPP_INCLUDED +#define BOOST_RANGE_JOIN_HPP_INCLUDED + +#include +#include +#include +#include + +namespace boost +{ + +template +iterator_range::type, + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME add_const< + BOOST_DEDUCED_TYPENAME range_value::type>::type> +> +join(const SinglePassRange1& r1, const SinglePassRange2& r2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + typedef range_detail::join_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME add_const< + BOOST_DEDUCED_TYPENAME range_value::type>::type> iterator_t; + + return iterator_range( + iterator_t(r1, r2, range_detail::join_iterator_begin_tag()), + iterator_t(r1, r2, range_detail::join_iterator_end_tag())); +} + +template +iterator_range::type, + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_value::type> +> +join(SinglePassRange1& r1, SinglePassRange2& r2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + typedef range_detail::join_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_value::type> iterator_t; + + return iterator_range( + iterator_t(r1, r2, range_detail::join_iterator_begin_tag()), + iterator_t(r1, r2, range_detail::join_iterator_end_tag())); +} + +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/mutable_iterator.hpp b/include/boost/range/mutable_iterator.hpp old mode 100755 new mode 100644 index 2f45c16..7beca66 --- a/include/boost/range/mutable_iterator.hpp +++ b/include/boost/range/mutable_iterator.hpp @@ -21,6 +21,7 @@ #include #else +#include #include #include #include @@ -31,11 +32,13 @@ namespace boost // default ////////////////////////////////////////////////////////////////////////// + namespace range_detail { + BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( iterator ) + } + template< typename C > - struct range_mutable_iterator - { - typedef BOOST_DEDUCED_TYPENAME C::iterator type; - }; + struct range_mutable_iterator : range_detail::extract_iterator + {}; ////////////////////////////////////////////////////////////////////////// // pair diff --git a/include/boost/range/numeric.hpp b/include/boost/range/numeric.hpp new file mode 100755 index 0000000..17e2cfe --- /dev/null +++ b/include/boost/range/numeric.hpp @@ -0,0 +1,117 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file algorithm.hpp +/// Contains range-based versions of the std algorithms +// +///////////////////////////////////////////////////////////////////////////// +// Copyright 2009 Neil Groves. +// Distributed under 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) +// + +// Copyright 2006 Thorsten Ottosen. +// Distributed under 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) +// +// Copyright 2004 Eric Niebler. +// Distributed under 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) + +#if defined(_MSC_VER) && _MSC_VER >= 1000 + #pragma once +#endif + +#ifndef BOOST_RANGE_NUMERIC_HPP +#define BOOST_RANGE_NUMERIC_HPP + +#include +#include +#include +#include +#include +#include + + +namespace boost +{ + template< class SinglePassRange, class Value > + inline Value accumulate( const SinglePassRange& rng, Value init ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::accumulate( boost::begin(rng), boost::end(rng), init ); + } + + template< class SinglePassRange, class Value, class BinaryOperation > + inline Value accumulate( const SinglePassRange& rng, Value init, BinaryOperation op ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::accumulate( boost::begin(rng), boost::end(rng), init, op ); + } + + + template< class SinglePassRange1, class SinglePassRange2, class Value > + inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init ) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) ); + return std::inner_product( boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), init ); + } + + template< class SinglePassRange1, + class SinglePassRange2, + class Value, + class BinaryOperation1, class BinaryOperation2 > + inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, + Value init, + BinaryOperation1 op1, BinaryOperation2 op2 ) + { + boost::function_requires< SinglePassRangeConcept >(); + boost::function_requires< SinglePassRangeConcept >(); + BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) ); + + return std::inner_product( boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), init, op1, op2 ); + } + + template< class SinglePassRange, class OutputIterator > + inline OutputIterator partial_sum ( const SinglePassRange& rng, + OutputIterator result ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::partial_sum( boost::begin(rng), boost::end(rng), result ); + } + + template< class SinglePassRange, class OutputIterator, class BinaryOperation > + inline OutputIterator partial_sum ( const SinglePassRange& rng, OutputIterator result, + BinaryOperation op ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::partial_sum( boost::begin(rng), boost::end(rng), result, op ); + } + + template< class SinglePassRange, class OutputIterator > + inline OutputIterator adjacent_difference ( const SinglePassRange& rng, + OutputIterator result ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::adjacent_difference( boost::begin(rng), boost::end(rng), + result ); + } + + template< class SinglePassRange, class OutputIterator, class BinaryOperation > + inline OutputIterator adjacent_difference ( const SinglePassRange& rng, + OutputIterator result, + BinaryOperation op ) + { + boost::function_requires< SinglePassRangeConcept >(); + return std::adjacent_difference( boost::begin(rng), boost::end(rng), + result, op ); + } + +} + +#endif diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp index dc66692..2f46c7b 100644 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -1,5 +1,6 @@ // Boost.Range library // +// Copyright Neil Groves 2009. // 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 @@ -22,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -151,14 +153,14 @@ namespace boost inline bool operator==( const sub_range& l, const sub_range& r ) { - return iterator_range_detail::equal( l, r ); + return boost::equal( l, r ); } template< class ForwardRange, class ForwardRange2 > inline bool operator!=( const sub_range& l, const sub_range& r ) { - return !iterator_range_detail::equal( l, r ); + return !boost::equal( l, r ); } template< class ForwardRange, class ForwardRange2 > diff --git a/include/boost/range/unbounded_range.hpp b/include/boost/range/unbounded_range.hpp new file mode 100755 index 0000000..570a0a4 --- /dev/null +++ b/include/boost/range/unbounded_range.hpp @@ -0,0 +1,73 @@ +#ifndef BOOST_RANGE_UNBOUNDED_RANGE_HPP +#define BOOST_RANGE_UNBOUNDED_RANGE_HPP + +#include +#include + +namespace boost +{ + template< class Iter > + struct unbounded_iterator_range : iterator_range + { + explicit unbounded_iterator_range( Iter r ) + : iterator_range( r, r ) + { + // + // Remark: by storing the same iterator + // twice, we can still allow + // comparison to execute without leading to + // operations on singular iterators + // + } + + private: + + bool empty() const + { + return false; + } + // + // Hide members that are illegal to use. + // + /* + void end() const; + void size() const; + void empty() const; + void equal() const; + operator bool() const; + bool operator==( unbounded_iterator_range ); + bool operator!=( unbounded_iterator_range ); + template< class S > + void operator[]( S s ) const; + template< class D > + void advance_end( D d ) const; + void back() const; + */ + }; + + template< class Iter > + inline unbounded_iterator_range unbounded_range( Iter r ) + { + return unbounded_iterator_range(r); + } + + namespace detail + { + char is_unbounded_range( ... ); + template< class Iter > + long is_unbounded_range( const unbounded_iterator_range* ); + } + + template< class T > + struct is_unbounded_range + { + private: + static T* ptr_; + + public: + BOOST_STATIC_CONSTANT( bool, + value = sizeof(long) == sizeof(detail::is_unbounded_range(ptr_) ) ); + }; +} + +#endif diff --git a/index.html b/index.html index 3e5f4bb..2a17910 100644 --- a/index.html +++ b/index.html @@ -1,84 +1,13 @@ - + - + - -Boost.Range Documentation - + Boost.Range Documentation + + - - - - - -
      -

      Range Library

      -
      - -

      - Copyright © 2003-2007 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: -

      - - - - -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      - + Automatic redirection failed, please go to doc/html/index.html - - - - diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c82a6c9..8cf4d7f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,5 +1,6 @@ # Boost.Range library # +# Copyright Neil Groves 2009 # 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 @@ -8,28 +9,124 @@ # For more information, see http://www.boost.org/libs/range/ # +# bring in rules for testing +import testing ; + +project + : requirements + /boost/test//boost_unit_test_framework/ + /boost/regex//boost_regex/ + static + multi + ; + rule range-test ( name : includes * ) { return [ - run $(name).cpp /boost/test//boost_unit_test_framework/static + run $(name).cpp /boost/test//boost_unit_test_framework /boost/regex//boost_regex/static + : : - : : gcc:"-Wall -Wunused " ] ; } 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 extension_mechanism ] -# [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] + [ range-test adaptor_test/adjacent_filtered ] + [ range-test adaptor_test/copied ] + [ range-test adaptor_test/filtered ] + [ range-test adaptor_test/indexed ] + [ range-test adaptor_test/indirected ] + [ range-test adaptor_test/map ] + [ range-test adaptor_test/replaced ] + [ range-test adaptor_test/replaced_if ] + [ range-test adaptor_test/reversed ] + [ range-test adaptor_test/sliced ] + [ range-test adaptor_test/strided ] + [ range-test adaptor_test/tokenized ] + [ range-test adaptor_test/transformed ] + [ range-test adaptor_test/uniqued ] + [ range-test adaptor_test/adjacent_filtered_example ] + [ range-test adaptor_test/copied_example ] + [ range-test adaptor_test/filtered_example ] + [ range-test adaptor_test/indexed_example ] + [ range-test adaptor_test/indirected_example ] + [ range-test adaptor_test/map_keys_example ] + [ range-test adaptor_test/map_values_example ] + [ range-test adaptor_test/replaced_example ] + [ range-test adaptor_test/replaced_if_example ] + [ range-test adaptor_test/reversed_example ] + [ range-test adaptor_test/sliced_example ] + [ range-test adaptor_test/strided_example ] + [ range-test adaptor_test/transformed_example ] + [ range-test adaptor_test/uniqued_example ] + [ range-test algorithm_test/adjacent_find ] + [ range-test algorithm_test/binary_search ] + [ range-test algorithm_test/copy ] + [ range-test algorithm_test/copy_backward ] + [ range-test algorithm_test/count ] + [ range-test algorithm_test/count_if ] + [ range-test algorithm_test/equal ] + [ range-test algorithm_test/equal_range ] + [ range-test algorithm_test/fill ] + [ range-test algorithm_test/find ] + [ range-test algorithm_test/find_if ] + [ range-test algorithm_test/find_end ] + [ range-test algorithm_test/find_first_of ] + [ range-test algorithm_test/for_each ] + [ range-test algorithm_test/generate ] + [ range-test algorithm_test/heap ] + [ range-test algorithm_test/includes ] + [ range-test algorithm_test/inplace_merge ] + [ range-test algorithm_test/lexicographical_compare ] + [ range-test algorithm_test/lower_bound ] + [ range-test algorithm_test/max_element ] + [ range-test algorithm_test/merge ] + [ range-test algorithm_test/min_element ] + [ range-test algorithm_test/mismatch ] + [ range-test algorithm_test/next_permutation ] + [ range-test algorithm_test/nth_element ] + [ range-test algorithm_test/partial_sort ] + [ range-test algorithm_test/partition ] + [ range-test algorithm_test/prev_permutation ] + [ range-test algorithm_test/random_shuffle ] + [ range-test algorithm_test/remove ] + [ range-test algorithm_test/remove_if ] + [ range-test algorithm_test/replace ] + [ range-test algorithm_test/replace_if ] + [ range-test algorithm_test/reverse ] + [ range-test algorithm_test/rotate ] + [ range-test algorithm_test/search ] + [ range-test algorithm_test/set_difference ] + [ range-test algorithm_test/set_intersection ] + [ range-test algorithm_test/set_symmetric_difference ] + [ range-test algorithm_test/set_union ] + [ range-test algorithm_test/sort ] + [ range-test algorithm_test/stable_partition ] + [ range-test algorithm_test/stable_sort ] + [ range-test algorithm_test/transform ] + [ range-test algorithm_test/unique ] + [ range-test algorithm_test/upper_bound ] + [ range-test adl_conformance ] + [ range-test adl_conformance_no_using ] + [ range-test algorithm ] + [ range-test algorithm_example ] + [ range-test array ] +# [ range-test atl : $(VC71_ROOT)/atlmfc/include ] + [ range-test combine ] + [ range-test compat2 ] + [ range-test compat3 ] + [ range-test const_ranges ] + [ range-test counting_range ] + [ range-test extension_mechanism ] + [ range-test irange ] + [ range-test iterator_pair ] + [ range-test iterator_range ] +# [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] + [ range-test join ] + [ range-test partial_workaround ] + [ range-test reversible_range ] + [ range-test std_container ] + [ range-test string ] + [ range-test sub_range ] ; diff --git a/test/adaptor_test/adjacent_filtered.cpp b/test/adaptor_test/adjacent_filtered.cpp new file mode 100644 index 0000000..48025ab --- /dev/null +++ b/test/adaptor_test/adjacent_filtered.cpp @@ -0,0 +1,110 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void adjacent_filtered_test_impl( Container& c ) + { + using namespace boost::adaptors; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + // This is my preferred syntax using the | operator. + std::vector< value_t > test_result1 + = boost::copy_range< std::vector< value_t > >( + c | adjacent_filtered(std::not_equal_to< value_t >())); + + // This is an alternative syntax preferred by some. + std::vector< value_t > test_result2 + = boost::copy_range< std::vector< value_t > >( + adaptors::adjacent_filter(c, std::not_equal_to< value_t >())); + + // Calculate the reference result. + std::vector< value_t > reference_result; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iter_t; + value_t prev_v = value_t(); + for (iter_t it = c.begin(); it != c.end(); ++it) + { + if (it == c.begin()) + { + reference_result.push_back(*it); + } + else if (*it != prev_v) + { + reference_result.push_back(*it); + } + prev_v = *it; + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_result.begin(), + reference_result.end(), + test_result1.begin(), + test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_result.begin(), + reference_result.end(), + test_result2.begin(), + test_result2.end() ); + } + + template< class Collection > + void adjacent_filtered_test_impl() + { + using namespace boost::assign; + + Collection c; + + // test empty collection + adjacent_filtered_test_impl(c); + + // test one element; + c += 1; + adjacent_filtered_test_impl(c); + + // test many elements; + c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9; + adjacent_filtered_test_impl(c); + } + + void adjacent_filtered_test() + { + adjacent_filtered_test_impl< std::vector< int > >(); + adjacent_filtered_test_impl< std::list< int > >(); + adjacent_filtered_test_impl< std::set< int > >(); + adjacent_filtered_test_impl< std::multiset< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.adjacent_filtered" ); + + test->add( BOOST_TEST_CASE( &boost::adjacent_filtered_test ) ); + + return test; +} diff --git a/test/adaptor_test/adjacent_filtered_example.cpp b/test/adaptor_test/adjacent_filtered_example.cpp new file mode 100644 index 0000000..b3538e8 --- /dev/null +++ b/test/adaptor_test/adjacent_filtered_example.cpp @@ -0,0 +1,58 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include +#include + +#include + +#include +#include + +namespace +{ + void adjacent_filtered_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,1,2,2,2,3,4,5,6; + + boost::copy( + input | adjacent_filtered(std::not_equal_to()), + std::ostream_iterator(std::cout, ",")); + + std::vector reference; + reference += 1,2,3,4,5,6; + + std::vector test; + boost::push_back(test, input | adjacent_filtered(std::not_equal_to())); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.adjacent_filtered_example" ); + + test->add( BOOST_TEST_CASE( &adjacent_filtered_example_test ) ); + + return test; +} \ No newline at end of file diff --git a/test/adaptor_test/copied.cpp b/test/adaptor_test/copied.cpp new file mode 100644 index 0000000..93f1cb7 --- /dev/null +++ b/test/adaptor_test/copied.cpp @@ -0,0 +1,84 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void copied_test_impl( Container& c ) + { + using namespace boost::adaptors; + + // This is my preferred syntax using the | operator. + std::vector< int > test_result1; + boost::push_back(test_result1, c | copied(0u, c.size())); + + // This is the alternative syntax preferred by some. + std::vector< int > test_result2; + boost::push_back(test_result2, adaptors::copy(c, 0u, c.size())); + + BOOST_CHECK_EQUAL_COLLECTIONS( test_result1.begin(), test_result1.end(), + c.begin(), c.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( test_result2.begin(), test_result2.end(), + c.begin(), c.end() ); + } + + template< class Container > + void copied_test_impl() + { + using namespace boost::assign; + + Container c; + + // test empty collection + copied_test_impl(c); + + // test one element + c += 1; + copied_test_impl(c); + + // test many elements + c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9; + copied_test_impl(c); + } + + void copied_test() + { + copied_test_impl< std::vector< int > >(); + copied_test_impl< std::deque< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.copied" ); + + test->add( BOOST_TEST_CASE( &boost::copied_test ) ); + + return test; +} diff --git a/test/adaptor_test/copied_example.cpp b/test/adaptor_test/copied_example.cpp new file mode 100644 index 0000000..f662a45 --- /dev/null +++ b/test/adaptor_test/copied_example.cpp @@ -0,0 +1,58 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include + +#include +#include + +namespace +{ + void copied_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | copied(1, 5), + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 2,3,4,5; + + std::vector test; + boost::push_back(test, input | copied(1, 5)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.copied_example" ); + + test->add( BOOST_TEST_CASE( &copied_example_test ) ); + + return test; +} \ No newline at end of file diff --git a/test/adaptor_test/filtered.cpp b/test/adaptor_test/filtered.cpp new file mode 100644 index 0000000..8e7b958 --- /dev/null +++ b/test/adaptor_test/filtered.cpp @@ -0,0 +1,135 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct always_false_pred + { + template< class T1 > + bool operator()(T1) const { return false; } + }; + + struct always_true_pred + { + template< class T1 > + bool operator()(T1) const { return true; } + }; + + struct is_even + { + template< class IntegerT > + bool operator()( IntegerT x ) const { return x % 2 == 0; } + }; + + struct is_odd + { + template< class IntegerT > + bool operator()( IntegerT x ) const { return x % 2 != 0; } + }; + + template< class Container, class Pred > + void filtered_test_impl( Container& c, Pred pred ) + { + using namespace boost::adaptors; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + // This is my preferred syntax using the | operator. + std::vector< value_t > test_result1; + boost::push_back(test_result1, c | filtered(pred)); + + // This is an alternative syntax preferred by some. + std::vector< value_t > test_result2; + boost::push_back(test_result2, adaptors::filter(c, pred)); + + // Calculate the reference result. + std::vector< value_t > reference_result; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iter_t; + for (iter_t it = c.begin(); it != c.end(); ++it) + { + if (pred(*it)) + reference_result.push_back(*it); + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_result.begin(), + reference_result.end(), + test_result1.begin(), + test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_result.begin(), + reference_result.end(), + test_result2.begin(), + test_result2.end() ); + } + + template< class Container, class Pred > + void filtered_test_impl() + { + using namespace boost::assign; + + Container c; + + // test empty container + filtered_test_impl(c, Pred()); + + // test one element + c += 1; + filtered_test_impl(c, Pred()); + + // test many elements + c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9; + filtered_test_impl(c, Pred()); + } + + template< class Container > + void filtered_test_all_predicates() + { + filtered_test_impl< Container, always_false_pred >(); + filtered_test_impl< Container, always_true_pred >(); + filtered_test_impl< Container, is_odd >(); + filtered_test_impl< Container, is_even >(); + } + + void filtered_test() + { + filtered_test_all_predicates< std::vector< int > >(); + filtered_test_all_predicates< std::list< int > >(); + filtered_test_all_predicates< std::set< int > >(); + filtered_test_all_predicates< std::multiset< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.filtered" ); + + test->add( BOOST_TEST_CASE( &boost::filtered_test ) ); + + return test; +} diff --git a/test/adaptor_test/filtered_example.cpp b/test/adaptor_test/filtered_example.cpp new file mode 100644 index 0000000..6d0e262 --- /dev/null +++ b/test/adaptor_test/filtered_example.cpp @@ -0,0 +1,62 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + struct is_even + { + bool operator()( int x ) const { return x % 2 == 0; } + }; + + void filtered_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | filtered(is_even()), + std::ostream_iterator(std::cout, ",")); + + std::vector reference; + reference += 2,4,6,8; + + std::vector test; + boost::push_back(test, input | filtered(is_even())); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.filtered_example" ); + + test->add( BOOST_TEST_CASE( &filtered_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/indexed.cpp b/test/adaptor_test/indexed.cpp new file mode 100644 index 0000000..2a9c45d --- /dev/null +++ b/test/adaptor_test/indexed.cpp @@ -0,0 +1,99 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void indexed_test_impl( Container& c ) + { + using namespace boost::adaptors; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + // This is my preferred syntax using the | operator. + std::vector< value_t > test_result1; + boost::push_back(test_result1, c | indexed(0)); + + // This is an alternative syntax preferred by some. + std::vector< value_t > test_result2; + boost::push_back(test_result2, adaptors::index(c, 0)); + + BOOST_CHECK_EQUAL_COLLECTIONS( c.begin(), c.end(), + test_result1.begin(), test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( c.begin(), c.end(), + test_result2.begin(), test_result2.end() ); + + boost::indexed_range< Container > test_result3 + = c | indexed(0); + + typedef BOOST_DEDUCED_TYPENAME boost::range_const_iterator< + boost::indexed_range< Container > >::type iter_t; + + iter_t it = test_result3.begin(); + for (std::size_t i = 0, count = c.size(); i < count; ++i) + { + BOOST_CHECK_EQUAL( i, static_cast(it.index()) ); + ++it; + } + + } + + template< class Container > + void indexed_test_impl() + { + using namespace boost::assign; + + Container c; + + // test empty container + indexed_test_impl(c); + + // test one element + c += 1; + indexed_test_impl(c); + + // test many elements + c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9; + indexed_test_impl(c); + } + + void indexed_test() + { + indexed_test_impl< std::vector< int > >(); + indexed_test_impl< std::list< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.indexed" ); + + test->add( BOOST_TEST_CASE( &boost::indexed_test ) ); + + return test; +} diff --git a/test/adaptor_test/indexed_example.cpp b/test/adaptor_test/indexed_example.cpp new file mode 100644 index 0000000..14837d2 --- /dev/null +++ b/test/adaptor_test/indexed_example.cpp @@ -0,0 +1,95 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + template + void display_element_and_index(Iterator first, Iterator last) + { + for (Iterator it = first; it != last; ++it) + { + std::cout << "Element = " << *it << " Index = " << it.index() << std::endl; + } + } + + template + void display_element_and_index(const SinglePassRange& rng) + { + display_element_and_index(boost::begin(rng), boost::end(rng)); + } + + template + void check_element_and_index( + Iterator1 test_first, + Iterator1 test_last, + Iterator2 reference_first, + Iterator2 reference_last) + { + BOOST_CHECK_EQUAL( std::distance(test_first, test_last), + std::distance(reference_first, reference_last) ); + + int reference_index = 0; + + Iterator1 test_it = test_first; + Iterator2 reference_it = reference_first; + for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index) + { + BOOST_CHECK_EQUAL( *test_it, *reference_it ); + BOOST_CHECK_EQUAL( test_it.index(), reference_index ); + } + } + + template + void check_element_and_index( + const SinglePassRange1& test_rng, + const SinglePassRange2& reference_rng) + { + check_element_and_index(boost::begin(test_rng), boost::end(test_rng), + boost::begin(reference_rng), boost::end(reference_rng)); + } + + void indexed_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 10,20,30,40,50,60,70,80,90; + + display_element_and_index( input | indexed(0) ); + + check_element_and_index( + input | indexed(0), + input); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.indexed_example" ); + + test->add( BOOST_TEST_CASE( &indexed_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/indirected.cpp b/test/adaptor_test/indirected.cpp new file mode 100644 index 0000000..fe3ebdf --- /dev/null +++ b/test/adaptor_test/indirected.cpp @@ -0,0 +1,99 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include + +#include +#include +#include +#include + +namespace boost +{ + namespace + { + + template< class Container > + void indirected_test_impl( Container& c ) + { + using namespace boost::adaptors; + + // This is my preferred syntax using the | operator. + std::vector< int > test_result1; + boost::push_back(test_result1, c | indirected); + + // This is an alternative syntax preferred by some. + std::vector< int > test_result2; + boost::push_back(test_result2, adaptors::indirect(c)); + + // Calculate the reference result. + std::vector< int > reference_result; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iter_t; + for (iter_t it = c.begin(); it != c.end(); ++it) + { + reference_result.push_back(**it); + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_result.begin(), + reference_result.end(), + test_result1.begin(), + test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_result.begin(), + reference_result.end(), + test_result2.begin(), + test_result2.end() ); + } + + template< class Container > + void indirected_test_impl() + { + using namespace boost::assign; + + Container c; + + indirected_test_impl(c); + + c += boost::shared_ptr(new int(1)); + indirected_test_impl(c); + + std::vector v; + v += 1,1,2,2,2,3,4,4,4,4,5,6,7,8,9,9; + for (std::vector::const_iterator it = v.begin(); it != v.end(); ++it) + { + c += boost::shared_ptr(new int(*it)); + } + indirected_test_impl(c); + } + + void indirected_test() + { + indirected_test_impl< std::vector< boost::shared_ptr< int > > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.indirected" ); + + test->add( BOOST_TEST_CASE( &boost::indirected_test ) ); + + return test; +} diff --git a/test/adaptor_test/indirected_example.cpp b/test/adaptor_test/indirected_example.cpp new file mode 100644 index 0000000..8e607a6 --- /dev/null +++ b/test/adaptor_test/indirected_example.cpp @@ -0,0 +1,60 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void indirected_example_test() + { + using namespace boost::adaptors; + + std::vector > input; + + for (int i = 0; i < 10; ++i) + input.push_back(boost::shared_ptr(new int(i))); + + boost::copy( + input | indirected, + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + for (int i = 0; i < 10; ++i) + reference.push_back(i); + + std::vector test; + boost::push_back(test, input | indirected); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.indirected_example" ); + + test->add( BOOST_TEST_CASE( &indirected_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/map.cpp b/test/adaptor_test/map.cpp new file mode 100644 index 0000000..73859b4 --- /dev/null +++ b/test/adaptor_test/map.cpp @@ -0,0 +1,127 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void map_test_keys( Container& c ) + { + using namespace boost::adaptors; + + std::vector keys; + boost::push_back(keys, c | map_keys); + + std::vector keys2; + boost::push_back(keys2, adaptors::keys(c)); + + std::vector reference_keys; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iter_t; + for (iter_t it = c.begin(); it != c.end(); ++it) + { + reference_keys.push_back(it->first); + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_keys.begin(), + reference_keys.end(), + keys.begin(), + keys.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_keys.begin(), + reference_keys.end(), + keys2.begin(), + keys2.end() ); + } + + template< class Container > + void map_test_values( Container& c ) + { + using namespace boost::adaptors; + + std::vector values; + boost::push_back(values, c | map_values); + + std::vector values2; + boost::push_back(values2, adaptors::values(c)); + + std::vector reference_values; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iter_t; + for (iter_t it = c.begin(); it != c.end(); ++it) + { + reference_values.push_back(it->second); + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_values.begin(), + reference_values.end(), + values.begin(), + values.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference_values.begin(), + reference_values.end(), + values2.begin(), + values2.end() ); + } + + template< class Container > + void map_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + map_test_keys(c); + map_test_values(c); + + // Test one element + c.insert(std::make_pair(1,2)); + map_test_keys(c); + map_test_values(c); + + // Test many elements + for (int x = 2; x < 10; ++x) + { + c.insert(std::make_pair(x, x * 2)); + } + map_test_keys(c); + map_test_values(c); + } + + void map_test() + { + map_test_impl< std::map >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.map" ); + + test->add( BOOST_TEST_CASE( &boost::map_test ) ); + + return test; +} diff --git a/test/adaptor_test/map_keys_example.cpp b/test/adaptor_test/map_keys_example.cpp new file mode 100644 index 0000000..df85456 --- /dev/null +++ b/test/adaptor_test/map_keys_example.cpp @@ -0,0 +1,60 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void map_keys_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); + + boost::copy( + input | map_keys, + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 0,1,2,3,4,5,6,7,8,9; + + std::vector test; + boost::push_back(test, input | map_keys); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.map_keys_example" ); + + test->add( BOOST_TEST_CASE( &map_keys_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/map_values_example.cpp b/test/adaptor_test/map_values_example.cpp new file mode 100644 index 0000000..dfb32e9 --- /dev/null +++ b/test/adaptor_test/map_values_example.cpp @@ -0,0 +1,60 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void map_values_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); + + boost::copy( + input | map_values, + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 0,10,20,30,40,50,60,70,80,90; + + std::vector test; + boost::push_back(test, input | map_values); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.map_values_example" ); + + test->add( BOOST_TEST_CASE( &map_values_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/replaced.cpp b/test/adaptor_test/replaced.cpp new file mode 100644 index 0000000..d3eac81 --- /dev/null +++ b/test/adaptor_test/replaced.cpp @@ -0,0 +1,87 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void replaced_test_impl( Container& c ) + { + using namespace boost::adaptors; + + const int value_to_replace = 1; + const int replacement_value = 0; + + std::vector< int > test_result1; + boost::push_back(test_result1, c | replaced(value_to_replace, replacement_value)); + + std::vector< int > test_result2; + boost::push_back(test_result2, adaptors::replace(c, value_to_replace, replacement_value)); + + std::vector< int > reference( c.begin(), c.end() ); + std::replace(reference.begin(), reference.end(), value_to_replace, replacement_value); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result1.begin(), test_result1.end() ); + } + + template< class Container > + void replaced_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + replaced_test_impl(c); + + // Test one + c += 1; + replaced_test_impl(c); + + // Test many + c += 1,1,1,2,2,2,3,3,3,3,3,4,5,6,6,6,7,8,9; + replaced_test_impl(c); + } + + void replaced_test() + { + replaced_test_impl< std::vector< int > >(); + replaced_test_impl< std::list< int > >(); + replaced_test_impl< std::set< int > >(); + replaced_test_impl< std::multiset< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.replaced" ); + + test->add( BOOST_TEST_CASE( &boost::replaced_test ) ); + + return test; +} diff --git a/test/adaptor_test/replaced_example.cpp b/test/adaptor_test/replaced_example.cpp new file mode 100644 index 0000000..fc1d2db --- /dev/null +++ b/test/adaptor_test/replaced_example.cpp @@ -0,0 +1,58 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void replaced_example_test() + { + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,2,5,2,7,2,9; + + boost::copy( + input | replaced(2, 10), + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 1,10,3,10,5,10,7,10,9; + + std::vector test; + boost::push_back(test, input | replaced(2, 10)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.replaced_example" ); + + test->add( BOOST_TEST_CASE( &replaced_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/replaced_if.cpp b/test/adaptor_test/replaced_if.cpp new file mode 100644 index 0000000..0bf227f --- /dev/null +++ b/test/adaptor_test/replaced_if.cpp @@ -0,0 +1,96 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct if_value_is_one + { + bool operator()(int x) const { return x == 1; } + }; + + template< class Container > + void replaced_if_test_impl( Container& c ) + { + using namespace boost::adaptors; + + if_value_is_one pred; + + const int replacement_value = 0; + + std::vector< int > test_result1; + boost::push_back(test_result1, c | replaced_if(pred, replacement_value)); + + std::vector< int > test_result2; + boost::push_back(test_result2, boost::adaptors::replace_if(c, pred, replacement_value)); + + std::vector< int > reference( c.begin(), c.end() ); + std::replace_if(reference.begin(), reference.end(), pred, replacement_value); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result1.begin(), test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result2.begin(), test_result2.end() ); + } + + template< class Container > + void replaced_if_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + replaced_if_test_impl(c); + + // Test one + c += 1; + replaced_if_test_impl(c); + + // Test many + c += 1,1,1,2,2,2,3,3,3,3,3,4,5,6,6,6,7,8,9; + replaced_if_test_impl(c); + } + + void replaced_if_test() + { + replaced_if_test_impl< std::vector< int > >(); + replaced_if_test_impl< std::list< int > >(); + replaced_if_test_impl< std::set< int > >(); + replaced_if_test_impl< std::multiset< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.replaced_if" ); + + test->add( BOOST_TEST_CASE( &boost::replaced_if_test ) ); + + return test; +} diff --git a/test/adaptor_test/replaced_if_example.cpp b/test/adaptor_test/replaced_if_example.cpp new file mode 100644 index 0000000..c762c2f --- /dev/null +++ b/test/adaptor_test/replaced_if_example.cpp @@ -0,0 +1,62 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + struct is_even + { + bool operator()(int x) const { return x % 2 == 0; } + }; + + void replaced_if_example_test() + { + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | replaced_if(is_even(), 10), + std::ostream_iterator(std::cout, ",")); + + std::vector reference; + reference += 1,10,3,10,5,10,7,10,9; + + std::vector test; + boost::push_back(test, input | replaced_if(is_even(), 10)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.replaced_if_example" ); + + test->add( BOOST_TEST_CASE( &replaced_if_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/reversed.cpp b/test/adaptor_test/reversed.cpp new file mode 100644 index 0000000..6663b36 --- /dev/null +++ b/test/adaptor_test/reversed.cpp @@ -0,0 +1,84 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include +#include + +namespace boost +{ + template< class Container > + void reversed_test_impl( Container& c ) + { + using namespace boost::adaptors; + + std::vector< int > test_result1; + boost::push_back(test_result1, c | reversed); + + std::vector< int > test_result2; + boost::push_back(test_result2, adaptors::reverse(c)); + + std::vector< int > reference( c.rbegin(), c.rend() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result1.begin(), test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result2.begin(), test_result2.end() ); + } + + template< class Container > + void reversed_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + reversed_test_impl(c); + + // Test one + c += 1; + reversed_test_impl(c); + + // Test many + c += 1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,5,6,7,8,9; + reversed_test_impl(c); + } + + void reversed_test() + { + reversed_test_impl< std::vector< int > >(); + reversed_test_impl< std::list< int > >(); + reversed_test_impl< std::set< int > >(); + reversed_test_impl< std::multiset< int > >(); + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.reversed" ); + + test->add( BOOST_TEST_CASE( &boost::reversed_test ) ); + + return test; +} diff --git a/test/adaptor_test/reversed_example.cpp b/test/adaptor_test/reversed_example.cpp new file mode 100644 index 0000000..553e7d7 --- /dev/null +++ b/test/adaptor_test/reversed_example.cpp @@ -0,0 +1,55 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void reversed_example_test() + { + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | reversed, + std::ostream_iterator(std::cout, ",")); + + + std::vector test; + boost::push_back(test, input | reversed); + + BOOST_CHECK_EQUAL_COLLECTIONS( input.rbegin(), input.rend(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.reversed_example" ); + + test->add( BOOST_TEST_CASE( &reversed_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/sliced.cpp b/test/adaptor_test/sliced.cpp new file mode 100644 index 0000000..f2221f6 --- /dev/null +++ b/test/adaptor_test/sliced.cpp @@ -0,0 +1,99 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void sliced_test_impl( Container& c ) + { + using namespace boost::adaptors; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector< value_t > test_result1; + boost::push_back(test_result1, c | sliced(0u,c.size())); + + BOOST_CHECK_EQUAL_COLLECTIONS( test_result1.begin(), test_result1.end(), + c.begin(), c.end() ); + + std::vector< value_t > test_alt_result1; + boost::push_back(test_alt_result1, adaptors::slice(c, 0u, c.size())); + BOOST_CHECK_EQUAL_COLLECTIONS( test_alt_result1.begin(), test_alt_result1.end(), + c.begin(), c.end() ); + + BOOST_CHECK( boost::empty(c | sliced(0u, 0u)) ); + + const std::size_t half_count = c.size() / 2u; + if (half_count > 0u) + { + std::vector< value_t > test_result2; + boost::push_back(test_result2, c | sliced(0u, half_count)); + + BOOST_CHECK_EQUAL_COLLECTIONS( test_result2.begin(), test_result2.end(), + c.begin(), c.begin() + half_count ); + + std::vector< value_t > test_alt_result2; + boost::push_back(test_alt_result2, adaptors::slice(c, 0u, half_count)); + BOOST_CHECK_EQUAL_COLLECTIONS( test_alt_result2.begin(), test_alt_result2.end(), + c.begin(), c.begin() + half_count ); + } + } + + template< class Container > + void sliced_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + sliced_test_impl(c); + + // Test one element + c += 1; + sliced_test_impl(c); + + // Test many elements + c += 1,1,1,2,2,3,4,5,6,6,6,7,8,9; + sliced_test_impl(c); + } + + void sliced_test() + { + sliced_test_impl< std::vector< int > >(); + sliced_test_impl< std::deque< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.sliced" ); + + test->add( BOOST_TEST_CASE( &boost::sliced_test ) ); + + return test; +} diff --git a/test/adaptor_test/sliced_example.cpp b/test/adaptor_test/sliced_example.cpp new file mode 100644 index 0000000..5761844 --- /dev/null +++ b/test/adaptor_test/sliced_example.cpp @@ -0,0 +1,58 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void sliced_example_test() + { + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | sliced(2, 5), + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 3,4,5; + + std::vector test; + boost::push_back(test, input | sliced(2, 5)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.sliced_example" ); + + test->add( BOOST_TEST_CASE( &sliced_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/strided.cpp b/test/adaptor_test/strided.cpp new file mode 100644 index 0000000..e09e0fb --- /dev/null +++ b/test/adaptor_test/strided.cpp @@ -0,0 +1,111 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include + +namespace boost +{ + namespace + { + const int STRIDE_SIZE = 2; + + template< class Container > + void strided_test_impl( Container& c ) + { + using namespace boost::adaptors; + + BOOST_ASSERT( c.size() % STRIDE_SIZE == 0 ); + + Container reference; + + { + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iterator_t; + iterator_t it = c.begin(); + for (iterator_t last = c.end(); + it != last; it += STRIDE_SIZE) + { + reference.push_back(*it); + } + } + + Container test; + boost::push_back( test, c | strided(2) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(), + reference.begin(), reference.end() ); + + Container test2; + boost::push_back( test2, adaptors::stride(c, 2) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( test2.begin(), test2.end(), + reference.begin(), reference.end() ); + + // Test the const versions: + const Container& cc = c; + Container test3; + boost::push_back( test3, cc | strided(2) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( test3.begin(), test3.end(), + reference.begin(), reference.end() ); + + Container test4; + boost::push_back( test4, adaptors::stride(cc, 2) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( test4.begin(), test4.end(), + reference.begin(), reference.end() ); + } + + template< class Container > + void strided_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + strided_test_impl(c); + + // Test two elements + c += 1,2; + strided_test_impl(c); + + // Test many elements + c += 1,1,1,2,2,3,4,5,6,6,6,7,8,9; + strided_test_impl(c); + } + + void strided_test() + { + strided_test_impl< std::vector< int > >(); + strided_test_impl< std::deque< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.strided" ); + + test->add( BOOST_TEST_CASE( &boost::strided_test ) ); + + return test; +} diff --git a/test/adaptor_test/strided_example.cpp b/test/adaptor_test/strided_example.cpp new file mode 100644 index 0000000..5754c53 --- /dev/null +++ b/test/adaptor_test/strided_example.cpp @@ -0,0 +1,58 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + void strided_example_test() + { + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | strided(2), + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 1,3,5,7,9; + + std::vector test; + boost::push_back(test, input | strided(2)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.strided_example" ); + + test->add( BOOST_TEST_CASE( &strided_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/tokenized.cpp b/test/adaptor_test/tokenized.cpp new file mode 100644 index 0000000..8180747 --- /dev/null +++ b/test/adaptor_test/tokenized.cpp @@ -0,0 +1,79 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include + +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Iterator, class Container > + void tokenized_test_impl( Container& c, std::size_t expected_result ) + { + using namespace boost::adaptors; + + std::vector< boost::sub_match< Iterator > > test_result1; + boost::push_back(test_result1, c | tokenized(boost::regex("\\b"))); + + BOOST_CHECK_EQUAL( test_result1.size(), expected_result ); + +// std::vector< boost::sub_match< Iterator > > test_result2; +// boost::push_back(test_result2, adaptors::tokenize(c, boost::regex("\\b"))); + +// BOOST_CHECK_EQUAL( test_result2.size(), expected_result ); + } + + template< class Container1, class Container2 > + void tokenized_test_impl() + { + Container1 c; + Container2& r = c; + + typedef typename boost::range_iterator::type It; + + // Test empty + tokenized_test_impl(r, 0u); + + // Test one element + c = "a"; + tokenized_test_impl(r, 2u); + + // Test many elements + c = "a b c d e f g hijlmnopqrstuvwxyz"; + tokenized_test_impl(r, 16u); + } + + void tokenized_test() + { +// tokenized_test_impl(); + tokenized_test_impl(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.tokenized" ); + + test->add( BOOST_TEST_CASE( &boost::tokenized_test ) ); + + return test; +} diff --git a/test/adaptor_test/transformed.cpp b/test/adaptor_test/transformed.cpp new file mode 100644 index 0000000..6b6121e --- /dev/null +++ b/test/adaptor_test/transformed.cpp @@ -0,0 +1,107 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct double_x + { + typedef int result_type; + int operator()(int x) const { return x * 2; } + }; + + struct halve_x + { + typedef int result_type; + int operator()(int x) const { return x / 2; } + }; + + template< class Container, class TransformFn > + void transformed_test_impl_core( Container& c, TransformFn fn ) + { + using namespace boost::adaptors; + + std::vector< int > test_result1; + boost::push_back(test_result1, c | transformed(fn)); + + std::vector< int > test_result2; + boost::push_back(test_result2, adaptors::transform(c, fn)); + + std::vector< int > reference; + std::transform(c.begin(), c.end(), std::back_inserter(reference), fn); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result1.begin(), test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result2.begin(), test_result2.end() ); + } + + template< class Container, class TransformFn > + void transformed_test_fn_impl() + { + using namespace boost::assign; + + Container c; + TransformFn fn; + + // Test empty + transformed_test_impl_core(c, fn); + + // Test one element + c += 1; + transformed_test_impl_core(c, fn); + + // Test many elements + c += 1,1,1,2,2,2,2,2,3,4,5,6,7,8,9; + transformed_test_impl_core(c, fn); + } + + template< class Container > + void transformed_test_impl() + { + transformed_test_fn_impl< Container, double_x >(); + transformed_test_fn_impl< Container, halve_x >(); + } + + void transformed_test() + { + transformed_test_impl< std::vector< int > >(); + transformed_test_impl< std::list< int > >(); + transformed_test_impl< std::set< int > >(); + transformed_test_impl< std::multiset< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.transformed" ); + + test->add( BOOST_TEST_CASE( &boost::transformed_test ) ); + + return test; +} diff --git a/test/adaptor_test/transformed_example.cpp b/test/adaptor_test/transformed_example.cpp new file mode 100644 index 0000000..3d05c95 --- /dev/null +++ b/test/adaptor_test/transformed_example.cpp @@ -0,0 +1,64 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include +#include + +#include + +namespace +{ + struct double_int + { + typedef int result_type; + int operator()(int x) const { return x * 2; } + }; + + void transformed_example_test() + { + using namespace boost::adaptors; + using namespace boost::assign; + + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | transformed(double_int()), + std::ostream_iterator(std::cout, ",")); + + + std::vector reference; + reference += 2,4,6,8,10,12,14,16,18,20; + + std::vector test; + boost::push_back(test, input | transformed(double_int())); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.transformed_example" ); + + test->add( BOOST_TEST_CASE( &transformed_example_test ) ); + + return test; +} diff --git a/test/adaptor_test/uniqued.cpp b/test/adaptor_test/uniqued.cpp new file mode 100644 index 0000000..9c96744 --- /dev/null +++ b/test/adaptor_test/uniqued.cpp @@ -0,0 +1,89 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include + +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void uniqued_test_impl( Container& c ) + { + using namespace boost::adaptors; + + std::vector< int > test_result1; + boost::push_back(test_result1, c | uniqued); + + std::vector< int > test_result2; + boost::push_back(test_result2, adaptors::unique(c)); + + std::vector< int > reference(c.begin(), c.end()); + reference.erase( + std::unique(reference.begin(), reference.end()), + reference.end()); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result1.begin(), test_result1.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result2.begin(), test_result2.end() ); + } + + template< class Container > + void uniqued_test_impl() + { + using namespace boost::assign; + + Container c; + + // Test empty + uniqued_test_impl(c); + + // Test one + c += 1; + uniqued_test_impl(c); + + // Test many + c += 1,1,1,2,2,2,2,2,3,3,3,3,4,5,6,6,6,7,7,7,8,8,9,9,9,9,9,10; + uniqued_test_impl(c); + } + + void uniqued_test() + { + uniqued_test_impl< std::vector< int > >(); + uniqued_test_impl< std::list< int > >(); + uniqued_test_impl< std::set< int > >(); + uniqued_test_impl< std::multiset< int > >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.uniqued" ); + + test->add( BOOST_TEST_CASE( &boost::uniqued_test ) ); + + return test; +} diff --git a/test/adaptor_test/uniqued_example.cpp b/test/adaptor_test/uniqued_example.cpp new file mode 100644 index 0000000..c48c54a --- /dev/null +++ b/test/adaptor_test/uniqued_example.cpp @@ -0,0 +1,57 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 +#include +#include +#include + +#include + +#include +#include + +namespace +{ + void uniqued_example_test() + { + using namespace boost::assign; + using namespace boost::adaptors; + + std::vector input; + input += 1,1,2,2,2,3,4,5,6; + + boost::copy( + input | uniqued, + std::ostream_iterator(std::cout, ",")); + + std::vector reference; + reference += 1,2,3,4,5,6; + + std::vector test; + boost::push_back( test, input | uniqued ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.uniqued_example" ); + + test->add( BOOST_TEST_CASE( &uniqued_example_test ) ); + + return test; +} diff --git a/test/adaptors.cpp b/test/adaptors.cpp new file mode 100644 index 0000000..ed2f915 --- /dev/null +++ b/test/adaptors.cpp @@ -0,0 +1,238 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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 +#include +#include +#include +#include +#include +#include + +template< class T > +struct less_than +{ + T val; + + less_than() : val(0) + {} + + less_than( T t ) : val(t) + {} + + bool operator()( const T& r ) const + { + return r < val; + } +}; + + + +template< class T > +struct multiply +{ + T val; + + typedef T& result_type; + + multiply( T t ) : val(t) + { } + + T& operator()( T& r ) const + { + return r *= 2; + } +}; + + + +template< class Rng > +void check_copy( Rng r ) +{ + // + // Make sure the generated iterators + // can actually be copied + // + Rng r2 = r; + r2 = r; +} + + + +template< class Rng > +void check() +{ + using namespace boost::adaptors; + + Rng rng = boost::assign::list_of(1)(2)(3)(4)(5).to_container( rng ); + Rng out; + + // + // test each alphabetically + // + BOOST_FOREACH( int i, rng | filtered( less_than(4) ) + /*| reversed*/ + | transformed( multiply(2) ) ) + { + out.push_back( i ); + } + + BOOST_CHECK_EQUAL( out.size(), 3u ); + BOOST_CHECK_EQUAL( *out.begin(), 2 ); + BOOST_CHECK_EQUAL( *boost::next(out.begin()), 4 ); + BOOST_CHECK_EQUAL( *boost::next(out.begin(),2), 6 ); + + rng = boost::assign::list_of(1)(1)(2)(2)(3)(3)(4)(5).to_container( rng ); + out.clear(); + /* + BOOST_FOREACH( int i, rng | adjacent_filtered( std::equal_to() ) + | uniqued ) + { + + out.push_back( i ); + }*/ + +} + + + +template< class IndirectRng > +void check_indirect() +{ + using namespace boost::adaptors; + + IndirectRng rng; + + std::vector< boost::shared_ptr< int > > holder; + + for( unsigned i = 0u; i != 20u; ++i ) + { + boost::shared_ptr v(new int(i)); + rng.push_back( v.get() ); + } + + BOOST_FOREACH( int& i, rng | indirected | reversed + | transformed( multiply(2) ) ) + { + i += 1; + } + + + +} + + + +template< class RandomAccessRng > +void check_random_access() +{ + using namespace boost::adaptors; + + RandomAccessRng rng(1, 20u); + RandomAccessRng out; + + BOOST_FOREACH( int i, rng | reversed + | transformed( multiply(2) ) + /* | sliced(0,15) */ ) + { + out.push_back( i ); + } + + + BOOST_FOREACH( int i, rng | copied(3u,13u) ) + { + out.push_back( i ); + } +} + + + +template< class Map > +void check_map() +{ + using namespace boost::adaptors; + + Map m; + m.insert( std::make_pair(1,2) ); + m.insert( std::make_pair(2,2) ); + m.insert( std::make_pair(3,2) ); + m.insert( std::make_pair(4,2) ); + m.insert( std::make_pair(5,2) ); + m.insert( std::make_pair(6,2) ); + m.insert( std::make_pair(7,2) ); + + std::vector keys + = boost::copy_range< std::vector >( m | map_keys ); + std::vector values + = boost::copy_range< std::vector >( m | map_values ); +} + + + +void check_regex() +{ + using namespace boost::adaptors; + std::string s("This is a string of tokens"); + std::vector tokens = + boost::copy_range< std::vector >( s | tokenized( "\\s+", -1 ) ); +} + + +void check_adaptors() +{ + check< std::vector >(); + check< std::list >(); + check_indirect< std::vector >(); + check_indirect< std::list >(); + + check_map< std::map >(); +// check_random_access< std::vector >(); + check_regex(); + + using namespace boost::adaptors; + std::vector vec(10u,20); + std::vector pvec; + std::map map; + + check_copy( vec | adjacent_filtered( std::equal_to() ) ); + // check_copy( vec | indexed ); + check_copy( vec | reversed ); + check_copy( vec | uniqued ); + check_copy( pvec | indirected ); + +// check_copy( vec | sliced(1,5) ); + // + // This does not return an iterator_range<>, so + // won't pass this test of implicit conversion + // check_copy( vec | copied(1,5) ); + // + check_copy( map | map_values ); + check_copy( map | map_keys ); + check_copy( std::string( "a string" ) | tokenized( "\\s+", -1 ) ); + check_copy( vec | filtered( less_than(2) ) ); + check_copy( vec | transformed( multiply(2) ) ); +} + +using boost::unit_test::test_suite; + +test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + using namespace boost; + + test_suite* test = BOOST_TEST_SUITE( "Range Test Suite - Adaptors" ); + + test->add( BOOST_TEST_CASE( &check_adaptors ) ); + + return test; +} + + diff --git a/test/adl_conformance.cpp b/test/adl_conformance.cpp old mode 100755 new mode 100644 index b44b7c4..2d7f290 --- a/test/adl_conformance.cpp +++ b/test/adl_conformance.cpp @@ -27,38 +27,41 @@ enum adl_types global_namespace }; -namespace boost +// Use boost_test rather than boost as the namespace for this test +// to allow the test framework to use boost::begin() etc. without +// violating the One Defintion Rule. +namespace boost_test { namespace range_detail { template< class Range > inline typename Range::iterator begin( Range& r ) { - return boost_namespace; + return boost_namespace; } - + template< class Range > inline typename Range::iterator begin( const Range& r ) { - return boost_namespace; + 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 ); } -} +} // 'boost_test' namespace find_templated @@ -74,7 +77,7 @@ namespace find_templated iterator end() { return unused; } iterator end() const { return unused; } }; - + // // A fully generic version here will create // ambiguity. @@ -84,7 +87,7 @@ namespace find_templated { return templated_namespace; } - + template< class T > inline typename range::iterator begin( const range& r ) { @@ -98,20 +101,20 @@ 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; @@ -132,12 +135,12 @@ struct range inline range::iterator begin( range& r ) { return global_namespace; -} +} inline range::iterator begin( const range& r ) { return global_namespace; -} +} void check_adl_conformance() { @@ -147,29 +150,29 @@ void check_adl_conformance() const find_non_templated::range r4; range r5; const range r6; - + // - // Notice how ADL kicks in even when we have qualified + // 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 ); + + BOOST_CHECK( boost_test::begin( r ) != boost_namespace ); + BOOST_CHECK( boost_test::begin( r2 ) != boost_namespace ); + BOOST_CHECK( boost_test::begin( r3 ) != boost_namespace ); + BOOST_CHECK( boost_test::begin( r4 ) != boost_namespace ); + BOOST_CHECK( boost_test::begin( r5 ) != boost_namespace ); + BOOST_CHECK( boost_test::begin( r6 ) != boost_namespace ); + + BOOST_CHECK_EQUAL( boost_test::begin( r ), templated_namespace ) ; + BOOST_CHECK_EQUAL( boost_test::begin( r2 ), templated_namespace ); + BOOST_CHECK_EQUAL( boost_test::begin( r3 ), non_templated_namespace ); + BOOST_CHECK_EQUAL( boost_test::begin( r4 ), non_templated_namespace ); + BOOST_CHECK_EQUAL( boost_test::begin( r5 ), global_namespace ); + BOOST_CHECK_EQUAL( boost_test::begin( r6 ), global_namespace ); } -#include +#include using boost::unit_test_framework::test_suite; diff --git a/test/algorithm.cpp b/test/algorithm.cpp new file mode 100644 index 0000000..1c0dbc3 --- /dev/null +++ b/test/algorithm.cpp @@ -0,0 +1,471 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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/ +// +// (C) Copyright Eric Niebler 2004. +// Use, modification and distribution are 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) + +/* + Revision history: + 13 December 2004 : Initial version. +*/ + +#ifdef _MSC_VER +// The 'secure' library warnings produce so much noise that it makes it +// impossible to see more useful warnings. + #define _SCL_SECURE_NO_WARNINGS +#endif + +#ifdef _MSC_VER + // counting_iterator generates a warning about truncating an integer + #pragma warning(push) + #pragma warning(disable : 4244) +#endif +#include +#ifdef _MSC_VER + template ::boost::counting_iterator; + #pragma warning(pop) +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +/////////////////////////////////////////////////////////////////////////////// +// dummy function object, used with algorithms +// +struct null_fun +{ + template + void operator()(T const &t) const + { + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// dummy predicate, used with algorithms +// +struct null_pred +{ + template + bool operator()(T const &t) const + { + return t == T(); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// dummy unary op, used with algorithms +// +struct null_op1 +{ + template + T const & operator()(T const & t) const + { + return t; + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// dummy binary op, used with algorithms +// +struct null_op2 +{ + template + T const & operator()(T const & t, U const & u) const + { + return t; + } +}; + +template +void test_random_algorithms(Rng & rng, std::random_access_iterator_tag) +{ + typedef BOOST_DEDUCED_TYPENAME boost::range_iterator::type iterator; + typedef BOOST_DEDUCED_TYPENAME boost::range_value::type value_type; + typedef BOOST_DEDUCED_TYPENAME boost::range_size::type size_type; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_category::type iterator_category; + + // just make sure these compile (for now) + if(0) + { + boost::random_shuffle(rng); + + // Must be a value since random_shuffle must take the generator by + // reference to match the standard. + null_op1 rng_generator; + boost::random_shuffle(rng, rng_generator); + + boost::sort(rng); + boost::sort(rng, std::less()); + + boost::stable_sort(rng); + boost::stable_sort(rng, std::less()); + + boost::partial_sort(rng, boost::begin(rng)); + boost::partial_sort(rng, boost::begin(rng), std::less()); + + boost::nth_element(rng, boost::begin(rng)); + boost::nth_element(rng, boost::begin(rng), std::less()); + + boost::push_heap(rng); + boost::push_heap(rng, std::less()); + + boost::pop_heap(rng); + boost::pop_heap(rng, std::less()); + + boost::make_heap(rng); + boost::make_heap(rng, std::less()); + + boost::sort_heap(rng); + boost::sort_heap(rng, std::less()); + } +} + +template +void test_random_algorithms(Rng & rng, std::input_iterator_tag) +{ + // no-op +} + +template +void test_algorithms(Rng & rng) +{ + typedef BOOST_DEDUCED_TYPENAME boost::range_iterator::type iterator; + typedef BOOST_DEDUCED_TYPENAME boost::range_value::type value_type; + typedef BOOST_DEDUCED_TYPENAME boost::range_size::type size_type; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_category::type iterator_category; + + // just make sure these compile (for now) + if(0) + { + value_type val = value_type(); + + value_type rng2[] = {value_type(),value_type(),value_type()}; + typedef value_type* iterator2; + + value_type out[100] = {}; + typedef value_type* out_iterator; + + null_fun f = null_fun(); + iterator i = iterator(); + bool b = bool(); + out_iterator o = out_iterator(); + size_type s = size_type(); + + f = boost::for_each(rng, null_fun()); + + i = boost::find(rng, val); + i = boost::find_if(rng, null_pred()); + + i = boost::find_end(rng, rng2); + i = boost::find_end(rng, rng2, std::equal_to()); + + i = boost::find_first_of(rng, rng2); + i = boost::find_first_of(rng, rng2, std::equal_to()); + + i = boost::adjacent_find(rng); + i = boost::adjacent_find(rng, std::equal_to()); + + s = boost::count(rng, val); + s = boost::count_if(rng, null_pred()); + + std::pair p1; + p1 = boost::mismatch(rng, rng2); + p1 = boost::mismatch(rng, rng2, std::equal_to()); + + b = boost::equal(rng, rng2); + b = boost::equal(rng, rng2, std::equal_to()); + + i = boost::search(rng, rng2); + i = boost::search(rng, rng2, std::equal_to()); + + o = boost::copy(rng, boost::begin(out)); + o = boost::copy_backward(rng, boost::end(out)); + + o = boost::transform(rng, boost::begin(out), null_op1()); + o = boost::transform(rng, rng2, boost::begin(out), null_op2()); + + boost::replace(rng, val, val); + boost::replace_if(rng, null_pred(), val); + +/* + o = boost::replace_copy(rng, boost::begin(out), val, val); + o = boost::replace_copy_if(rng, boost::begin(out), null_pred(), val); +*/ + + boost::fill(rng, val); + // + // size requires RandomAccess + // + //boost::fill_n(rng, boost::size(rng), val); + //boost::fill_n(rng, std::distance(boost::begin(rng),boost::end(rng)),val); + + boost::generate(rng, &std::rand); + // + // size requires RandomAccess + // + //boost::generate_n(rng, boost::size(rng), &std::rand); + //boost::generate_n(rng,std::distance(boost::begin(rng),boost::end(rng)), &std::rand); + + i = boost::remove(rng, val); + i = boost::remove_if(rng, null_pred()); + +/* + o = boost::remove_copy(rng, boost::begin(out), val); + o = boost::remove_copy_if(rng, boost::begin(out), null_pred()); +*/ + + typename boost::range_return::type rrng = boost::unique(rng); + rrng = boost::unique(rng, std::equal_to()); + +/* + o = boost::unique_copy(rng, boost::begin(out)); + o = boost::unique_copy(rng, boost::begin(out), std::equal_to()); +*/ + + boost::reverse(rng); + +/* + o = boost::reverse_copy(rng, boost::begin(out)); +*/ + + boost::rotate(rng, boost::begin(rng)); + +/* + o = boost::rotate_copy(rng, boost::begin(rng), boost::begin(out)); +*/ + + i = boost::partition(rng, null_pred()); + i = boost::stable_partition(rng, null_pred()); + +/* + o = boost::partial_sort_copy(rng, out); + o = boost::partial_sort_copy(rng, out, std::less()); +*/ + + i = boost::lower_bound(rng, val); + i = boost::lower_bound(rng, val, std::less()); + + i = boost::upper_bound(rng, val); + i = boost::upper_bound(rng, val, std::less()); + + std::pair p2; + p2 = boost::equal_range(rng, val); + p2 = boost::equal_range(rng, val, std::less()); + + b = boost::binary_search(rng, val); + b = boost::binary_search(rng, val, std::less()); + + boost::inplace_merge(rng, boost::begin(rng)); + boost::inplace_merge(rng, boost::begin(rng), std::less()); + + b = boost::includes(rng, rng2); + b = boost::includes(rng, rng2, std::equal_to()); + + o = boost::set_union(rng, rng2, boost::begin(out)); + o = boost::set_union(rng, rng2, boost::begin(out), std::equal_to()); + + o = boost::set_intersection(rng, rng2, boost::begin(out)); + o = boost::set_intersection(rng, rng2, boost::begin(out), std::equal_to()); + + o = boost::set_difference(rng, rng2, boost::begin(out)); + o = boost::set_difference(rng, rng2, boost::begin(out), std::equal_to()); + + o = boost::set_symmetric_difference(rng, rng2, boost::begin(out)); + o = boost::set_symmetric_difference(rng, rng2, boost::begin(out), std::equal_to()); + + i = boost::min_element(rng); + i = boost::min_element(rng, std::less()); + + i = boost::max_element(rng); + i = boost::max_element(rng, std::less()); + + b = boost::lexicographical_compare(rng, rng); + b = boost::lexicographical_compare(rng, rng, std::equal_to()); + + b = boost::next_permutation(rng); + b = boost::next_permutation(rng, std::less()); + + b = boost::prev_permutation(rng); + b = boost::prev_permutation(rng, std::less()); + + ///////////////////////////////////////////////////////////////////// + // numeric algorithms + ///////////////////////////////////////////////////////////////////// + + val = boost::accumulate( rng, val ); + val = boost::accumulate( rng, val, null_op2() ); + val = boost::inner_product( rng, rng, val ); + val = boost::inner_product( rng, rng, val, + null_op2(), null_op2() ); + o = boost::partial_sum( rng, boost::begin(out) ); + o = boost::partial_sum( rng, boost::begin(out), null_op2() ); + o = boost::adjacent_difference( rng, boost::begin(out) ); + o = boost::adjacent_difference( rng, boost::begin(out), + null_op2() ); + + } + + // test the algorithms that require a random-access range + test_random_algorithms(rng, iterator_category()); +} + +int* addr(int &i) { return &i; } +bool true_(int) { return true; } + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +void simple_compile_test() +{ + // int_iterator + typedef ::boost::counting_iterator int_iterator; + + // define come containers + std::list my_list(int_iterator(1),int_iterator(6)); + + + std::vector my_vector(int_iterator(1),int_iterator(6)); + + std::pair::iterator,std::vector::iterator> my_pair(my_vector.begin(),my_vector.end()); + + // test the algorithms with list and const list + test_algorithms(my_list); + test_algorithms(my_vector); + test_algorithms(my_pair); + + + std::vector v; + std::vector& cv = v; + + using namespace boost; + +#define BOOST_RANGE_RETURNS_TEST( function_name, cont ) \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); \ + function_name (cont); + + BOOST_RANGE_RETURNS_TEST( adjacent_find, cv ); + BOOST_RANGE_RETURNS_TEST( adjacent_find, v ); + BOOST_RANGE_RETURNS_TEST( max_element, cv ); + BOOST_RANGE_RETURNS_TEST( max_element, v ); + BOOST_RANGE_RETURNS_TEST( min_element, cv ); + BOOST_RANGE_RETURNS_TEST( min_element, v ); + BOOST_RANGE_RETURNS_TEST( unique, v ); +#undef BOOST_RANGE_RETURNS_TEST + +#define BOOST_RANGE_RETURNS_TEST1( function_name, cont, arg1 ) \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); \ + function_name (cont, arg1); + + BOOST_RANGE_RETURNS_TEST1( adjacent_find, cv, std::less() ); + BOOST_RANGE_RETURNS_TEST1( adjacent_find, v, std::less() ); + BOOST_RANGE_RETURNS_TEST1( find, cv, 0 ); + BOOST_RANGE_RETURNS_TEST1( find, v, 0 ); + BOOST_RANGE_RETURNS_TEST1( find_end, cv, cv ); + BOOST_RANGE_RETURNS_TEST1( find_end, cv, v ); + BOOST_RANGE_RETURNS_TEST1( find_end, v, cv ); + BOOST_RANGE_RETURNS_TEST1( find_end, v, v ); + BOOST_RANGE_RETURNS_TEST1( find_first_of, cv, cv ); + BOOST_RANGE_RETURNS_TEST1( find_first_of, cv, v ); + BOOST_RANGE_RETURNS_TEST1( find_first_of, v, cv ); + BOOST_RANGE_RETURNS_TEST1( find_first_of, v, v ); + BOOST_RANGE_RETURNS_TEST1( find_if, cv, std::negate() ); + BOOST_RANGE_RETURNS_TEST1( find_if, v, std::negate() ); + BOOST_RANGE_RETURNS_TEST1( search, cv, cv ); + BOOST_RANGE_RETURNS_TEST1( search, cv, v ); + BOOST_RANGE_RETURNS_TEST1( search, v, cv ); + BOOST_RANGE_RETURNS_TEST1( search, v, v ); + + BOOST_RANGE_RETURNS_TEST1( remove, v, 0 ); + BOOST_RANGE_RETURNS_TEST1( remove_if, v, std::negate() ); + + BOOST_RANGE_RETURNS_TEST1( lower_bound, cv, 0 ); + BOOST_RANGE_RETURNS_TEST1( lower_bound, v, 0 ); + BOOST_RANGE_RETURNS_TEST1( max_element, cv, std::less() ); + BOOST_RANGE_RETURNS_TEST1( max_element, v, std::less() ); + BOOST_RANGE_RETURNS_TEST1( min_element, cv, std::less() ); + BOOST_RANGE_RETURNS_TEST1( min_element, v, std::less() ); + BOOST_RANGE_RETURNS_TEST1( upper_bound, cv, 0 ); + BOOST_RANGE_RETURNS_TEST1( upper_bound, v, 0 ); + BOOST_RANGE_RETURNS_TEST1( partition, cv, std::negate() ); + BOOST_RANGE_RETURNS_TEST1( partition, v, std::negate() ); + BOOST_RANGE_RETURNS_TEST1( stable_partition, cv, std::negate() ); + BOOST_RANGE_RETURNS_TEST1( stable_partition, v, std::negate() ); + +#undef BOOST_RANGE_RETURNS_TEST1 + +#define BOOST_RANGE_RETURNS_TEST2( function_name, arg1, arg2 ) \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); \ + function_name (v, arg1, arg2); + + BOOST_RANGE_RETURNS_TEST2( find_end, v, std::less() ); + BOOST_RANGE_RETURNS_TEST2( find_first_of, v, std::less() ); + BOOST_RANGE_RETURNS_TEST2( search, v, std::less() ); + BOOST_RANGE_RETURNS_TEST2( lower_bound, 0, std::less() ); + BOOST_RANGE_RETURNS_TEST2( upper_bound, 0, std::less() ); + +#undef BOOST_RANGE_RETURNS_TEST2 +} + +using boost::unit_test::test_suite; + +test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + using namespace boost; + + test_suite* test = BOOST_TEST_SUITE( "Range Test Suite - Algorithm" ); + + test->add( BOOST_TEST_CASE( &simple_compile_test ) ); + + return test; +} + diff --git a/test/algorithm_test/adjacent_find.cpp b/test/algorithm_test/adjacent_find.cpp new file mode 100644 index 0000000..914736b --- /dev/null +++ b/test/algorithm_test/adjacent_find.cpp @@ -0,0 +1,89 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_adjacent_find_impl() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator_t; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator const_iterator_t; + + Container cont; + const Container& cref_cont = cont; + + std::equal_to pred; + + BOOST_CHECK( boost::adjacent_find(cont) == cont.end() ); + BOOST_CHECK( boost::adjacent_find(cref_cont) == cref_cont.end() ); + BOOST_CHECK( boost::adjacent_find(cont, pred) == cont.end() ); + BOOST_CHECK( boost::adjacent_find(cref_cont, pred) == cref_cont.end() ); + + cont += 1; + BOOST_CHECK( boost::adjacent_find(cont) == cont.end() ); + BOOST_CHECK( boost::adjacent_find(cref_cont) == cref_cont.end() ); + BOOST_CHECK( boost::adjacent_find(cont, pred) == cont.end() ); + BOOST_CHECK( boost::adjacent_find(cref_cont, pred) == cref_cont.end() ); + + cont += 2,3,4,5,5,5,6,7,8,9; + iterator_t it = boost::adjacent_find(cont); + iterator_t it_pred = boost::adjacent_find(cont, pred); + BOOST_CHECK( it == it_pred ); + BOOST_CHECK( it != cont.end() ); + BOOST_CHECK( it == std::adjacent_find(cont.begin(), cont.end()) ); + if (it != cont.end()) + { + BOOST_CHECK( *it == 5 ); + } + const_iterator_t cit = boost::adjacent_find(cref_cont); + const_iterator_t cit_pred = boost::adjacent_find(cref_cont, pred); + BOOST_CHECK( cit == cit_pred ); + BOOST_CHECK( cit != cref_cont.end() ); + BOOST_CHECK( cit == std::adjacent_find(cref_cont.begin(), cref_cont.end()) ); + if (cit != cref_cont.end()) + { + BOOST_CHECK( *cit == 5 ); + } + } + + void test_adjacent_find() + { + test_adjacent_find_impl< std::vector >(); + test_adjacent_find_impl< std::list >(); + test_adjacent_find_impl< std::multiset >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.adjacent_find" ); + + test->add( BOOST_TEST_CASE( &boost::test_adjacent_find ) ); + + return test; +} diff --git a/test/algorithm_test/binary_search.cpp b/test/algorithm_test/binary_search.cpp new file mode 100644 index 0000000..e0aca31 --- /dev/null +++ b/test/algorithm_test/binary_search.cpp @@ -0,0 +1,122 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test(Container& cont) + { + Container reference(cont); + Container test(cont); + + bool reference_result + = std::binary_search(reference.begin(), reference.end(), 5); + + bool test_result = boost::binary_search(test, 5); + + BOOST_CHECK( reference_result == test_result ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container& cont, BinaryPredicate pred) + { + Container reference(cont); + Container test(cont); + + sort_container(reference, pred); + sort_container(test, pred); + + bool reference_result + = std::binary_search(reference.begin(), reference.end(), 5, + pred); + + bool test_result = boost::binary_search(test, 5, pred); + + BOOST_CHECK( reference_result == test_result ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_binary_search_impl() + { + using namespace boost::assign; + + Container cont; + + test(cont); + test_pred(cont, std::less()); + test_pred(cont, std::greater()); + + cont.clear(); + cont += 1; + test(cont); + test_pred(cont, std::less()); + test_pred(cont, std::greater()); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test(cont); + test_pred(cont, std::less()); + test_pred(cont, std::greater()); + } + + void test_binary_search() + { + test_binary_search_impl< std::vector >(); + test_binary_search_impl< std::list >(); + test_binary_search_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.binary_search" ); + + test->add( BOOST_TEST_CASE( &boost::test_binary_search ) ); + + return test; +} diff --git a/test/algorithm_test/copy.cpp b/test/algorithm_test/copy.cpp new file mode 100644 index 0000000..932d190 --- /dev/null +++ b/test/algorithm_test/copy.cpp @@ -0,0 +1,67 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_copy_impl() + { + Container source; + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector target; + target.resize(source.size()); + + typedef BOOST_DEDUCED_TYPENAME range_iterator< std::vector >::type iterator_t; + iterator_t it = boost::copy(source, target.begin()); + + BOOST_CHECK( it == target.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + target.begin(), target.end(), + source.begin(), source.end() + ); + } + + void test_copy() + { + test_copy_impl< std::vector >(); + test_copy_impl< std::list >(); + test_copy_impl< std::set >(); + test_copy_impl< std::multiset >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.copy" ); + + test->add( BOOST_TEST_CASE( &boost::test_copy ) ); + + return test; +} diff --git a/test/algorithm_test/copy_backward.cpp b/test/algorithm_test/copy_backward.cpp new file mode 100644 index 0000000..d66082a --- /dev/null +++ b/test/algorithm_test/copy_backward.cpp @@ -0,0 +1,64 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_copy_backward_impl() + { + Container source; + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector target; + target.resize(source.size()); + + typedef BOOST_DEDUCED_TYPENAME range_iterator< std::vector >::type iterator_t; + iterator_t it = boost::copy_backward(source, target.begin()); + + BOOST_CHECK( it == target.end() ); + BOOST_CHECK_EQUAL_COLLECTIONS( target.begin(), target.end(), + source.rbegin(), source.rend() ); + } + + void test_copy_backward() + { + test_copy_backward_impl< std::vector >(); + test_copy_backward_impl< std::list >(); + test_copy_backward_impl< std::set >(); + test_copy_backward_impl< std::multiset >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.copy_backward" ); + + test->add( BOOST_TEST_CASE( &boost::test_copy_backward ) ); + + return test; +} diff --git a/test/algorithm_test/count.cpp b/test/algorithm_test/count.cpp new file mode 100644 index 0000000..d364710 --- /dev/null +++ b/test/algorithm_test/count.cpp @@ -0,0 +1,77 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_count_impl() + { + using namespace boost::assign; + + Container cont; + const Container& cref_cont = cont; + + BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) ); + BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) ); + + cont += 1; + BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) ); + BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) ); + BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1) ); + BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1) ); + + cont += 2,3,4,5,6,7,8,9; + BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) ); + BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) ); + BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1) ); + BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1) ); + + cont += 2; + BOOST_CHECK_EQUAL( 0u, boost::count(cont, 0) ); + BOOST_CHECK_EQUAL( 0u, boost::count(cref_cont, 0) ); + BOOST_CHECK_EQUAL( 1u, boost::count(cont, 1) ); + BOOST_CHECK_EQUAL( 1u, boost::count(cref_cont, 1) ); + BOOST_CHECK_EQUAL( 2u, boost::count(cont, 2) ); + BOOST_CHECK_EQUAL( 2u, boost::count(cref_cont, 2) ); + } + + void test_count() + { + test_count_impl< std::vector >(); + test_count_impl< std::list >(); + test_count_impl< std::multiset >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.count" ); + + test->add( BOOST_TEST_CASE( &boost::test_count ) ); + + return test; +} diff --git a/test/algorithm_test/count_if.cpp b/test/algorithm_test/count_if.cpp new file mode 100644 index 0000000..11526b4 --- /dev/null +++ b/test/algorithm_test/count_if.cpp @@ -0,0 +1,85 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include "../test_function/false_predicate.hpp" +#include "../test_function/equal_to_x.hpp" +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_count_if_impl() + { + using namespace boost::range_test_function; + using namespace boost::assign; + + typedef equal_to_x pred_t; + + Container cont; + const Container& cref_cont = cont; + + BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) ); + + cont += 1; + BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 1u, boost::count_if(cont, pred_t(1)) ); + BOOST_CHECK_EQUAL( 1u, boost::count_if(cref_cont, pred_t(1)) ); + + cont += 2,3,4,5,6,7,8,9; + BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 1u, boost::count_if(cont, pred_t(1)) ); + BOOST_CHECK_EQUAL( 1u, boost::count_if(cref_cont, pred_t(1)) ); + + cont += 2; + BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, pred_t(0)) ); + BOOST_CHECK_EQUAL( 1u, boost::count_if(cont, pred_t(1)) ); + BOOST_CHECK_EQUAL( 1u, boost::count_if(cref_cont, pred_t(1)) ); + BOOST_CHECK_EQUAL( 2u, boost::count_if(cont, pred_t(2)) ); + BOOST_CHECK_EQUAL( 2u, boost::count_if(cref_cont, pred_t(2)) ); + + BOOST_CHECK_EQUAL( 0u, boost::count_if(cont, false_predicate()) ); + BOOST_CHECK_EQUAL( 0u, boost::count_if(cref_cont, false_predicate()) ); + } + + void test_count_if() + { + test_count_if_impl< std::vector >(); + test_count_if_impl< std::list >(); + test_count_if_impl< std::multiset >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.count_if" ); + + test->add( BOOST_TEST_CASE( &boost::test_count_if ) ); + + return test; +} diff --git a/test/algorithm_test/equal.cpp b/test/algorithm_test/equal.cpp new file mode 100644 index 0000000..d750706 --- /dev/null +++ b/test/algorithm_test/equal.cpp @@ -0,0 +1,103 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container1, class Container2 > + void test_equal_impl() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type container1_t; + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type container2_t; + + container1_t mcont1; + container2_t mcont2; + + Container1& cont1 = mcont1; + Container2& cont2 = mcont2; + + BOOST_CHECK( boost::equal(cont1, cont2) ); + BOOST_CHECK( boost::equal(cont1, cont2, std::equal_to()) ); + BOOST_CHECK( boost::equal(cont1, cont2, std::not_equal_to()) ); + + mcont1 += 1; + BOOST_CHECK( !boost::equal(cont1, cont2) ); + BOOST_CHECK( !boost::equal(cont1, cont2, std::equal_to()) ); + BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to()) ); + + mcont1.clear(); + mcont2 += 1; + BOOST_CHECK( !boost::equal(cont1, cont2) ); + BOOST_CHECK( !boost::equal(cont1, cont2, std::equal_to()) ); + BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to()) ); + + mcont1 += 1; + BOOST_CHECK( boost::equal(cont1, cont2) ); + BOOST_CHECK( boost::equal(cont1, cont2, std::equal_to()) ); + BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to()) ); + + mcont1 += 2,3,4,5,6,7,8,9; + mcont2 += 2,3,4,5,6,7,8,9; + BOOST_CHECK( boost::equal(cont1, cont2) ); + BOOST_CHECK( boost::equal(cont1, cont2, std::equal_to()) ); + BOOST_CHECK( !boost::equal(cont1, cont2, std::not_equal_to()) ); + } + + template< class Container1, class Container2 > + void test_driver() + { + typedef Container1 container1_t; + typedef Container2 container2_t; + typedef BOOST_DEDUCED_TYPENAME boost::add_const::type const_container1_t; + typedef BOOST_DEDUCED_TYPENAME boost::add_const::type const_container2_t; + + test_equal_impl< const_container1_t, const_container2_t >(); + test_equal_impl< const_container1_t, container2_t >(); + test_equal_impl< container1_t, const_container2_t >(); + test_equal_impl< container1_t, container2_t >(); + } + + void test_equal() + { + test_driver< std::list, std::list >(); + test_driver< std::vector, std::vector >(); + test_driver< std::set, std::set >(); + test_driver< std::multiset, std::multiset >(); + test_driver< std::list, std::vector >(); + test_driver< std::vector, std::list >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.equal" ); + + test->add( BOOST_TEST_CASE( &boost::test_equal ) ); + + return test; +} diff --git a/test/algorithm_test/equal_range.cpp b/test/algorithm_test/equal_range.cpp new file mode 100644 index 0000000..652508c --- /dev/null +++ b/test/algorithm_test/equal_range.cpp @@ -0,0 +1,175 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void check_result( + const Container& reference, + Pair reference_pair, + const Container& test, + Pair test_pair + ) + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type + const_iterator_t; + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + BOOST_CHECK_EQUAL( + std::distance(reference.begin(), reference_pair.first), + std::distance(test.begin(), test_pair.first) + ); + + BOOST_CHECK_EQUAL( + std::distance(reference.begin(), reference_pair.second), + std::distance(test.begin(), test_pair.second) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference_pair.first, reference_pair.second, + test_pair.first, test_pair.second + ); + } + + template + void test(Container& cont) + { + Container reference(cont); + Container test(cont); + + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + typedef std::pair pair_t; + + pair_t reference_result + = std::equal_range(reference.begin(), reference.end(), 5); + + pair_t test_result = boost::equal_range(test, 5); + + check_result(reference, reference_result, + test, test_result); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type container_t; + + container_t reference_temp(cont); + container_t test_temp(cont); + + sort_container(reference_temp, pred); + sort_container(test_temp, pred); + + Container reference(reference_temp); + Container test(test_temp); + + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + typedef std::pair pair_t; + + pair_t reference_result + = std::equal_range(reference.begin(), reference.end(), 5, + BinaryPredicate()); + + pair_t test_result = boost::equal_range(test, 5, BinaryPredicate()); + + check_result(reference, reference_result, + test, test_result); + } + + template + void test_driver(const Container& cont) + { + Container mutable_cont(cont); + test(mutable_cont); + + test(cont); + } + + template + void test_pred_driver(const Container& cont, BinaryPredicate pred) + { + Container mutable_cont(cont); + test_pred(mutable_cont, pred); + + test_pred(cont, pred); + } + + template + void test_equal_range_impl() + { + using namespace boost::assign; + + Container cont; + + test_driver(cont); + test_pred_driver(cont, std::less()); + test_pred_driver(cont, std::greater()); + + cont.clear(); + cont += 1; + test_driver(cont); + test_pred_driver(cont, std::less()); + test_pred_driver(cont, std::greater()); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_driver(cont); + test_pred_driver(cont, std::less()); + test_pred_driver(cont, std::greater()); + } + + void test_equal_range() + { + test_equal_range_impl< std::vector >(); + test_equal_range_impl< std::list >(); + test_equal_range_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.equal_range" ); + + test->add( BOOST_TEST_CASE( &boost::test_equal_range ) ); + + return test; +} diff --git a/test/algorithm_test/fill.cpp b/test/algorithm_test/fill.cpp new file mode 100644 index 0000000..93dba7e --- /dev/null +++ b/test/algorithm_test/fill.cpp @@ -0,0 +1,80 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_fill_impl(Container& cont) + { + Container reference(cont); + std::fill(reference.begin(), reference.end(), 1); + + Container target(cont); + boost::fill(target, 1); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + } + + template< class Container > + void test_fill_impl() + { + using namespace boost::assign; + + Container cont; + test_fill_impl(cont); + + cont.clear(); + cont += 2; + test_fill_impl(cont); + + cont.clear(); + cont += 1,2; + test_fill_impl(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_fill_impl(cont); + } + + void test_fill() + { + test_fill_impl< std::vector >(); + test_fill_impl< std::list >(); + test_fill_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.fill" ); + + test->add( BOOST_TEST_CASE( &boost::test_fill ) ); + + return test; +} diff --git a/test/algorithm_test/find.cpp b/test/algorithm_test/find.cpp new file mode 100644 index 0000000..e0607f0 --- /dev/null +++ b/test/algorithm_test/find.cpp @@ -0,0 +1,102 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + class find_test_policy + { + public: + template + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::find(cont, 3); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy&, Container& cont) + { + return boost::find(cont, 3); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::find(cont.begin(), cont.end(), 3); + } + }; + + template + void test_find_container() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME remove_const::type container_t; + + range_test::range_return_test_driver test_driver; + + container_t mcont; + Container& cont = mcont; + test_driver(cont, find_test_policy()); + + mcont.clear(); + mcont += 1; + test_driver(cont, find_test_policy()); + + mcont.clear(); + mcont += 1,2,3,4,5,6,7,8,9; + test_driver(cont, find_test_policy()); + } + + void test_find() + { + test_find_container< std::vector >(); + test_find_container< std::list >(); + test_find_container< std::deque >(); + + test_find_container< const std::vector >(); + test_find_container< const std::list >(); + test_find_container< const std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.find" ); + + test->add( BOOST_TEST_CASE( &boost::test_find ) ); + + return test; +} diff --git a/test/algorithm_test/find_end.cpp b/test/algorithm_test/find_end.cpp new file mode 100644 index 0000000..fb44e52 --- /dev/null +++ b/test/algorithm_test/find_end.cpp @@ -0,0 +1,181 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + class find_end_test_policy + { + typedef Container2 container2_t; + public: + explicit find_end_test_policy(const Container2& cont) + : m_cont(cont) + { + } + + container2_t cont() { return m_cont; } + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::find_end(cont, m_cont); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::find_end(cont, policy.cont()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::find_end(cont.begin(), cont.end(), + m_cont.begin(), m_cont.end()); + } + + private: + Container2 m_cont; + }; + + template + class find_end_pred_test_policy + { + typedef Container2 container2_t; + public: + explicit find_end_pred_test_policy(const Container2& cont) + : m_cont(cont) + { + } + + container2_t& cont() { return m_cont; } + BinaryPredicate& pred() { return m_pred; } + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::find_end(cont, m_cont, m_pred); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::find_end(cont, policy.cont(), policy.pred()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::find_end(cont.begin(), cont.end(), + m_cont.begin(), m_cont.end(), + m_pred); + } + + private: + Container2 m_cont; + BinaryPredicate m_pred; + }; + + template + void run_tests(Container1& cont1, Container2& cont2) + { + range_test::range_return_test_driver test_driver; + test_driver(cont1, find_end_test_policy(cont2)); + test_driver(cont1, find_end_pred_test_policy >(cont2)); + test_driver(cont2, find_end_pred_test_policy >(cont2)); + } + + template + void test_find_end_impl() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME remove_const::type container1_t; + typedef BOOST_DEDUCED_TYPENAME remove_const::type container2_t; + + container1_t mcont1; + Container1& cont1 = mcont1; + container2_t mcont2; + Container2& cont2 = mcont2; + + run_tests(cont1, cont2); + + mcont1 += 1; + run_tests(cont1, cont2); + + mcont2 += 1; + run_tests(cont1, cont2); + + mcont1 += 2,3,4,5,6,7,8,9; + mcont2 += 2,3,4; + run_tests(cont1, cont2); + + mcont2.clear(); + mcont2 += 7,8,9; + run_tests(cont1, cont2); + } + + void test_find_end() + { + test_find_end_impl< std::vector, std::vector >(); + test_find_end_impl< std::list, std::list >(); + test_find_end_impl< std::deque, std::deque >(); + test_find_end_impl< const std::vector, const std::vector >(); + test_find_end_impl< const std::list, const std::list >(); + test_find_end_impl< const std::deque, const std::deque >(); + test_find_end_impl< const std::vector, const std::list >(); + test_find_end_impl< const std::list, const std::vector >(); + test_find_end_impl< const std::vector, std::list >(); + test_find_end_impl< const std::list, std::vector >(); + test_find_end_impl< std::vector, std::list >(); + test_find_end_impl< std::list, std::vector >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.find_end" ); + + test->add( BOOST_TEST_CASE( &boost::test_find_end ) ); + + return test; +} diff --git a/test/algorithm_test/find_first_of.cpp b/test/algorithm_test/find_first_of.cpp new file mode 100644 index 0000000..b3d18e2 --- /dev/null +++ b/test/algorithm_test/find_first_of.cpp @@ -0,0 +1,181 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + class find_first_of_test_policy + { + typedef Container2 container2_t; + public: + explicit find_first_of_test_policy(const Container2& cont) + : m_cont(cont) + { + } + + container2_t& cont() { return m_cont; } + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::find_first_of(cont, m_cont); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::find_first_of(cont, policy.cont()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::find_first_of(cont.begin(), cont.end(), + m_cont.begin(), m_cont.end()); + } + + private: + Container2 m_cont; + }; + + template + class find_first_of_pred_test_policy + { + typedef Container2 container2_t; + public: + explicit find_first_of_pred_test_policy(const Container2& cont) + : m_cont(cont) + { + } + + container2_t& cont() { return m_cont; } + BinaryPredicate& pred() { return m_pred; } + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::find_first_of(cont, m_cont, m_pred); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::find_first_of(cont, policy.cont(), policy.pred()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::find_first_of(cont.begin(), cont.end(), + m_cont.begin(), m_cont.end(), + m_pred); + } + + private: + Container2 m_cont; + BinaryPredicate m_pred; + }; + + template + void run_tests(Container1& cont1, Container2& cont2) + { + range_test::range_return_test_driver test_driver; + test_driver(cont1, find_first_of_test_policy(cont2)); + test_driver(cont1, find_first_of_pred_test_policy >(cont2)); + test_driver(cont2, find_first_of_pred_test_policy >(cont2)); + } + + template + void test_find_first_of_impl() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME remove_const::type container1_t; + typedef BOOST_DEDUCED_TYPENAME remove_const::type container2_t; + + container1_t mcont1; + Container1& cont1 = mcont1; + container2_t mcont2; + Container2& cont2 = mcont2; + + run_tests(cont1, cont2); + + mcont1 += 1; + run_tests(cont1, cont2); + + mcont2 += 1; + run_tests(cont1, cont2); + + mcont1 += 2,3,4,5,6,7,8,9; + mcont2 += 2,3,4; + run_tests(cont1, cont2); + + mcont2.clear(); + mcont2 += 7,8,9; + run_tests(cont1, cont2); + } + + void test_find_first_of() + { + test_find_first_of_impl< std::vector, std::vector >(); + test_find_first_of_impl< std::list, std::list >(); + test_find_first_of_impl< std::deque, std::deque >(); + test_find_first_of_impl< const std::vector, const std::vector >(); + test_find_first_of_impl< const std::list, const std::list >(); + test_find_first_of_impl< const std::deque, const std::deque >(); + test_find_first_of_impl< const std::vector, const std::list >(); + test_find_first_of_impl< const std::list, const std::vector >(); + test_find_first_of_impl< const std::vector, std::list >(); + test_find_first_of_impl< const std::list, std::vector >(); + test_find_first_of_impl< std::vector, std::list >(); + test_find_first_of_impl< std::list, std::vector >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.find_first_of" ); + + test->add( BOOST_TEST_CASE( &boost::test_find_first_of ) ); + + return test; +} diff --git a/test/algorithm_test/find_if.cpp b/test/algorithm_test/find_if.cpp new file mode 100644 index 0000000..4ee85a2 --- /dev/null +++ b/test/algorithm_test/find_if.cpp @@ -0,0 +1,123 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include "../test_driver/range_return_test_driver.hpp" +#include "../test_function/greater_than_x.hpp" +#include "../test_function/false_predicate.hpp" +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + class find_if_test_policy + { + public: + explicit find_if_test_policy(UnaryPredicate pred) + : m_pred(pred) {} + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::find_if(cont, m_pred); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(find_if_test_policy& policy, Container& cont) + { + return boost::find_if(cont, policy.pred()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::find_if(cont.begin(), cont.end(), m_pred); + } + + UnaryPredicate& pred() { return m_pred; } + + private: + UnaryPredicate m_pred; + }; + + template + find_if_test_policy + make_policy(UnaryPredicate pred) + { + return find_if_test_policy(pred); + } + + template + void test_find_if_container() + { + using namespace boost::assign; + using namespace boost::range_test_function; + + typedef BOOST_DEDUCED_TYPENAME remove_const::type container_t; + + range_test::range_return_test_driver test_driver; + + container_t mcont; + Container& cont = mcont; + test_driver(cont, make_policy(greater_than_x(5))); + test_driver(cont, make_policy(false_predicate())); + + mcont.clear(); + mcont += 1; + test_driver(cont, make_policy(greater_than_x(5))); + test_driver(cont, make_policy(false_predicate())); + + mcont.clear(); + mcont += 1,2,3,4,5,6,7,8,9; + test_driver(cont, make_policy(greater_than_x(5))); + test_driver(cont, make_policy(false_predicate())); + } + + void test_find_if() + { + test_find_if_container< std::vector >(); + test_find_if_container< std::list >(); + test_find_if_container< std::deque >(); + + test_find_if_container< const std::vector >(); + test_find_if_container< const std::list >(); + test_find_if_container< const std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.find_if" ); + + test->add( BOOST_TEST_CASE( &boost::test_find_if ) ); + + return test; +} diff --git a/test/algorithm_test/for_each.cpp b/test/algorithm_test/for_each.cpp new file mode 100644 index 0000000..56f2ef5 --- /dev/null +++ b/test/algorithm_test/for_each.cpp @@ -0,0 +1,86 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include + +#include +#include +#include +#include "../test_function/check_equal_fn.hpp" + +namespace boost +{ + namespace + { + template< class SinglePassRange > + void test_for_each_impl( SinglePassRange rng ) + { + using namespace boost::range_test_function; + + typedef check_equal_fn< SinglePassRange > fn_t; + + // Test the mutable version + fn_t result_fn = boost::for_each(rng, fn_t(rng)); + BOOST_CHECK_EQUAL( boost::distance(rng), result_fn.invocation_count() ); + + // Test the constant version + const SinglePassRange& cref_rng = rng; + result_fn = boost::for_each(cref_rng, fn_t(cref_rng)); + BOOST_CHECK_EQUAL( boost::distance(cref_rng), result_fn.invocation_count() ); + } + + template< class Container > + void test_for_each_t() + { + using namespace boost::assign; + + // Test empty + Container cont; + test_for_each_impl(cont); + + // Test one element + cont += 0; + test_for_each_impl(cont); + + // Test many elements + cont += 1,2,3,4,5,6,7,8,9; + test_for_each_impl(cont); + } + + void test_for_each() + { + boost::array a = { 0,1,2,3,4,5,6,7,8,9 }; + test_for_each_impl(a); + + test_for_each_t< std::vector >(); + test_for_each_t< std::list >(); + test_for_each_t< std::set >(); + test_for_each_t< std::multiset >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.for_each" ); + + test->add( BOOST_TEST_CASE( &boost::test_for_each ) ); + + return test; +} \ No newline at end of file diff --git a/test/algorithm_test/generate.cpp b/test/algorithm_test/generate.cpp new file mode 100644 index 0000000..ab47b06 --- /dev/null +++ b/test/algorithm_test/generate.cpp @@ -0,0 +1,90 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + class generator_fn + { + public: + typedef int result_type; + + generator_fn() : m_count(0) {} + int operator()() { return ++m_count; } + + private: + int m_count; + }; + + template< class Container > + void test_generate_impl(Container& cont) + { + Container reference(cont); + std::generate(reference.begin(), reference.end(), generator_fn()); + + Container test(cont); + boost::generate(test, generator_fn()); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_generate_impl() + { + using namespace boost::assign; + + Container cont; + test_generate_impl(cont); + + cont.clear(); + cont += 9; + test_generate_impl(cont); + + cont.clear(); + cont += 9,8,7,6,5,4,3,2,1; + test_generate_impl(cont); + } + + void test_generate() + { + test_generate_impl< std::vector >(); + test_generate_impl< std::list >(); + test_generate_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.generate" ); + + test->add( BOOST_TEST_CASE( &boost::test_generate ) ); + + return test; +} diff --git a/test/algorithm_test/heap.cpp b/test/algorithm_test/heap.cpp new file mode 100644 index 0000000..933d1f6 --- /dev/null +++ b/test/algorithm_test/heap.cpp @@ -0,0 +1,122 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void check_equal(const Container1& cont1, const Container2& cont2) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + cont1.begin(), cont1.end(), + cont2.begin(), cont2.end() + ); + } + + void test() + { + using namespace boost::assign; + + std::vector reference; + reference += 1,2,3,4,5,6,7,8,9; + + std::vector test_cont(reference); + + std::make_heap(reference.begin(), reference.end()); + boost::make_heap(test_cont); + check_equal(reference, test_cont); + + std::push_heap(reference.begin(), reference.end()); + boost::push_heap(test_cont); + check_equal(reference, test_cont); + + std::make_heap(reference.begin(), reference.end()); + boost::make_heap(test_cont); + + std::sort_heap(reference.begin(), reference.end()); + boost::sort_heap(test_cont); + check_equal(reference, test_cont); + + std::make_heap(reference.begin(), reference.end()); + boost::make_heap(test_cont); + + std::pop_heap(reference.begin(), reference.end()); + boost::pop_heap(test_cont); + check_equal(reference, test_cont); + } + + template + void test_pred(BinaryPredicate pred) + { + using namespace boost::assign; + + std::vector reference; + reference += 1,2,3,4,5,6,7,8,9; + std::sort(reference.begin(), reference.end(), pred); + + std::vector test_cont(reference); + + std::make_heap(reference.begin(), reference.end(), pred); + boost::make_heap(test_cont, pred); + check_equal(reference, test_cont); + + reference.push_back(5); + test_cont.push_back(5); + std::push_heap(reference.begin(), reference.end(), pred); + boost::push_heap(test_cont, pred); + check_equal(reference, test_cont); + + std::make_heap(reference.begin(), reference.end(), pred); + boost::make_heap(test_cont, pred); + + std::sort_heap(reference.begin(), reference.end(), pred); + boost::sort_heap(test_cont, pred); + check_equal(reference, test_cont); + + std::make_heap(reference.begin(), reference.end(), pred); + boost::make_heap(test_cont, pred); + + std::pop_heap(reference.begin(), reference.end(), pred); + boost::pop_heap(test_cont, pred); + check_equal(reference, test_cont); + } + + void test_heap() + { + test(); + test_pred(std::less()); + test_pred(std::greater()); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.heap" ); + + test->add( BOOST_TEST_CASE( &boost::test_heap ) ); + + return test; +} diff --git a/test/algorithm_test/includes.cpp b/test/algorithm_test/includes.cpp new file mode 100644 index 0000000..f928957 --- /dev/null +++ b/test/algorithm_test/includes.cpp @@ -0,0 +1,157 @@ +// Copyright Neil Groves 2009. 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 +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test(Container1& cont1, Container2& cont2) + { + Container1 old_cont1(cont1); + Container2 old_cont2(cont2); + + bool reference_result + = std::includes(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end()); + + bool test_result = boost::includes(cont1, cont2); + + BOOST_CHECK( reference_result == test_result ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + old_cont1.begin(), old_cont1.end(), + cont1.begin(), cont1.end() + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + old_cont2.begin(), old_cont2.end(), + cont2.begin(), cont2.end() + ); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, + BinaryPredicate pred) + { + sort_container(cont1, pred); + sort_container(cont2, pred); + + Container1 old_cont1(cont1); + Container2 old_cont2(cont2); + + bool reference_result + = std::includes(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + pred); + + bool test_result = boost::includes(cont1, cont2, pred); + + BOOST_CHECK( reference_result == test_result ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + old_cont1.begin(), old_cont1.end(), + cont1.begin(), cont1.end() + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + old_cont2.begin(), old_cont2.end(), + cont2.begin(), cont2.end() + ); + } + + template + void test_includes_impl( + Container1& cont1, + Container2& cont2 + ) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_includes_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_includes_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_includes_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_includes_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7,8,9; + cont2 += 2,3,4; + test_includes_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 2,3,4; + cont2 += 1,2,3,4,5,6,7,8,9; + test_includes_impl(cont1, cont2); + } + + void test_includes() + { + test_includes_impl< std::vector, std::vector >(); + test_includes_impl< std::list, std::list >(); + test_includes_impl< std::deque, std::deque >(); + test_includes_impl< std::vector, std::list >(); + test_includes_impl< std::list, std::vector >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.includes" ); + + test->add( BOOST_TEST_CASE( &boost::test_includes ) ); + + return test; +} diff --git a/test/algorithm_test/inplace_merge.cpp b/test/algorithm_test/inplace_merge.cpp new file mode 100644 index 0000000..f109257 --- /dev/null +++ b/test/algorithm_test/inplace_merge.cpp @@ -0,0 +1,145 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::vector reference_target(cont1.begin(), cont1.end()); + reference_target.insert(reference_target.end(), + cont2.begin(), cont2.end()); + + std::vector test_target(reference_target); + + std::inplace_merge(reference_target.begin(), + reference_target.begin() + cont1.size(), + reference_target.end()); + + boost::inplace_merge(test_target, + test_target.begin() + cont1.size()); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference_target.begin(), reference_target.end(), + test_target.begin(), test_target.end() + ); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + sort_container(cont1, pred); + sort_container(cont2, pred); + + std::vector reference_target(cont1.begin(), cont1.end()); + reference_target.insert(reference_target.end(), + cont2.begin(), cont2.end()); + + std::vector test_target(reference_target); + + std::inplace_merge(reference_target.begin(), + reference_target.begin() + cont1.size(), + reference_target.end(), pred); + + boost::inplace_merge(test_target, + test_target.begin() + cont1.size(), + pred); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference_target.begin(), reference_target.end(), + test_target.begin(), test_target.end() + ); + } + + template + void test_inplace_merge_impl(Container1& cont1, Container2& cont2) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_inplace_merge_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_inplace_merge_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_inplace_merge_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_inplace_merge_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,3,5,7,9,11,13,15,17,19; + cont2 += 2,4,6,8,10,12,14,16,18,20; + test_inplace_merge_impl(cont1, cont2); + } + + void test_inplace_merge() + { + test_inplace_merge_impl< std::vector, std::vector >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.inplace_merge" ); + + test->add( BOOST_TEST_CASE( &boost::test_inplace_merge ) ); + + return test; +} diff --git a/test/algorithm_test/lexicographical_compare.cpp b/test/algorithm_test/lexicographical_compare.cpp new file mode 100644 index 0000000..c57f390 --- /dev/null +++ b/test/algorithm_test/lexicographical_compare.cpp @@ -0,0 +1,151 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_lexicographical_compare_impl_nopred(ForwardRange1& rng1, + ForwardRange2& rng2) + { + bool reference = std::lexicographical_compare( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); + + bool test = boost::lexicographical_compare(rng1, rng2); + + BOOST_CHECK( reference == test ); + } + + template + void test_lexicographical_compare_impl_pred(ForwardRange1& rng1, + ForwardRange2& rng2, + BinaryPredicate pred) + { + bool reference = std::lexicographical_compare( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), + pred); + + bool test = boost::lexicographical_compare(rng1, rng2, pred); + + BOOST_CHECK( reference == test ); + } + + template + void test_lexicographical_compare_impl(Container1& cont1, + Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME boost::range_value::type value_t; + + test_lexicographical_compare_impl_nopred(cont1, cont2); + test_lexicographical_compare_impl_pred(cont1, cont2, std::less()); + test_lexicographical_compare_impl_pred(cont1, cont2, std::greater()); + } + + template + void test_lexicographical_compare_impl() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type container1_t; + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type container2_t; + + container1_t cont1; + container2_t cont2; + test_lexicographical_compare_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1.push_back(1); + cont2.push_back(1); + test_lexicographical_compare_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 2; + cont2 += 1; + test_lexicographical_compare_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + cont2 += 2; + test_lexicographical_compare_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7; + cont2 += 1,2,3,4,5,6,7; + test_lexicographical_compare_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7; + cont2 += 1,2,3,4,5,6; + test_lexicographical_compare_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6; + cont2 += 1,2,3,4,5,6,7; + test_lexicographical_compare_impl(cont1, cont2); + } + + template + void test_lexicographical_compare_rhs() + { + typedef BOOST_DEDUCED_TYPENAME range_value::type value_t; + + test_lexicographical_compare_impl >(); + test_lexicographical_compare_impl >(); + test_lexicographical_compare_impl >(); + test_lexicographical_compare_impl >(); + test_lexicographical_compare_impl >(); + test_lexicographical_compare_impl >(); + } + + void test_lexicographical_compare() + { + test_lexicographical_compare_rhs< const std::vector >(); + test_lexicographical_compare_rhs< const std::deque >(); + test_lexicographical_compare_rhs< const std::list >(); + test_lexicographical_compare_rhs< std::vector >(); + test_lexicographical_compare_rhs< std::deque >(); + test_lexicographical_compare_rhs< std::list >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.lexicographical_compare" ); + + test->add( BOOST_TEST_CASE( &boost::test_lexicographical_compare ) ); + + return test; +} diff --git a/test/algorithm_test/lower_bound.cpp b/test/algorithm_test/lower_bound.cpp new file mode 100644 index 0000000..44cc120 --- /dev/null +++ b/test/algorithm_test/lower_bound.cpp @@ -0,0 +1,172 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + class lower_bound_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::lower_bound(cont, 5); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy&, Container& cont) + { + return boost::lower_bound(cont, 5); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::lower_bound(cont.begin(), cont.end(), 5); + } + }; + + template< class BinaryPredicate > + struct lower_bound_pred_policy + { + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::lower_bound(cont, 5, m_pred); + } + + template< range_return_value return_type > + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::lower_bound( + cont, 5, policy.pred()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::lower_bound( + cont.begin(), cont.end(), 5, m_pred); + } + + BinaryPredicate& pred() { return m_pred; } + + private: + BinaryPredicate m_pred; + }; + + template + void test_lower_bound_impl(TestPolicy policy, BinaryPredicate pred) + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME remove_const::type container_t; + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + range_test::range_return_test_driver test_driver; + + container_t mcont; + Container& cont = mcont; + + test_driver(cont, policy); + + mcont.clear(); + mcont += 1; + + std::vector temp(mcont.begin(), mcont.end()); + std::sort(temp.begin(), temp.end(), pred); + mcont.assign(temp.begin(), temp.end()); + + test_driver(cont, policy); + + mcont.clear(); + mcont += 1,2,3,4,5,6,7,8,9; + + temp.assign(mcont.begin(), mcont.end()); + std::sort(temp.begin(), temp.end(), pred); + mcont.assign(temp.begin(), temp.end()); + + test_driver(cont, policy); + } + + template + void test_lower_bound_impl() + { + test_lower_bound_impl( + lower_bound_policy(), + std::less() + ); + + test_lower_bound_impl( + lower_bound_pred_policy >(), + std::less() + ); + + test_lower_bound_impl( + lower_bound_pred_policy >(), + std::greater() + ); + } + + void test_lower_bound() + { + test_lower_bound_impl< std::vector >(); + test_lower_bound_impl< std::list >(); + test_lower_bound_impl< std::deque >(); + + test_lower_bound_impl< const std::vector >(); + test_lower_bound_impl< const std::list >(); + test_lower_bound_impl< const std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.lower_bound" ); + + test->add( BOOST_TEST_CASE( &boost::test_lower_bound ) ); + + return test; +} diff --git a/test/algorithm_test/max_element.cpp b/test/algorithm_test/max_element.cpp new file mode 100644 index 0000000..a9f76b8 --- /dev/null +++ b/test/algorithm_test/max_element.cpp @@ -0,0 +1,149 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + class max_element_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::max_element(cont); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy&, Container& cont) + { + return boost::max_element(cont); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::max_element(cont.begin(), cont.end()); + } + }; + + template + class max_element_pred_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::max_element(cont, Pred()); + } + + Pred pred() const { return Pred(); } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::max_element(cont, policy.pred()); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::max_element(cont.begin(), cont.end(), Pred()); + } + }; + + template + void test_max_element_impl(TestPolicy policy) + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME remove_const::type container_t; + + range_test::range_return_test_driver test_driver; + + container_t cont; + + test_driver(cont, policy); + + cont.clear(); + cont += 1; + + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,3,4,5,6,7,8,9; + + test_driver(cont, policy); + } + + template + void test_max_element_impl() + { + test_max_element_impl(max_element_test_policy()); + + test_max_element_impl( + max_element_pred_test_policy >()); + + test_max_element_impl( + max_element_pred_test_policy >()); + } + + void test_max_element() + { + test_max_element_impl< const std::vector >(); + test_max_element_impl< const std::deque >(); + test_max_element_impl< const std::list >(); + + test_max_element_impl< std::vector >(); + test_max_element_impl< std::deque >(); + test_max_element_impl< std::list >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.max_element" ); + + test->add( BOOST_TEST_CASE( &boost::test_max_element ) ); + + return test; +} diff --git a/test/algorithm_test/merge.cpp b/test/algorithm_test/merge.cpp new file mode 100644 index 0000000..aed7cd7 --- /dev/null +++ b/test/algorithm_test/merge.cpp @@ -0,0 +1,157 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::vector reference_target( cont1.size() + cont2.size() ); + + iterator_t reference_it + = std::merge(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference_target.begin()); + + std::vector test_target( cont1.size() + cont2.size() ); + + iterator_t test_it + = boost::merge(cont1, cont2, test_target.begin()); + + BOOST_CHECK_EQUAL( + std::distance(reference_target.begin(), reference_it), + std::distance(test_target.begin(), test_it) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference_target.begin(), reference_target.end(), + test_target.begin(), test_target.end() + ); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + sort_container(cont1, pred); + sort_container(cont2, pred); + + std::vector reference_target( cont1.size() + cont2.size() ); + + iterator_t reference_it + = std::merge(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference_target.begin(), pred); + + std::vector test_target( cont1.size() + cont2.size() ); + + iterator_t test_it + = boost::merge(cont1, cont2, test_target.begin(), pred); + + BOOST_CHECK_EQUAL( + std::distance(reference_target.begin(), reference_it), + std::distance(test_target.begin(), test_it) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference_target.begin(), reference_target.end(), + test_target.begin(), test_target.end() + ); + } + + template + void test_merge_impl(Container1& cont1, Container2& cont2) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_merge_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_merge_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_merge_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_merge_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,3,5,7,9,11,13,15,17,19; + cont2 += 2,4,6,8,10,12,14,16,18,20; + test_merge_impl(cont1, cont2); + } + + void test_merge() + { + test_merge_impl< std::vector, std::vector >(); + test_merge_impl< std::list, std::list >(); + test_merge_impl< std::deque, std::deque >(); + + test_merge_impl< std::list, std::vector >(); + test_merge_impl< std::vector, std::list >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.merge" ); + + test->add( BOOST_TEST_CASE( &boost::test_merge ) ); + + return test; +} diff --git a/test/algorithm_test/min_element.cpp b/test/algorithm_test/min_element.cpp new file mode 100644 index 0000000..400372d --- /dev/null +++ b/test/algorithm_test/min_element.cpp @@ -0,0 +1,149 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + class min_element_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::min_element(cont); + } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy&, Container& cont) + { + return boost::min_element(cont); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::min_element(cont.begin(), cont.end()); + } + }; + + template + class min_element_pred_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::min_element(cont, Pred()); + } + + Pred pred() const { return Pred(); } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::min_element(cont, policy.pred()); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::min_element(cont.begin(), cont.end(), Pred()); + } + }; + + template + void test_min_element_impl(TestPolicy policy) + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME remove_const::type container_t; + + range_test::range_return_test_driver test_driver; + + container_t cont; + + test_driver(cont, policy); + + cont.clear(); + cont += 1; + + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,3,4,5,6,7,8,9; + + test_driver(cont, policy); + } + + template + void test_min_element_impl() + { + test_min_element_impl(min_element_test_policy()); + + test_min_element_impl( + min_element_pred_test_policy >()); + + test_min_element_impl( + min_element_pred_test_policy >()); + } + + void test_min_element() + { + test_min_element_impl< const std::vector >(); + test_min_element_impl< const std::deque >(); + test_min_element_impl< const std::list >(); + + test_min_element_impl< std::vector >(); + test_min_element_impl< std::deque >(); + test_min_element_impl< std::list >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.min_element" ); + + test->add( BOOST_TEST_CASE( &boost::test_min_element ) ); + + return test; +} diff --git a/test/algorithm_test/mismatch.cpp b/test/algorithm_test/mismatch.cpp new file mode 100644 index 0000000..eb8f5e7 --- /dev/null +++ b/test/algorithm_test/mismatch.cpp @@ -0,0 +1,181 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container1, class Container2 > + void test_mismatch_impl() + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type MutableContainer1; + typedef BOOST_DEDUCED_TYPENAME boost::remove_const::type MutableContainer2; + + MutableContainer1 cont1; + const Container1& cref_cont1 = cont1; + MutableContainer2 cont2; + const Container2& cref_cont2 = cont2; + + typedef BOOST_DEDUCED_TYPENAME Container1::iterator iterator1_t; + typedef BOOST_DEDUCED_TYPENAME Container1::const_iterator const_iterator1_t; + typedef BOOST_DEDUCED_TYPENAME Container2::iterator iterator2_t; + typedef BOOST_DEDUCED_TYPENAME Container2::const_iterator const_iterator2_t; + + typedef std::pair pair_mmit_t; + typedef std::pair pair_cmit_t; + typedef std::pair pair_mcit_t; + typedef std::pair pair_ccit_t; + + pair_mmit_t pair_mmit = boost::mismatch(cont1, cont2); + BOOST_CHECK( pair_mmit.first == cont1.end() ); + BOOST_CHECK( pair_mmit.second == cont2.end() ); + pair_mmit = boost::mismatch(cont1, cont2, std::equal_to()); + BOOST_CHECK( pair_mmit.first == cont1.end() ); + BOOST_CHECK( pair_mmit.second == cont2.end() ); + + pair_cmit_t pair_cmit = boost::mismatch(cref_cont1, cont2); + BOOST_CHECK( pair_cmit.first == cref_cont1.end() ); + BOOST_CHECK( pair_cmit.second == cont2.end() ); + pair_cmit = boost::mismatch(cref_cont1, cont2, std::equal_to()); + BOOST_CHECK( pair_cmit.first == cref_cont1.end() ); + BOOST_CHECK( pair_cmit.second == cont2.end() ); + + pair_mcit_t pair_mcit = boost::mismatch(cont1, cref_cont2); + BOOST_CHECK( pair_mcit.first == cont1.end() ); + BOOST_CHECK( pair_mcit.second == cref_cont2.end() ); + pair_mcit = boost::mismatch(cont1, cref_cont2, std::equal_to()); + BOOST_CHECK( pair_mcit.first == cont1.end() ); + BOOST_CHECK( pair_mcit.second == cref_cont2.end() ); + + pair_ccit_t pair_ccit = boost::mismatch(cref_cont1, cref_cont2); + BOOST_CHECK( pair_ccit.first == cref_cont1.end() ); + BOOST_CHECK( pair_ccit.second == cref_cont2.end() ); + pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::equal_to()); + BOOST_CHECK( pair_ccit.first == cref_cont1.end() ); + BOOST_CHECK( pair_ccit.second == cref_cont2.end() ); + + cont1 += 1,2,3,4; + cont2 += 1,2,3,4; + pair_mmit = boost::mismatch(cont1, cont2); + BOOST_CHECK( pair_mmit.first == cont1.end() ); + BOOST_CHECK( pair_mmit.second == cont2.end() ); + pair_mmit = boost::mismatch(cont1, cont2, std::equal_to()); + BOOST_CHECK( pair_mmit.first == cont1.end() ); + BOOST_CHECK( pair_mmit.second == cont2.end() ); + + pair_cmit = boost::mismatch(cref_cont1, cont2); + BOOST_CHECK( pair_cmit.first == cref_cont1.end() ); + BOOST_CHECK( pair_cmit.second == cont2.end() ); + pair_cmit = boost::mismatch(cref_cont1, cont2, std::equal_to()); + BOOST_CHECK( pair_cmit.first == cref_cont1.end() ); + BOOST_CHECK( pair_cmit.second == cont2.end() ); + + pair_mcit = boost::mismatch(cont1, cref_cont2); + BOOST_CHECK( pair_mcit.first == cont1.end() ); + BOOST_CHECK( pair_mcit.second == cref_cont2.end() ); + pair_mcit = boost::mismatch(cont1, cref_cont2, std::equal_to()); + BOOST_CHECK( pair_mcit.first == cont1.end() ); + BOOST_CHECK( pair_mcit.second == cref_cont2.end() ); + + pair_ccit = boost::mismatch(cref_cont1, cref_cont2); + BOOST_CHECK( pair_ccit.first == cref_cont1.end() ); + BOOST_CHECK( pair_ccit.second == cref_cont2.end() ); + pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::equal_to()); + BOOST_CHECK( pair_ccit.first == cref_cont1.end() ); + BOOST_CHECK( pair_ccit.second == cref_cont2.end() ); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4; + cont2 += 1,2,5,4; + pair_mmit = boost::mismatch(cont1, cont2); + BOOST_CHECK( pair_mmit.first != cont1.end() && *pair_mmit.first == 3 ); + BOOST_CHECK( pair_mmit.second != cont2.end() && *pair_mmit.second == 5 ); + pair_mmit = boost::mismatch(cont1, cont2, std::equal_to()); + BOOST_CHECK( pair_mmit.first != cont1.end() && *pair_mmit.first == 3 ); + BOOST_CHECK( pair_mmit.second != cont2.end() && *pair_mmit.second == 5 ); + pair_mmit = boost::mismatch(cont1, cont2, std::not_equal_to()); + BOOST_CHECK( pair_mmit.first == cont1.begin() ); + BOOST_CHECK( pair_mmit.second == cont2.begin() ); + + pair_cmit = boost::mismatch(cref_cont1, cont2); + BOOST_CHECK( pair_cmit.first != cref_cont1.end() && *pair_cmit.first == 3 ); + BOOST_CHECK( pair_cmit.second != cont2.end() && *pair_cmit.second == 5 ); + pair_cmit = boost::mismatch(cref_cont1, cont2, std::equal_to()); + BOOST_CHECK( pair_cmit.first != cref_cont1.end() && *pair_cmit.first == 3 ); + BOOST_CHECK( pair_cmit.second != cont2.end() && *pair_cmit.second == 5 ); + pair_cmit = boost::mismatch(cref_cont1, cont2, std::not_equal_to()); + BOOST_CHECK( pair_cmit.first == cref_cont1.begin() ); + BOOST_CHECK( pair_cmit.second == cont2.begin() ); + + pair_mcit = boost::mismatch(cont1, cref_cont2); + BOOST_CHECK( pair_mcit.first != cont1.end() && *pair_mcit.first == 3 ); + BOOST_CHECK( pair_mcit.second != cref_cont2.end() && *pair_mcit.second == 5 ); + pair_mcit = boost::mismatch(cont1, cref_cont2, std::equal_to()); + BOOST_CHECK( pair_mcit.first != cont1.end() && *pair_mcit.first == 3 ); + BOOST_CHECK( pair_mcit.second != cref_cont2.end() && *pair_mcit.second == 5 ); + pair_mcit = boost::mismatch(cont1, cref_cont2, std::not_equal_to()); + BOOST_CHECK( pair_mcit.first == cont1.begin() ); + BOOST_CHECK( pair_mcit.second == cref_cont2.begin() ); + + pair_ccit = boost::mismatch(cref_cont1, cref_cont2); + BOOST_CHECK( pair_ccit.first != cref_cont1.end() && *pair_ccit.first == 3 ); + BOOST_CHECK( pair_ccit.second != cref_cont2.end() && *pair_ccit.second == 5 ); + pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::equal_to()); + BOOST_CHECK( pair_ccit.first != cref_cont1.end() && *pair_ccit.first == 3 ); + BOOST_CHECK( pair_ccit.second != cref_cont2.end() && *pair_ccit.second == 5 ); + pair_ccit = boost::mismatch(cref_cont1, cref_cont2, std::not_equal_to()); + BOOST_CHECK( pair_ccit.first == cref_cont1.begin() ); + BOOST_CHECK( pair_ccit.second == cref_cont2.begin() ); + } + + void test_mismatch() + { + test_mismatch_impl< std::list, std::list >(); + test_mismatch_impl< const std::list, std::list >(); + test_mismatch_impl< std::list, const std::list >(); + test_mismatch_impl< const std::list, const std::list >(); + + test_mismatch_impl< std::vector, std::list >(); + test_mismatch_impl< const std::vector, std::list >(); + test_mismatch_impl< std::vector, const std::list >(); + test_mismatch_impl< const std::vector, const std::list >(); + + test_mismatch_impl< std::list, std::vector >(); + test_mismatch_impl< const std::list, std::vector >(); + test_mismatch_impl< std::list, const std::vector >(); + test_mismatch_impl< const std::list, const std::vector >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.mismatch" ); + + test->add( BOOST_TEST_CASE( &boost::test_mismatch ) ); + + return test; +} diff --git a/test/algorithm_test/next_permutation.cpp b/test/algorithm_test/next_permutation.cpp new file mode 100644 index 0000000..c2d782b --- /dev/null +++ b/test/algorithm_test/next_permutation.cpp @@ -0,0 +1,108 @@ +// Copyright Neil Groves 2009. 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 +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_next_permutation_impl(const Container& cont) + { + Container reference(cont); + Container test(cont); + + const bool reference_ret + = std::next_permutation(reference.begin(), reference.end()); + + const bool test_ret + = boost::next_permutation(test); + + BOOST_CHECK( reference_ret == test_ret ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_next_permutation_pred_impl(const Container& cont, + BinaryPredicate pred) + { + Container reference(cont); + Container test(cont); + + const bool reference_ret + = std::next_permutation(reference.begin(), reference.end(), + pred); + + const bool test_ret + = boost::next_permutation(test, pred); + + BOOST_CHECK( reference_ret == test_ret ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_next_permutation_(const Container& cont) + { + test_next_permutation_impl(cont); + test_next_permutation_pred_impl(cont, std::less()); + test_next_permutation_pred_impl(cont, std::greater()); + } + + template + void run_tests() + { + using namespace boost::assign; + + Container cont; + test_next_permutation_(cont); + + cont.clear(); + cont += 1; + test_next_permutation_(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_next_permutation_(cont); + } + + void test_next_permutation() + { + run_tests< std::vector >(); + run_tests< std::list >(); + run_tests< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.next_permutation" ); + + test->add( BOOST_TEST_CASE( &boost::test_next_permutation ) ); + + return test; +} diff --git a/test/algorithm_test/nth_element.cpp b/test/algorithm_test/nth_element.cpp new file mode 100644 index 0000000..dac2a2f --- /dev/null +++ b/test/algorithm_test/nth_element.cpp @@ -0,0 +1,149 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct nth_element_policy + { + template + void test_nth_element(Container& cont, Iterator mid) + { + boost::nth_element(cont, mid); + } + + template + void reference_nth_element(Container& cont, Iterator mid) + { + std::nth_element(cont.begin(), mid, cont.end()); + } + }; + + template + struct nth_element_pred_policy + { + template + void test_nth_element(Container& cont, Iterator mid) + { + boost::nth_element(cont, mid, BinaryPredicate()); + } + + template + void reference_nth_element(Container& cont, Iterator mid) + { + std::nth_element(cont.begin(), mid, cont.end(), BinaryPredicate()); + } + }; + + template + void test_nth_element_tp_impl(Container& cont, TestPolicy policy) + { + Container reference(cont); + Container test(cont); + + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + BOOST_CHECK_EQUAL( reference.size(), test.size() ); + if (reference.size() != test.size()) + return; + + iterator_t reference_mid = reference.begin(); + iterator_t test_mid = test.begin(); + + bool complete = false; + while (!complete) + { + if (reference_mid == reference.end()) + complete = true; + + policy.test_nth_element(test, test_mid); + policy.reference_nth_element(reference, reference_mid); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + if (reference_mid != reference.end()) + { + ++reference_mid; + ++test_mid; + } + } + } + + template + void test_nth_element_impl(Container& cont) + { + test_nth_element_tp_impl(cont, nth_element_policy()); + } + + template + void test_nth_element_impl(Container& cont, BinaryPredicate pred) + { + test_nth_element_tp_impl(cont, nth_element_pred_policy()); + } + + template + void run_tests(Container& cont) + { + test_nth_element_impl(cont); + test_nth_element_impl(cont, std::less()); + test_nth_element_impl(cont, std::greater()); + } + + template + void test_nth_element_impl() + { + using namespace boost::assign; + + Container cont; + run_tests(cont); + + cont.clear(); + cont += 1; + run_tests(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + run_tests(cont); + } + + void test_nth_element() + { + test_nth_element_impl< std::vector >(); + test_nth_element_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.nth_element" ); + + test->add( BOOST_TEST_CASE( &boost::test_nth_element ) ); + + return test; +} diff --git a/test/algorithm_test/partial_sort.cpp b/test/algorithm_test/partial_sort.cpp new file mode 100644 index 0000000..62ff64b --- /dev/null +++ b/test/algorithm_test/partial_sort.cpp @@ -0,0 +1,149 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct partial_sort_policy + { + template + void test_partial_sort(Container& cont, Iterator mid) + { + boost::partial_sort(cont, mid); + } + + template + void reference_partial_sort(Container& cont, Iterator mid) + { + std::partial_sort(cont.begin(), mid, cont.end()); + } + }; + + template + struct partial_sort_pred_policy + { + template + void test_partial_sort(Container& cont, Iterator mid) + { + boost::partial_sort(cont, mid, BinaryPredicate()); + } + + template + void reference_partial_sort(Container& cont, Iterator mid) + { + std::partial_sort(cont.begin(), mid, cont.end(), BinaryPredicate()); + } + }; + + template + void test_partial_sort_tp_impl(Container& cont, TestPolicy policy) + { + Container reference(cont); + Container test(cont); + + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + BOOST_CHECK_EQUAL( reference.size(), test.size() ); + if (reference.size() != test.size()) + return; + + iterator_t reference_mid = reference.begin(); + iterator_t test_mid = test.begin(); + + bool complete = false; + while (!complete) + { + if (reference_mid == reference.end()) + complete = true; + + policy.test_partial_sort(test, test_mid); + policy.reference_partial_sort(reference, reference_mid); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + if (reference_mid != reference.end()) + { + ++reference_mid; + ++test_mid; + } + } + } + + template + void test_partial_sort_impl(Container& cont) + { + test_partial_sort_tp_impl(cont, partial_sort_policy()); + } + + template + void test_partial_sort_impl(Container& cont, BinaryPredicate pred) + { + test_partial_sort_tp_impl(cont, partial_sort_pred_policy()); + } + + template + void test_partial_sort_impl() + { + using namespace boost::assign; + + Container cont; + test_partial_sort_impl(cont); + test_partial_sort_impl(cont, std::less()); + test_partial_sort_impl(cont, std::greater()); + + cont.clear(); + cont += 1; + test_partial_sort_impl(cont); + test_partial_sort_impl(cont, std::less()); + test_partial_sort_impl(cont, std::greater()); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_partial_sort_impl(cont); + test_partial_sort_impl(cont, std::less()); + test_partial_sort_impl(cont, std::greater()); + } + + void test_partial_sort() + { + test_partial_sort_impl< std::vector >(); + test_partial_sort_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.partial_sort" ); + + test->add( BOOST_TEST_CASE( &boost::test_partial_sort ) ); + + return test; +} diff --git a/test/algorithm_test/partition.cpp b/test/algorithm_test/partition.cpp new file mode 100644 index 0000000..e71c9a7 --- /dev/null +++ b/test/algorithm_test/partition.cpp @@ -0,0 +1,111 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct equal_to_5 + { + typedef bool result_type; + typedef int argument_type; + bool operator()(int x) const { return x == 5; } + }; + + // test the 'partition' algorithm + template + class partition_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::partition(cont, UnaryPredicate()); + } + + UnaryPredicate pred() const { return UnaryPredicate(); } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::partition(cont, policy.pred()); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::partition(cont.begin(), cont.end(), UnaryPredicate()); + } + }; + + template + void test_partition_impl() + { + using namespace boost::assign; + + range_test::range_return_test_driver test_driver; + + partition_test_policy< equal_to_5 > policy; + + Container cont; + test_driver(cont, policy); + + cont.clear(); + cont += 1; + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,2,2,3,4,5,6,7,8,9; + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,2,2,3,3,3,3,4,4,4,4,4,4,4,5,6,7,8,9; + test_driver(cont, policy); + } + + void test_partition() + { + test_partition_impl< std::vector >(); + test_partition_impl< std::list >(); + test_partition_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.partition" ); + + test->add( BOOST_TEST_CASE( &boost::test_partition ) ); + + return test; +} diff --git a/test/algorithm_test/prev_permutation.cpp b/test/algorithm_test/prev_permutation.cpp new file mode 100644 index 0000000..e1073c9 --- /dev/null +++ b/test/algorithm_test/prev_permutation.cpp @@ -0,0 +1,108 @@ +// Copyright Neil Groves 2009. 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 +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_prev_permutation_impl(const Container& cont) + { + Container reference(cont); + Container test(cont); + + const bool reference_ret + = std::prev_permutation(reference.begin(), reference.end()); + + const bool test_ret + = boost::prev_permutation(test); + + BOOST_CHECK( reference_ret == test_ret ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_prev_permutation_pred_impl(const Container& cont, + BinaryPredicate pred) + { + Container reference(cont); + Container test(cont); + + const bool reference_ret + = std::prev_permutation(reference.begin(), reference.end(), + pred); + + const bool test_ret + = boost::prev_permutation(test, pred); + + BOOST_CHECK( reference_ret == test_ret ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_prev_permutation_(const Container& cont) + { + test_prev_permutation_impl(cont); + test_prev_permutation_pred_impl(cont, std::less()); + test_prev_permutation_pred_impl(cont, std::greater()); + } + + template + void run_tests() + { + using namespace boost::assign; + + Container cont; + test_prev_permutation_(cont); + + cont.clear(); + cont += 1; + test_prev_permutation_(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_prev_permutation_(cont); + } + + void test_prev_permutation() + { + run_tests< std::vector >(); + run_tests< std::list >(); + run_tests< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.prev_permutation" ); + + test->add( BOOST_TEST_CASE( &boost::test_prev_permutation ) ); + + return test; +} diff --git a/test/algorithm_test/random_shuffle.cpp b/test/algorithm_test/random_shuffle.cpp new file mode 100644 index 0000000..ba55f51 --- /dev/null +++ b/test/algorithm_test/random_shuffle.cpp @@ -0,0 +1,178 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include "../test_function/counted_function.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + class counted_generator + : private range_test_function::counted_function + { + public: + typedef Int result_type; + typedef Int argument_type; + + using range_test_function::counted_function::invocation_count; + + result_type operator()(argument_type modulo_value) + { + invoked(); + return static_cast(std::rand() % modulo_value); + } + }; + + template + bool test_shuffle_result( + const Container& old_cont, + const Container& new_cont + ) + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + // The size must remain equal + BOOST_CHECK_EQUAL( old_cont.size(), new_cont.size() ); + if (old_cont.size() != new_cont.size()) + return false; + + if (new_cont.size() < 2) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + old_cont.begin(), old_cont.end(), + new_cont.begin(), new_cont.end() + ); + + return std::equal(old_cont.begin(), old_cont.end(), + new_cont.begin()); + } + + // Elements must only be moved around. This is tested by + // ensuring the count of each element remains the + // same. + bool failed = false; + iterator_t last = old_cont.end(); + for (iterator_t it = old_cont.begin(); !failed && (it != last); ++it) + { + const std::size_t old_count + = std::count(old_cont.begin(), old_cont.end(), *it); + + const std::size_t new_count + = std::count(new_cont.begin(), new_cont.end(), *it); + + BOOST_CHECK_EQUAL( old_count, new_count ); + + failed = (old_count != new_count); + } + + return !failed; + } + + template + void test_random_shuffle_nogen_impl(Container& cont) + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + const int MAX_RETRIES = 10000; + + bool shuffled = false; + for (int attempt = 0; !shuffled && (attempt < MAX_RETRIES); ++attempt) + { + Container test(cont); + boost::random_shuffle(test); + bool ok = test_shuffle_result(cont, test); + if (!ok) + break; + + // Since the counts are equal, then if they are + // not equal the contents must have been shuffled + if (cont.size() == test.size() + && !std::equal(cont.begin(), cont.end(), test.begin())) + { + shuffled = true; + } + } + } + + template + void test_random_shuffle_gen_impl(Container& cont) + { + RandomGenerator gen; + Container old_cont(cont); + boost::random_shuffle(cont, gen); + test_shuffle_result(cont, old_cont); + if (cont.size() > 2) + { + BOOST_CHECK( gen.invocation_count() > 0 ); + } + } + + template + void test_random_shuffle_impl(Container& cont) + { + Container old_cont(cont); + boost::random_shuffle(cont); + test_shuffle_result(cont, old_cont); + } + + template + void test_random_shuffle_impl() + { + using namespace boost::assign; + + typedef counted_generator< + BOOST_DEDUCED_TYPENAME range_difference::type > generator_t; + + Container cont; + test_random_shuffle_nogen_impl(cont); + test_random_shuffle_gen_impl(cont); + + cont.clear(); + cont += 1; + test_random_shuffle_nogen_impl(cont); + test_random_shuffle_gen_impl(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_random_shuffle_nogen_impl(cont); + test_random_shuffle_gen_impl(cont); + } + + void test_random_shuffle() + { + test_random_shuffle_impl< std::vector >(); + test_random_shuffle_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.random_shuffle" ); + + test->add( BOOST_TEST_CASE( &boost::test_random_shuffle ) ); + + return test; +} diff --git a/test/algorithm_test/remove.cpp b/test/algorithm_test/remove.cpp new file mode 100644 index 0000000..46e6591 --- /dev/null +++ b/test/algorithm_test/remove.cpp @@ -0,0 +1,92 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container, class Value > + void test_remove_impl( const Container& c, Value to_remove ) + { + Container reference(c); + + typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator_t; + + iterator_t reference_it + = std::remove(reference.begin(), reference.end(), to_remove); + + Container test(c); + iterator_t test_it = boost::remove(test, to_remove); + + BOOST_CHECK_EQUAL( std::distance(test.begin(), test_it), + std::distance(reference.begin(), reference_it) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_remove_impl() + { + using namespace boost::assign; + + Container cont; + test_remove_impl(cont, 0); + + cont.clear(); + cont += 1; + test_remove_impl(cont, 0); + test_remove_impl(cont, 1); + + cont.clear(); + cont += 1,1,1,1,1; + test_remove_impl(cont, 0); + test_remove_impl(cont, 1); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_remove_impl(cont, 1); + test_remove_impl(cont, 9); + test_remove_impl(cont, 4); + } + + void test_remove() + { + test_remove_impl< std::vector >(); + test_remove_impl< std::list >(); + test_remove_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove" ); + + test->add( BOOST_TEST_CASE( &boost::test_remove ) ); + + return test; +} diff --git a/test/algorithm_test/remove_if.cpp b/test/algorithm_test/remove_if.cpp new file mode 100644 index 0000000..1e77e7b --- /dev/null +++ b/test/algorithm_test/remove_if.cpp @@ -0,0 +1,99 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container, class UnaryPredicate > + void test_remove_if_impl( const Container& c, UnaryPredicate pred ) + { + Container reference(c); + + typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator_t; + + iterator_t reference_it + = std::remove_if(reference.begin(), reference.end(), pred); + + Container test(c); + iterator_t test_it = boost::remove_if(test, pred); + + BOOST_CHECK_EQUAL( std::distance(test.begin(), test_it), + std::distance(reference.begin(), reference_it) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_remove_if_( const Container& c, int to_remove ) + { + test_remove_if_impl(c, boost::bind(std::equal_to(), _1, to_remove)); + test_remove_if_impl(c, boost::bind(std::not_equal_to(), _1, to_remove)); + } + + template< class Container > + void test_remove_if_impl() + { + using namespace boost::assign; + + Container cont; + test_remove_if_(cont, 0); + + cont.clear(); + cont += 1; + test_remove_if_(cont, 0); + test_remove_if_(cont, 1); + + cont.clear(); + cont += 1,1,1,1,1; + test_remove_if_(cont, 0); + test_remove_if_(cont, 1); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_remove_if_(cont, 1); + test_remove_if_(cont, 9); + test_remove_if_(cont, 4); + } + + inline void test_remove_if() + { + test_remove_if_impl< std::vector >(); + test_remove_if_impl< std::list >(); + test_remove_if_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove_if" ); + + test->add( BOOST_TEST_CASE( &boost::test_remove_if ) ); + + return test; +} diff --git a/test/algorithm_test/replace.cpp b/test/algorithm_test/replace.cpp new file mode 100644 index 0000000..4a882dc --- /dev/null +++ b/test/algorithm_test/replace.cpp @@ -0,0 +1,79 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_replace_impl(Container& cont) + { + const int what = 2; + const int with_what = 5; + + std::vector reference(cont.begin(), cont.end()); + std::replace(reference.begin(), reference.end(), what, with_what); + + std::vector target(cont.begin(), cont.end()); + boost::replace(target, what, with_what); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + + } + + template< class Container > + void test_replace_impl() + { + using namespace boost::assign; + + Container cont; + test_replace_impl(cont); + + cont.clear(); + cont += 1; + test_replace_impl(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_replace_impl(cont); + } + + void test_replace() + { + test_replace_impl< std::vector >(); + test_replace_impl< std::list >(); + test_replace_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.replace" ); + + test->add( BOOST_TEST_CASE( &boost::test_replace ) ); + + return test; +} diff --git a/test/algorithm_test/replace_if.cpp b/test/algorithm_test/replace_if.cpp new file mode 100644 index 0000000..e1dd26f --- /dev/null +++ b/test/algorithm_test/replace_if.cpp @@ -0,0 +1,90 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container, class UnaryPredicate > + void test_replace_if_impl(Container& cont, UnaryPredicate pred) + { + const int what = 2; + const int with_what = 5; + + std::vector reference(cont.begin(), cont.end()); + std::replace_if(reference.begin(), reference.end(), + boost::bind(pred, _1, what), with_what); + + std::vector target(cont.begin(), cont.end()); + boost::replace_if(target, boost::bind(pred, _1, what), with_what); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + + } + + template< class Container > + void test_replace_if_impl(Container& cont) + { + test_replace_if_impl(cont, std::equal_to()); + test_replace_if_impl(cont, std::not_equal_to()); + } + + template< class Container > + void test_replace_if_impl() + { + using namespace boost::assign; + + Container cont; + test_replace_if_impl(cont); + + cont.clear(); + cont += 1; + test_replace_if_impl(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_replace_if_impl(cont); + } + + void test_replace_if() + { + test_replace_if_impl< std::vector >(); + test_replace_if_impl< std::list >(); + test_replace_if_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.replace_if" ); + + test->add( BOOST_TEST_CASE( &boost::test_replace_if ) ); + + return test; +} diff --git a/test/algorithm_test/reverse.cpp b/test/algorithm_test/reverse.cpp new file mode 100644 index 0000000..611a464 --- /dev/null +++ b/test/algorithm_test/reverse.cpp @@ -0,0 +1,78 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_reverse_impl(Container& cont) + { + Container reference(cont); + Container test(cont); + + boost::reverse(test); + std::reverse(reference.begin(), reference.end()); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_reverse_impl() + { + using namespace boost::assign; + + Container cont; + test_reverse_impl(cont); + + cont.clear(); + cont += 1; + test_reverse_impl(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_reverse_impl(cont); + } + + void test_reverse() + { + test_reverse_impl< std::vector >(); + test_reverse_impl< std::list >(); + test_reverse_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.reverse" ); + + test->add( BOOST_TEST_CASE( &boost::test_reverse ) ); + + return test; +} diff --git a/test/algorithm_test/rotate.cpp b/test/algorithm_test/rotate.cpp new file mode 100644 index 0000000..f8b394a --- /dev/null +++ b/test/algorithm_test/rotate.cpp @@ -0,0 +1,99 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_rotate_impl(Container& cont, Iterator where_it) + { + Container reference(cont); + Container test(cont); + + Iterator reference_where_it = reference.begin(); + std::advance(reference_where_it, + std::distance(cont.begin(), where_it)); + + std::rotate(reference.begin(), reference_where_it, reference.end()); + + Iterator test_where_it = test.begin(); + std::advance(test_where_it, + std::distance(cont.begin(), where_it)); + + boost::rotate(test, test_where_it); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_rotate_impl(Container& cont) + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + iterator_t last = cont.end(); + for (iterator_t it = cont.begin(); it != last; ++it) + { + test_rotate_impl(cont, it); + } + } + + template + void test_rotate_impl() + { + using namespace boost::assign; + + Container cont; + test_rotate_impl(cont); + + cont.clear(); + cont += 1; + test_rotate_impl(cont); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_rotate_impl(cont); + } + + void test_rotate() + { + test_rotate_impl< std::vector >(); + test_rotate_impl< std::list >(); + test_rotate_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.rotate" ); + + test->add( BOOST_TEST_CASE( &boost::test_rotate ) ); + + return test; +} diff --git a/test/algorithm_test/search.cpp b/test/algorithm_test/search.cpp new file mode 100644 index 0000000..460f70d --- /dev/null +++ b/test/algorithm_test/search.cpp @@ -0,0 +1,97 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container1, class Container2 > + void test_search_impl(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::const_iterator const_iterator1_t; + typedef BOOST_DEDUCED_TYPENAME Container1::iterator iterator1_t; + + const Container1& ccont1 = cont1; + const Container2& ccont2 = cont2; + + iterator1_t it = boost::search(cont1, cont2); + iterator1_t it2 = boost::search(cont1, ccont2); + const_iterator1_t cit = boost::search(ccont1, cont2); + const_iterator1_t cit2 = boost::search(ccont1, ccont2); + + BOOST_CHECK( it == std::search(cont1.begin(), cont1.end(), cont2.begin(), cont2.end()) ); + BOOST_CHECK( it2 == std::search(cont1.begin(), cont1.end(), ccont2.begin(), ccont2.end()) ); + BOOST_CHECK( cit == std::search(ccont1.begin(), ccont1.end(), cont2.begin(), cont2.end()) ); + BOOST_CHECK( cit2 == std::search(ccont1.begin(), ccont1.end(), ccont2.begin(), ccont2.end()) ); + } + + template< class Container1, class Container2 > + void test_search_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_search_impl(cont1, cont2); + + cont1 += 1; + test_search_impl(cont1, cont2); + + cont1.clear(); + cont2 += 1; + test_search_impl(cont1, cont2); + + cont1 += 1; + test_search_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7,8,9; + cont2 += 10,11,12; + test_search_impl(cont1, cont2); + + cont2.clear(); + cont2 += 4,5,6; + test_search_impl(cont1, cont2); + } + + void test_search() + { + test_search_impl< std::list, std::list >(); + test_search_impl< std::vector, std::vector >(); + test_search_impl< std::set, std::set >(); + test_search_impl< std::list, std::vector >(); + test_search_impl< std::vector, std::list >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.search" ); + + test->add( BOOST_TEST_CASE( &boost::test_search ) ); + + return test; +} diff --git a/test/algorithm_test/set_difference.cpp b/test/algorithm_test/set_difference.cpp new file mode 100644 index 0000000..7fb0974 --- /dev/null +++ b/test/algorithm_test/set_difference.cpp @@ -0,0 +1,170 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void check_result( + Container1& reference, + Iterator reference_result, + Container2& test_cont, + Iterator test_result + ) + { + BOOST_CHECK_EQUAL( + std::distance(reference.begin(), reference_result), + std::distance(test_cont.begin(), test_result) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test_cont.begin(), test_cont.end() + ); + } + + template + void test(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_difference(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin()); + + iterator_t test_result + = boost::set_difference(cont1, cont2, test_cont.begin()); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, + BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + sort_container(cont1, pred); + sort_container(cont2, pred); + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_difference(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin(), + pred); + + iterator_t test_result + = boost::set_difference(cont1, cont2, test_cont.begin(), pred); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void test_set_difference_impl( + Container1& cont1, + Container2& cont2 + ) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_set_difference_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_set_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_set_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_set_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7,8,9; + cont2 += 2,3,4; + test_set_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 2,3,4; + cont2 += 1,2,3,4,5,6,7,8,9; + test_set_difference_impl(cont1, cont2); + } + + void test_set_difference() + { + test_set_difference_impl< std::vector, std::vector >(); + test_set_difference_impl< std::list, std::list >(); + test_set_difference_impl< std::deque, std::deque >(); + test_set_difference_impl< std::vector, std::list >(); + test_set_difference_impl< std::list, std::vector >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.set_difference" ); + + test->add( BOOST_TEST_CASE( &boost::test_set_difference ) ); + + return test; +} diff --git a/test/algorithm_test/set_intersection.cpp b/test/algorithm_test/set_intersection.cpp new file mode 100644 index 0000000..5e2ce1b --- /dev/null +++ b/test/algorithm_test/set_intersection.cpp @@ -0,0 +1,170 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void check_result( + Container1& reference, + Iterator reference_result, + Container2& test_cont, + Iterator test_result + ) + { + BOOST_CHECK_EQUAL( + std::distance(reference.begin(), reference_result), + std::distance(test_cont.begin(), test_result) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test_cont.begin(), test_cont.end() + ); + } + + template + void test(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_intersection(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin()); + + iterator_t test_result + = boost::set_intersection(cont1, cont2, test_cont.begin()); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, + BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + sort_container(cont1, pred); + sort_container(cont2, pred); + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_intersection(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin(), + pred); + + iterator_t test_result + = boost::set_intersection(cont1, cont2, test_cont.begin(), pred); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void test_set_intersection_impl( + Container1& cont1, + Container2& cont2 + ) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_set_intersection_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_set_intersection_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_set_intersection_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_set_intersection_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7,8,9; + cont2 += 2,3,4; + test_set_intersection_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 2,3,4; + cont2 += 1,2,3,4,5,6,7,8,9; + test_set_intersection_impl(cont1, cont2); + } + + void test_set_intersection() + { + test_set_intersection_impl< std::vector, std::vector >(); + test_set_intersection_impl< std::list, std::list >(); + test_set_intersection_impl< std::deque, std::deque >(); + test_set_intersection_impl< std::vector, std::list >(); + test_set_intersection_impl< std::list, std::vector >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.set_intersection" ); + + test->add( BOOST_TEST_CASE( &boost::test_set_intersection ) ); + + return test; +} diff --git a/test/algorithm_test/set_symmetric_difference.cpp b/test/algorithm_test/set_symmetric_difference.cpp new file mode 100644 index 0000000..149532c --- /dev/null +++ b/test/algorithm_test/set_symmetric_difference.cpp @@ -0,0 +1,172 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void check_result( + Container1& reference, + Iterator reference_result, + Container2& test_cont, + Iterator test_result + ) + { + BOOST_CHECK_EQUAL( + std::distance(reference.begin(), reference_result), + std::distance(test_cont.begin(), test_result) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test_cont.begin(), test_cont.end() + ); + } + + template + void test(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_symmetric_difference(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin()); + + iterator_t test_result + = boost::set_symmetric_difference(cont1, cont2, + test_cont.begin()); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, + BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + sort_container(cont1, pred); + sort_container(cont2, pred); + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_symmetric_difference(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin(), + pred); + + iterator_t test_result + = boost::set_symmetric_difference(cont1, cont2, + test_cont.begin(), pred); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void test_set_symmetric_difference_impl( + Container1& cont1, + Container2& cont2 + ) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_set_symmetric_difference_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_set_symmetric_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_set_symmetric_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_set_symmetric_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7,8,9; + cont2 += 2,3,4; + test_set_symmetric_difference_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 2,3,4; + cont2 += 1,2,3,4,5,6,7,8,9; + test_set_symmetric_difference_impl(cont1, cont2); + } + + void test_set_symmetric_difference() + { + test_set_symmetric_difference_impl< std::vector, std::vector >(); + test_set_symmetric_difference_impl< std::list, std::list >(); + test_set_symmetric_difference_impl< std::deque, std::deque >(); + test_set_symmetric_difference_impl< std::vector, std::list >(); + test_set_symmetric_difference_impl< std::list, std::vector >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.set_symmetric_difference" ); + + test->add( BOOST_TEST_CASE( &boost::test_set_symmetric_difference ) ); + + return test; +} diff --git a/test/algorithm_test/set_union.cpp b/test/algorithm_test/set_union.cpp new file mode 100644 index 0000000..f9450b3 --- /dev/null +++ b/test/algorithm_test/set_union.cpp @@ -0,0 +1,170 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void check_result( + Container1& reference, + Iterator reference_result, + Container2& test_cont, + Iterator test_result + ) + { + BOOST_CHECK_EQUAL( + std::distance(reference.begin(), reference_result), + std::distance(test_cont.begin(), test_result) + ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test_cont.begin(), test_cont.end() + ); + } + + template + void test(Container1& cont1, Container2& cont2) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_union(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin()); + + iterator_t test_result + = boost::set_union(cont1, cont2, test_cont.begin()); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void sort_container(Container& cont, BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + } + + template + void test_pred(Container1 cont1, Container2 cont2, + BinaryPredicate pred) + { + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + sort_container(cont1, pred); + sort_container(cont2, pred); + + std::vector reference(cont1.size() + cont2.size()); + std::vector test_cont(reference); + + iterator_t reference_result + = std::set_union(cont1.begin(), cont1.end(), + cont2.begin(), cont2.end(), + reference.begin(), + pred); + + iterator_t test_result + = boost::set_union(cont1, cont2, test_cont.begin(), pred); + + check_result(reference, reference_result, + test_cont, test_result); + } + + template + void test_set_union_impl( + Container1& cont1, + Container2& cont2 + ) + { + test(cont1, cont2); + test_pred(cont1, cont2, std::less()); + test_pred(cont1, cont2, std::greater()); + } + + template + void test_set_union_impl() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_set_union_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1; + test_set_union_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont2 += 1; + test_set_union_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 1,2,3,4,5,6,7,8,9; + cont2 += 2,3,4; + test_set_union_impl(cont1, cont2); + + cont1.clear(); + cont2.clear(); + cont1 += 2,3,4; + cont2 += 1,2,3,4,5,6,7,8,9; + test_set_union_impl(cont1, cont2); + } + + void test_set_union() + { + test_set_union_impl< std::vector, std::vector >(); + test_set_union_impl< std::list, std::list >(); + test_set_union_impl< std::deque, std::deque >(); + test_set_union_impl< std::vector, std::list >(); + test_set_union_impl< std::list, std::vector >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.set_union" ); + + test->add( BOOST_TEST_CASE( &boost::test_set_union ) ); + + return test; +} diff --git a/test/algorithm_test/sort.cpp b/test/algorithm_test/sort.cpp new file mode 100644 index 0000000..b1b26e7 --- /dev/null +++ b/test/algorithm_test/sort.cpp @@ -0,0 +1,97 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_sort_impl(Container& cont) + { + Container reference(cont); + Container test(cont); + + boost::sort(test); + std::sort(reference.begin(), reference.end()); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_sort_impl(Container& cont, BinaryPredicate pred) + { + Container reference(cont); + Container test(cont); + + boost::sort(test, pred); + std::sort(reference.begin(), reference.end(), pred); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_sort_impl() + { + using namespace boost::assign; + + Container cont; + test_sort_impl(cont); + test_sort_impl(cont, std::less()); + test_sort_impl(cont, std::greater()); + + cont.clear(); + cont += 1; + test_sort_impl(cont); + test_sort_impl(cont, std::less()); + test_sort_impl(cont, std::greater()); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_sort_impl(cont); + test_sort_impl(cont, std::less()); + test_sort_impl(cont, std::greater()); + } + + void test_sort() + { + test_sort_impl< std::vector >(); + test_sort_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.sort" ); + + test->add( BOOST_TEST_CASE( &boost::test_sort ) ); + + return test; +} diff --git a/test/algorithm_test/stable_partition.cpp b/test/algorithm_test/stable_partition.cpp new file mode 100644 index 0000000..99db6be --- /dev/null +++ b/test/algorithm_test/stable_partition.cpp @@ -0,0 +1,112 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + struct equal_to_5 + { + typedef bool result_type; + typedef int argument_type; + bool operator()(int x) const { return x == 5; } + }; + + // test the 'partition' algorithm + template + class stable_partition_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::stable_partition(cont, UnaryPredicate()); + } + + UnaryPredicate pred() const { return UnaryPredicate(); } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::stable_partition(cont, policy.pred()); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::stable_partition(cont.begin(), cont.end(), UnaryPredicate()); + } + }; + + template + void test_stable_partition_impl() + { + using namespace boost::assign; + + range_test::range_return_test_driver test_driver; + + stable_partition_test_policy< equal_to_5 > policy; + + Container cont; + test_driver(cont, policy); + + cont.clear(); + cont += 1; + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,2,2,3,4,5,6,7,8,9; + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,2,2,3,3,3,3,4,4,4,4,4,4,4,5,6,7,8,9; + test_driver(cont, policy); + } + + void test_stable_partition() + { + test_stable_partition_impl< std::vector >(); + test_stable_partition_impl< std::list >(); + test_stable_partition_impl< std::deque >(); + } + } +} + + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.stable_partition" ); + + test->add( BOOST_TEST_CASE( &boost::test_stable_partition ) ); + + return test; +} diff --git a/test/algorithm_test/stable_sort.cpp b/test/algorithm_test/stable_sort.cpp new file mode 100644 index 0000000..eb5518c --- /dev/null +++ b/test/algorithm_test/stable_sort.cpp @@ -0,0 +1,97 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template + void test_stable_sort_impl(Container& cont) + { + Container reference(cont); + Container test(cont); + + boost::stable_sort(test); + std::stable_sort(reference.begin(), reference.end()); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_stable_sort_impl(Container& cont, BinaryPredicate pred) + { + Container reference(cont); + Container test(cont); + + boost::stable_sort(test, pred); + std::stable_sort(reference.begin(), reference.end(), pred); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + } + + template + void test_stable_sort_impl() + { + using namespace boost::assign; + + Container cont; + test_stable_sort_impl(cont); + test_stable_sort_impl(cont, std::less()); + test_stable_sort_impl(cont, std::greater()); + + cont.clear(); + cont += 1; + test_stable_sort_impl(cont); + test_stable_sort_impl(cont, std::less()); + test_stable_sort_impl(cont, std::greater()); + + cont.clear(); + cont += 1,2,3,4,5,6,7,8,9; + test_stable_sort_impl(cont); + test_stable_sort_impl(cont, std::less()); + test_stable_sort_impl(cont, std::greater()); + } + + void test_stable_sort() + { + test_stable_sort_impl< std::vector >(); + test_stable_sort_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.stable_sort" ); + + test->add( BOOST_TEST_CASE( &boost::test_stable_sort ) ); + + return test; +} diff --git a/test/algorithm_test/transform.cpp b/test/algorithm_test/transform.cpp new file mode 100644 index 0000000..7f016a2 --- /dev/null +++ b/test/algorithm_test/transform.cpp @@ -0,0 +1,158 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include "../test_function/multiply_by_x.hpp" +#include +#include +#include +#include + +namespace boost +{ + namespace + { + template< class Container > + void test_transform_impl1(Container& cont) + { + using namespace boost::range_test_function; + + const Container& ccont = cont; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + std::vector target(cont.size()); + std::vector reference(cont.size()); + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + multiply_by_x fn(2); + + iterator_t reference_it + = std::transform(cont.begin(), cont.end(), reference.begin(), fn); + + iterator_t test_it + = boost::transform(cont, target.begin(), fn); + + BOOST_CHECK( test_it == target.end() ); + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + + target.clear(); + target.resize(ccont.size()); + + test_it = boost::transform(ccont, target.begin(), fn); + + BOOST_CHECK( test_it == target.end() ); + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + } + + template< class Container > + void test_transform_impl1() + { + using namespace boost::assign; + + Container cont; + + test_transform_impl1(cont); + + cont += 1; + test_transform_impl1(cont); + + cont += 2,3,4,5,6,7; + test_transform_impl1(cont); + } + + template< class Container1, class Container2 > + void test_transform_impl2(Container1& cont1, Container2& cont2) + { + const Container1& ccont1 = cont1; + const Container2& ccont2 = cont2; + + BOOST_CHECK_EQUAL( cont1.size(), cont2.size() ); + + typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_t; + + std::vector target(cont1.size()); + std::vector reference(cont1.size()); + typedef BOOST_DEDUCED_TYPENAME std::vector::iterator iterator_t; + + std::multiplies fn; + + iterator_t reference_it + = std::transform(cont1.begin(), cont1.end(), + cont2.begin(), reference.begin(), fn); + + iterator_t test_it + = boost::transform(cont1, cont2, target.begin(), fn); + + BOOST_CHECK( test_it == target.end() ); + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + + target.clear(); + target.resize(ccont1.size()); + + test_it = boost::transform(ccont1, ccont2, target.begin(), fn); + + BOOST_CHECK( test_it == target.end() ); + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + } + + template< class Container1, class Container2 > + void test_transform_impl2() + { + using namespace boost::assign; + + Container1 cont1; + Container2 cont2; + + test_transform_impl2(cont1, cont2); + + cont1 += 1; + cont2 += 2; + test_transform_impl2(cont1, cont2); + + cont1 += 2,3,4,5,6,7; + cont2 += 4,6,8,10,12,14; + test_transform_impl2(cont1, cont2); + } + + void test_transform() + { + test_transform_impl1< std::vector >(); + test_transform_impl1< std::list >(); + test_transform_impl1< std::set >(); + test_transform_impl1< std::multiset >(); + + test_transform_impl2< std::vector, std::list >(); + test_transform_impl2< std::list, std::vector >(); + test_transform_impl2< std::set, std::set >(); + test_transform_impl2< std::multiset, std::list >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.transform" ); + + test->add( BOOST_TEST_CASE( &boost::test_transform ) ); + + return test; +} diff --git a/test/algorithm_test/unique.cpp b/test/algorithm_test/unique.cpp new file mode 100644 index 0000000..f5d75cf --- /dev/null +++ b/test/algorithm_test/unique.cpp @@ -0,0 +1,166 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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 + +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + // test the 'unique' algorithm without a predicate + class unique_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + // There isn't an iterator return version of boost::unique, so just + // perform the standard algorithm + return std::unique(cont.begin(), cont.end()); + } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy&, Container& cont) + { + return boost::unique(cont); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::unique(cont.begin(), cont.end()); + } + }; + + // test the 'unique' algorithm with a predicate + template + class unique_pred_test_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + // There isn't an iterator return version of boost::unique, so just + // perform the standard algorithm + return std::unique(cont.begin(), cont.end(), Pred()); + } + + Pred pred() const { return Pred(); } + + template< range_return_value return_type > + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::unique(cont, policy.pred()); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::unique(cont.begin(), cont.end(), Pred()); + } + }; + + template + void test_unique_impl(TestPolicy policy, Pred pred) + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + range_test::range_return_test_driver test_driver; + + Container cont; + + test_driver(cont, policy); + + cont.clear(); + cont += 1; + + std::vector temp(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + + test_driver(cont, policy); + + cont.clear(); + cont += 1,2,2,2,2,3,4,5,6,7,8,9; + + temp.assign(cont.begin(), cont.end()); + std::sort(temp.begin(), temp.end(), pred); + cont.assign(temp.begin(), temp.end()); + + test_driver(cont, policy); + } + + template + void test_unique_impl() + { + test_unique_impl( + unique_test_policy(), + std::less() + ); + + test_unique_impl( + unique_pred_test_policy >(), + std::less() + ); + + test_unique_impl( + unique_pred_test_policy >(), + std::greater() + ); + } + + void test_unique() + { + test_unique_impl< std::vector >(); + test_unique_impl< std::list >(); + test_unique_impl< std::deque >(); + } + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.unique" ); + + test->add( BOOST_TEST_CASE( &boost::test_unique ) ); + + return test; +} diff --git a/test/algorithm_test/upper_bound.cpp b/test/algorithm_test/upper_bound.cpp new file mode 100644 index 0000000..3df7164 --- /dev/null +++ b/test/algorithm_test/upper_bound.cpp @@ -0,0 +1,170 @@ +// Copyright Neil Groves 2009. 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 + +#include +#include +#include "../test_driver/range_return_test_driver.hpp" +#include +#include +#include +#include +#include +#include + +namespace boost +{ + namespace + { + class upper_bound_policy + { + public: + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::upper_bound(cont, 5); + } + + template + struct test_range + { + template + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy&, Container& cont) + { + return boost::upper_bound(cont, 5); + } + }; + + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::upper_bound(cont.begin(), cont.end(), 5); + } + }; + + template< class BinaryPredicate > + struct upper_bound_pred_policy + { + template< class Container > + BOOST_DEDUCED_TYPENAME range_iterator::type + test_iter(Container& cont) + { + return boost::upper_bound(cont, 5, BinaryPredicate()); + } + + template< range_return_value result_type> + struct test_range + { + template< class Container, class Policy > + BOOST_DEDUCED_TYPENAME range_return::type + operator()(Policy& policy, Container& cont) + { + return boost::upper_bound( + cont, 5, policy.pred()); + } + }; + + template + BOOST_DEDUCED_TYPENAME range_iterator::type + reference(Container& cont) + { + return std::upper_bound( + cont.begin(), cont.end(), 5, BinaryPredicate()); + } + + BinaryPredicate& pred() { return m_pred; } + + private: + BinaryPredicate m_pred; + }; + + template + void test_upper_bound_impl(TestPolicy policy, BinaryPredicate pred) + { + using namespace boost::assign; + + typedef BOOST_DEDUCED_TYPENAME remove_const::type container_t; + typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t; + + range_test::range_return_test_driver test_driver; + + container_t mcont; + Container& cont = mcont; + + test_driver(cont, policy); + + mcont.clear(); + mcont += 1; + + std::vector temp(mcont.begin(), mcont.end()); + std::sort(temp.begin(), temp.end(), pred); + mcont.assign(temp.begin(), temp.end()); + + test_driver(cont, policy); + + mcont.clear(); + mcont += 1,2,3,4,5,6,7,8,9; + + temp.assign(mcont.begin(), mcont.end()); + std::sort(temp.begin(), temp.end(), pred); + mcont.assign(temp.begin(), temp.end()); + + test_driver(cont, policy); + } + + template + void test_upper_bound_impl() + { + test_upper_bound_impl( + upper_bound_policy(), + std::less() + ); + + test_upper_bound_impl( + upper_bound_pred_policy >(), + std::less() + ); + + test_upper_bound_impl( + upper_bound_pred_policy >(), + std::greater() + ); + } + } + + void test_upper_bound() + { + test_upper_bound_impl< std::vector >(); + test_upper_bound_impl< std::list >(); + test_upper_bound_impl< std::deque >(); + + test_upper_bound_impl< const std::vector >(); + test_upper_bound_impl< const std::list >(); + test_upper_bound_impl< const std::deque >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm.upper_bound" ); + + test->add( BOOST_TEST_CASE( &boost::test_upper_bound ) ); + + return test; +} diff --git a/test/combine.cpp b/test/combine.cpp new file mode 100644 index 0000000..9e29a11 --- /dev/null +++ b/test/combine.cpp @@ -0,0 +1,69 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2006. 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 +#include +#include +#include + + +struct add +{ + template< class T > + int operator()( const T& tuple ) const + { + return boost::get<0>(tuple) + boost::get<1>(tuple); + } +}; + +template< class CombinedRng > +void apply( const CombinedRng& r ) +{ + std::vector v; + for( typename boost::range_iterator::type + i = boost::begin(r), + e = boost::end(r); + i != e; ++i ) + { + + } +} + +void test_combine() +{ + std::vector v1, v2, v3; + v1 = boost::assign::list_of(1)(2)(3)(4); + v2 = boost::assign::list_of(1)(2)(3)(4); + + int i1, i2; + BOOST_FOREACH( boost::tie( i1, i2 ), boost::combine(v1,v2) ) + { + v3.push_back( i1 + i2 ); + } + + BOOST_CHECK_EQUAL( v3.size(), v1.size() ); +} + + + +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( &test_combine ) ); + + return test; +} + + diff --git a/test/compat2.cpp b/test/compat2.cpp old mode 100755 new mode 100644 index 412fb7e..1a5359c --- a/test/compat2.cpp +++ b/test/compat2.cpp @@ -42,7 +42,7 @@ template< typename C > class iterator_of { public: - typedef range_iterator::BOOST_NESTED_TEMPLATE pts::type type; + typedef BOOST_DEDUCED_TYPENAME range_iterator::BOOST_NESTED_TEMPLATE pts::type type; }; #include diff --git a/test/counting_range.cpp b/test/counting_range.cpp new file mode 100644 index 0000000..b5d79a1 --- /dev/null +++ b/test/counting_range.cpp @@ -0,0 +1,73 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +// Disable a warning from since this noise might +// stop us detecting a problem in our code. +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +namespace boost +{ + namespace + { + template + void counting_range_test_impl(int first, int last) + { + Container reference; + for (int i = first; i < last; ++i) + reference.push_back(i); + + Container test; + push_back( test, counting_range(first, last) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end()); + } + + template + void counting_range_test_impl() + { + counting_range_test_impl(0, 0); + counting_range_test_impl(-1, -1); + counting_range_test_impl(-1, 0); + counting_range_test_impl(0, 1); + counting_range_test_impl(-100, 100); + counting_range_test_impl(50, 55); + } + } + + void counting_range_test() + { + counting_range_test_impl >(); + counting_range_test_impl >(); + counting_range_test_impl >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.counting_range" ); + + test->add( BOOST_TEST_CASE( &boost::counting_range_test ) ); + + return test; +} \ No newline at end of file diff --git a/test/irange.cpp b/test/irange.cpp new file mode 100644 index 0000000..d71f184 --- /dev/null +++ b/test/irange.cpp @@ -0,0 +1,131 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 +#include +#include +#include +#include +#include + +namespace boost +{ + // Test an integer range with a step size of 1. + template + void test_irange_impl(Integer first, Integer last) + { + std::vector reference; + for (Integer i = first; i < last; ++i) + { + reference.push_back(i); + } + + std::vector test; + boost::push_back(test, boost::irange(first, last)); + + BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(), + reference.begin(), reference.end() ); + } + + // Test an integer range with a runtime specified step size. + template + void test_irange_impl(Integer first, Integer last, int step) + { + BOOST_ASSERT( step != 0 ); + std::vector reference; + if (step > 0) + { + for (Integer i = first; i < last; i += step) + reference.push_back(i); + } + else + { + for (Integer i = first; i > last; i += step) + reference.push_back(i); + } + + std::vector test; + boost::push_back(test, boost::irange(first, last, step)); + + BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(), + reference.begin(), reference.end() ); + } + + // Test driver function that for an integer range [first, last) + // drives the test implementation through various integer + // types. + void test_irange(int first, int last) + { + test_irange_impl(first,last); + test_irange_impl(first, last); + test_irange_impl(first, last); + test_irange_impl(first, last); + test_irange_impl(first, last); + test_irange_impl(first, last); + test_irange_impl(first, last); + test_irange_impl(first, last); + } + + // Test driver function that for an integer range [first, last) + // drives the test implementation through various integer + // types step_size items at a time. + void test_irange(int first, int last, int step_size) + { + BOOST_ASSERT( step_size != 0 ); + BOOST_ASSERT( (last - first) % step_size == 0 ); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + test_irange_impl(first, last, step_size); + } + + // Implementation of the unit test for the integer range + // function. + // This starts the test drivers to drive a set of integer types + // for a combination of range values chosen to exercise a large + // number of implementation branches. + void irange_unit_test() + { + // Test the single-step version of irange(first, last) + test_irange(0, 0); + test_irange(0, 1); + test_irange(0, 10); + test_irange(1, 1); + test_irange(1, 2); + test_irange(1, 11); + + // Test the n-step version of irange(first, last, step-size) + test_irange(0, 0, 1); + test_irange(0, 0, -1); + test_irange(0, 10, 1); + test_irange(10, 0, -1); + test_irange(0, 2, 2); + test_irange(2, 0, -2); + test_irange(10, 20, 5); + test_irange(20, 10, -5); + } +} // namespace boost + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.irange" ); + + test->add(BOOST_TEST_CASE( &boost::irange_unit_test )); + + return test; +} diff --git a/test/join.cpp b/test/join.cpp new file mode 100644 index 0000000..290e651 --- /dev/null +++ b/test/join.cpp @@ -0,0 +1,273 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +namespace boost +{ + namespace + { + // This function is a helper function that writes integers + // of increasing value into a range. It is used to test + // that joined ranged may be written to. + // + // Requires: + // - Range uses shallow copy semantics. + template< typename Range > + void fill_with_ints(Range rng) + { + typedef typename range_iterator::type iterator; + iterator target = boost::begin(rng); + const int count = boost::distance(rng); + for (int i = 0; i < count; ++i) + { + *target = i; + ++target; + } + } + + // The test_join_traversal function is used to provide additional + // tests based upon the underlying join iterator traversal. + // The join iterator takes care of the appropriate demotion, and + // this demotion. + + // test_join_traversal - additional tests for input and forward + // traversal iterators. This is of course a no-op. + template< typename Range1, typename Range2, typename TraversalTag > + void test_join_traversal(Range1& rng1, Range2& rng2, TraversalTag) + { + } + + // test_join_traversal - additional tests for bidirectional + // traversal iterators. + template< typename Range1, typename Range2 > + void test_join_traversal(Range1& rng1, Range2& rng2, boost::bidirectional_traversal_tag) + { + typedef typename range_value::type value_type; + std::vector reference(boost::begin(rng1), boost::end(rng1)); + boost::push_back(reference, rng2); + std::reverse(reference.begin(), reference.end()); + + std::vector test_result; + BOOST_REVERSE_FOREACH( value_type x, join(rng1, rng2) ) + { + test_result.push_back(x); + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result.begin(), test_result.end() ); + } + + // Test helper function to implement the additional tests for random + // access traversal iterators. This is used by the test_join_traversal + // function for random access iterators. The reason that the test + // implementation is put into this function is to utilise + // template parameter type deduction for the joined range type. + template< typename Range1, typename Range2, typename JoinedRange > + void test_random_access_join(Range1& rng1, Range2& rng2, JoinedRange joined) + { + BOOST_CHECK_EQUAL( boost::end(joined) - boost::begin(joined), boost::distance(joined) ); + BOOST_CHECK( boost::end(joined) <= boost::begin(joined) ); + BOOST_CHECK( boost::begin(joined) >= boost::end(joined) ); + if (boost::empty(joined)) + { + BOOST_CHECK(!(boost::begin(joined) < boost::end(joined))); + BOOST_CHECK(!(boost::end(joined) > boost::begin(joined))); + } + else + { + BOOST_CHECK(boost::begin(joined) < boost::end(joined)); + BOOST_CHECK(boost::end(joined) < boost::begin(joined)); + } + + typedef typename boost::range_difference::type difference_t; + const difference_t count = boost::distance(joined); + BOOST_CHECK( boost::begin(joined) + count == boost::end(joined) ); + BOOST_CHECK( boost::end(joined) - count == boost::begin(joined) ); + + typedef typename boost::range_iterator::type iterator_t; + iterator_t it = boost::begin(joined); + it += count; + BOOST_CHECK( it == boost::end(joined) ); + + it = boost::end(joined); + it -= count; + BOOST_CHECK( it == boost::begin(joined) ); + } + + // test_join_traversal function for random access traversal joined + // ranges. + template< typename Range1, typename Range2 > + void test_join_traversal(Range1& rng1, Range2& rng2, boost::random_access_traversal_tag) + { + test_join_traversal(rng1, rng2, boost::bidirectional_traversal_tag()); + test_random_access_join(rng1, rng2, join(rng1, rng2)); + } + + // Test the ability to write values into a joined range. This is + // achieved by copying the constant collections, altering them + // and then checking the result. Hence this relies upon both + // rng1 and rng2 having value copy semantics. + template< typename Collection1, typename Collection2 > + void test_write_to_joined_range(const Collection1& rng1, const Collection2& rng2) + { + Collection1 c1(rng1); + Collection2 c2(rng2); + typedef typename boost::range_value::type value_t; + fill_with_ints(boost::join(c1,c2)); + + // Ensure that the size of the written range has not been + // altered. + BOOST_CHECK_EQUAL( boost::distance(c1), boost::distance(rng1) ); + BOOST_CHECK_EQUAL( boost::distance(c2), boost::distance(rng2) ); + + // For each element x, in c1 ensure that it has been written to + // with incrementing integers + int x = 0; + typedef typename range_iterator::type iterator1; + iterator1 it1 = boost::begin(c1); + for (; it1 != boost::end(c1); ++it1) + { + BOOST_CHECK_EQUAL( x, *it1 ); + ++x; + } + + // For each element y, in c2 ensure that it has been written to + // with incrementing integers + typedef typename range_iterator::type iterator2; + iterator2 it2 = boost::begin(c2); + for (; it2 != boost::end(c2); ++it2) + { + BOOST_CHECK_EQUAL( x, *it2 ); + ++x; + } + } + + // Perform a unit test of a Boost.Range join() comparing + // it to a reference that is populated by appending + // elements from both source ranges into a vector. + template< typename Collection1, typename Collection2 > + void test_join_impl(Collection1& rng1, Collection2& rng2) + { + typedef typename range_value::type value_type; + std::vector reference(boost::begin(rng1), boost::end(rng1)); + boost::push_back(reference, rng2); + + std::vector test_result; + boost::push_back(test_result, join(rng1, rng2)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test_result.begin(), test_result.end() ); + + typedef boost::range_detail::join_iterator< + typename boost::range_iterator::type, + typename boost::range_iterator::type + > join_iterator_t; + + typedef boost::iterator_traversal< join_iterator_t > tag_t; + + test_join_traversal(rng1, rng2, tag_t()); + + test_write_to_joined_range(rng1, rng2); + } + + // Make a collection filling it with items from the source + // range. This is used to build collections of various + // sizes populated with various values designed to optimize + // the code coverage exercised by the core test function + // test_join_impl. + template + boost::shared_ptr makeCollection(const Range& source) + { + boost::shared_ptr c(new Collection); + c->insert(c->end(), boost::begin(source), boost::end(source)); + return c; + } + + // This templatised version of the test_join_impl function + // generates and populates collections which are later + // used as input to the core test function. + // The caller of this function explicitly provides the + // template parameters. This supports the generation + // of testing a large combination of range types to be + // joined. It is of particular importance to remember + // to combine a random_access range with a bidirectional + // range to determine that the correct demotion of + // types occurs in the join_iterator. + template< typename Collection1, typename Collection2 > + void test_join_impl() + { + typedef boost::shared_ptr collection1_ptr; + typedef boost::shared_ptr collection2_ptr; + typedef boost::shared_ptr collection1_cptr; + typedef boost::shared_ptr collection2_cptr; + std::vector< collection1_cptr > left_containers; + std::vector< collection2_cptr > right_containers; + + left_containers.push_back(collection1_ptr(new Collection1)); + left_containers.push_back(makeCollection(irange(0,1))); + left_containers.push_back(makeCollection(irange(0,100))); + + right_containers.push_back(collection2_ptr(new Collection2)); + right_containers.push_back(makeCollection(irange(0,1))); + right_containers.push_back(makeCollection(irange(0,100))); + + BOOST_FOREACH( collection1_cptr left_container, left_containers ) + { + BOOST_FOREACH( collection2_cptr right_container, right_containers ) + { + test_join_impl(*left_container, *right_container); + } + } + } + + // entry-point into the unit test for the join() function + // this tests a representative sample of combinations of + // source range type. + void join_test() + { + test_join_impl< std::vector, std::vector >(); + test_join_impl< std::list, std::list >(); + test_join_impl< std::deque, std::deque >(); + + test_join_impl< std::vector, std::list >(); + test_join_impl< std::list, std::vector >(); + test_join_impl< std::vector, std::deque >(); + test_join_impl< std::deque, std::vector >(); + } + + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.joined" ); + + test->add( BOOST_TEST_CASE( &boost::join_test ) ); + + return test; +} diff --git a/test/test_driver/range_return_test_driver.hpp b/test/test_driver/range_return_test_driver.hpp new file mode 100644 index 0000000..6f4fc3b --- /dev/null +++ b/test/test_driver/range_return_test_driver.hpp @@ -0,0 +1,405 @@ +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_TEST_DRIVER_RANGE_RETURN_TEST_DRIVER_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_DRIVER_RANGE_RETURN_TEST_DRIVER_HPP_INCLUDED + +#include +#include +#include + +namespace boost +{ + namespace range_test + { + // check the results of an algorithm that returns + // a range_return. + // + // This version is the general version. It should never be called. + // All calls should invoke specialized implementations. + template< range_return_value return_type > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + Iterator test_it, + Iterator reference_it + ) + { + BOOST_ASSERT( false ); + } + }; + + // check the results of an algorithm that returns + // a 'found' iterator + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + Iterator test_it, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + BOOST_CHECK_EQUAL( std::distance(test.begin(), test_it), + std::distance(reference.begin(), reference_it) ); + } + }; + + // check the results of an algorithm that returns + // a 'next(found)' iterator + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + Iterator test_it, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + if (reference_it == reference.end()) + { + BOOST_CHECK( test_it == test.end() ); + } + else + { + BOOST_CHECK_EQUAL( + std::distance(test.begin(), test_it), + std::distance(reference.begin(), reference_it) + 1); + } + } + }; + + // check the results of an algorithm that returns + // a 'prior(found)' iterator + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + Iterator test_it, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + if (reference_it == reference.begin()) + { + BOOST_CHECK( test_it == test.begin() ); + } + else + { + BOOST_CHECK_EQUAL( + std::distance(test.begin(), test_it) + 1, + std::distance(reference.begin(), reference_it)); + } + } + }; + + // check the results of an algorithm that returns + // a '[begin, found)' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + BOOST_CHECK( test_rng.begin() == test.begin() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference_it, + boost::begin(test_rng), boost::end(test_rng) + ); + } + }; + + // check the results of an algorithm that returns + // a '[begin, next(found))' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + BOOST_CHECK( test_rng.begin() == test.begin() ); + + if (reference_it == reference.end()) + { + BOOST_CHECK( test_rng.end() == test.end() ); + } + else + { + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), boost::next(reference_it), + test_rng.begin(), test_rng.end()); + } + } + }; + + // check the results of an algorithm that returns + // a '[begin, prior(found))' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + BOOST_CHECK( test_rng.begin() == test.begin() ); + + if (reference_it == reference.begin()) + { + BOOST_CHECK( boost::end(test_rng) == test.begin() ); + } + else + { + BOOST_CHECK_EQUAL( std::distance(boost::begin(test_rng), boost::end(test_rng)) + 1, + std::distance(reference.begin(), reference_it) ); + } + } + }; + + // check the results of an algorithm that returns + // a '[found, end)' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + BOOST_CHECK_EQUAL( + std::distance(test.begin(), boost::begin(test_rng)), + std::distance(reference.begin(), reference_it)); + + BOOST_CHECK( boost::end(test_rng) == test.end() ); + } + }; + + // check the results of an algorithm that returns + // a '[next(found), end)' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + BOOST_CHECK( test_rng.end() == test.end() ); + + if (reference_it == reference.end()) + { + BOOST_CHECK( test_rng.begin() == test.end() ); + } + else + { + BOOST_CHECK_EQUAL_COLLECTIONS( + boost::next(reference_it), reference.end(), + test_rng.begin(), test_rng.end() + ); + } + } + }; + + // check the results of an algorithm that returns + // a 'prior(found), end)' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + BOOST_CHECK( test_rng.end() == test.end() ); + + if (reference_it == reference.begin()) + { + BOOST_CHECK( test_rng.begin() == test.begin() ); + } + else + { + BOOST_CHECK_EQUAL_COLLECTIONS( + boost::prior(reference_it), reference.end(), + test_rng.begin(), test_rng.end() + ); + } + } + }; + + // check the results of an algorithm that returns + // a '[begin, end)' range + template< > + struct check_results + { + template< class Container, class Iterator > + static void check( + Container& test, + Container& reference, + iterator_range test_rng, + Iterator reference_it + ) + { + BOOST_CHECK_EQUAL_COLLECTIONS( + reference.begin(), reference.end(), + test.begin(), test.end() + ); + + BOOST_CHECK( test_rng.begin() == test.begin() ); + BOOST_CHECK( test_rng.end() == test.end() ); + } + }; + + // A test driver to exercise a test through all of the range_return + // combinations. + // + // The test driver also contains the code required to check the + // return value correctness. + // + // The TestPolicy needs to implement two functions: + // + // - perform the boost range version of the algorithm that returns + // a range_return::type + // template + // BOOST_DEDUCED_TYPENAME range_return::type + // test(Container& cont); + // + // - perform the reference std version of the algorithm that + // returns the standard iterator result + // template + // BOOST_DEDUCED_TYPENAME range_iterator::type + // reference(Container& cont); + class range_return_test_driver + { + public: + template< class Container, + class TestPolicy > + void operator()(Container& cont, TestPolicy policy) + { + test_range_iter (cont, policy); + test_range ()(cont, policy); + test_range ()(cont, policy); + test_range ()(cont, policy); + test_range()(cont, policy); + test_range ()(cont, policy); + test_range()(cont, policy); + test_range ()(cont, policy); + test_range ()(cont, policy); + test_range ()(cont, policy); + test_range ()(cont, policy); + } + + private: + template< class Container, class TestPolicy > + void test_range_iter( + Container& cont, + TestPolicy policy + ) + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + Container reference(cont); + Container test(cont); + + iterator_t range_result = policy.test_iter(test); + iterator_t reference_it = policy.reference(reference); + + check_results::check(test, reference, + range_result, reference_it); + } + + template< range_return_value result_type, class Container, class TestPolicy > + struct test_range + { + void operator()(Container& cont, TestPolicy policy) + { + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + typedef BOOST_DEDUCED_TYPENAME range_return::type range_return_t; + typedef BOOST_DEDUCED_TYPENAME TestPolicy::template test_range test_range_t; + + Container reference(cont); + Container test_cont(cont); + + range_return_t range_result = test_range_t()(policy, test_cont); + iterator_t reference_it = policy.reference(reference); + + check_results::check(test_cont, reference, + range_result, reference_it); + } + }; + }; + } +} + +#endif // include guard diff --git a/test/test_function/check_equal_fn.hpp b/test/test_function/check_equal_fn.hpp new file mode 100644 index 0000000..8da2ed8 --- /dev/null +++ b/test/test_function/check_equal_fn.hpp @@ -0,0 +1,49 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_FUNCTIONS_CHECK_EQUAL_FN_HPP_INCLUDED +#define BOOST_RANGE_TEST_FUNCTIONS_CHECK_EQUAL_FN_HPP_INCLUDED + +#include "counted_function.hpp" + +namespace boost +{ + namespace range_test_function + { + template< class Collection > + class check_equal_fn : private counted_function + { + typedef BOOST_DEDUCED_TYPENAME Collection::const_iterator iter_t; + public: + explicit check_equal_fn( const Collection& c ) + : m_it(boost::begin(c)), m_last(boost::end(c)) {} + + using counted_function::invocation_count; + + void operator()(int x) const + { + invoked(); + BOOST_CHECK( m_it != m_last ); + if (m_it != m_last) + { + BOOST_CHECK_EQUAL( *m_it, x ); + ++m_it; + } + } + + private: + mutable iter_t m_it; + iter_t m_last; + }; + + } // namespace range_test_function +} // namespace boost + +#endif // include guard diff --git a/test/test_function/counted_function.hpp b/test/test_function/counted_function.hpp new file mode 100644 index 0000000..4a74515 --- /dev/null +++ b/test/test_function/counted_function.hpp @@ -0,0 +1,40 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_FUNCTION_COUNTED_FUNCTION_HPP_INCLUDED +#define BOOST_RANGE_TEST_FUNCTION_COUNTED_FUNCTION_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + + class counted_function + { + public: + counted_function() : m_count(0u) {} + + void invoked() const + { + ++m_count; + } + + // Return the number of times that this function object + // has been invoked. + unsigned int invocation_count() const { return m_count; } + + private: + mutable unsigned int m_count; + }; + + } +} + +#endif // include guard diff --git a/test/test_function/equal_to_x.hpp b/test/test_function/equal_to_x.hpp new file mode 100644 index 0000000..14d0016 --- /dev/null +++ b/test/test_function/equal_to_x.hpp @@ -0,0 +1,33 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_EQUAL_TO_X_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_EQUAL_TO_X_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + template + struct equal_to_x + { + typedef bool result_type; + typedef Arg argument_type; + + explicit equal_to_x(Arg x) : m_x(x) {} + bool operator()(Arg x) const { return x == m_x; } + + private: + Arg m_x; + }; + } +} + +#endif // include guard diff --git a/test/test_function/false_predicate.hpp b/test/test_function/false_predicate.hpp new file mode 100644 index 0000000..533e83d --- /dev/null +++ b/test/test_function/false_predicate.hpp @@ -0,0 +1,29 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_FALSE_PREDICATE_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_FALSE_PREDICATE_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + struct false_predicate + { + typedef bool result_type; + + bool operator()() const { return false; } + template bool operator()(Arg) const { return false; } + template bool operator()(Arg1,Arg2) const { return false; } + }; + } +} + +#endif // include guard diff --git a/test/test_function/greater_than_x.hpp b/test/test_function/greater_than_x.hpp new file mode 100644 index 0000000..032f594 --- /dev/null +++ b/test/test_function/greater_than_x.hpp @@ -0,0 +1,32 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_FUNCTION_GREATER_THAN_X_HPP_INCLUDED +#define BOOST_RANGE_TEST_FUNCTION_GREATER_THAN_X_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + template< class Number > + struct greater_than_x + { + typedef bool result_type; + typedef Number argument_type; + + explicit greater_than_x(Number x) : m_x(x) {} + bool operator()(Number x) const { return x > m_x; } + private: + Number m_x; + }; + } // namespace range_test_function +} // namespace boost + +#endif // include guard diff --git a/test/test_function/multiply_by_x.hpp b/test/test_function/multiply_by_x.hpp new file mode 100644 index 0000000..b343c61 --- /dev/null +++ b/test/test_function/multiply_by_x.hpp @@ -0,0 +1,32 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_MULTIPLY_BY_X_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_MULTIPLY_BY_X_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + template< class Arg > + struct multiply_by_x + { + typedef Arg result_type; + typedef Arg argument_type; + + explicit multiply_by_x(Arg x) : m_x(x) {} + Arg operator()(Arg x) const { return x * m_x; } + private: + Arg m_x; + }; + } +} + +#endif // include guard From bed353556f8d4ccc27ba1e472c440dedaa14c58d Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 28 Mar 2010 18:37:28 +0000 Subject: [PATCH 80/92] Corrected namespace of the pipe operator for the copied adaptor. [SVN r60901] --- include/boost/range/adaptor/copied.hpp | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/boost/range/adaptor/copied.hpp b/include/boost/range/adaptor/copied.hpp index 72b2860..ae76653 100755 --- a/include/boost/range/adaptor/copied.hpp +++ b/include/boost/range/adaptor/copied.hpp @@ -21,35 +21,35 @@ namespace boost namespace range_detail { template< class T > - struct copy_holder - : holder2 + struct copy_holder + : holder2 { - copy_holder( std::size_t t, std::size_t u ) + copy_holder( std::size_t t, std::size_t u ) : holder2(t,u) { } }; - template< class CopyableRandomAccessRng, class Int > - inline CopyableRandomAccessRng - operator|( const CopyableRandomAccessRng& r, const copy_holder& f ) - { - iterator_range< - BOOST_DEDUCED_TYPENAME range_iterator::type > - temp( sliced_impl( r, f ) ); - return CopyableRandomAccessRng( temp.begin(), temp.end() ); - } - } // 'range_detail' namespace adaptors - { + { + template< class CopyableRandomAccessRng, class Int > + inline CopyableRandomAccessRng + operator|( const CopyableRandomAccessRng& r, const range_detail::copy_holder& f ) + { + iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > + temp( range_detail::sliced_impl( r, f ) ); + return CopyableRandomAccessRng( temp.begin(), temp.end() ); + } + namespace { - const range_detail::forwarder2 + const range_detail::forwarder2 copied = range_detail::forwarder2(); } - + template inline CopyableRandomAccessRange copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u) @@ -58,11 +58,11 @@ namespace boost BOOST_DEDUCED_TYPENAME range_iterator::type> temp( adaptors::slice(rng, t, u)); - + return CopyableRandomAccessRange( temp.begin(), temp.end() ); } } // 'adaptors' - + } #endif From 40d20d65ca14f7eb29ffa82bc232d2cda0367970 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 28 Mar 2010 19:44:33 +0000 Subject: [PATCH 81/92] Fix compilation of Boost.Range adaptors on GCC 64-bit [SVN r60904] --- include/boost/range/adaptor/copied.hpp | 34 ++++----- include/boost/range/adaptor/indexed.hpp | 93 ++++++++++--------------- include/boost/range/adaptor/sliced.hpp | 75 +++++++------------- 3 files changed, 75 insertions(+), 127 deletions(-) diff --git a/include/boost/range/adaptor/copied.hpp b/include/boost/range/adaptor/copied.hpp index ae76653..1862b5f 100755 --- a/include/boost/range/adaptor/copied.hpp +++ b/include/boost/range/adaptor/copied.hpp @@ -18,38 +18,28 @@ namespace boost { - namespace range_detail - { - template< class T > - struct copy_holder - : holder2 - { - copy_holder( std::size_t t, std::size_t u ) - : holder2(t,u) - { } - }; - - } // 'range_detail' - namespace adaptors { - template< class CopyableRandomAccessRng, class Int > + struct copied + { + copied(std::size_t t_, std::size_t u_) + : t(t_), u(u_) {} + + std::size_t t; + std::size_t u; + }; + + template< class CopyableRandomAccessRng > inline CopyableRandomAccessRng - operator|( const CopyableRandomAccessRng& r, const range_detail::copy_holder& f ) + operator|( const CopyableRandomAccessRng& r, const copied& f ) { iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - temp( range_detail::sliced_impl( r, f ) ); + temp( adaptors::slice( r, f.t, f.u ) ); return CopyableRandomAccessRng( temp.begin(), temp.end() ); } - namespace - { - const range_detail::forwarder2 - copied = range_detail::forwarder2(); - } - template inline CopyableRandomAccessRange copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u) diff --git a/include/boost/range/adaptor/indexed.hpp b/include/boost/range/adaptor/indexed.hpp index cab8e1d..4c00cdd 100755 --- a/include/boost/range/adaptor/indexed.hpp +++ b/include/boost/range/adaptor/indexed.hpp @@ -27,7 +27,15 @@ namespace boost { - + namespace adaptors + { + struct indexed + { + explicit indexed(std::size_t x) : val(x) {} + std::size_t val; + }; + } + namespace range_detail { template< class Iter > @@ -35,16 +43,16 @@ namespace boost : public boost::iterator_adaptor< indexed_iterator, Iter > { private: - typedef boost::iterator_adaptor< indexed_iterator, Iter > - base; + typedef boost::iterator_adaptor< indexed_iterator, Iter > + base; typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type; index_type index_; - + public: explicit indexed_iterator( Iter i, index_type index ) - : base(i), index_(index) + : base(i), index_(index) { BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" ); } @@ -53,12 +61,12 @@ namespace boost { return index_; } - + private: friend class boost::iterator_core_access; - - void increment() - { + + void increment() + { ++index_; ++(this->base_reference()); } @@ -80,7 +88,7 @@ namespace boost }; template< class Rng > - struct indexed_range : + struct indexed_range : iterator_range< indexed_iterator::type> > { private: @@ -90,49 +98,11 @@ namespace boost base; public: template< class Index > - indexed_range( Index i, Rng& r ) + indexed_range( Index i, Rng& r ) : base( iter_type(boost::begin(r), i), iter_type(boost::end(r),i) ) { } }; - - template< class T > - struct index_holder : holder - { - index_holder( T r ) : holder(r) - { } - }; - - struct index_forwarder - { - template< class T > - index_holder operator()( T r ) const - { - return r; - } - - index_holder operator()( int r = 0 ) const - { - return r; - } - }; - - template< class SinglePassRange > - inline indexed_range - operator|( SinglePassRange& r, - const index_holder::type>& f ) - { - return indexed_range( f.val, r ); - } - - template< class SinglePassRange > - inline indexed_range - operator|( const SinglePassRange& r, - const index_holder::type>& f ) - { - return indexed_range( f.val, r ); - } - } // 'range_detail' // Make this available to users of this library. It will sometimes be @@ -141,21 +111,30 @@ namespace boost using range_detail::indexed_range; namespace adaptors - { - namespace + { + template< class SinglePassRange > + inline indexed_range + operator|( SinglePassRange& r, + const indexed& f ) { - const range_detail::forwarder - indexed = - range_detail::forwarder(); + return indexed_range( f.val, r ); } - + + template< class SinglePassRange > + inline indexed_range + operator|( const SinglePassRange& r, + const indexed& f ) + { + return indexed_range( f.val, r ); + } + template inline indexed_range index(SinglePassRange& rng, Index index) { return indexed_range(index, rng); } - + template inline indexed_range index(const SinglePassRange& rng, Index index) @@ -163,7 +142,7 @@ namespace boost return indexed_range(index, rng); } } // 'adaptors' - + } #ifdef BOOST_MSVC diff --git a/include/boost/range/adaptor/sliced.hpp b/include/boost/range/adaptor/sliced.hpp index 9629ce4..eb506e0 100755 --- a/include/boost/range/adaptor/sliced.hpp +++ b/include/boost/range/adaptor/sliced.hpp @@ -19,17 +19,25 @@ namespace boost { namespace adaptors { + struct sliced + { + sliced(std::size_t t_, std::size_t u_) + : t(t_), u(u_) {} + std::size_t t; + std::size_t u; + }; + template< class RandomAccessRange > - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > + inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > slice( RandomAccessRange& rng, std::size_t t, std::size_t u ) { BOOST_ASSERT( t <= u && "error in slice indices" ); - BOOST_ASSERT( static_cast(boost::size(rng)) >= u && + BOOST_ASSERT( static_cast(boost::size(rng)) >= u && "second slice index out of bounds" ); - return make_iterator_range( rng, t, u - boost::size(rng) ); + return boost::make_iterator_range( rng, t, u - boost::size(rng) ); } - + template< class RandomAccessRange > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > slice( const RandomAccessRange& rng, std::size_t t, std::size_t u ) @@ -37,56 +45,27 @@ namespace boost BOOST_ASSERT( t <= u && "error in slice indices" ); BOOST_ASSERT( static_cast(boost::size(rng)) >= u && "second slice index out of bounds" ); - - return make_iterator_range( rng, t, u - boost::size(rng) ); - } - } // 'adaptors' - - namespace range_detail - { - template< class T > - struct slice_holder - : holder2 - { - slice_holder( std::size_t t, std::size_t u ) - : holder2(t,u) - { } - }; - - template - inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - sliced_impl( R& r, const H& f) - { - return adaptors::slice(r, f.val1, f.val2); - } - - template< class RandomAccessRange, class Int > - inline iterator_range< - BOOST_DEDUCED_TYPENAME range_iterator::type > - operator|( RandomAccessRange& r, const slice_holder& f ) - { - return sliced_impl( r, f ); + + return boost::make_iterator_range( rng, t, u - boost::size(rng) ); } - template< class RandomAccessRange, class Int > - inline iterator_range< - BOOST_DEDUCED_TYPENAME range_iterator::type > - operator|( const RandomAccessRange& r, const slice_holder& f ) + template< class RandomAccessRange > + inline iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > + operator|( RandomAccessRange& r, const sliced& f ) { - return sliced_impl( r, f ); + return adaptors::slice( r, f.t, f.u ); } - } // 'range_detail' - - namespace adaptors - { - namespace + template< class RandomAccessRange > + inline iterator_range< + BOOST_DEDUCED_TYPENAME range_iterator::type > + operator|( const RandomAccessRange& r, const sliced& f ) { - const range_detail::forwarder2 - sliced = range_detail::forwarder2(); + return adaptors::slice( r, f.t, f.u ); } - } - -} + + } // namespace adaptors +} // namespace boost #endif From 629ab6adbfa020dcb824aad58fcd5afd09a44c52 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 28 Mar 2010 20:03:49 +0000 Subject: [PATCH 82/92] Correct Boost.Range irange unit test failure on 64-bit GCC [SVN r60905] --- include/boost/range/irange.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/range/irange.hpp b/include/boost/range/irange.hpp index 486be6e..ee25d45 100644 --- a/include/boost/range/irange.hpp +++ b/include/boost/range/irange.hpp @@ -36,14 +36,16 @@ namespace boost integer_iterator, Integer, boost::random_access_traversal_tag, - const Integer& + Integer, + std::ptrdiff_t > { typedef boost::iterator_facade< integer_iterator, Integer, boost::random_access_traversal_tag, - const Integer& + Integer, + std::ptrdiff_t > base_t; public: typedef typename base_t::value_type value_type; From b4ae711d4eaf890f217df37490b76ada1b0a60a9 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 09:02:21 +0000 Subject: [PATCH 83/92] Boost.Range minor documentation corrections and code comment fixes. [SVN r61014] --- doc/concepts.qbk | 12 ++--- doc/html/index.html | 4 +- .../range/concepts/bidirectional_range.html | 26 ++++----- doc/html/range/concepts/concept_checking.html | 2 +- doc/html/range/concepts/forward_range.html | 10 ++-- .../range/concepts/random_access_range.html | 14 ++--- .../range/concepts/single_pass_range.html | 16 +++--- doc/html/range/introduction.html | 18 +++---- doc/html/range/mfc_atl.html | 4 +- .../adaptors/adaptors_introduction.html | 6 +-- .../algorithms/heap_algorithms/make_heap.html | 10 ++-- .../algorithms/heap_algorithms/pop_heap.html | 12 ++--- .../algorithms/heap_algorithms/push_heap.html | 12 ++--- .../next_permutation.html | 10 ++-- .../prev_permutation.html | 10 ++-- .../copy.html | 12 ++--- .../copy_backward.html | 12 ++--- .../fill.html | 10 ++-- .../generate.html | 12 ++--- .../inplace_merge.html | 16 +++--- .../merge.html | 22 ++++---- .../nth_element.html | 10 ++-- .../partial_sort.html | 10 ++-- .../partition.html | 10 ++-- .../random_shuffle.html | 12 ++--- .../remove.html | 10 ++-- .../remove_if.html | 10 ++-- .../replace.html | 10 ++-- .../replace_if.html | 10 ++-- .../rotate.html | 12 ++--- .../sort.html | 10 ++-- .../stable_partition.html | 12 ++--- .../stable_sort.html | 10 ++-- .../transform.html | 12 ++--- .../unique.html | 10 ++-- .../range_algorithm_new_algorithms/erase.html | 10 ++-- .../for_each.html | 10 ++-- .../insert.html | 10 ++-- .../overwrite.html | 10 ++-- .../push_back.html | 10 ++-- .../push_front.html | 10 ++-- .../remove_erase.html | 10 ++-- .../remove_erase_if.html | 10 ++-- .../adjacent_find.html | 10 ++-- .../binary_search.html | 12 ++--- .../count.html | 10 ++-- .../equal.html | 10 ++-- .../equal_range.html | 12 ++--- .../find.html | 10 ++-- .../find_end.html | 10 ++-- .../find_first_of.html | 10 ++-- .../find_if.html | 12 ++--- .../for_each.html | 10 ++-- .../lexicographical_compare.html | 10 ++-- .../lower_bound.html | 12 ++--- .../max_element.html | 10 ++-- .../min_element.html | 10 ++-- .../mismatch.html | 12 ++--- .../search.html | 10 ++-- .../upper_bound.html | 12 ++--- .../algorithms/range_numeric/accumulate.html | 14 ++--- .../range_numeric/adjacent_difference.html | 16 +++--- .../range_numeric/inner_product.html | 20 +++---- .../algorithms/range_numeric/partial_sum.html | 16 +++--- .../algorithms/set_algorithms/includes.html | 12 ++--- .../set_algorithms/set_difference.html | 12 ++--- .../set_algorithms/set_intersection.html | 12 ++--- .../set_symmetric_difference.html | 12 ++--- .../algorithms/set_algorithms/set_union.html | 12 ++--- .../range/reference/extending/method_2.html | 24 +++++---- .../extending/method_3/method_3_1.html | 12 ++--- .../extending/method_3/method_3_2.html | 6 +-- doc/html/range/reference/overview.html | 2 +- .../reference/ranges/counting_range.html | 8 +-- doc/html/range/reference/ranges/irange.html | 10 ++-- .../range/reference/ranges/istream_range.html | 6 +-- doc/html/range/reference/semantics.html | 2 +- doc/html/range/utilities/iterator_range.html | 6 +-- doc/html/range/utilities/join.html | 4 +- doc/html/range/utilities/sub_range.html | 2 +- doc/introduction.qbk | 6 +-- doc/reference/algorithm/merge.qbk | 6 +-- doc/reference/algorithm/stable_partition.qbk | 2 +- doc/reference/extending.qbk | 44 +++++++-------- doc/reference/numeric/inner_product.qbk | 4 +- doc/reference/overview.qbk | 2 +- .../boost/range/adaptor/adjacent_filtered.hpp | 16 +++--- include/boost/range/adaptor/filtered.hpp | 53 +++++++++---------- include/boost/range/adaptor/indexed.hpp | 32 ++++++----- include/boost/range/adaptor/indirected.hpp | 20 +++---- include/boost/range/adaptor/replaced.hpp | 14 ++--- 91 files changed, 534 insertions(+), 533 deletions(-) diff --git a/doc/concepts.qbk b/doc/concepts.qbk index b7c408d..cc6fd23 100644 --- a/doc/concepts.qbk +++ b/doc/concepts.qbk @@ -7,7 +7,7 @@ A Range is a [*/concept/] similar to the STL [@http://www.sgi.com/Technology/STL 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 * own the elements that can be accessed through it, -* have copy semantics, +* have copy semantics, Because of the second requirement, a Range object must be passed by (const or non-const) reference in generic code. @@ -165,7 +165,7 @@ __forward_range__ [] [[Valid reverse range] [For 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.]] - [[Completeness ] [`An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.]] + [[Completeness ] [An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.]] ] [heading See also] @@ -203,7 +203,7 @@ __bidirectional_range__ [heading Complexity guarantees] -`boost::size(a)` is completes in amortized constant time. +`boost::size(a)` completes in amortized constant time. [heading Invariants] @@ -222,13 +222,13 @@ Each of the range concepts has a corresponding concept checking class in the fil `` BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); `` - + An additional concept check is required for the value access property of the range based on the range's iterator type. For example to check for a ForwardReadableRange, the following code is required. `` BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); BOOST_CONCEPT_ASSERT(( ReadableIteratorConcept::type> )); -`` +`` The following range concept checking classes are provided. @@ -245,7 +245,7 @@ __iterator_concepts__ __concept_check__ -[endsect] +[endsect] [endsect] diff --git a/doc/html/index.html b/doc/html/index.html index e52fb31..4f1a4a1 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -30,7 +30,7 @@
      -

      +

      Distributed under 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)

      @@ -135,7 +135,7 @@

      - +

      Last revised: March 28, 2010 at 14:28:09 GMT

      Last revised: April 03, 2010 at 08:56:46 GMT


      diff --git a/doc/html/range/concepts/bidirectional_range.html b/doc/html/range/concepts/bidirectional_range.html index 99a8ccb..796ca14 100644 --- a/doc/html/range/concepts/bidirectional_range.html +++ b/doc/html/range/concepts/bidirectional_range.html @@ -27,7 +27,7 @@ Bidirectional Range
      - + Notation
      @@ -65,7 +65,7 @@
      - + Description

      @@ -75,7 +75,7 @@ Traversal Iterator.

      - + Refinement of
      @@ -83,7 +83,7 @@ Forward Range

      - + Associated types
      @@ -136,7 +136,7 @@
      - + Valid expressions
      @@ -221,7 +221,7 @@
      - + Complexity guarantees
      @@ -232,7 +232,7 @@ Forward Range.

      - + Invariants
      @@ -264,21 +264,15 @@

      - An algorithm - that iterates - through the - range [boost::rbegin(a),boost::rend(a)) - will pass - through every - element of - a`. + An algorithm that iterates through the range [boost::rbegin(a),boost::rend(a)) + will pass through every element of a.

      - + See also

      diff --git a/doc/html/range/concepts/concept_checking.html b/doc/html/range/concepts/concept_checking.html index 65088d1..37175b4 100644 --- a/doc/html/range/concepts/concept_checking.html +++ b/doc/html/range/concepts/concept_checking.html @@ -79,7 +79,7 @@

    - + See also

    diff --git a/doc/html/range/concepts/forward_range.html b/doc/html/range/concepts/forward_range.html index 42ba1f0..9076b68 100644 --- a/doc/html/range/concepts/forward_range.html +++ b/doc/html/range/concepts/forward_range.html @@ -27,7 +27,7 @@ Forward Range

    - + Notation
    @@ -65,7 +65,7 @@
    - + Description

    @@ -73,14 +73,14 @@ Traversal Iterator.

    - + Refinement of

    Single Pass Range

    - + Associated types
    @@ -132,7 +132,7 @@
    - + See also

    diff --git a/doc/html/range/concepts/random_access_range.html b/doc/html/range/concepts/random_access_range.html index adbf102..97b3171 100644 --- a/doc/html/range/concepts/random_access_range.html +++ b/doc/html/range/concepts/random_access_range.html @@ -27,7 +27,7 @@ Random Access Range

    - + Description

    @@ -35,7 +35,7 @@ Access Traversal Iterator.

    - + Refinement of
    @@ -43,7 +43,7 @@ Bidirectional Range

    - + Valid expressions
    @@ -89,7 +89,7 @@
    - + Expression semantics
    @@ -139,15 +139,15 @@
    - + Complexity guarantees

    - boost::size(a) is completes in amortized constant time. + boost::size(a) completes in amortized constant time.

    - + Invariants
    diff --git a/doc/html/range/concepts/single_pass_range.html b/doc/html/range/concepts/single_pass_range.html index 92daf10..10669d1 100644 --- a/doc/html/range/concepts/single_pass_range.html +++ b/doc/html/range/concepts/single_pass_range.html @@ -27,7 +27,7 @@ Single Pass Range
    - + Notation
    @@ -65,7 +65,7 @@
    - + Description

    @@ -73,7 +73,7 @@ Pass Iterator.

    - + Associated types
    @@ -126,7 +126,7 @@
    - + Valid expressions
    @@ -198,7 +198,7 @@
    - + Expression semantics
    @@ -266,7 +266,7 @@
    - + Complexity guarantees
    @@ -276,7 +276,7 @@ constant time.

    - + Invariants
    @@ -316,7 +316,7 @@
    - + See also

    diff --git a/doc/html/range/introduction.html b/doc/html/range/introduction.html index 6bef0ed..8bce31d 100644 --- a/doc/html/range/introduction.html +++ b/doc/html/range/introduction.html @@ -36,14 +36,14 @@ 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. + The most common form of ranges used throughout the C++ community are standard + library containers. When writing algorithms however, one often finds it desirable + for the algorithm to accept 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, @@ -125,7 +125,7 @@ std::cout << my_generic_replace( my_view, 4, 2 ); std::cout << my_generic_replace( str, 'a', 'b' ); -// prints '3', '5' and '0' +// prints '3', '5' and '0'

  • diff --git a/doc/html/range/mfc_atl.html b/doc/html/range/mfc_atl.html index 4ae5a35..8d5ed19 100644 --- a/doc/html/range/mfc_atl.html +++ b/doc/html/range/mfc_atl.html @@ -34,7 +34,7 @@
    References
    - + Introduction

    @@ -100,7 +100,7 @@

    - + Overview

    diff --git a/doc/html/range/reference/adaptors/adaptors_introduction.html b/doc/html/range/reference/adaptors/adaptors_introduction.html index bcd20b4..efa54fd 100644 --- a/doc/html/range/reference/adaptors/adaptors_introduction.html +++ b/doc/html/range/reference/adaptors/adaptors_introduction.html @@ -122,7 +122,7 @@ situations, you will really appreciate the succinctness of operator|().

    - + Composition of Adaptors
    @@ -159,7 +159,7 @@ is the design solution to this problem.

    - + Range Adaptor alternative to copy_if algorithm
    @@ -176,7 +176,7 @@

    - + Range Adaptor alternative to count_if algorithm
    diff --git a/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html b/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html index 5645d07..d8d4033 100644 --- a/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html +++ b/doc/html/range/reference/algorithms/heap_algorithms/make_heap.html @@ -28,7 +28,7 @@ make_heap
    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -61,14 +61,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/heap_algorithm.hpp

    - + Requirements

    @@ -119,7 +119,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html b/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html index 524f86c..f1588b7 100644 --- a/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html +++ b/doc/html/range/reference/algorithms/heap_algorithms/pop_heap.html @@ -28,7 +28,7 @@ pop_heap

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -63,14 +63,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/heap_algorithm.hpp

    - + Requirements

    @@ -121,7 +121,7 @@

    - + Precondition:
      @@ -131,7 +131,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html b/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html index 357465b..35b64ca 100644 --- a/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html +++ b/doc/html/range/reference/algorithms/heap_algorithms/push_heap.html @@ -28,7 +28,7 @@ push_heap

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -63,14 +63,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/heap_algorithm.hpp

    - + Requirements

    @@ -121,7 +121,7 @@

    - + Precondition:
      @@ -131,7 +131,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html b/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html index 5f7dce0..8521343 100644 --- a/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html +++ b/doc/html/range/reference/algorithms/permutation_algorithms/next_permutation.html @@ -28,7 +28,7 @@ next_permutation

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -67,14 +67,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/permutation.hpp

    - + Requirements

    @@ -125,7 +125,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html b/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html index 6a37365..a1e0d1d 100644 --- a/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html +++ b/doc/html/range/reference/algorithms/permutation_algorithms/prev_permutation.html @@ -28,7 +28,7 @@ prev_permutation

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -67,14 +67,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/permutation.hpp

    - + Requirements

    @@ -125,7 +125,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html index 401b24e..0decd23 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy.html @@ -28,7 +28,7 @@ Range Algorithm - copy

    - + Prototype

    @@ -40,7 +40,7 @@

    - + Description

    @@ -51,14 +51,14 @@ distance(source_rng)

    - + Definition

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

    - + Requirements
      @@ -79,7 +79,7 @@
    - + Precondition:
      @@ -93,7 +93,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html index 53e315e..541db9a 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/copy_backward.html @@ -28,7 +28,7 @@ Range Algorithm - copy_backward

    - + Prototype

    @@ -42,7 +42,7 @@

    - + Description

    @@ -60,14 +60,14 @@ denotes the end of the output sequence.

    - + Definition

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

    - + Requirements
      @@ -88,7 +88,7 @@
    - + Precondition:
      @@ -102,7 +102,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html index ad3f8a8..4bb5340 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/fill.html @@ -28,7 +28,7 @@ Range Algorithm - fill

    - + Prototype

    @@ -43,7 +43,7 @@

    - + Description

    @@ -52,14 +52,14 @@ in the range rng.

    - + Definition

    Defined in the header file boost/range/algorithm/fill.hpp

    - + Requirements
      @@ -82,7 +82,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html index a78b8e9..1a5ba8a 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/generate.html @@ -28,7 +28,7 @@ Range Algorithm - generate

    - + Prototype

    @@ -43,7 +43,7 @@

    - + Description

    @@ -53,14 +53,14 @@ Returns the resultant range.

    - + Definition

    Defined in the header file boost/range/algorithm/generate.hpp

    - + Requirements
      @@ -84,7 +84,7 @@
    - + Precondition:
      @@ -98,7 +98,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html index 4192d22..fafc9d5 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/inplace_merge.html @@ -28,7 +28,7 @@ Range Algorithm - inplace_merge

    - + Prototype

    @@ -59,7 +59,7 @@

    - + Description

    @@ -72,14 +72,14 @@ input range is preserved.

    - + Definition

    Defined in the header file boost/range/algorithm/inplace_merge.hpp

    - + Requirements

    @@ -116,11 +116,11 @@ argument types.

    - + Precondition:
    - + For the non-predicate version:
    @@ -143,7 +143,7 @@
    - + For the predicate version:
    @@ -164,7 +164,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html index 5df7c4d..9bd570e 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/merge.html @@ -28,7 +28,7 @@ Range Algorithm - merge

    - + Prototype

    @@ -42,7 +42,7 @@ OutputIterator merge(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out); - + template< class SinglePassRange1, class SinglePassRange2, @@ -57,7 +57,7 @@

    - + Description

    @@ -76,14 +76,14 @@ version uses the predicate instead of operator<().

    - + Definition

    Defined in the header file boost/range/algorithm/merge.hpp

    - + Requirements

    @@ -151,11 +151,11 @@

    - + Precondition:
    - + For the non-predicate version:
    @@ -190,19 +190,19 @@
    - + For the predicate version:
    • The elements of rng1 - is in ascending order. That is, for each adjacent element pair [x,y], of rng1, + are in ascending order. That is, for each adjacent element pair [x,y], of rng1, pred(y, x) == false.
    • The elements of rng2 - is in ascending order. That is, for each adjacent element pair [x,y], of rng2, + are in ascending order. That is, for each adjacent element pair [x,y], of rng2, pred(y, x) == false.
    • @@ -221,7 +221,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html index bc4497a..b8d27f0 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/nth_element.html @@ -28,7 +28,7 @@ Range Algorithm - nth_element

    - + Prototype

    @@ -55,7 +55,7 @@

    - + Description

    @@ -66,14 +66,14 @@ is the same as the element that would be in that position if rng has been sorted.

    - + Definition

    Defined in the header file boost/range/algorithm/nth_element.hpp

    - + Requirements

    @@ -124,7 +124,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html index 1c161c7..d218c43 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partial_sort.html @@ -28,7 +28,7 @@ Range Algorithm - partial_sort

    - + Prototype

    @@ -55,7 +55,7 @@

    - + Description

    @@ -71,14 +71,14 @@ predicate instead.

    - + Definition

    Defined in the header file boost/range/algorithm/partial_sort.hpp

    - + Requirements

    @@ -129,7 +129,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html index e592ec2..4136a2a 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/partition.html @@ -28,7 +28,7 @@ Range Algorithm - partition

    - + Prototype

    @@ -67,7 +67,7 @@

    - + Description

    @@ -81,14 +81,14 @@ corresponds to the middle iterator.

    - + Definition

    Defined in the header file boost/range/algorithm/partition.hpp

    - + Requirements
      @@ -108,7 +108,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html index 56e47b7..190f66f 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/random_shuffle.html @@ -28,7 +28,7 @@ Range Algorithm - random_shuffle

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -61,14 +61,14 @@ the shuffles range.

    - + Definition

    Defined in the header file boost/range/algorithm/random_shuffle.hpp

    - + Requirements

    @@ -99,7 +99,7 @@

    - + Precondition:
    • @@ -108,7 +108,7 @@ maximum value.
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html index 525845d..4cb906c 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove.html @@ -28,7 +28,7 @@ Range Algorithm - remove

    - + Prototype

    @@ -67,7 +67,7 @@

    - + Description

    @@ -84,14 +84,14 @@ are dereferenceable, but the elements are unspecified.

    - + Definition

    Defined in the header file boost/range/algorithm/remove.hpp

    - + Requirements
      @@ -114,7 +114,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html index a6d8c56..9896adc 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/remove_if.html @@ -28,7 +28,7 @@ Range Algorithm - remove_if

    - + Prototype

    @@ -67,7 +67,7 @@

    - + Description

    @@ -83,14 +83,14 @@ are unspecified.

    - + Definition

    Defined in the header file boost/range/algorithm/remove_if.hpp

    - + Requirements
      @@ -113,7 +113,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html index ab1ea36..ab4232d 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace.html @@ -28,7 +28,7 @@ Range Algorithm - replace

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -58,14 +58,14 @@ Return a reference to rng.

    - + Definition

    Defined in the header file boost/range/algorithm/replace.hpp

    - + Requirements
      @@ -94,7 +94,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html index 8f0e4b3..7677651 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/replace_if.html @@ -28,7 +28,7 @@ Range Algorithm - replace_if

    - + Prototype

    @@ -43,7 +43,7 @@

    - + Description

    @@ -52,14 +52,14 @@ Returns a reference to rng.

    - + Definition

    Defined in the header file boost/range/algorithm/replace_if.hpp

    - + Requirements
      @@ -91,7 +91,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html index 6930b56..55faad4 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/rotate.html @@ -28,7 +28,7 @@ Range Algorithm - rotate

    - + Prototype

    @@ -45,7 +45,7 @@

    - + Description

    @@ -54,14 +54,14 @@ and [middle, end(rng)). Returns a reference to rng.

    - + Definition

    Defined in the header file boost/range/algorithm/rotate.hpp

    - + Requirements
      @@ -75,7 +75,7 @@
    - + Precondition:
      @@ -87,7 +87,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html index 55764e6..290f8e7 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/sort.html @@ -28,7 +28,7 @@ Range Algorithm - sort

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -72,14 +72,14 @@ [x,y], pred(y, x) == false.

    - + Definition

    Defined in the header file boost/range/algorithm/sort.hpp

    - + Requirements

    @@ -130,7 +130,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html index 016e37f..eb0032a 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_partition.html @@ -28,7 +28,7 @@ Range Algorithm - stable_partition

    - + Prototype

    @@ -61,7 +61,7 @@

    - + Description

    @@ -71,7 +71,7 @@ Once this function has completed all of the elements that satisfy pred appear before all of the elements that fail to satisfy it. stable_partition differs from partition - because it preserves relative order. It is table. + because it preserves relative order. It is stable.

    For the versions that return an iterator, the return value is the iterator @@ -83,14 +83,14 @@ the iterator to the first element that fails to satisfy pred.

    - + Definition

    Defined in the header file boost/range/algorithm/stable_partition.hpp

    - + Requirements
      @@ -108,7 +108,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html index 613739f..984024d 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/stable_sort.html @@ -28,7 +28,7 @@ Range Algorithm - stable_sort

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -72,14 +72,14 @@ [x,y], pred(y,x) == false.

    - + Definition

    Defined in the header file boost/range/algorithm/stable_sort.hpp

    - + Requirements

    @@ -130,7 +130,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html index 458f1b4..58da4ca 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/transform.html @@ -28,7 +28,7 @@ Range Algorithm - transform

    - + Prototype

    @@ -57,7 +57,7 @@

    - + Description

    @@ -93,14 +93,14 @@ The return value is out + min(distance(rng1), distance(rng2)).

    - + Definition

    Defined in the header file boost/range/algorithm/transform.hpp

    - + Requirements

    @@ -170,7 +170,7 @@

    - + Precondition:

    @@ -202,7 +202,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html index bad1018..aaa5525 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html +++ b/doc/html/range/reference/algorithms/range_algorithm_mutating_algorithms/unique.html @@ -28,7 +28,7 @@ Range Algorithm - unique

    - + Prototype

    @@ -69,7 +69,7 @@

    - + Description

    @@ -87,14 +87,14 @@ type.

    - + Definition

    Defined in the header file boost/range/algorithm/unique.hpp

    - + Requirements

    @@ -138,7 +138,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html index 37fbd37..3520dba 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/erase.html @@ -28,7 +28,7 @@ erase

    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -53,14 +53,14 @@ target.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/erase.hpp

    - + Requirements
    1. @@ -68,7 +68,7 @@ erase of an iterator range.
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html index bbeb90f..4a1cb75 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/for_each.html @@ -28,7 +28,7 @@ for_each

    - + Prototype

    @@ -73,7 +73,7 @@

    - + Description

    @@ -89,14 +89,14 @@ It is safe to call this function with unequal length ranges.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/for_each.hpp

    - + Requirements
      @@ -126,7 +126,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html index bac1fdf..fc06253 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/insert.html @@ -28,7 +28,7 @@ insert

    - + Prototype

    @@ -45,7 +45,7 @@

    - + Description

    @@ -55,14 +55,14 @@ target.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/insert.hpp

    - + Requirements
      @@ -82,7 +82,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html index a83b172..b856c39 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/overwrite.html @@ -28,7 +28,7 @@ overwrite

    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -53,14 +53,14 @@ into the range to.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/overwrite.hpp

    - + Requirements
      @@ -87,7 +87,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html index ab51754..26741e2 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_back.html @@ -28,7 +28,7 @@ push_back

    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -53,14 +53,14 @@ to the back of the container target.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/push_back.hpp

    - + Requirements
      @@ -80,7 +80,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html index a1658e2..4afd63c 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/push_front.html @@ -28,7 +28,7 @@ push_front

    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -53,14 +53,14 @@ to the front of the container target.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/push_front.hpp

    - + Requirements
      @@ -80,7 +80,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html index b6ab1b0..f80666a 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase.html @@ -28,7 +28,7 @@ remove_erase

    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -54,14 +54,14 @@ algorithm which merely rearranges elements.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/erase.hpp

    - + Requirements
    1. @@ -69,7 +69,7 @@ erase of an iterator range.
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html index 39eef41..0f4c190 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html +++ b/doc/html/range/reference/algorithms/range_algorithm_new_algorithms/remove_erase_if.html @@ -28,7 +28,7 @@ remove_erase_if

    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -55,14 +55,14 @@ algorithm which merely rearranges elements.

    - + Definition

    Defined in the header file boost/range/algorithm_ext/erase.hpp

    - + Requirements
      @@ -76,7 +76,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html index c9a58d1..e45a101 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/adjacent_find.html @@ -28,7 +28,7 @@ Range Algorithm - adjacent_find

    - + Prototype

    @@ -77,7 +77,7 @@

    - + Description

    @@ -98,14 +98,14 @@ is true.

    - + Definition

    Defined in the header file boost/range/algorithm/adjacent_find.hpp

    - + Requirements

    @@ -143,7 +143,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html index ddabdc7..247d8bc 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/binary_search.html @@ -28,7 +28,7 @@ binary_search

    - + Prototype

    @@ -43,7 +43,7 @@

    - + Description

    @@ -53,14 +53,14 @@ range rng.

    - + Definition

    Defined in the header file boost/range/algorithm/binary_search.hpp

    - + Requirements

    @@ -111,7 +111,7 @@

    - + Precondition:

    @@ -129,7 +129,7 @@ order according to the function object pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html index c30c6e6..bdfc489 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/count.html @@ -28,7 +28,7 @@ count

    - + Prototype

    @@ -45,7 +45,7 @@

    - + Description

    @@ -55,14 +55,14 @@ is true.

    - + Definition

    Defined in the header file boost/range/algorithm/count.hpp

    - + Requirements
      @@ -85,7 +85,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html index 8d45dcd..d6d54a1 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal.html @@ -28,7 +28,7 @@ equal

    - + Prototype

    @@ -53,7 +53,7 @@

    - + Description

    @@ -71,14 +71,14 @@ considered equal in the predicate version if pred(x,y) is true.

    - + Definition

    Defined in the header file boost/range/algorithm/equal.hpp

    - + Requirements

    @@ -139,7 +139,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html index ff5a0b9..94bd133 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/equal_range.html @@ -28,7 +28,7 @@ equal_range

    - + Prototype

    @@ -71,7 +71,7 @@

    - + Description

    @@ -85,14 +85,14 @@ is determined by pred.

    - + Definition

    Defined in the header file boost/range/algorithm/equal_range.hpp

    - + Requirements

    @@ -143,7 +143,7 @@

    - + Precondition:

    @@ -155,7 +155,7 @@ is ordered in ascending order according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html index 5c89b56..3e45381 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find.html @@ -28,7 +28,7 @@ find

    - + Prototype

    @@ -61,7 +61,7 @@

    - + Description

    @@ -72,14 +72,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/find.hpp

    - + Requirements
      @@ -100,7 +100,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html index a1fd3c0..9412d18 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_end.html @@ -28,7 +28,7 @@ find_end

    - + Prototype

    @@ -96,7 +96,7 @@

    - + Description

    @@ -111,14 +111,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/find_end.hpp

    - + Requirements

    @@ -178,7 +178,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html index 5a353e2..5f15b42 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_first_of.html @@ -28,7 +28,7 @@ find_first_of

    - + Prototype

    @@ -96,7 +96,7 @@

    - + Description

    @@ -116,14 +116,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/find_first_of.hpp

    - + Requirements

    @@ -177,7 +177,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html index 548c215..424b833 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/find_if.html @@ -28,7 +28,7 @@ find_if

    - + Prototype

    @@ -61,7 +61,7 @@

    - + Description

    @@ -76,14 +76,14 @@ defines found in the same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/find_if.hpp

    - + Requirements
      @@ -102,7 +102,7 @@
    - + Precondition:

    @@ -110,7 +110,7 @@ rng, *i is in the domain of UnaryPredicate.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html index 80aceea..3c85cc0 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/for_each.html @@ -28,7 +28,7 @@ for_each

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -59,14 +59,14 @@ fun(x).

    - + Definition

    Defined in the header file boost/range/algorithm/for_each.hpp

    - + Requirements
      @@ -90,7 +90,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html index 469333a..0cf9505 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lexicographical_compare.html @@ -28,7 +28,7 @@ lexicographical_compare

    - + Prototype

    @@ -53,7 +53,7 @@

    - + Description

    @@ -73,14 +73,14 @@ predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/lexicographical_compare.hpp

    - + Requirements

    @@ -145,7 +145,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html index 686416f..4e1f526 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/lower_bound.html @@ -28,7 +28,7 @@ lower_bound

    - + Prototype

    @@ -61,7 +61,7 @@

    - + Description

    @@ -84,14 +84,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/lower_bound.hpp

    - + Requirements

    @@ -142,7 +142,7 @@

    - + Precondition:

    @@ -160,7 +160,7 @@ order according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html index 07fca98..8ca03f7 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/max_element.html @@ -28,7 +28,7 @@ max_element

    - + Prototype

    @@ -84,7 +84,7 @@

    - + Description

    @@ -98,14 +98,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/max_element.hpp

    - + Requirements

    @@ -142,7 +142,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html index 90a0a22..08903d1 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/min_element.html @@ -28,7 +28,7 @@ min_element

    - + Prototype

    @@ -84,7 +84,7 @@

    - + Description

    @@ -98,14 +98,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/min_element.hpp

    - + Requirements

    @@ -142,7 +142,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html index d783d9a..5a168da 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/mismatch.html @@ -28,7 +28,7 @@ mismatch

    - + Prototype

    @@ -106,7 +106,7 @@

    - + Description

    @@ -124,14 +124,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/mismatch.hpp

    - + Requirements

    @@ -192,14 +192,14 @@

    - + Precondition:

    distance(rng2) >= distance(rng1)

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html index 891d51d..1dcf8c0 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/search.html @@ -28,7 +28,7 @@ search

    - + Prototype

    @@ -96,7 +96,7 @@

    - + Description

    @@ -115,14 +115,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/search.hpp

    - + Requirements

    @@ -183,7 +183,7 @@

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html index 40bd80e..8db1558 100644 --- a/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html +++ b/doc/html/range/reference/algorithms/range_algorithm_non_mutating_algorithms/upper_bound.html @@ -28,7 +28,7 @@ upper_bound

    - + Prototype

    @@ -61,7 +61,7 @@

    - + Description

    @@ -83,14 +83,14 @@ same manner as the returned iterator described above.

    - + Definition

    Defined in the header file boost/range/algorithm/upper_bound.hpp

    - + Requirements

    @@ -141,7 +141,7 @@

    - + Precondition:

    @@ -159,7 +159,7 @@ order according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_numeric/accumulate.html b/doc/html/range/reference/algorithms/range_numeric/accumulate.html index 8f19f51..448b1fa 100644 --- a/doc/html/range/reference/algorithms/range_numeric/accumulate.html +++ b/doc/html/range/reference/algorithms/range_numeric/accumulate.html @@ -28,7 +28,7 @@ accumulate

    - + Prototype

    @@ -53,7 +53,7 @@

    - + Description

    @@ -64,18 +64,18 @@ The return value is the resultant value of the above algorithm.

    - + Definition

    Defined in the header file boost/range/numeric.hpp

    - + Requirements
    - + For the first version
    @@ -100,7 +100,7 @@
    - + For the second version
    @@ -134,7 +134,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html b/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html index 23fed4f..8c76593 100644 --- a/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html +++ b/doc/html/range/reference/algorithms/range_numeric/adjacent_difference.html @@ -28,7 +28,7 @@ adjacent_difference

    - + Prototype

    @@ -55,7 +55,7 @@

    - + Description

    @@ -69,18 +69,18 @@ instead of operator-().

    - + Definition

    Defined in the header file boost/range/numeric.hpp

    - + Requirements
    - + For the first version
    @@ -111,7 +111,7 @@
    - + For the second version
    @@ -146,7 +146,7 @@
    - + Precondition:

    @@ -154,7 +154,7 @@ + distance(rng)) is a valid range.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_numeric/inner_product.html b/doc/html/range/reference/algorithms/range_numeric/inner_product.html index 273fe4e..6d48b14 100644 --- a/doc/html/range/reference/algorithms/range_numeric/inner_product.html +++ b/doc/html/range/reference/algorithms/range_numeric/inner_product.html @@ -28,7 +28,7 @@ inner_product

    - + Prototype

    @@ -39,7 +39,7 @@ class Value> Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, - Value init); + Value init ); template<class SinglePassRange1, class SinglePassRange2, @@ -49,12 +49,12 @@ Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init, - BinaryOperation1 op1, + BinaryOperation1 op1 );

    - + Description

    @@ -67,18 +67,18 @@ algorithm please see inner_product.

    - + Definition

    Defined in the header file boost/range/numeric.hpp

    - + Requirements
    - + For the first version
    @@ -113,7 +113,7 @@
    - + For the second version
    @@ -162,14 +162,14 @@
    - + Precondition:

    distance(rng2) >= distance(rng1) is a valid range.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/range_numeric/partial_sum.html b/doc/html/range/reference/algorithms/range_numeric/partial_sum.html index 6b52687..b89e58e 100644 --- a/doc/html/range/reference/algorithms/range_numeric/partial_sum.html +++ b/doc/html/range/reference/algorithms/range_numeric/partial_sum.html @@ -28,7 +28,7 @@ partial_sum

    - + Prototype

    @@ -49,7 +49,7 @@

    - + Description

    @@ -58,18 +58,18 @@ in the same manner as std::partial_sum(boost::begin(rng), boost::end(rng), out_it). See partial_sum.

    - + Definition

    Defined in the header file boost/range/numeric.hpp

    - + Requirements
    - + For the first version
    @@ -99,7 +99,7 @@
    - + For the second version
    @@ -128,7 +128,7 @@
    - + Precondition:

    @@ -136,7 +136,7 @@ + distance(rng)) is a valid range.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/set_algorithms/includes.html b/doc/html/range/reference/algorithms/set_algorithms/includes.html index e7eedb3..015474a 100644 --- a/doc/html/range/reference/algorithms/set_algorithms/includes.html +++ b/doc/html/range/reference/algorithms/set_algorithms/includes.html @@ -28,7 +28,7 @@ includes

    - + Prototype

    @@ -48,7 +48,7 @@

    - + Description

    @@ -60,14 +60,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/set_algorithm.hpp

    - + Requirements

    @@ -145,7 +145,7 @@

    - + Precondition:

    @@ -163,7 +163,7 @@ according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_difference.html b/doc/html/range/reference/algorithms/set_algorithms/set_difference.html index a8f32c6..58d8a54 100644 --- a/doc/html/range/reference/algorithms/set_algorithms/set_difference.html +++ b/doc/html/range/reference/algorithms/set_algorithms/set_difference.html @@ -28,7 +28,7 @@ set_difference

    - + Prototype

    @@ -57,7 +57,7 @@

    - + Description

    @@ -71,14 +71,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/set_algorithm.hpp

    - + Requirements

    @@ -164,7 +164,7 @@

    - + Precondition:

    @@ -182,7 +182,7 @@ according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html b/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html index 5ead92b..65840cd 100644 --- a/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html +++ b/doc/html/range/reference/algorithms/set_algorithms/set_intersection.html @@ -28,7 +28,7 @@ set_intersection

    - + Prototype

    @@ -57,7 +57,7 @@

    - + Description

    @@ -71,14 +71,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/set_algorithm.hpp

    - + Requirements

    @@ -164,7 +164,7 @@

    - + Precondition:

    @@ -182,7 +182,7 @@ according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html b/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html index 738d029..a25e8e4 100644 --- a/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html +++ b/doc/html/range/reference/algorithms/set_algorithms/set_symmetric_difference.html @@ -28,7 +28,7 @@ set_symmetric_difference

    - + Prototype

    @@ -59,7 +59,7 @@

    - + Description

    @@ -75,14 +75,14 @@ the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/set_algorithm.hpp

    - + Requirements

    @@ -168,7 +168,7 @@

    - + Precondition:

    @@ -186,7 +186,7 @@ according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/algorithms/set_algorithms/set_union.html b/doc/html/range/reference/algorithms/set_algorithms/set_union.html index 02dfe3f..90c343c 100644 --- a/doc/html/range/reference/algorithms/set_algorithms/set_union.html +++ b/doc/html/range/reference/algorithms/set_algorithms/set_union.html @@ -28,7 +28,7 @@ set_union

    - + Prototype

    @@ -57,7 +57,7 @@

    - + Description

    @@ -70,14 +70,14 @@ in the predicate versions.

    - + Definition

    Defined in the header file boost/range/algorithm/set_algorithm.hpp

    - + Requirements

    @@ -163,7 +163,7 @@

    - + Precondition:

    @@ -181,7 +181,7 @@ according to pred.

    - + Complexity

    diff --git a/doc/html/range/reference/extending/method_2.html b/doc/html/range/reference/extending/method_2.html index cdda356..f4f3524 100644 --- a/doc/html/range/reference/extending/method_2.html +++ b/doc/html/range/reference/extending/method_2.html @@ -159,7 +159,7 @@ template< class T > struct Pair { - T first, last; + T first, last; }; } // namespace 'Foo' @@ -194,31 +194,31 @@ { // // The required functions. These should be defined in - // the same namespace as 'Pair', in this case + // the same namespace as 'Pair', in this case // in namespace 'Foo'. // - + template< class T > inline T range_begin( Pair<T>& x ) - { + { return x.first; } template< class T > inline T range_begin( const Pair<T>& x ) - { + { return x.first; } template< class T > inline T range_end( Pair<T>& x ) - { + { return x.last; } template< class T > inline T range_end( const Pair<T>& x ) - { + { return x.last; } @@ -226,14 +226,14 @@ #include <vector> -int main() +int main(int argc, const char* argv[]) { typedef std::vector<int>::iterator iter; std::vector<int> vec; Foo::Pair<iter> pair = { vec.begin(), vec.end() }; - const Foo::Pair<iter>& cpair = pair; + const Foo::Pair<iter>& cpair = pair; // - // Notice that we call 'begin' etc with qualification. + // Notice that we call 'begin' etc with qualification. // iter i = boost::begin( pair ); iter e = boost::end( pair ); @@ -244,7 +244,9 @@ boost::range_reverse_iterator< const Foo::Pair<iter> >::type ri = boost::rbegin( cpair ), re = boost::rend( cpair ); -} + + return 0; +}

    diff --git a/doc/html/range/reference/extending/method_3/method_3_1.html b/doc/html/range/reference/extending/method_3/method_3_1.html index d45ef05..e995bee 100644 --- a/doc/html/range/reference/extending/method_3/method_3_1.html +++ b/doc/html/range/reference/extending/method_3/method_3_1.html @@ -47,11 +47,11 @@ typedef boost::iterator_range< boost::reverse_iterator< typename boost::range_iterator<R>::type> > base; - + public: typedef boost::reverse_iterator< typename boost::range_iterator<R>::type > iterator; - + reverse_range(R& r) : base(iterator(boost::end(r)), iterator(boost::begin(r))) { } @@ -68,17 +68,17 @@
  • Implement operator|
    template< class BidirectionalRng >
    -inline reverse_range<BidirectionalRng> 
    +inline reverse_range<BidirectionalRng>
     operator|( BidirectionalRng& r, detail::reverse_forwarder )
     {
    -	return reverse_range<BidirectionalRng>( r );   
    +	return reverse_range<BidirectionalRng>( r );
     }
     
     template< class BidirectionalRng >
    -inline reverse_range<const BidirectionalRng> 
    +inline reverse_range<const BidirectionalRng>
     operator|( const BidirectionalRng& r, detail::reverse_forwarder )
     {
    -	return reverse_range<const BidirectionalRng>( r );   
    +	return reverse_range<const BidirectionalRng>( r );
     }
     
  • diff --git a/doc/html/range/reference/extending/method_3/method_3_2.html b/doc/html/range/reference/extending/method_3/method_3_2.html index 58d6bc8..f0bae90 100644 --- a/doc/html/range/reference/extending/method_3/method_3_2.html +++ b/doc/html/range/reference/extending/method_3/method_3_2.html @@ -40,12 +40,12 @@ public: typedef const Value& result_type; typedef const Value& argument_type; - + replace_value(const Value& from, const Value& to) : m_from(from), m_to(to) { } - + const Value& operator()(const Value& x) const { return (x == m_from) ? m_to : x; @@ -68,7 +68,7 @@ typedef replace_value<value_type> Fn; typedef boost::transform_iterator<Fn, iterator_base> replaced_iterator; typedef boost::iterator_range<replaced_iterator> base_t; - + public: replace_range(Range& rng, value_type from, value_type to) : base_t(replaced_iterator(boost::begin(rng), Fn(from,to)), diff --git a/doc/html/range/reference/overview.html b/doc/html/range/reference/overview.html index 63c4433..ae0bbf0 100644 --- a/doc/html/range/reference/overview.html +++ b/doc/html/range/reference/overview.html @@ -27,7 +27,7 @@ Overview

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

    • diff --git a/doc/html/range/reference/ranges/counting_range.html b/doc/html/range/reference/ranges/counting_range.html index 4a3fae5..b556488 100644 --- a/doc/html/range/reference/ranges/counting_range.html +++ b/doc/html/range/reference/ranges/counting_range.html @@ -27,7 +27,7 @@ counting_range
    - + Prototype

    @@ -48,7 +48,7 @@

    - + Description

    @@ -58,14 +58,14 @@ (from Boost.Iterator).

    - + Definition

    Defined in header file boost/range/counting_range.hpp

    - + Requirements
    1. diff --git a/doc/html/range/reference/ranges/irange.html b/doc/html/range/reference/ranges/irange.html index 18aaeca..f4565c0 100644 --- a/doc/html/range/reference/ranges/irange.html +++ b/doc/html/range/reference/ranges/irange.html @@ -27,7 +27,7 @@ irange
    - + Prototype

    @@ -44,7 +44,7 @@

    - + Description

    @@ -58,14 +58,14 @@ parameters denoted a half-open range.

    - + Definition

    Defined in the header file boost/range/irange.hpp

    - + Requirements
      @@ -79,7 +79,7 @@
    - + Complexity

    diff --git a/doc/html/range/reference/ranges/istream_range.html b/doc/html/range/reference/ranges/istream_range.html index 599d368..e7d81d8 100644 --- a/doc/html/range/reference/ranges/istream_range.html +++ b/doc/html/range/reference/ranges/istream_range.html @@ -27,7 +27,7 @@ istream_range

    - + Prototype

    @@ -40,7 +40,7 @@

    - + Description

    @@ -49,7 +49,7 @@ wrapping a std::istream_iterator.

    - + Definition

    diff --git a/doc/html/range/reference/semantics.html b/doc/html/range/reference/semantics.html index dafb2d9..fbb1aa8 100644 --- a/doc/html/range/reference/semantics.html +++ b/doc/html/range/reference/semantics.html @@ -31,7 +31,7 @@

    Functions
    - + notation
    diff --git a/doc/html/range/utilities/iterator_range.html b/doc/html/range/utilities/iterator_range.html index f7d7b4a..07efc15 100644 --- a/doc/html/range/utilities/iterator_range.html +++ b/doc/html/range/utilities/iterator_range.html @@ -47,7 +47,7 @@ limitation is simply propogated from the underlying iterator type.

    - + Synopsis

    @@ -187,7 +187,7 @@ iterators from the same container.

    - + Details member functions
    @@ -218,7 +218,7 @@

    - + Details functions
    diff --git a/doc/html/range/utilities/join.html b/doc/html/range/utilities/join.html index 2902714..c2c9e15 100644 --- a/doc/html/range/utilities/join.html +++ b/doc/html/range/utilities/join.html @@ -39,7 +39,7 @@ if the end of a range has been reached internally during traversal.

    - + Synposis

    @@ -65,7 +65,7 @@

    - + Example

    diff --git a/doc/html/range/utilities/sub_range.html b/doc/html/range/utilities/sub_range.html index 7e1dd1b..0b474d7 100644 --- a/doc/html/range/utilities/sub_range.html +++ b/doc/html/range/utilities/sub_range.html @@ -35,7 +35,7 @@ is.

    - + Synopsis

    diff --git a/doc/introduction.qbk b/doc/introduction.qbk index 4529d92..c25eeae 100644 --- a/doc/introduction.qbk +++ b/doc/introduction.qbk @@ -2,7 +2,7 @@ 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. +The most common form of ranges used throughout the C++ community are standard library containers. When writing algorithms however, one often finds it desirable for the algorithm to accept 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. @@ -64,10 +64,10 @@ Below are given a small example (the complete example can be found [@http://www. std::cout << my_generic_replace( my_view, 4, 2 ); std::cout << my_generic_replace( str, 'a', 'b' ); - // prints '3', '5' and '0' + // 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 versions of `find()` since we cannot forward a non-const rvalue with reference arguments (see this article about __the_forwarding_problem__ ). -[endsect] +[endsect] diff --git a/doc/reference/algorithm/merge.qbk b/doc/reference/algorithm/merge.qbk index 2f538bc..edfed92 100644 --- a/doc/reference/algorithm/merge.qbk +++ b/doc/reference/algorithm/merge.qbk @@ -11,7 +11,7 @@ template< OutputIterator merge(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out); - + template< class SinglePassRange1, class SinglePassRange2, @@ -68,8 +68,8 @@ Defined in the header file `boost/range/algorithm/merge.hpp` [heading For the predicate version:] -* The elements of `rng1` is in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng1`, `pred(y, x) == false`. -* The elements of `rng2` is in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng2`, `pred(y, x) == false`. +* The elements of `rng1` are in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng1`, `pred(y, x) == false`. +* The elements of `rng2` are in ascending order. That is, for each adjacent element pair `[x,y]`, of `rng2`, `pred(y, x) == false`. * The ranges `rng1` and `[out, out + distance(rng1) + distance(rng2))` do not overlap. * The ranges `rng2` and `[out, out + distance(rng1) + distance(rng2))` do not overlap. * `[out, out + distance(rng1) + distance(rng2))` is a valid range. diff --git a/doc/reference/algorithm/stable_partition.qbk b/doc/reference/algorithm/stable_partition.qbk index 30e9311..b68aa11 100644 --- a/doc/reference/algorithm/stable_partition.qbk +++ b/doc/reference/algorithm/stable_partition.qbk @@ -30,7 +30,7 @@ stable_partition(const ForwardRange& rng, UnaryPredicate pred); [heading Description] -`stable_partition` reorders the elements in the range `rng` base on the function object `pred`. Once this function has completed all of the elements that satisfy `pred` appear before all of the elements that fail to satisfy it. `stable_partition` differs from `partition` because it preserves relative order. It is table. +`stable_partition` reorders the elements in the range `rng` base on the function object `pred`. Once this function has completed all of the elements that satisfy `pred` appear before all of the elements that fail to satisfy it. `stable_partition` differs from `partition` because it preserves relative order. It is stable. For the versions that return an iterator, the return value is the iterator to the first element that fails to satisfy `pred`. diff --git a/doc/reference/extending.qbk b/doc/reference/extending.qbk index 8cf6a74..13b0b5e 100644 --- a/doc/reference/extending.qbk +++ b/doc/reference/extending.qbk @@ -64,7 +64,7 @@ A complete example is given here: template< class T > struct Pair { - T first, last; + T first, last; }; } // namespace 'Foo' @@ -99,31 +99,31 @@ A complete example is given here: { // // The required functions. These should be defined in - // the same namespace as 'Pair', in this case + // the same namespace as 'Pair', in this case // in namespace 'Foo'. // - + template< class T > inline T range_begin( Pair& x ) - { + { return x.first; } template< class T > inline T range_begin( const Pair& x ) - { + { return x.first; } template< class T > inline T range_end( Pair& x ) - { + { return x.last; } template< class T > inline T range_end( const Pair& x ) - { + { return x.last; } @@ -131,14 +131,14 @@ A complete example is given here: #include - int main() + int main(int argc, const char* argv[]) { typedef std::vector::iterator iter; std::vector vec; Foo::Pair pair = { vec.begin(), vec.end() }; - const Foo::Pair& cpair = pair; + const Foo::Pair& cpair = pair; // - // Notice that we call 'begin' etc with qualification. + // Notice that we call 'begin' etc with qualification. // iter i = boost::begin( pair ); iter e = boost::end( pair ); @@ -149,7 +149,9 @@ A complete example is given here: boost::range_reverse_iterator< const Foo::Pair >::type ri = boost::rbegin( cpair ), re = boost::rend( cpair ); - } + + return 0; + } `` [endsect] @@ -175,11 +177,11 @@ private: typedef boost::iterator_range< boost::reverse_iterator< typename boost::range_iterator::type> > base; - + public: typedef boost::reverse_iterator< typename boost::range_iterator::type > iterator; - + reverse_range(R& r) : base(iterator(boost::end(r)), iterator(boost::begin(r))) { } @@ -196,17 +198,17 @@ namespace detail { # Implement `operator|` `` template< class BidirectionalRng > -inline reverse_range +inline reverse_range operator|( BidirectionalRng& r, detail::reverse_forwarder ) { - return reverse_range( r ); + return reverse_range( r ); } template< class BidirectionalRng > -inline reverse_range +inline reverse_range operator|( const BidirectionalRng& r, detail::reverse_forwarder ) { - return reverse_range( r ); + return reverse_range( r ); } `` @@ -226,12 +228,12 @@ class replace_value public: typedef const Value& result_type; typedef const Value& argument_type; - + replace_value(const Value& from, const Value& to) : m_from(from), m_to(to) { } - + const Value& operator()(const Value& x) const { return (x == m_from) ? m_to : x; @@ -254,7 +256,7 @@ private: typedef replace_value Fn; typedef boost::transform_iterator replaced_iterator; typedef boost::iterator_range base_t; - + public: replace_range(Range& rng, value_type from, value_type to) : base_t(replaced_iterator(boost::begin(rng), Fn(from,to)), @@ -263,7 +265,7 @@ public: } }; `` - + # Implement a holder class to hold the arguments required to construct the RangeAdaptor. The holder combines multiple parameters into one that can be passed as the right operand of `operator|()`. diff --git a/doc/reference/numeric/inner_product.qbk b/doc/reference/numeric/inner_product.qbk index a56062a..2b42f8d 100644 --- a/doc/reference/numeric/inner_product.qbk +++ b/doc/reference/numeric/inner_product.qbk @@ -8,7 +8,7 @@ template Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, - Value init); + Value init ); template` diff --git a/include/boost/range/adaptor/adjacent_filtered.hpp b/include/boost/range/adaptor/adjacent_filtered.hpp index 944665b..aedc888 100644 --- a/include/boost/range/adaptor/adjacent_filtered.hpp +++ b/include/boost/range/adaptor/adjacent_filtered.hpp @@ -104,7 +104,7 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME range_iterator::type raw_iterator; - P bi_pred; + P m_bi_pred; // Get the first element in the half-open range that // passes the filter predicate. @@ -146,8 +146,8 @@ namespace boost adjacent_filter_range( const P& p, R& r, bool default_pass ) : base_range( skip_iter( this, to_valid(boost::begin(r), boost::end(r), p, default_pass)), skip_iter( this, boost::end(r) ) ), - bi_pred( p ), - _default_pass(default_pass) + m_bi_pred( p ), + m_default_pass(default_pass) { } @@ -155,11 +155,11 @@ namespace boost { BOOST_ASSERT( current != this->end().base() ); - current = to_valid(next(current), this->end().base(), bi_pred, _default_pass); + current = to_valid(next(current), this->end().base(), m_bi_pred, m_default_pass); } private: - bool _default_pass; + bool m_default_pass; }; template< class T > @@ -214,7 +214,7 @@ namespace boost // Bring adjacent_filter_range into the boost namespace so that users of // this library may specify the return type of the '|' operator and - // make_adjacent_filtered_range() + // adjacent_filter() using range_detail::adjacent_filter_range; namespace adaptors @@ -222,8 +222,8 @@ namespace boost namespace { const range_detail::forwarder - adjacent_filtered = - range_detail::forwarder(); + adjacent_filtered = + range_detail::forwarder(); const range_detail::forwarder adjacent_filtered_excl = diff --git a/include/boost/range/adaptor/filtered.hpp b/include/boost/range/adaptor/filtered.hpp index c3e9ef5..1bc4799 100755 --- a/include/boost/range/adaptor/filtered.hpp +++ b/include/boost/range/adaptor/filtered.hpp @@ -20,22 +20,21 @@ namespace boost namespace range_detail { template< class P, class R > - struct filter_range : - boost::iterator_range< - boost::filter_iterator< P, - BOOST_DEDUCED_TYPENAME range_iterator::type - > - > + struct filter_range : + boost::iterator_range< + boost::filter_iterator< P, + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > { private: typedef boost::iterator_range< - boost::filter_iterator< P, - BOOST_DEDUCED_TYPENAME range_iterator::type - > - > - base; + boost::filter_iterator< P, + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > base; public: - filter_range( P p, R& r ) + filter_range( P p, R& r ) : base( make_filter_iterator( p, boost::begin(r), boost::end(r) ), make_filter_iterator( p, boost::end(r), boost::end(r) ) ) { } @@ -47,48 +46,48 @@ namespace boost filter_holder( T r ) : holder(r) { } }; - + template< class InputRng, class Predicate > - inline filter_range - operator|( InputRng& r, + inline filter_range + operator|( InputRng& r, const filter_holder& f ) { - return filter_range( f.val, r ); + return filter_range( f.val, r ); } - + template< class InputRng, class Predicate > - inline filter_range - operator|( const InputRng& r, + inline filter_range + operator|( const InputRng& r, const filter_holder& f ) { - return filter_range( f.val, r ); + return filter_range( f.val, r ); } - + } // 'range_detail' // Unusual use of 'using' is intended to bring filter_range into the boost namespace // while leaving the mechanics of the '|' operator in range_detail and maintain // argument dependent lookup. // filter_range logically needs to be in the boost namespace to allow user of - // the library to define the return type for make_filtered_range() + // the library to define the return type for filter() using range_detail::filter_range; namespace adaptors - { + { namespace { - const range_detail::forwarder - filtered = + const range_detail::forwarder + filtered = range_detail::forwarder(); } - + template inline filter_range filter(InputRange& rng, Predicate filter_pred) { return range_detail::filter_range( filter_pred, rng ); } - + template inline filter_range filter(const InputRange& rng, Predicate filter_pred) diff --git a/include/boost/range/adaptor/indexed.hpp b/include/boost/range/adaptor/indexed.hpp index 4c00cdd..7050185 100755 --- a/include/boost/range/adaptor/indexed.hpp +++ b/include/boost/range/adaptor/indexed.hpp @@ -29,6 +29,10 @@ namespace boost { namespace adaptors { + // This structure exists to carry the parameters from the '|' operator + // to the index adapter. The expression rng | indexed(1) instantiates + // this structure and passes it as the right-hand operand to the + // '|' operator. struct indexed { explicit indexed(std::size_t x) : val(x) {} @@ -48,18 +52,18 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type; - index_type index_; + index_type m_index; public: explicit indexed_iterator( Iter i, index_type index ) - : base(i), index_(index) + : base(i), m_index(index) { - BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" ); + BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" ); } index_type index() const { - return index_; + return m_index; } private: @@ -67,22 +71,22 @@ namespace boost void increment() { - ++index_; + ++m_index; ++(this->base_reference()); } void decrement() { - BOOST_ASSERT( index_ > 0 && "Indexed Iterator out of bounds" ); - --index_; + BOOST_ASSERT( m_index > 0 && "Indexed Iterator out of bounds" ); + --m_index; --(this->base_reference()); } void advance( index_type n ) { - index_ += n; - BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" ); + m_index += n; + BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" ); this->base_reference() += n; } }; @@ -107,7 +111,7 @@ namespace boost // Make this available to users of this library. It will sometimes be // required since it is the return type of operator '|' and - // make_indexed_range(). + // index(). using range_detail::indexed_range; namespace adaptors @@ -130,16 +134,16 @@ namespace boost template inline indexed_range - index(SinglePassRange& rng, Index index) + index(SinglePassRange& rng, Index index_value) { - return indexed_range(index, rng); + return indexed_range(index_value, rng); } template inline indexed_range - index(const SinglePassRange& rng, Index index) + index(const SinglePassRange& rng, Index index_value) { - return indexed_range(index, rng); + return indexed_range(index_value, rng); } } // 'adaptors' diff --git a/include/boost/range/adaptor/indirected.hpp b/include/boost/range/adaptor/indirected.hpp index 47eeb85..5b13cfb 100644 --- a/include/boost/range/adaptor/indirected.hpp +++ b/include/boost/range/adaptor/indirected.hpp @@ -21,22 +21,22 @@ namespace boost template< class R > struct indirect_range : public boost::iterator_range< - boost::indirect_iterator< - BOOST_DEDUCED_TYPENAME range_iterator::type - > - > + boost::indirect_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > { private: typedef boost::iterator_range< - boost::indirect_iterator< - BOOST_DEDUCED_TYPENAME range_iterator::type - > - > + boost::indirect_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > base; public: - indirect_range( R& r ) - : base( r ) + explicit indirect_range( R& r ) + : base( r ) { } }; diff --git a/include/boost/range/adaptor/replaced.hpp b/include/boost/range/adaptor/replaced.hpp index 1690797..bdc0a2d 100644 --- a/include/boost/range/adaptor/replaced.hpp +++ b/include/boost/range/adaptor/replaced.hpp @@ -32,18 +32,18 @@ namespace boost typedef const Value& first_argument_type; replace_value(const Value& from, const Value& to) - : _from(from), _to(to) + : m_from(from), m_to(to) { } const Value& operator()(const Value& x) const { - return (x == _from) ? _to : x; + return (x == m_from) ? m_to : x; } private: - Value _from; - Value _to; + Value m_from; + Value m_to; }; template< class R > @@ -109,7 +109,7 @@ namespace boost replaced = range_detail::forwarder2(); } - + template inline replace_range replace(InputRange& rng, @@ -118,7 +118,7 @@ namespace boost { return replace_range(rng, from, to); } - + template inline replace_range replace(const InputRange& rng, @@ -127,7 +127,7 @@ namespace boost { return replace_range(rng, from ,to); } - + } // 'adaptors' } // 'boost' From 22c72c53ebaa46c8fbbabae4c4005fc596a8d2c9 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 19:14:13 +0000 Subject: [PATCH 84/92] Boost.Range algorithms are now in the boost::range namespace and brought into boost by the appropriate using statement. This allows better interoperation with Boost.Algorithm since errors only occur when the use calls similarly named ambiguous functions. In this event the user can disambiguate by using algorithm::xxx() or range::xxx(). This iteration also updates the concept assert code in the range algorithms. [SVN r61023] --- .../boost/range/algorithm/adjacent_find.hpp | 182 +++++----- .../boost/range/algorithm/binary_search.hpp | 44 ++- include/boost/range/algorithm/copy.hpp | 28 +- .../boost/range/algorithm/copy_backward.hpp | 34 +- include/boost/range/algorithm/count.hpp | 44 ++- include/boost/range/algorithm/count_if.hpp | 46 +-- include/boost/range/algorithm/equal.hpp | 66 ++-- include/boost/range/algorithm/equal_range.hpp | 106 +++--- include/boost/range/algorithm/fill.hpp | 28 +- include/boost/range/algorithm/fill_n.hpp | 30 +- include/boost/range/algorithm/find.hpp | 84 +++-- include/boost/range/algorithm/find_end.hpp | 226 ++++++------ .../boost/range/algorithm/find_first_of.hpp | 231 ++++++------ include/boost/range/algorithm/find_if.hpp | 88 ++--- include/boost/range/algorithm/for_each.hpp | 42 ++- include/boost/range/algorithm/generate.hpp | 47 +-- .../boost/range/algorithm/heap_algorithm.hpp | 299 ++++++++-------- .../boost/range/algorithm/inplace_merge.hpp | 94 ++--- .../algorithm/lexicographical_compare.hpp | 62 ++-- include/boost/range/algorithm/lower_bound.hpp | 156 ++++---- include/boost/range/algorithm/max_element.hpp | 164 +++++---- include/boost/range/algorithm/merge.hpp | 68 ++-- include/boost/range/algorithm/min_element.hpp | 164 +++++---- include/boost/range/algorithm/mismatch.hpp | 247 +++++++------ include/boost/range/algorithm/nth_element.hpp | 86 ++--- .../boost/range/algorithm/partial_sort.hpp | 88 ++--- .../range/algorithm/partial_sort_copy.hpp | 70 ++-- include/boost/range/algorithm/partition.hpp | 86 ++--- include/boost/range/algorithm/permutation.hpp | 177 +++++---- .../boost/range/algorithm/random_shuffle.hpp | 82 +++-- include/boost/range/algorithm/remove.hpp | 94 ++--- include/boost/range/algorithm/remove_copy.hpp | 36 +- include/boost/range/algorithm/remove_if.hpp | 89 ++--- include/boost/range/algorithm/replace.hpp | 52 +-- .../boost/range/algorithm/replace_copy.hpp | 32 +- .../boost/range/algorithm/replace_copy_if.hpp | 40 ++- include/boost/range/algorithm/replace_if.hpp | 55 +-- include/boost/range/algorithm/reverse.hpp | 44 ++- .../boost/range/algorithm/reverse_copy.hpp | 40 ++- include/boost/range/algorithm/rotate.hpp | 50 +-- include/boost/range/algorithm/rotate_copy.hpp | 10 +- include/boost/range/algorithm/search.hpp | 207 +++++------ include/boost/range/algorithm/search_n.hpp | 223 ++++++------ .../boost/range/algorithm/set_algorithm.hpp | 338 +++++++++--------- include/boost/range/algorithm/sort.hpp | 83 +++-- .../range/algorithm/stable_partition.hpp | 91 ++--- include/boost/range/algorithm/stable_sort.hpp | 82 +++-- include/boost/range/algorithm/swap_ranges.hpp | 38 +- include/boost/range/algorithm/transform.hpp | 84 +++-- include/boost/range/algorithm/unique.hpp | 160 +++++---- include/boost/range/algorithm/unique_copy.hpp | 50 +-- include/boost/range/algorithm/upper_bound.hpp | 160 +++++---- 52 files changed, 2766 insertions(+), 2461 deletions(-) diff --git a/include/boost/range/algorithm/adjacent_find.hpp b/include/boost/range/algorithm/adjacent_find.hpp index c84ecec..c42e5ee 100755 --- a/include/boost/range/algorithm/adjacent_find.hpp +++ b/include/boost/range/algorithm/adjacent_find.hpp @@ -19,101 +19,107 @@ namespace boost { - /// \brief template function adjacent_find - /// - /// range-based version of the adjacent_find std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< typename ForwardRange > - inline typename range_iterator::type - adjacent_find(ForwardRange & rng) + namespace range { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return std::adjacent_find(boost::begin(rng),boost::end(rng)); - } - /// \overload - template< typename ForwardRange > - inline typename range_iterator::type - adjacent_find(const ForwardRange& rng) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return std::adjacent_find(boost::begin(rng),boost::end(rng)); - } +/// \brief template function adjacent_find +/// +/// range-based version of the adjacent_find std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template< typename ForwardRange > +inline typename range_iterator::type +adjacent_find(ForwardRange & rng) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::adjacent_find(boost::begin(rng),boost::end(rng)); +} - /// \overload - template< typename ForwardRange, typename BinaryPredicate > - inline typename range_iterator::type - adjacent_find(ForwardRange & rng, BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, - typename range_value::type>)); - return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); - } +/// \overload +template< typename ForwardRange > +inline typename range_iterator::type +adjacent_find(const ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::adjacent_find(boost::begin(rng),boost::end(rng)); +} - /// \overload - template< typename ForwardRange, typename BinaryPredicate > - inline typename range_iterator::type - adjacent_find(const ForwardRange& rng, BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, - typename range_value::type>)); - return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); - } +/// \overload +template< typename ForwardRange, typename BinaryPredicate > +inline typename range_iterator::type +adjacent_find(ForwardRange & rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + typename range_value::type>)); + return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); +} + +/// \overload +template< typename ForwardRange, typename BinaryPredicate > +inline typename range_iterator::type +adjacent_find(const ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + typename range_value::type>)); + return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); +} // range_return overloads - /// \overload - template< range_return_value re, typename ForwardRange > - inline typename range_return::type - adjacent_find(ForwardRange & rng) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return range_return:: - pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), - rng); - } - - /// \overload - template< range_return_value re, typename ForwardRange > - inline typename range_return::type - adjacent_find(const ForwardRange& rng) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return range_return:: - pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), - rng); - } - - /// \overload - template< range_return_value re, typename ForwardRange, typename BinaryPredicate > - inline typename range_return::type - adjacent_find(ForwardRange& rng, BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, - typename range_value::type>)); - return range_return:: - pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), - rng); - } - - /// \overload - template< range_return_value re, typename ForwardRange, typename BinaryPredicate > - inline typename range_return::type - adjacent_find(const ForwardRange& rng, BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return range_return:: - pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), - rng); - } +/// \overload +template< range_return_value re, typename ForwardRange > +inline typename range_return::type +adjacent_find(ForwardRange & rng) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), + rng); } +/// \overload +template< range_return_value re, typename ForwardRange > +inline typename range_return::type +adjacent_find(const ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), + rng); +} + +/// \overload +template< range_return_value re, typename ForwardRange, typename BinaryPredicate > +inline typename range_return::type +adjacent_find(ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + typename range_value::type>)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), + rng); +} + +/// \overload +template< range_return_value re, typename ForwardRange, typename BinaryPredicate > +inline typename range_return::type +adjacent_find(const ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), + rng); +} + + } // namespace range + using range::adjacent_find; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/binary_search.hpp b/include/boost/range/algorithm/binary_search.hpp index 666f19c..41860a5 100755 --- a/include/boost/range/algorithm/binary_search.hpp +++ b/include/boost/range/algorithm/binary_search.hpp @@ -17,27 +17,33 @@ namespace boost { - /// \brief template function binary_search - /// - /// range-based version of the binary_search std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline bool binary_search(const ForwardRange& rng, const Value& val) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::binary_search(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template - inline bool binary_search(const ForwardRange& rng, const Value& val, - BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::binary_search(boost::begin(rng), boost::end(rng), val, pred); - } +/// \brief template function binary_search +/// +/// range-based version of the binary_search std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline bool binary_search(const ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::binary_search(boost::begin(rng), boost::end(rng), val); } +/// \overload +template +inline bool binary_search(const ForwardRange& rng, const Value& val, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::binary_search(boost::begin(rng), boost::end(rng), val, pred); +} + + } // namespace range + using range::binary_search; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/copy.hpp b/include/boost/range/algorithm/copy.hpp index 27b88ab..b097d00 100644 --- a/include/boost/range/algorithm/copy.hpp +++ b/include/boost/range/algorithm/copy.hpp @@ -18,18 +18,24 @@ namespace boost { - /// \brief template function copy - /// - /// range-based version of the copy std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre OutputIterator is a model of the OutputIteratorConcept - template< class SinglePassRange, class OutputIterator > - inline OutputIterator copy(const SinglePassRange& rng, OutputIterator out) + namespace range { - //BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return std::copy(boost::begin(rng),boost::end(rng),out); - } + +/// \brief template function copy +/// +/// range-based version of the copy std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre OutputIterator is a model of the OutputIteratorConcept +template< class SinglePassRange, class OutputIterator > +inline OutputIterator copy(const SinglePassRange& rng, OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::copy(boost::begin(rng),boost::end(rng),out); } + } // namespace range + using range::copy; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/copy_backward.hpp b/include/boost/range/algorithm/copy_backward.hpp index 34dbebb..fddd0a8 100755 --- a/include/boost/range/algorithm/copy_backward.hpp +++ b/include/boost/range/algorithm/copy_backward.hpp @@ -17,21 +17,27 @@ namespace boost { - /// \brief template function copy_backward - /// - /// range-based version of the copy_backwards std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - /// \pre BidirectionalTraversalWriteableIterator is a model of the BidirectionalIteratorConcept - /// \pre BidirectionalTraversalWriteableIterator is a model of the WriteableIteratorConcept - template< class BidirectionalRange, class BidirectionalTraversalWriteableIterator > - inline BidirectionalTraversalWriteableIterator - copy_backward(const BidirectionalRange& rng, - BidirectionalTraversalWriteableIterator out) + namespace range { - boost::function_requires< BidirectionalRangeConcept >(); - return std::copy_backward(boost::begin(rng), boost::end(rng), out); - } + +/// \brief template function copy_backward +/// +/// range-based version of the copy_backwards std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +/// \pre BidirectionalTraversalWriteableIterator is a model of the BidirectionalIteratorConcept +/// \pre BidirectionalTraversalWriteableIterator is a model of the WriteableIteratorConcept +template< class BidirectionalRange, class BidirectionalTraversalWriteableIterator > +inline BidirectionalTraversalWriteableIterator +copy_backward(const BidirectionalRange& rng, + BidirectionalTraversalWriteableIterator out) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::copy_backward(boost::begin(rng), boost::end(rng), out); } + } // namespace range + using range::copy_backward; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/count.hpp b/include/boost/range/algorithm/count.hpp index e695a0c..ab4fdd1 100755 --- a/include/boost/range/algorithm/count.hpp +++ b/include/boost/range/algorithm/count.hpp @@ -18,27 +18,33 @@ namespace boost { - /// \brief template function count - /// - /// range-based version of the count std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - template< class SinglePassRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_difference::type - count(SinglePassRange& rng, const Value& val) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - return std::count(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template< class SinglePassRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_difference::type - count(const SinglePassRange& rng, const Value& val) - { - boost::function_requires< SinglePassRangeConcept >(); - return std::count(boost::begin(rng), boost::end(rng), val); - } +/// \brief template function count +/// +/// range-based version of the count std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +template< class SinglePassRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_difference::type +count(SinglePassRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::count(boost::begin(rng), boost::end(rng), val); } +/// \overload +template< class SinglePassRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_difference::type +count(const SinglePassRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::count(boost::begin(rng), boost::end(rng), val); +} + + } // namespace range + using range::count; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/count_if.hpp b/include/boost/range/algorithm/count_if.hpp index 9f8b929..611312c 100755 --- a/include/boost/range/algorithm/count_if.hpp +++ b/include/boost/range/algorithm/count_if.hpp @@ -18,28 +18,34 @@ namespace boost { - /// \brief template function count_if - /// - /// range-based version of the count_if std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre UnaryPredicate is a model of the UnaryPredicateConcept - template< class SinglePassRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME boost::range_difference::type - count_if(SinglePassRange& rng, UnaryPredicate pred) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - return std::count_if(boost::begin(rng), boost::end(rng), pred); - } - /// \overload - template< class SinglePassRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME boost::range_difference::type - count_if(const SinglePassRange& rng, UnaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - return std::count_if(boost::begin(rng), boost::end(rng), pred); - } +/// \brief template function count_if +/// +/// range-based version of the count_if std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre UnaryPredicate is a model of the UnaryPredicateConcept +template< class SinglePassRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME boost::range_difference::type +count_if(SinglePassRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::count_if(boost::begin(rng), boost::end(rng), pred); } +/// \overload +template< class SinglePassRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME boost::range_difference::type +count_if(const SinglePassRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::count_if(boost::begin(rng), boost::end(rng), pred); +} + + } // namespace range + using range::count_if; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/equal.hpp b/include/boost/range/algorithm/equal.hpp index a7be749..e9a16fd 100755 --- a/include/boost/range/algorithm/equal.hpp +++ b/include/boost/range/algorithm/equal.hpp @@ -143,40 +143,46 @@ namespace boost return equal_impl(first1, last1, first2, last2, pred, tag1, tag2); } - - } - /// \brief template function equal - /// - /// range-based version of the equal std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< class SinglePassRange1, class SinglePassRange2 > - inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 ) + } // namespace range_detail + + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return range_detail::equal( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2) ); - } + /// \brief template function equal + /// + /// range-based version of the equal std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre BinaryPredicate is a model of the BinaryPredicateConcept + template< class SinglePassRange1, class SinglePassRange2 > + inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 ) + { + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - /// \overload - template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > - inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2, - BinaryPredicate pred ) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); + return ::boost::range_detail::equal( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2) ); + } - return range_detail::equal( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), - pred); - } -} + /// \overload + template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > + inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2, + BinaryPredicate pred ) + { + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::equal( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), + pred); + } + + } // namespace range + using range::equal; +} // namespace boost #endif // include guard diff --git a/include/boost/range/algorithm/equal_range.hpp b/include/boost/range/algorithm/equal_range.hpp index 235b9db..0643701 100755 --- a/include/boost/range/algorithm/equal_range.hpp +++ b/include/boost/range/algorithm/equal_range.hpp @@ -17,58 +17,64 @@ namespace boost { - /// \brief template function equal_range - /// - /// range-based version of the equal_range std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre SortPredicate is a model of the BinaryPredicateConcept - template - inline std::pair< - BOOST_DEDUCED_TYPENAME boost::range_iterator::type, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type - > - equal_range(ForwardRange& rng, const Value& val) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::equal_range(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template - inline std::pair< - BOOST_DEDUCED_TYPENAME boost::range_iterator::type, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type - > - equal_range(const ForwardRange& rng, const Value& val) - { - boost::function_requires< ForwardRangeConcept >(); - return std::equal_range(boost::begin(rng), boost::end(rng), val); - } - - /// \overload - template - inline std::pair< - BOOST_DEDUCED_TYPENAME boost::range_iterator::type, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type - > - equal_range(ForwardRange& rng, const Value& val, SortPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); - } - - /// \overload - template - inline std::pair< - BOOST_DEDUCED_TYPENAME boost::range_iterator::type, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type - > - equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); - } +/// \brief template function equal_range +/// +/// range-based version of the equal_range std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre SortPredicate is a model of the BinaryPredicateConcept +template +inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > +equal_range(ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::equal_range(boost::begin(rng), boost::end(rng), val); } +/// \overload +template +inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > +equal_range(const ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::equal_range(boost::begin(rng), boost::end(rng), val); +} + +/// \overload +template +inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > +equal_range(ForwardRange& rng, const Value& val, SortPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); +} + +/// \overload +template +inline std::pair< + BOOST_DEDUCED_TYPENAME boost::range_iterator::type, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type + > +equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); +} + + } // namespace range + using range::equal_range; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/fill.hpp b/include/boost/range/algorithm/fill.hpp index cc4b352..4d4d750 100755 --- a/include/boost/range/algorithm/fill.hpp +++ b/include/boost/range/algorithm/fill.hpp @@ -17,18 +17,24 @@ namespace boost { - /// \brief template function fill - /// - /// range-based version of the fill std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class Value > - inline ForwardRange& fill(ForwardRange& rng, const Value& val) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - std::fill(boost::begin(rng), boost::end(rng), val); - return rng; - } + +/// \brief template function fill +/// +/// range-based version of the fill std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class Value > +inline ForwardRange& fill(ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::fill(boost::begin(rng), boost::end(rng), val); + return rng; +} + + } // namespace range + using range::fill; } #endif // include guard diff --git a/include/boost/range/algorithm/fill_n.hpp b/include/boost/range/algorithm/fill_n.hpp index 2283e23..a6c32bd 100755 --- a/include/boost/range/algorithm/fill_n.hpp +++ b/include/boost/range/algorithm/fill_n.hpp @@ -18,19 +18,25 @@ namespace boost { - /// \brief template function fill_n - /// - /// range-based version of the fill_n std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class Size, class Value > - inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - BOOST_ASSERT( static_cast(std::distance(boost::begin(rng), boost::end(rng))) >= n ); - std::fill_n(boost::begin(rng), n, val); - return rng; - } + +/// \brief template function fill_n +/// +/// range-based version of the fill_n std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class Size, class Value > +inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_ASSERT( static_cast(std::distance(boost::begin(rng), boost::end(rng))) >= n ); + std::fill_n(boost::begin(rng), n, val); + return rng; } + } // namespace range + using range::fill_n; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/find.hpp b/include/boost/range/algorithm/find.hpp index 1f9c667..d9d5b14 100755 --- a/include/boost/range/algorithm/find.hpp +++ b/include/boost/range/algorithm/find.hpp @@ -18,49 +18,55 @@ namespace boost { - /// \brief template function find - /// - /// range-based version of the find std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - template< class SinglePassRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find( SinglePassRange& rng, const Value& val ) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - return std::find(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template< class SinglePassRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find( const SinglePassRange& rng, const Value& val ) - { - boost::function_requires< SinglePassRangeConcept >(); - return std::find(boost::begin(rng), boost::end(rng), val); - } + +/// \brief template function find +/// +/// range-based version of the find std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +template< class SinglePassRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find( SinglePassRange& rng, const Value& val ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::find(boost::begin(rng), boost::end(rng), val); +} +/// \overload +template< class SinglePassRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find( const SinglePassRange& rng, const Value& val ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::find(boost::begin(rng), boost::end(rng), val); +} // range_return overloads - /// \overload - template< range_return_value re, class SinglePassRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - find( SinglePassRange& rng, const Value& val ) - { - boost::function_requires< SinglePassRangeConcept >(); - return range_return:: - pack(std::find(boost::begin(rng), boost::end(rng), val), - rng); - } - /// \overload - template< range_return_value re, class SinglePassRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - find( const SinglePassRange& rng, const Value& val ) - { - boost::function_requires< SinglePassRangeConcept >(); - return range_return:: - pack(std::find(boost::begin(rng), boost::end(rng), val), - rng); - } +/// \overload +template< range_return_value re, class SinglePassRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +find( SinglePassRange& rng, const Value& val ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return range_return:: + pack(std::find(boost::begin(rng), boost::end(rng), val), + rng); +} +/// \overload +template< range_return_value re, class SinglePassRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +find( const SinglePassRange& rng, const Value& val ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return range_return:: + pack(std::find(boost::begin(rng), boost::end(rng), val), + rng); +} + + } // namespace range + using range::find; } #endif // include guard diff --git a/include/boost/range/algorithm/find_end.hpp b/include/boost/range/algorithm/find_end.hpp index a16478a..aaf4888 100755 --- a/include/boost/range/algorithm/find_end.hpp +++ b/include/boost/range/algorithm/find_end.hpp @@ -18,119 +18,125 @@ namespace boost { - /// \brief template function find_end - /// - /// range-based version of the find_end std algorithm - /// - /// \pre ForwardRange1 is a model of the ForwardRangeConcept - /// \pre ForwardRange2 is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type - find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return std::find_end(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } - - /// \overload - template< class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return std::find_end(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } - - /// \overload - template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return std::find_end(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); - } - - /// \overload - template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return std::find_end(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_end(ForwardRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_end(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)), - rng1); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_end(const ForwardRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_end(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)), - rng1); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2, - class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_end(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred), - rng1); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2, - class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_end(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred), - rng1); - } +/// \brief template function find_end +/// +/// range-based version of the find_end std algorithm +/// +/// \pre ForwardRange1 is a model of the ForwardRangeConcept +/// \pre ForwardRange2 is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template< class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type +find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); } +/// \overload +template< class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2) +{ + + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); +} + +/// \overload +template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); +} + +/// \overload +template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return std::find_end(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); +} + +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_end(ForwardRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); +} + +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); +} + +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred), + rng1); +} + +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_end(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred), + rng1); +} + + } // namespace range + using range::find_end; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/find_first_of.hpp b/include/boost/range/algorithm/find_first_of.hpp index 70d143c..3902cd0 100755 --- a/include/boost/range/algorithm/find_first_of.hpp +++ b/include/boost/range/algorithm/find_first_of.hpp @@ -18,122 +18,127 @@ namespace boost { - /// \brief template function find_first_of - /// - /// range-based version of the find_first_of std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre ForwardRange2 is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< class SinglePassRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return std::find_first_of(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } - - /// \overload - template< class SinglePassRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_first_of(SinglePassRange1 const & rng1, ForwardRange2 const & rng2) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return std::find_first_of(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } - - /// \overload - template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return std::find_first_of(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); - } - - /// \overload - template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return std::find_first_of(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); - } - -// range return overloads - /// \overload - template< range_return_value re, class SinglePassRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)), - rng1); - } - - /// \overload - template< range_return_value re, class SinglePassRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)), - rng1); - } - - /// \overload - template< range_return_value re, class SinglePassRange1, class ForwardRange2, - class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred), - rng1); - } - - /// \overload - template< range_return_value re, class SinglePassRange1, class ForwardRange2, - class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - - return range_return:: - pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2),pred), - rng1); - } +/// \brief template function find_first_of +/// +/// range-based version of the find_first_of std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre ForwardRange2 is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template< class SinglePassRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); } +/// \overload +template< class SinglePassRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_first_of(SinglePassRange1 const & rng1, ForwardRange2 const & rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); +} + +/// \overload +template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); +} + +/// \overload +template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return std::find_first_of(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); +} + +// range return overloads +/// \overload +template< range_return_value re, class SinglePassRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); +} + +/// \overload +template< range_return_value re, class SinglePassRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)), + rng1); +} + +/// \overload +template< range_return_value re, class SinglePassRange1, class ForwardRange2, + class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred), + rng1); +} + +/// \overload +template< range_return_value re, class SinglePassRange1, class ForwardRange2, + class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + + return range_return:: + pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2),pred), + rng1); +} + + } // namespace range + using range::find_first_of; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/find_if.hpp b/include/boost/range/algorithm/find_if.hpp index 9d13f29..f36c4e5 100755 --- a/include/boost/range/algorithm/find_if.hpp +++ b/include/boost/range/algorithm/find_if.hpp @@ -18,52 +18,56 @@ namespace boost { - /// \brief template function find_if - /// - /// range-based version of the find_if std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre UnaryPredicate is a model of the UnaryPredicateConcept - template< class SinglePassRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_if( SinglePassRange& rng, UnaryPredicate pred ) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - return std::find_if(boost::begin(rng), boost::end(rng), pred); - } - /// \overload - template< class SinglePassRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - find_if( const SinglePassRange& rng, UnaryPredicate pred ) - { - boost::function_requires< SinglePassRangeConcept >(); - return std::find_if(boost::begin(rng), boost::end(rng), pred); - } + +/// \brief template function find_if +/// +/// range-based version of the find_if std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre UnaryPredicate is a model of the UnaryPredicateConcept +template< class SinglePassRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_if( SinglePassRange& rng, UnaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::find_if(boost::begin(rng), boost::end(rng), pred); +} +/// \overload +template< class SinglePassRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +find_if( const SinglePassRange& rng, UnaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::find_if(boost::begin(rng), boost::end(rng), pred); +} // range_return overloads - /// \overload - template< range_return_value re, class SinglePassRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_if( SinglePassRange& rng, UnaryPredicate pred ) - { - boost::function_requires< SinglePassRangeConcept >(); - return range_return:: - pack(std::find_if(boost::begin(rng), boost::end(rng), pred), - rng); - } - /// \overload - template< range_return_value re, class SinglePassRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - find_if( const SinglePassRange& rng, UnaryPredicate pred ) - { - boost::function_requires< SinglePassRangeConcept >(); - return range_return:: - pack(std::find_if(boost::begin(rng), boost::end(rng), pred), - rng); - } - - +/// \overload +template< range_return_value re, class SinglePassRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_if( SinglePassRange& rng, UnaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return range_return:: + pack(std::find_if(boost::begin(rng), boost::end(rng), pred), + rng); +} +/// \overload +template< range_return_value re, class SinglePassRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +find_if( const SinglePassRange& rng, UnaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return range_return:: + pack(std::find_if(boost::begin(rng), boost::end(rng), pred), + rng); } + } // namespace range + using range::find_if; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/for_each.hpp b/include/boost/range/algorithm/for_each.hpp index 689b3e4..5145432 100755 --- a/include/boost/range/algorithm/for_each.hpp +++ b/include/boost/range/algorithm/for_each.hpp @@ -17,26 +17,32 @@ namespace boost { - /// \brief template function for_each - /// - /// range-based version of the for_each std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre UnaryFunction is a model of the UnaryFunctionConcept - template< class SinglePassRange, class UnaryFunction > - inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun) + namespace range { - boost::function_requires< SinglePassRangeConcept< SinglePassRange > >(); - return std::for_each(boost::begin(rng),boost::end(rng),fun); - } - /// \overload - template< class SinglePassRange, class UnaryFunction > - inline UnaryFunction for_each(SinglePassRange const & rng, UnaryFunction fun) - { - boost::function_requires< SinglePassRangeConcept< SinglePassRange > >(); - return std::for_each(boost::begin(rng),boost::end(rng),fun); - } +/// \brief template function for_each +/// +/// range-based version of the for_each std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre UnaryFunction is a model of the UnaryFunctionConcept +template< class SinglePassRange, class UnaryFunction > +inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::for_each(boost::begin(rng),boost::end(rng),fun); +} + +/// \overload +template< class SinglePassRange, class UnaryFunction > +inline UnaryFunction for_each(SinglePassRange const & rng, UnaryFunction fun) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::for_each(boost::begin(rng),boost::end(rng),fun); +} + + } // namespace range + using range::for_each; } // namespace boost #endif // include guard diff --git a/include/boost/range/algorithm/generate.hpp b/include/boost/range/algorithm/generate.hpp index 48bdb70..7b7dde7 100755 --- a/include/boost/range/algorithm/generate.hpp +++ b/include/boost/range/algorithm/generate.hpp @@ -17,28 +17,33 @@ namespace boost { - /// \brief template function generate - /// - /// range-based version of the generate std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre Generator is a model of the UnaryFunctionConcept - template< class ForwardRange, class Generator > - inline ForwardRange& generate( ForwardRange& rng, Generator gen ) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - std::generate(boost::begin(rng), boost::end(rng), gen); - return rng; - } - - /// \overload - template< class ForwardRange, class Generator > - inline const ForwardRange& generate(const ForwardRange& rng, Generator gen) - { - boost::function_requires< ForwardRangeConcept >(); - std::generate(boost::begin(rng), boost::end(rng), gen); - return rng; - } +/// \brief template function generate +/// +/// range-based version of the generate std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre Generator is a model of the UnaryFunctionConcept +template< class ForwardRange, class Generator > +inline ForwardRange& generate( ForwardRange& rng, Generator gen ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::generate(boost::begin(rng), boost::end(rng), gen); + return rng; } +/// \overload +template< class ForwardRange, class Generator > +inline const ForwardRange& generate(const ForwardRange& rng, Generator gen) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::generate(boost::begin(rng), boost::end(rng), gen); + return rng; +} + + } // namespace range + using range::generate; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/heap_algorithm.hpp b/include/boost/range/algorithm/heap_algorithm.hpp index 411b1ab..05c9013 100755 --- a/include/boost/range/algorithm/heap_algorithm.hpp +++ b/include/boost/range/algorithm/heap_algorithm.hpp @@ -17,153 +17,162 @@ namespace boost { - /// \brief template function push_heap - /// - /// range-based version of the push_heap std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre Compare is a model of the BinaryPredicateConcept - template - inline void push_heap(RandomAccessRange& rng) + namespace range { - boost::function_requires< RandomAccessRangeConcept >(); - std::push_heap(boost::begin(rng), boost::end(rng)); - } - /// \overload - template - inline void push_heap(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::push_heap(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline void push_heap(RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \overload - template - inline void push_heap(const RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \brief template function pop_heap - /// - /// range-based version of the pop_heap std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre Compare is a model of the BinaryPredicateConcept - template - inline void pop_heap(RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::pop_heap(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline void pop_heap(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::pop_heap(boost::begin(rng),boost::end(rng)); - } - - /// \overload - template - inline void pop_heap(RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \overload - template - inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \brief template function make_heap - /// - /// range-based version of the make_heap std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre Compare is a model of the BinaryPredicateConcept - template - inline void make_heap(RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::make_heap(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline void make_heap(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::make_heap(boost::begin(rng),boost::end(rng)); - } - - /// \overload - template - inline void make_heap(RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \overload - template - inline void make_heap(const RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \brief template function sort_heap - /// - /// range-based version of the sort_heap std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre Compare is a model of the BinaryPredicateConcept - template - inline void sort_heap(RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort_heap(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline void sort_heap(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort_heap(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline void sort_heap(RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); - } - - /// \overload - template - inline void sort_heap(const RandomAccessRange& rng, Compare comp_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); - } +/// \brief template function push_heap +/// +/// range-based version of the push_heap std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre Compare is a model of the BinaryPredicateConcept +template +inline void push_heap(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::push_heap(boost::begin(rng), boost::end(rng)); } +/// \overload +template +inline void push_heap(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::push_heap(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline void push_heap(RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \overload +template +inline void push_heap(const RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \brief template function pop_heap +/// +/// range-based version of the pop_heap std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre Compare is a model of the BinaryPredicateConcept +template +inline void pop_heap(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::pop_heap(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline void pop_heap(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::pop_heap(boost::begin(rng),boost::end(rng)); +} + +/// \overload +template +inline void pop_heap(RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \overload +template +inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \brief template function make_heap +/// +/// range-based version of the make_heap std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre Compare is a model of the BinaryPredicateConcept +template +inline void make_heap(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::make_heap(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline void make_heap(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::make_heap(boost::begin(rng),boost::end(rng)); +} + +/// \overload +template +inline void make_heap(RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \overload +template +inline void make_heap(const RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \brief template function sort_heap +/// +/// range-based version of the sort_heap std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre Compare is a model of the BinaryPredicateConcept +template +inline void sort_heap(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort_heap(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline void sort_heap(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort_heap(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline void sort_heap(RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + +/// \overload +template +inline void sort_heap(const RandomAccessRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); +} + + } // namespace range + using range::push_heap; + using range::pop_heap; + using range::make_heap; + using range::sort_heap; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/inplace_merge.hpp b/include/boost/range/algorithm/inplace_merge.hpp index 419dabf..867b70c 100755 --- a/include/boost/range/algorithm/inplace_merge.hpp +++ b/include/boost/range/algorithm/inplace_merge.hpp @@ -17,52 +17,58 @@ namespace boost { - /// \brief template function inplace_merge - /// - /// range-based version of the inplace_merge std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type middle) + namespace range { - boost::function_requires< BidirectionalRangeConcept >(); - std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); - return rng; - } - /// \overload - template - inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle) - { - boost::function_requires< BidirectionalRangeConcept >(); - std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); - return rng; - } - - /// \overload - template - inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, - BinaryPredicate pred) - { - boost::function_requires< BidirectionalRangeConcept >(); - std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); - return rng; - } - - /// \overload - template - inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, - BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, - BinaryPredicate pred) - { - boost::function_requires< BidirectionalRangeConcept >(); - std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); - return rng; - } +/// \brief template function inplace_merge +/// +/// range-based version of the inplace_merge std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); + return rng; } +/// \overload +template +inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); + return rng; +} + +/// \overload +template +inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); + return rng; +} + +/// \overload +template +inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, + BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); + return rng; +} + + } // namespace range + using range::inplace_merge; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/lexicographical_compare.hpp b/include/boost/range/algorithm/lexicographical_compare.hpp index dc79d09..9c72526 100755 --- a/include/boost/range/algorithm/lexicographical_compare.hpp +++ b/include/boost/range/algorithm/lexicographical_compare.hpp @@ -17,36 +17,42 @@ namespace boost { - /// \brief template function lexicographic_compare - /// - /// range-based version of the lexicographic_compare std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - template - inline bool lexicographical_compare(const SinglePassRange1& rng1, - const SinglePassRange2& rng2) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::lexicographical_compare( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)); - } - /// \overload - template - inline bool lexicographical_compare(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::lexicographical_compare( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } +/// \brief template function lexicographic_compare +/// +/// range-based version of the lexicographic_compare std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +template +inline bool lexicographical_compare(const SinglePassRange1& rng1, + const SinglePassRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::lexicographical_compare( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); } +/// \overload +template +inline bool lexicographical_compare(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::lexicographical_compare( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); +} + + } // namespace range + using range::lexicographical_compare; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/lower_bound.hpp b/include/boost/range/algorithm/lower_bound.hpp index 3bd313e..682ba36 100755 --- a/include/boost/range/algorithm/lower_bound.hpp +++ b/include/boost/range/algorithm/lower_bound.hpp @@ -18,82 +18,88 @@ namespace boost { - /// \brief template function lower_bound - /// - /// range-based version of the lower_bound std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - lower_bound( ForwardRange& rng, Value val ) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::lower_bound(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template< class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - lower_bound( const ForwardRange& rng, Value val ) - { - boost::function_requires< ForwardRangeConcept >(); - return std::lower_bound(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template< class ForwardRange, class Value, class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); - } - /// \overload - template< class ForwardRange, class Value, class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - lower_bound( ForwardRange& rng, Value val ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - lower_bound( const ForwardRange& rng, Value val ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value, class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value, class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), - rng); - } + +/// \brief template function lower_bound +/// +/// range-based version of the lower_bound std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +lower_bound( ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::lower_bound(boost::begin(rng), boost::end(rng), val); +} +/// \overload +template< class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +lower_bound( const ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::lower_bound(boost::begin(rng), boost::end(rng), val); +} +/// \overload +template< class ForwardRange, class Value, class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); +} +/// \overload +template< class ForwardRange, class Value, class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +lower_bound( ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +lower_bound( const ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value, class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value, class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); } + } // namespace range + using range::lower_bound; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/max_element.hpp b/include/boost/range/algorithm/max_element.hpp index 8274ff3..3e4df5f 100755 --- a/include/boost/range/algorithm/max_element.hpp +++ b/include/boost/range/algorithm/max_element.hpp @@ -18,92 +18,98 @@ namespace boost { - /// \brief template function max_element - /// - /// range-based version of the max_element std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - max_element(ForwardRange& rng) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::max_element(boost::begin(rng), boost::end(rng)); - } - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - max_element(const ForwardRange& rng) - { - boost::function_requires< ForwardRangeConcept >(); - return std::max_element(boost::begin(rng), boost::end(rng)); - } +/// \brief template function max_element +/// +/// range-based version of the max_element std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +max_element(ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::max_element(boost::begin(rng), boost::end(rng)); +} - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - max_element(ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::max_element(boost::begin(rng), boost::end(rng), pred); - } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +max_element(const ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::max_element(boost::begin(rng), boost::end(rng)); +} - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - max_element(const ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::max_element(boost::begin(rng), boost::end(rng), pred); - } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +max_element(ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::max_element(boost::begin(rng), boost::end(rng), pred); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +max_element(const ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::max_element(boost::begin(rng), boost::end(rng), pred); +} // range_return overloads - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - max_element(ForwardRange& rng) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng)), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - max_element(const ForwardRange& rng) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng)), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - max_element(ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng), pred), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - max_element(const ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng), pred), - rng); - } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +max_element(ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng)), + rng); } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +max_element(const ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng)), + rng); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +max_element(ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng), pred), + rng); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +max_element(const ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::max_element(boost::begin(rng), boost::end(rng), pred), + rng); +} + + } // namespace range + using range::max_element; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/merge.hpp b/include/boost/range/algorithm/merge.hpp index 61bf7c2..7f6030c 100755 --- a/include/boost/range/algorithm/merge.hpp +++ b/include/boost/range/algorithm/merge.hpp @@ -17,39 +17,45 @@ namespace boost { - /// \brief template function merge - /// - /// range-based version of the merge std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - /// - template - inline OutputIterator merge(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::merge(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out); - } - /// \overload - template - inline OutputIterator merge(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::merge(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out, pred); - } +/// \brief template function merge +/// +/// range-based version of the merge std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +/// +template +inline OutputIterator merge(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::merge(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); } +/// \overload +template +inline OutputIterator merge(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::merge(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); +} + + } // namespace range + using range::merge; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/min_element.hpp b/include/boost/range/algorithm/min_element.hpp index 66f87f0..1fb0f24 100755 --- a/include/boost/range/algorithm/min_element.hpp +++ b/include/boost/range/algorithm/min_element.hpp @@ -18,92 +18,98 @@ namespace boost { - /// \brief template function min_element - /// - /// range-based version of the min_element std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - min_element(ForwardRange& rng) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::min_element(boost::begin(rng), boost::end(rng)); - } - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - min_element(const ForwardRange& rng) - { - boost::function_requires< ForwardRangeConcept >(); - return std::min_element(boost::begin(rng), boost::end(rng)); - } +/// \brief template function min_element +/// +/// range-based version of the min_element std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +min_element(ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::min_element(boost::begin(rng), boost::end(rng)); +} - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - min_element(ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::min_element(boost::begin(rng), boost::end(rng), pred); - } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +min_element(const ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::min_element(boost::begin(rng), boost::end(rng)); +} - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - min_element(const ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::min_element(boost::begin(rng), boost::end(rng), pred); - } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +min_element(ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::min_element(boost::begin(rng), boost::end(rng), pred); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +min_element(const ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::min_element(boost::begin(rng), boost::end(rng), pred); +} // range_return overloads - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - min_element(ForwardRange& rng) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng)), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - min_element(const ForwardRange& rng) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng)), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - min_element(ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng), pred), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - min_element(const ForwardRange& rng, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng), pred), - rng); - } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +min_element(ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng)), + rng); } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +min_element(const ForwardRange& rng) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng)), + rng); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +min_element(ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng), pred), + rng); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +min_element(const ForwardRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::min_element(boost::begin(rng), boost::end(rng), pred), + rng); +} + + } // namespace range + using range::min_element; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/mismatch.hpp b/include/boost/range/algorithm/mismatch.hpp index 71198c2..c1cfa87 100755 --- a/include/boost/range/algorithm/mismatch.hpp +++ b/include/boost/range/algorithm/mismatch.hpp @@ -57,126 +57,139 @@ namespace boost return std::pair(first1, first2); } - } + } // namespace range_detail - /// \brief template function mismatch - /// - /// range-based version of the mismatch std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< class SinglePassRange1, class SinglePassRange2 > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); +/// \brief template function mismatch +/// +/// range-based version of the mismatch std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template< class SinglePassRange1, class SinglePassRange2 > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)); - } - - /// \overload - template< class SinglePassRange1, class SinglePassRange2 > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)); - } - - /// \overload - template< class SinglePassRange1, class SinglePassRange2 > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)); - } - - /// \overload - template< class SinglePassRange1, class SinglePassRange2 > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)); - } - - - /// \overload - template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } - - /// \overload - template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } - - /// \overload - template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } - - /// \overload - template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > - inline std::pair< - BOOST_DEDUCED_TYPENAME range_iterator::type, - BOOST_DEDUCED_TYPENAME range_iterator::type > - mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - - return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2)); } +/// \overload +template< class SinglePassRange1, class SinglePassRange2 > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2)); +} + +/// \overload +template< class SinglePassRange1, class SinglePassRange2 > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2)); +} + +/// \overload +template< class SinglePassRange1, class SinglePassRange2 > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2)); +} + + +/// \overload +template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), pred); +} + +/// \overload +template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), pred); +} + +/// \overload +template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), pred); +} + +/// \overload +template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate > +inline std::pair< + BOOST_DEDUCED_TYPENAME range_iterator::type, + BOOST_DEDUCED_TYPENAME range_iterator::type > +mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::mismatch_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), pred); +} + + } // namespace range + using range::mismatch; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/nth_element.hpp b/include/boost/range/algorithm/nth_element.hpp index d082a6a..431aa23 100755 --- a/include/boost/range/algorithm/nth_element.hpp +++ b/include/boost/range/algorithm/nth_element.hpp @@ -17,48 +17,54 @@ namespace boost { - /// \brief template function nth_element - /// - /// range-based version of the nth_element std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline void nth_element(RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type nth) + namespace range { - boost::function_requires< RandomAccessRangeConcept >(); - std::nth_element(boost::begin(rng), nth, boost::end(rng)); - } - /// \overload - template - inline void nth_element(const RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type nth) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::nth_element(boost::begin(rng),nth,boost::end(rng)); - } - - /// \overload - template - inline void nth_element(RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type nth, - BinaryPredicate sort_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred); - } - - /// \overload - template - inline void nth_element(const RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type nth, - BinaryPredicate sort_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::nth_element(boost::begin(rng),nth,boost::end(rng), sort_pred); - } +/// \brief template function nth_element +/// +/// range-based version of the nth_element std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline void nth_element(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::nth_element(boost::begin(rng), nth, boost::end(rng)); } +/// \overload +template +inline void nth_element(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::nth_element(boost::begin(rng),nth,boost::end(rng)); +} + +/// \overload +template +inline void nth_element(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth, + BinaryPredicate sort_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred); +} + +/// \overload +template +inline void nth_element(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type nth, + BinaryPredicate sort_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::nth_element(boost::begin(rng),nth,boost::end(rng), sort_pred); +} + + } // namespace range + using range::nth_element; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/partial_sort.hpp b/include/boost/range/algorithm/partial_sort.hpp index a80d544..2881bd4 100755 --- a/include/boost/range/algorithm/partial_sort.hpp +++ b/include/boost/range/algorithm/partial_sort.hpp @@ -17,49 +17,55 @@ namespace boost { - /// \brief template function partial_sort - /// - /// range-based version of the partial_sort std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline void partial_sort(RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type middle) + namespace range { - boost::function_requires< RandomAccessRangeConcept >(); - std::partial_sort(boost::begin(rng), middle, boost::end(rng)); - } - /// \overload - template - inline void partial_sort(const RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type middle) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::partial_sort(boost::begin(rng), middle, boost::end(rng)); - } - - /// \overload - template - inline void partial_sort(RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type middle, - BinaryPredicate sort_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::partial_sort(boost::begin(rng), middle, boost::end(rng), - sort_pred); - } - - /// \overload - template - inline void partial_sort(const RandomAccessRange& rng, - BOOST_DEDUCED_TYPENAME range_iterator::type middle, - BinaryPredicate sort_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred); - } +/// \brief template function partial_sort +/// +/// range-based version of the partial_sort std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline void partial_sort(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::partial_sort(boost::begin(rng), middle, boost::end(rng)); } +/// \overload +template +inline void partial_sort(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::partial_sort(boost::begin(rng), middle, boost::end(rng)); +} + +/// \overload +template +inline void partial_sort(RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle, + BinaryPredicate sort_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::partial_sort(boost::begin(rng), middle, boost::end(rng), + sort_pred); +} + +/// \overload +template +inline void partial_sort(const RandomAccessRange& rng, + BOOST_DEDUCED_TYPENAME range_iterator::type middle, + BinaryPredicate sort_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred); +} + + } // namespace range + using range::partial_sort; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/partial_sort_copy.hpp b/include/boost/range/algorithm/partial_sort_copy.hpp index 5adf435..d95cf27 100755 --- a/include/boost/range/algorithm/partial_sort_copy.hpp +++ b/include/boost/range/algorithm/partial_sort_copy.hpp @@ -18,41 +18,47 @@ namespace boost { - /// \brief template function partial_sort_copy - /// - /// range-based version of the partial_sort_copy std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre RandomAccessRange is a model of the Mutable_RandomAccessRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline typename range_iterator::type - partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2) + namespace range { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); - BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); - BOOST_CONCEPT_ASSERT((LessThanComparableConcept::type>)); - return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)); - } +/// \brief template function partial_sort_copy +/// +/// range-based version of the partial_sort_copy std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre RandomAccessRange is a model of the Mutable_RandomAccessRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline typename range_iterator::type +partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2) +{ + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); + BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); + BOOST_CONCEPT_ASSERT((LessThanComparableConcept::type>)); - /// \overload - template - inline typename range_iterator::type - partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2, - BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); - BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); - - return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } + return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2)); } +/// \overload +template +inline typename range_iterator::type +partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); + BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); + + return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); +} + + } // namespace range + using range::partial_sort_copy; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/partition.hpp b/include/boost/range/algorithm/partition.hpp index 779a32d..f7dfbbb 100755 --- a/include/boost/range/algorithm/partition.hpp +++ b/include/boost/range/algorithm/partition.hpp @@ -18,51 +18,57 @@ namespace boost { - /// \brief template function partition - /// - /// range-based version of the partition std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - partition(ForwardRange& rng, UnaryPredicate pred) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::partition(boost::begin(rng),boost::end(rng),pred); - } - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - partition(const ForwardRange& rng, UnaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::partition(boost::begin(rng),boost::end(rng),pred); - } +/// \brief template function partition +/// +/// range-based version of the partition std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +partition(ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::partition(boost::begin(rng),boost::end(rng),pred); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +partition(const ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::partition(boost::begin(rng),boost::end(rng),pred); +} // range_return overloads - /// \overload - template< range_return_value re, class ForwardRange, - class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - partition(ForwardRange& rng, UnaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return boost::range_return:: - pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); - } - - /// \overload - template< range_return_value re, class ForwardRange, - class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - partition(const ForwardRange& rng, UnaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return boost::range_return:: - pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); - } +/// \overload +template< range_return_value re, class ForwardRange, + class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +partition(ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return boost::range_return:: + pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); } +/// \overload +template< range_return_value re, class ForwardRange, + class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +partition(const ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return boost::range_return:: + pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); +} + + } // namespace range + using range::partition; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/permutation.hpp b/include/boost/range/algorithm/permutation.hpp index 01dee35..6a80ef8 100755 --- a/include/boost/range/algorithm/permutation.hpp +++ b/include/boost/range/algorithm/permutation.hpp @@ -17,101 +17,92 @@ namespace boost { - /// \brief template function next_permutation - /// - /// range-based version of the next_permutation std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - /// \pre Compare is a model of the BinaryPredicateConcept - template - inline bool next_permutation(BidirectionalRange& rng) + namespace range { - boost::function_requires< - BidirectionalRangeConcept >(); - return std::next_permutation(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline bool next_permutation(const BidirectionalRange& rng) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::next_permutation(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::next_permutation(boost::begin(rng), boost::end(rng), - comp_pred); - } - - /// \overload - template - inline bool next_permutation(const BidirectionalRange& rng, - Compare comp_pred) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::next_permutation(boost::begin(rng), boost::end(rng), - comp_pred); - } - - /// \brief template function prev_permutation - /// - /// range-based version of the prev_permutation std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - /// \pre Compare is a model of the BinaryPredicateConcept - template - inline bool prev_permutation(BidirectionalRange& rng) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::prev_permutation(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline bool prev_permutation(const BidirectionalRange& rng) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::prev_permutation(boost::begin(rng), boost::end(rng)); - } - - /// \overload - template - inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::prev_permutation(boost::begin(rng), boost::end(rng), - comp_pred); - } - - /// \overload - template - inline bool prev_permutation(const BidirectionalRange& rng, - Compare comp_pred) - { - boost::function_requires< - BidirectionalRangeConcept >(); - - return std::prev_permutation(boost::begin(rng), boost::end(rng), - comp_pred); - } +/// \brief template function next_permutation +/// +/// range-based version of the next_permutation std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +/// \pre Compare is a model of the BinaryPredicateConcept +template +inline bool next_permutation(BidirectionalRange& rng) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::next_permutation(boost::begin(rng), boost::end(rng)); } +/// \overload +template +inline bool next_permutation(const BidirectionalRange& rng) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::next_permutation(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::next_permutation(boost::begin(rng), boost::end(rng), + comp_pred); +} + +/// \overload +template +inline bool next_permutation(const BidirectionalRange& rng, + Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::next_permutation(boost::begin(rng), boost::end(rng), + comp_pred); +} + +/// \brief template function prev_permutation +/// +/// range-based version of the prev_permutation std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +/// \pre Compare is a model of the BinaryPredicateConcept +template +inline bool prev_permutation(BidirectionalRange& rng) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::prev_permutation(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline bool prev_permutation(const BidirectionalRange& rng) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::prev_permutation(boost::begin(rng), boost::end(rng)); +} + +/// \overload +template +inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::prev_permutation(boost::begin(rng), boost::end(rng), + comp_pred); +} + +/// \overload +template +inline bool prev_permutation(const BidirectionalRange& rng, + Compare comp_pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::prev_permutation(boost::begin(rng), boost::end(rng), + comp_pred); +} + + } // namespace range + using range::next_permutation; + using range::prev_permutation; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/random_shuffle.hpp b/include/boost/range/algorithm/random_shuffle.hpp index dbc35b0..b90bdd1 100755 --- a/include/boost/range/algorithm/random_shuffle.hpp +++ b/include/boost/range/algorithm/random_shuffle.hpp @@ -17,46 +17,52 @@ namespace boost { - /// \brief template function random_shuffle - /// - /// range-based version of the random_shuffle std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre Generator is a model of the UnaryFunctionConcept - template - inline RandomAccessRange& random_shuffle(RandomAccessRange& rng) + namespace range { - boost::function_requires< RandomAccessRangeConcept >(); - std::random_shuffle(boost::begin(rng), boost::end(rng)); - return rng; - } - /// \overload - template - inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::random_shuffle(boost::begin(rng),boost::end(rng)); - return rng; - } - - /// \overload - template - inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::random_shuffle(boost::begin(rng), boost::end(rng), gen); - return rng; - } - - /// \overload - template - inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::random_shuffle(boost::begin(rng), boost::end(rng), gen); - return rng; - } +/// \brief template function random_shuffle +/// +/// range-based version of the random_shuffle std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre Generator is a model of the UnaryFunctionConcept +template +inline RandomAccessRange& random_shuffle(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::random_shuffle(boost::begin(rng), boost::end(rng)); + return rng; } +/// \overload +template +inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::random_shuffle(boost::begin(rng),boost::end(rng)); + return rng; +} + +/// \overload +template +inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::random_shuffle(boost::begin(rng), boost::end(rng), gen); + return rng; +} + +/// \overload +template +inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::random_shuffle(boost::begin(rng), boost::end(rng), gen); + return rng; +} + + } // namespace range + using range::random_shuffle; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/remove.hpp b/include/boost/range/algorithm/remove.hpp index 093d831..ed4dad0 100755 --- a/include/boost/range/algorithm/remove.hpp +++ b/include/boost/range/algorithm/remove.hpp @@ -18,53 +18,57 @@ namespace boost { - /// \brief template function remove - /// - /// range-based version of the remove std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - remove(ForwardRange& rng, const Value& val) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::remove(boost::begin(rng),boost::end(rng),val); - } - /// \overload - template< class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - remove(const ForwardRange& rng, const Value& val) - { - boost::function_requires< ForwardRangeConcept >(); - return std::remove(boost::begin(rng),boost::end(rng),val); - } - -// range_return overloads - - /// \overload - template< range_return_value re, class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - remove(ForwardRange& rng, const Value& val) - { - boost::function_requires< ForwardRangeConcept >(); - - return range_return::pack( - std::remove(boost::begin(rng), boost::end(rng), val), - rng); - } - - /// \overload - template< range_return_value re, class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - remove(const ForwardRange& rng, const Value& val) - { - boost::function_requires< ForwardRangeConcept >(); - - return range_return::pack( - std::remove(boost::begin(rng), boost::end(rng), val), - rng); - } +/// \brief template function remove +/// +/// range-based version of the remove std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +remove(ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::remove(boost::begin(rng),boost::end(rng),val); } +/// \overload +template< class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +remove(const ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::remove(boost::begin(rng),boost::end(rng),val); +} + +// range_return overloads + +/// \overload +template< range_return_value re, class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +remove(ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::remove(boost::begin(rng), boost::end(rng), val), + rng); +} + +/// \overload +template< range_return_value re, class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +remove(const ForwardRange& rng, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::remove(boost::begin(rng), boost::end(rng), val), + rng); +} + + } // namespace range + using range::remove; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/remove_copy.hpp b/include/boost/range/algorithm/remove_copy.hpp index 75b84cb..1568240 100755 --- a/include/boost/range/algorithm/remove_copy.hpp +++ b/include/boost/range/algorithm/remove_copy.hpp @@ -17,22 +17,28 @@ namespace boost { - /// \brief template function remove_copy - /// - /// range-based version of the remove_copy std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre OutputIterator is a model of the OutputIteratorConcept - /// \pre Value is a model of the EqualityComparableConcept - /// \pre Objects of type Value can be compared for equality with objects of - /// InputIterator's value type. - template< class SinglePassRange, class OutputIterator, class Value > - inline OutputIterator - remove_copy(SinglePassRange& rng, OutputIterator out_it, const Value& val) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val); - } + +/// \brief template function remove_copy +/// +/// range-based version of the remove_copy std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre OutputIterator is a model of the OutputIteratorConcept +/// \pre Value is a model of the EqualityComparableConcept +/// \pre Objects of type Value can be compared for equality with objects of +/// InputIterator's value type. +template< class SinglePassRange, class OutputIterator, class Value > +inline OutputIterator +remove_copy(SinglePassRange& rng, OutputIterator out_it, const Value& val) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val); } + } // namespace range + using range::remove_copy; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/remove_if.hpp b/include/boost/range/algorithm/remove_if.hpp index 2c0bbe9..5a51d13 100755 --- a/include/boost/range/algorithm/remove_if.hpp +++ b/include/boost/range/algorithm/remove_if.hpp @@ -18,53 +18,58 @@ namespace boost { - /// \brief template function remove_if - /// - /// range-based version of the remove_if std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre UnaryPredicate is a model of the UnaryPredicateConcept - template< class ForwardRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type - remove_if(ForwardRange& rng, UnaryPredicate pred) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::remove_if(boost::begin(rng), boost::end(rng), pred); - } - /// \overload - template< class ForwardRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type - remove_if(const ForwardRange& rng, UnaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return std::remove_if(boost::begin(rng),boost::end(rng),pred); - } +/// \brief template function remove_if +/// +/// range-based version of the remove_if std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre UnaryPredicate is a model of the UnaryPredicateConcept +template< class ForwardRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type +remove_if(ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::remove_if(boost::begin(rng), boost::end(rng), pred); +} + +/// \overload +template< class ForwardRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type +remove_if(const ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::remove_if(boost::begin(rng),boost::end(rng),pred); +} // range_return overloads - /// \overload - template< range_return_value re, class ForwardRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - remove_if(ForwardRange& rng, UnaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::remove_if(boost::begin(rng), boost::end(rng), pred), - rng); - } - - /// \overload - template< range_return_value re, class ForwardRange, class UnaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - remove_if(const ForwardRange& rng, UnaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return::pack( - std::remove_if(boost::begin(rng), boost::end(rng), pred), - rng); - } - +/// \overload +template< range_return_value re, class ForwardRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +remove_if(ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::remove_if(boost::begin(rng), boost::end(rng), pred), + rng); } +/// \overload +template< range_return_value re, class ForwardRange, class UnaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +remove_if(const ForwardRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return::pack( + std::remove_if(boost::begin(rng), boost::end(rng), pred), + rng); +} + + } // namespace range + using range::remove_if; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/replace.hpp b/include/boost/range/algorithm/replace.hpp index ec105de..2d1d537 100755 --- a/include/boost/range/algorithm/replace.hpp +++ b/include/boost/range/algorithm/replace.hpp @@ -17,31 +17,37 @@ namespace boost { - /// \brief template function replace - /// - /// range-based version of the replace std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class Value > - inline ForwardRange& - replace(ForwardRange& rng, const Value& what, - const Value& with_what) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - std::replace(boost::begin(rng), boost::end(rng), what, with_what); - return rng; - } - /// \overload - template< class ForwardRange, class Value > - inline const ForwardRange& - replace(const ForwardRange& rng, const Value& what, - const Value& with_what) - { - boost::function_requires< ForwardRangeConcept >(); - std::replace(boost::begin(rng), boost::end(rng), what, with_what); - return rng; - } +/// \brief template function replace +/// +/// range-based version of the replace std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class Value > +inline ForwardRange& +replace(ForwardRange& rng, const Value& what, + const Value& with_what) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::replace(boost::begin(rng), boost::end(rng), what, with_what); + return rng; } +/// \overload +template< class ForwardRange, class Value > +inline const ForwardRange& +replace(const ForwardRange& rng, const Value& what, + const Value& with_what) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::replace(boost::begin(rng), boost::end(rng), what, with_what); + return rng; +} + + } // namespace range + using range::replace; +} // namespace boost; + #endif // include guard diff --git a/include/boost/range/algorithm/replace_copy.hpp b/include/boost/range/algorithm/replace_copy.hpp index f4250b1..cfdd2d5 100755 --- a/include/boost/range/algorithm/replace_copy.hpp +++ b/include/boost/range/algorithm/replace_copy.hpp @@ -17,20 +17,26 @@ namespace boost { - /// \brief template function replace_copy - /// - /// range-based version of the replace_copy std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class OutputIterator, class Value > - inline OutputIterator - replace_copy(ForwardRange& rng, OutputIterator out_it, const Value& what, - const Value& with_what) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::replace_copy(boost::begin(rng), boost::end(rng), out_it, - what, with_what); - } + +/// \brief template function replace_copy +/// +/// range-based version of the replace_copy std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class OutputIterator, class Value > +inline OutputIterator +replace_copy(ForwardRange& rng, OutputIterator out_it, const Value& what, + const Value& with_what) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::replace_copy(boost::begin(rng), boost::end(rng), out_it, + what, with_what); } + } // namespace range + using range::replace_copy; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/replace_copy_if.hpp b/include/boost/range/algorithm/replace_copy_if.hpp index c03cb95..ba34e38 100755 --- a/include/boost/range/algorithm/replace_copy_if.hpp +++ b/include/boost/range/algorithm/replace_copy_if.hpp @@ -17,24 +17,30 @@ namespace boost { - /// \brief template function replace_copy_if - /// - /// range-based version of the replace_copy_if std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre Predicate is a model of the PredicateConcept - /// \pre Value is convertible to Predicate's argument type - /// \pre Value is Assignable - /// \pre Value is convertible to a type in OutputIterator's set of value types. - template< class ForwardRange, class OutputIterator, class Predicate, class Value > - inline OutputIterator - replace_copy_if(ForwardRange& rng, OutputIterator out_it, Predicate pred, - const Value& with_what) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it, - pred, with_what); - } + +/// \brief template function replace_copy_if +/// +/// range-based version of the replace_copy_if std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre Predicate is a model of the PredicateConcept +/// \pre Value is convertible to Predicate's argument type +/// \pre Value is Assignable +/// \pre Value is convertible to a type in OutputIterator's set of value types. +template< class ForwardRange, class OutputIterator, class Predicate, class Value > +inline OutputIterator +replace_copy_if(ForwardRange& rng, OutputIterator out_it, Predicate pred, + const Value& with_what) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it, + pred, with_what); } + } // namespace range + using range::replace_copy_if; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/replace_if.hpp b/include/boost/range/algorithm/replace_if.hpp index bbee464..211e895 100755 --- a/include/boost/range/algorithm/replace_if.hpp +++ b/include/boost/range/algorithm/replace_if.hpp @@ -17,33 +17,38 @@ namespace boost { - /// \brief template function replace_if - /// - /// range-based version of the replace_if std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre UnaryPredicate is a model of the UnaryPredicateConcept - template< class ForwardRange, class UnaryPredicate, class Value > - inline ForwardRange& - replace_if(ForwardRange& rng, UnaryPredicate pred, - const Value& val) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - std::replace_if(boost::begin(rng), boost::end(rng), pred, val); - return rng; - } - - /// \overload - template< class ForwardRange, class UnaryPredicate, class Value > - inline const ForwardRange& - replace_if(const ForwardRange& rng, UnaryPredicate pred, - const Value& val) - { - boost::function_requires< ForwardRangeConcept >(); - std::replace_if(boost::begin(rng), boost::end(rng), pred, val); - return rng; - } +/// \brief template function replace_if +/// +/// range-based version of the replace_if std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre UnaryPredicate is a model of the UnaryPredicateConcept +template< class ForwardRange, class UnaryPredicate, class Value > +inline ForwardRange& + replace_if(ForwardRange& rng, UnaryPredicate pred, + const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::replace_if(boost::begin(rng), boost::end(rng), pred, val); + return rng; } +/// \overload +template< class ForwardRange, class UnaryPredicate, class Value > +inline const ForwardRange& + replace_if(const ForwardRange& rng, UnaryPredicate pred, + const Value& val) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::replace_if(boost::begin(rng), boost::end(rng), pred, val); + return rng; +} + + } // namespace range + using range::replace_if; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/reverse.hpp b/include/boost/range/algorithm/reverse.hpp index 3015d1d..bc6d960 100755 --- a/include/boost/range/algorithm/reverse.hpp +++ b/include/boost/range/algorithm/reverse.hpp @@ -18,27 +18,33 @@ namespace boost { - /// \brief template function reverse - /// - /// range-based version of the reverse std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - template - inline BidirectionalRange& reverse(BidirectionalRange& rng) + namespace range { - boost::function_requires< BidirectionalRangeConcept >(); - std::reverse(boost::begin(rng), boost::end(rng)); - return rng; - } - /// \overload - template - inline const BidirectionalRange& reverse(const BidirectionalRange& rng) - { - boost::function_requires< BidirectionalRangeConcept >(); - std::reverse(boost::begin(rng), boost::end(rng)); - return rng; - } +/// \brief template function reverse +/// +/// range-based version of the reverse std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +template +inline BidirectionalRange& reverse(BidirectionalRange& rng) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + std::reverse(boost::begin(rng), boost::end(rng)); + return rng; } +/// \overload +template +inline const BidirectionalRange& reverse(const BidirectionalRange& rng) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + std::reverse(boost::begin(rng), boost::end(rng)); + return rng; +} + + } // namespace range + using range::reverse; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/reverse_copy.hpp b/include/boost/range/algorithm/reverse_copy.hpp index 817675a..47b1337 100755 --- a/include/boost/range/algorithm/reverse_copy.hpp +++ b/include/boost/range/algorithm/reverse_copy.hpp @@ -18,25 +18,31 @@ namespace boost { - /// \brief template function reverse_copy - /// - /// range-based version of the reverse_copy std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - template - inline OutputIterator reverse_copy(BidirectionalRange& rng, OutputIterator out) + namespace range { - BOOST_CONCEPT_ASSERT((BidirectionalRangeConcept)); - return std::reverse_copy(boost::begin(rng), boost::end(rng), out); - } - /// \overload - template - inline OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out) - { - BOOST_CONCEPT_ASSERT((BidirectionalRangeConcept)); - return std::reverse_copy(boost::begin(rng), boost::end(rng), out); - } +/// \brief template function reverse_copy +/// +/// range-based version of the reverse_copy std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +template +inline OutputIterator reverse_copy(BidirectionalRange& rng, OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::reverse_copy(boost::begin(rng), boost::end(rng), out); } +/// \overload +template +inline OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::reverse_copy(boost::begin(rng), boost::end(rng), out); +} + + } // namespace range + using range::reverse_copy; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/rotate.hpp b/include/boost/range/algorithm/rotate.hpp index 27eb0c9..8e6c377 100755 --- a/include/boost/range/algorithm/rotate.hpp +++ b/include/boost/range/algorithm/rotate.hpp @@ -17,30 +17,36 @@ namespace boost { - /// \brief template function rotate - /// - /// range-based version of the rotate std algorithm - /// - /// \pre Rng meets the requirements for a Forward range - template - inline ForwardRange& rotate(ForwardRange& rng, - typename range_iterator::type middle) + namespace range { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - std::rotate(boost::begin(rng), middle, boost::end(rng)); - return rng; - } - /// \overload - template - inline const ForwardRange& - rotate(const ForwardRange& rng, - typename range_iterator::type middle) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - std::rotate(boost::begin(rng), middle, boost::end(rng)); - return rng; - } +/// \brief template function rotate +/// +/// range-based version of the rotate std algorithm +/// +/// \pre Rng meets the requirements for a Forward range +template +inline ForwardRange& rotate(ForwardRange& rng, + typename range_iterator::type middle) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::rotate(boost::begin(rng), middle, boost::end(rng)); + return rng; } +/// \overload +template +inline const ForwardRange& + rotate(const ForwardRange& rng, + typename range_iterator::type middle) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + std::rotate(boost::begin(rng), middle, boost::end(rng)); + return rng; +} + + } // namespace range + using range::rotate; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/rotate_copy.hpp b/include/boost/range/algorithm/rotate_copy.hpp index 123ea04..6751101 100755 --- a/include/boost/range/algorithm/rotate_copy.hpp +++ b/include/boost/range/algorithm/rotate_copy.hpp @@ -18,6 +18,9 @@ namespace boost { + namespace range + { + /// \brief template function rotate /// /// range-based version of the rotate std algorithm @@ -30,9 +33,12 @@ namespace boost OutputIterator target ) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::rotate_copy(boost::begin(rng), middle, boost::end(rng), target); } -} + + } // namespace range + using range::rotate_copy; +} // namespace boost #endif // include guard diff --git a/include/boost/range/algorithm/search.hpp b/include/boost/range/algorithm/search.hpp index 62f61e0..70526ad 100755 --- a/include/boost/range/algorithm/search.hpp +++ b/include/boost/range/algorithm/search.hpp @@ -18,114 +18,119 @@ namespace boost { - /// \brief template function search - /// - /// range-based version of the search std algorithm - /// - /// \pre ForwardRange1 is a model of the ForwardRangeConcept - /// \pre ForwardRange2 is a model of the ForwardRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - search(ForwardRange1& rng1, const ForwardRange2& rng2) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } - /// \overload - template< class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - search(const ForwardRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } +/// \brief template function search +/// +/// range-based version of the search std algorithm +/// +/// \pre ForwardRange1 is a model of the ForwardRangeConcept +/// \pre ForwardRange2 is a model of the ForwardRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template< class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +search(ForwardRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); +} - /// \overload - template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); - } +/// \overload +template< class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); +} - /// \overload - template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - search(const ForwardRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); - } +/// \overload +template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); +} + +/// \overload +template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred); +} // range_return overloads - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_return::type - search(ForwardRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)), - rng1); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2 > - inline BOOST_DEDUCED_TYPENAME range_return::type - search(const ForwardRange1& rng1, const ForwardRange2& rng2) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)), - rng1); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2, - class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred), - rng1); - } - - /// \overload - template< range_return_value re, class ForwardRange1, class ForwardRange2, - class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - search(const ForwardRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< ForwardRangeConcept >(); - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::search(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred), - rng1); - } - +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_return::type +search(ForwardRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)), + rng1); } +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2 > +inline BOOST_DEDUCED_TYPENAME range_return::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)), + rng1); +} + +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred), + rng1); +} + +/// \overload +template< range_return_value re, class ForwardRange1, class ForwardRange2, + class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +search(const ForwardRange1& rng1, const ForwardRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::search(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2),pred), + rng1); +} + + } // namespace range + using range::search; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/search_n.hpp b/include/boost/range/algorithm/search_n.hpp index 65f2510..d7b84ae 100755 --- a/include/boost/range/algorithm/search_n.hpp +++ b/include/boost/range/algorithm/search_n.hpp @@ -19,122 +19,127 @@ namespace boost { - /// \brief template function search - /// - /// range-based version of the search std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - /// \pre Integer is an integral type - /// \pre Value is a model of the EqualityComparableConcept - /// \pre ForwardRange's value type is a model of the EqualityComparableConcept - /// \pre Object's of ForwardRange's value type can be compared for equality with Objects of type Value - template< typename ForwardRange, typename Integer, typename Value > - inline typename range_iterator::type - search_n(ForwardRange& rng, Integer count, const Value& value) + namespace range { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return std::search_n(boost::begin(rng),boost::end(rng), count, value); - } - /// \overload - template< typename ForwardRange, typename Integer, typename Value > - inline typename range_iterator::type - search_n(const ForwardRange& rng, Integer count, const Value& value) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return std::search_n(boost::begin(rng), boost::end(rng), count, value); - } +/// \brief template function search +/// +/// range-based version of the search std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +/// \pre Integer is an integral type +/// \pre Value is a model of the EqualityComparableConcept +/// \pre ForwardRange's value type is a model of the EqualityComparableConcept +/// \pre Object's of ForwardRange's value type can be compared for equality with Objects of type Value +template< typename ForwardRange, typename Integer, typename Value > +inline typename range_iterator::type +search_n(ForwardRange& rng, Integer count, const Value& value) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::search_n(boost::begin(rng),boost::end(rng), count, value); +} - /// \overload - template< typename ForwardRange, typename Integer, class Value, - typename BinaryPredicate > - inline typename range_iterator::type - search_n(ForwardRange& rng, Integer count, const Value& value, - BinaryPredicate binary_pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); - return std::search_n(boost::begin(rng), boost::end(rng), - count, value, binary_pred); - } +/// \overload +template< typename ForwardRange, typename Integer, typename Value > +inline typename range_iterator::type +search_n(const ForwardRange& rng, Integer count, const Value& value) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return std::search_n(boost::begin(rng), boost::end(rng), count, value); +} - /// \overload - template< typename ForwardRange, typename Integer, typename Value, - typename BinaryPredicate > - inline typename range_iterator::type - search_n(const ForwardRange& rng, Integer count, const Value& value, - BinaryPredicate binary_pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); - return std::search_n(boost::begin(rng), boost::end(rng), - count, value, binary_pred); - } +/// \overload +template< typename ForwardRange, typename Integer, class Value, + typename BinaryPredicate > +inline typename range_iterator::type +search_n(ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate binary_pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); + return std::search_n(boost::begin(rng), boost::end(rng), + count, value, binary_pred); +} + +/// \overload +template< typename ForwardRange, typename Integer, typename Value, + typename BinaryPredicate > +inline typename range_iterator::type +search_n(const ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate binary_pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); + return std::search_n(boost::begin(rng), boost::end(rng), + count, value, binary_pred); +} // range_return overloads - /// \overload - template< range_return_value re, typename ForwardRange, typename Integer, - typename Value > - inline typename range_return::type - search_n(ForwardRange& rng, Integer count, const Value& value) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return range_return:: - pack(std::search_n(boost::begin(rng),boost::end(rng), - count, value), - rng); - } - - /// \overload - template< range_return_value re, typename ForwardRange, typename Integer, - class Value > - inline typename range_return::type - search_n(const ForwardRange& rng, Integer count, const Value& value) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - return range_return:: - pack(std::search_n(boost::begin(rng), boost::end(rng), - count, value), - rng); - } - - /// \overload - template< range_return_value re, typename ForwardRange, typename Integer, - typename Value, typename BinaryPredicate > - inline typename range_return::type - search_n(ForwardRange& rng, Integer count, const Value& value, - BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, - const Value&>)); - return range_return:: - pack(std::search_n(boost::begin(rng), boost::end(rng), - count, value, pred), - rng); - } - - /// \overload - template< range_return_value re, typename ForwardRange, typename Integer, - typename Value, typename BinaryPredicate > - inline typename range_return::type - search_n(const ForwardRange& rng, Integer count, const Value& value, - BinaryPredicate pred) - { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, - const Value&>)); - return range_return:: - pack(std::search_n(boost::begin(rng), boost::end(rng), - count, value, pred), - rng); - } - +/// \overload +template< range_return_value re, typename ForwardRange, typename Integer, + typename Value > +inline typename range_return::type +search_n(ForwardRange& rng, Integer count, const Value& value) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::search_n(boost::begin(rng),boost::end(rng), + count, value), + rng); } +/// \overload +template< range_return_value re, typename ForwardRange, typename Integer, + class Value > +inline typename range_return::type +search_n(const ForwardRange& rng, Integer count, const Value& value) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + return range_return:: + pack(std::search_n(boost::begin(rng), boost::end(rng), + count, value), + rng); +} + +/// \overload +template< range_return_value re, typename ForwardRange, typename Integer, + typename Value, typename BinaryPredicate > +inline typename range_return::type +search_n(ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + const Value&>)); + return range_return:: + pack(std::search_n(boost::begin(rng), boost::end(rng), + count, value, pred), + rng); +} + +/// \overload +template< range_return_value re, typename ForwardRange, typename Integer, + typename Value, typename BinaryPredicate > +inline typename range_return::type +search_n(const ForwardRange& rng, Integer count, const Value& value, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, + const Value&>)); + return range_return:: + pack(std::search_n(boost::begin(rng), boost::end(rng), + count, value, pred), + rng); +} + + } // namespace range + using range::search_n; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/set_algorithm.hpp b/include/boost/range/algorithm/set_algorithm.hpp index 48580a9..ce7e9b1 100755 --- a/include/boost/range/algorithm/set_algorithm.hpp +++ b/include/boost/range/algorithm/set_algorithm.hpp @@ -17,172 +17,182 @@ namespace boost { - /// \brief template function includes - /// - /// range-based version of the includes std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline bool includes(const SinglePassRange1& rng1, - const SinglePassRange2& rng2) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::includes(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); - } - /// \overload - template - inline bool includes(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::includes(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred); - } - - /// \brief template function set_union - /// - /// range-based version of the set_union std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline OutputIterator set_union(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_union(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out); - } - - /// \overload - template - inline OutputIterator set_union(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_union(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out, pred); - } - - /// \brief template function set_intersection - /// - /// range-based version of the set_intersection std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline OutputIterator set_intersection(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_intersection(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out); - } - - /// \overload - template - inline OutputIterator set_intersection(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_intersection(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), - out, pred); - } - - /// \brief template function set_difference - /// - /// range-based version of the set_difference std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline OutputIterator set_difference(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_difference(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out); - } - - /// \overload - template - inline OutputIterator set_difference(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_difference( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out, pred); - } - - /// \brief template function set_symmetric_difference - /// - /// range-based version of the set_symmetric_difference std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline OutputIterator - set_symmetric_difference(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out); - } - - /// \overload - template - inline OutputIterator - set_symmetric_difference(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out, - BinaryPredicate pred) - { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return std::set_symmetric_difference( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), out, pred); - } +/// \brief template function includes +/// +/// range-based version of the includes std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline bool includes(const SinglePassRange1& rng1, + const SinglePassRange2& rng2) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::includes(boost::begin(rng1),boost::end(rng1), + boost::begin(rng2),boost::end(rng2)); } +/// \overload +template +inline bool includes(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::includes(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), pred); +} + +/// \brief template function set_union +/// +/// range-based version of the set_union std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline OutputIterator set_union(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_union(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); +} + +/// \overload +template +inline OutputIterator set_union(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_union(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); +} + +/// \brief template function set_intersection +/// +/// range-based version of the set_intersection std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline OutputIterator set_intersection(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_intersection(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); +} + +/// \overload +template +inline OutputIterator set_intersection(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_intersection(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), + out, pred); +} + +/// \brief template function set_difference +/// +/// range-based version of the set_difference std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline OutputIterator set_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_difference(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); +} + +/// \overload +template +inline OutputIterator set_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_difference( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); +} + +/// \brief template function set_symmetric_difference +/// +/// range-based version of the set_symmetric_difference std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline OutputIterator +set_symmetric_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out); +} + +/// \overload +template +inline OutputIterator +set_symmetric_difference(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::set_symmetric_difference( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), out, pred); +} + + } // namespace range + using range::includes; + using range::set_union; + using range::set_intersection; + using range::set_difference; + using range::set_symmetric_difference; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/sort.hpp b/include/boost/range/algorithm/sort.hpp index 78669b0..238c48d 100755 --- a/include/boost/range/algorithm/sort.hpp +++ b/include/boost/range/algorithm/sort.hpp @@ -17,47 +17,52 @@ namespace boost { - /// \brief template function sort - /// - /// range-based version of the sort std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline RandomAccessRange& sort(RandomAccessRange& rng) + namespace range { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort(boost::begin(rng), boost::end(rng)); - return rng; - } - - /// \overload - template - inline const RandomAccessRange& sort(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort(boost::begin(rng),boost::end(rng)); - return rng; - } - - /// \overload - template - inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort(boost::begin(rng), boost::end(rng), pred); - return rng; - } - - /// \overload - template - inline const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::sort(boost::begin(rng), boost::end(rng), pred); - return rng; - } +/// \brief template function sort +/// +/// range-based version of the sort std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline RandomAccessRange& sort(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort(boost::begin(rng), boost::end(rng)); + return rng; } +/// \overload +template +inline const RandomAccessRange& sort(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort(boost::begin(rng),boost::end(rng)); + return rng; +} + +/// \overload +template +inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort(boost::begin(rng), boost::end(rng), pred); + return rng; +} + +/// \overload +template +inline const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::sort(boost::begin(rng), boost::end(rng), pred); + return rng; +} + + } // namespace range + using range::sort; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/stable_partition.hpp b/include/boost/range/algorithm/stable_partition.hpp index b0c6cc8..46cb616 100755 --- a/include/boost/range/algorithm/stable_partition.hpp +++ b/include/boost/range/algorithm/stable_partition.hpp @@ -18,51 +18,56 @@ namespace boost { - /// \brief template function stable_partition - /// - /// range-based version of the stable_partition std algorithm - /// - /// \pre BidirectionalRange is a model of the BidirectionalRangeConcept - /// \pre UnaryPredicate is a model of the UnaryPredicateConcept - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - stable_partition(BidirectionalRange& rng, UnaryPredicate pred) + namespace range { - boost::function_requires< BidirectionalRangeConcept >(); - return std::stable_partition(boost::begin(rng), boost::end(rng), pred); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_iterator::type - stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) - { - boost::function_requires< BidirectionalRangeConcept >(); - return std::stable_partition(boost::begin(rng),boost::end(rng),pred); - } - -// range_return overloads - template - inline BOOST_DEDUCED_TYPENAME range_return::type - stable_partition(BidirectionalRange& rng, UnaryPredicate pred) - { - boost::function_requires< BidirectionalRangeConcept >(); - return range_return::pack( - std::stable_partition(boost::begin(rng), boost::end(rng), pred), - rng); - } - - /// \overload - template - inline BOOST_DEDUCED_TYPENAME range_return::type - stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) - { - boost::function_requires< BidirectionalRangeConcept >(); - return range_return::pack( - std::stable_partition(boost::begin(rng),boost::end(rng),pred), - rng); - } +/// \brief template function stable_partition +/// +/// range-based version of the stable_partition std algorithm +/// +/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept +/// \pre UnaryPredicate is a model of the UnaryPredicateConcept +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +stable_partition(BidirectionalRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::stable_partition(boost::begin(rng), boost::end(rng), pred); } +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_iterator::type +stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return std::stable_partition(boost::begin(rng),boost::end(rng),pred); +} + +// range_return overloads +template +inline BOOST_DEDUCED_TYPENAME range_return::type +stable_partition(BidirectionalRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return range_return::pack( + std::stable_partition(boost::begin(rng), boost::end(rng), pred), + rng); +} + +/// \overload +template +inline BOOST_DEDUCED_TYPENAME range_return::type +stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) +{ + BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + return range_return::pack( + std::stable_partition(boost::begin(rng),boost::end(rng),pred), + rng); +} + + } // namespace range + using range::stable_partition; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/stable_sort.hpp b/include/boost/range/algorithm/stable_sort.hpp index fba48d9..700933e 100755 --- a/include/boost/range/algorithm/stable_sort.hpp +++ b/include/boost/range/algorithm/stable_sort.hpp @@ -17,46 +17,52 @@ namespace boost { - /// \brief template function stable_sort - /// - /// range-based version of the stable_sort std algorithm - /// - /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template - inline RandomAccessRange& stable_sort(RandomAccessRange& rng) + namespace range { - boost::function_requires< RandomAccessRangeConcept >(); - std::stable_sort(boost::begin(rng), boost::end(rng)); - return rng; - } - /// \overload - template - inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::stable_sort(boost::begin(rng), boost::end(rng)); - return rng; - } - - /// \overload - template - inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate sort_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); - return rng; - } - - /// \overload - template - inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate sort_pred) - { - boost::function_requires< RandomAccessRangeConcept >(); - std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); - return rng; - } +/// \brief template function stable_sort +/// +/// range-based version of the stable_sort std algorithm +/// +/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template +inline RandomAccessRange& stable_sort(RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::stable_sort(boost::begin(rng), boost::end(rng)); + return rng; } +/// \overload +template +inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::stable_sort(boost::begin(rng), boost::end(rng)); + return rng; +} + +/// \overload +template +inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate sort_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); + return rng; +} + +/// \overload +template +inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate sort_pred) +{ + BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); + return rng; +} + + } // namespace range + using range::stable_sort; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/swap_ranges.hpp b/include/boost/range/algorithm/swap_ranges.hpp index 0b64b9c..ffc0fc8 100755 --- a/include/boost/range/algorithm/swap_ranges.hpp +++ b/include/boost/range/algorithm/swap_ranges.hpp @@ -57,25 +57,31 @@ namespace boost } } // namespace range_detail - /// \brief template function swap_ranges - /// - /// range-based version of the swap_ranges std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - template< typename SinglePassRange1, typename SinglePassRange2 > - inline SinglePassRange2& - swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2) + namespace range { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - boost::range_detail::swap_ranges_impl( - boost::begin(range1), boost::end(range1), - boost::begin(range2), boost::end(range2)); +/// \brief template function swap_ranges +/// +/// range-based version of the swap_ranges std algorithm +/// +/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept +/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept +template< typename SinglePassRange1, typename SinglePassRange2 > +inline SinglePassRange2& +swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2) +{ + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - return range2; - } + boost::range_detail::swap_ranges_impl( + boost::begin(range1), boost::end(range1), + boost::begin(range2), boost::end(range2)); + + return range2; } + } // namespace range + using range::swap_ranges; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/transform.hpp b/include/boost/range/algorithm/transform.hpp index ca3e956..d12904b 100755 --- a/include/boost/range/algorithm/transform.hpp +++ b/include/boost/range/algorithm/transform.hpp @@ -18,25 +18,31 @@ namespace boost { - /// \brief template function transform - /// - /// range-based version of the transform std algorithm - /// - /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept - /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept - /// \pre OutputIterator is a model of the OutputIteratorConcept - /// \pre UnaryOperation is a model of the UnaryFunctionConcept - /// \pre BinaryOperation is a model of the BinaryFunctionConcept - template< class SinglePassRange1, - class OutputIterator, - class UnaryOperation > - inline OutputIterator - transform(const SinglePassRange1& rng, - OutputIterator out, - UnaryOperation fun) + namespace range { - return std::transform(boost::begin(rng),boost::end(rng),out,fun); - } + + /// \brief template function transform + /// + /// range-based version of the transform std algorithm + /// + /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept + /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept + /// \pre OutputIterator is a model of the OutputIteratorConcept + /// \pre UnaryOperation is a model of the UnaryFunctionConcept + /// \pre BinaryOperation is a model of the BinaryFunctionConcept + template< class SinglePassRange1, + class OutputIterator, + class UnaryOperation > + inline OutputIterator + transform(const SinglePassRange1& rng, + OutputIterator out, + UnaryOperation fun) + { + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::transform(boost::begin(rng),boost::end(rng),out,fun); + } + + } // namespace range namespace range_detail { @@ -62,24 +68,30 @@ namespace boost } } - /// \overload - template< class SinglePassRange1, - class SinglePassRange2, - class OutputIterator, - class BinaryOperation > - inline OutputIterator - transform(const SinglePassRange1& rng1, - const SinglePassRange2& rng2, - OutputIterator out, - BinaryOperation fun) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - boost::function_requires< SinglePassRangeConcept >(); - return range_detail::transform_impl( - boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), - out, fun); - } -} + + /// \overload + template< class SinglePassRange1, + class SinglePassRange2, + class OutputIterator, + class BinaryOperation > + inline OutputIterator + transform(const SinglePassRange1& rng1, + const SinglePassRange2& rng2, + OutputIterator out, + BinaryOperation fun) + { + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return range_detail::transform_impl( + boost::begin(rng1), boost::end(rng1), + boost::begin(rng2), boost::end(rng2), + out, fun); + } + + } // namespace range + using range::transform; +} // namespace boost #endif // include guard diff --git a/include/boost/range/algorithm/unique.hpp b/include/boost/range/algorithm/unique.hpp index 8d8ee1a..43e3b82 100755 --- a/include/boost/range/algorithm/unique.hpp +++ b/include/boost/range/algorithm/unique.hpp @@ -18,84 +18,90 @@ namespace boost { - /// \brief template function unique - /// - /// range-based version of the unique std algorithm - /// - /// \pre Rng meets the requirements for a Forward range - template< range_return_value re, class ForwardRange > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( ForwardRange& rng ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack( std::unique( boost::begin(rng), - boost::end(rng)), rng ); - } + namespace range + { - /// \overload - template< range_return_value re, class ForwardRange > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( const ForwardRange& rng ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack( std::unique( boost::begin(rng), - boost::end(rng)), rng ); - } - /// \overload - template< range_return_value re, class ForwardRange, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( ForwardRange& rng, BinaryPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::unique(boost::begin(rng), boost::end(rng), pred), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( const ForwardRange& rng, BinaryPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::unique(boost::begin(rng), boost::end(rng), pred), - rng); - } - - /// \overload - template< class ForwardRange > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( ForwardRange& rng ) - { - boost::function_requires< ForwardRangeConcept >(); - return boost::unique(rng); - } - /// \overload - template< class ForwardRange > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( const ForwardRange& rng ) - { - boost::function_requires< ForwardRangeConcept >(); - return boost::unique(rng); - } - /// \overload - template< class ForwardRange, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - unique( ForwardRange& rng, BinaryPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return boost::unique(rng); - } - /// \overload - template< class ForwardRange, class BinaryPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - unique( const ForwardRange& rng, BinaryPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return boost::unique(rng, pred); - } +/// \brief template function unique +/// +/// range-based version of the unique std algorithm +/// +/// \pre Rng meets the requirements for a Forward range +template< range_return_value re, class ForwardRange > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( ForwardRange& rng ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack( std::unique( boost::begin(rng), + boost::end(rng)), rng ); } +/// \overload +template< range_return_value re, class ForwardRange > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( const ForwardRange& rng ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack( std::unique( boost::begin(rng), + boost::end(rng)), rng ); +} +/// \overload +template< range_return_value re, class ForwardRange, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( ForwardRange& rng, BinaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::unique(boost::begin(rng), boost::end(rng), pred), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( const ForwardRange& rng, BinaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::unique(boost::begin(rng), boost::end(rng), pred), + rng); +} + +/// \overload +template< class ForwardRange > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( ForwardRange& rng ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return ::boost::range::unique(rng); +} +/// \overload +template< class ForwardRange > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( const ForwardRange& rng ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return ::boost::range::unique(rng); +} +/// \overload +template< class ForwardRange, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +unique( ForwardRange& rng, BinaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return ::boost::range::unique(rng); +} +/// \overload +template< class ForwardRange, class BinaryPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +unique( const ForwardRange& rng, BinaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return ::boost::range::unique(rng, pred); +} + + } // namespace range + using range::unique; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/unique_copy.hpp b/include/boost/range/algorithm/unique_copy.hpp index 4d2a3f2..909017b 100755 --- a/include/boost/range/algorithm/unique_copy.hpp +++ b/include/boost/range/algorithm/unique_copy.hpp @@ -17,29 +17,35 @@ namespace boost { - /// \brief template function unique_copy - /// - /// range-based version of the unique_copy std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre OutputIterator is a model of the OutputIteratorConcept - /// \pre BinaryPredicate is a model of the BinaryPredicateConcept - template< class SinglePassRange, class OutputIterator > - inline OutputIterator - unique_copy( const SinglePassRange& rng, OutputIterator out_it ) - { - boost::function_requires< SinglePassRangeConcept >(); - return std::unique_copy(boost::begin(rng), boost::end(rng), out_it); - } - /// \overload - template< class SinglePassRange, class OutputIterator, class BinaryPredicate > - inline OutputIterator - unique_copy( const SinglePassRange& rng, OutputIterator out_it, - BinaryPredicate pred ) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred); - } + +/// \brief template function unique_copy +/// +/// range-based version of the unique_copy std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre OutputIterator is a model of the OutputIteratorConcept +/// \pre BinaryPredicate is a model of the BinaryPredicateConcept +template< class SinglePassRange, class OutputIterator > +inline OutputIterator +unique_copy( const SinglePassRange& rng, OutputIterator out_it ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::unique_copy(boost::begin(rng), boost::end(rng), out_it); +} +/// \overload +template< class SinglePassRange, class OutputIterator, class BinaryPredicate > +inline OutputIterator +unique_copy( const SinglePassRange& rng, OutputIterator out_it, + BinaryPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred); } + } // namespace range + using range::unique_copy; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm/upper_bound.hpp b/include/boost/range/algorithm/upper_bound.hpp index 8d17abf..e11acad 100755 --- a/include/boost/range/algorithm/upper_bound.hpp +++ b/include/boost/range/algorithm/upper_bound.hpp @@ -18,84 +18,90 @@ namespace boost { - /// \brief template function upper_bound - /// - /// range-based version of the upper_bound std algorithm - /// - /// \pre ForwardRange is a model of the ForwardRangeConcept - template< class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - upper_bound( ForwardRange& rng, Value val ) + namespace range { - boost::function_requires< ForwardRangeConcept >(); - return std::upper_bound(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template< class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - upper_bound( const ForwardRange& rng, Value val ) - { - boost::function_requires< ForwardRangeConcept >(); - return std::upper_bound(boost::begin(rng), boost::end(rng), val); - } - /// \overload - template< class ForwardRange, class Value, class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); - } - /// \overload - template< class ForwardRange, class Value, class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_iterator::type - upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - upper_bound( ForwardRange& rng, Value val ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value > - inline BOOST_DEDUCED_TYPENAME range_return::type - upper_bound( const ForwardRange& rng, Value val ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value, - class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), - rng); - } - /// \overload - template< range_return_value re, class ForwardRange, class Value, - class SortPredicate > - inline BOOST_DEDUCED_TYPENAME range_return::type - upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) - { - boost::function_requires< ForwardRangeConcept >(); - return range_return:: - pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), - rng); - } + +/// \brief template function upper_bound +/// +/// range-based version of the upper_bound std algorithm +/// +/// \pre ForwardRange is a model of the ForwardRangeConcept +template< class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +upper_bound( ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::upper_bound(boost::begin(rng), boost::end(rng), val); +} +/// \overload +template< class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +upper_bound( const ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::upper_bound(boost::begin(rng), boost::end(rng), val); +} +/// \overload +template< class ForwardRange, class Value, class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); +} +/// \overload +template< class ForwardRange, class Value, class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_iterator::type +upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +upper_bound( ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value > +inline BOOST_DEDUCED_TYPENAME range_return::type +upper_bound( const ForwardRange& rng, Value val ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value, + class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); +} +/// \overload +template< range_return_value re, class ForwardRange, class Value, + class SortPredicate > +inline BOOST_DEDUCED_TYPENAME range_return::type +upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + return range_return:: + pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), + rng); } + } // namespace range + using range::upper_bound; +} // namespace boost + #endif // include guard From 690ebf406e7fbbd53e61aa0f2ed276d4c8501653 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 19:28:03 +0000 Subject: [PATCH 85/92] Boost.Range correct the adjacent_filtered adaptor to be resilient accident argument dependent lookup of boost::next [SVN r61024] --- include/boost/range/adaptor/adjacent_filtered.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/range/adaptor/adjacent_filtered.hpp b/include/boost/range/adaptor/adjacent_filtered.hpp index aedc888..4f0bb75 100644 --- a/include/boost/range/adaptor/adjacent_filtered.hpp +++ b/include/boost/range/adaptor/adjacent_filtered.hpp @@ -116,7 +116,7 @@ namespace boost { if (default_pass) { - raw_iterator nxt = next(it); + raw_iterator nxt = ::boost::next(it); while (nxt != last && !bi_pred(*it, *nxt)) { ++it; @@ -125,7 +125,7 @@ namespace boost } else { - raw_iterator nxt = next(it); + raw_iterator nxt = ::boost::next(it); for(; nxt != last; ++it, ++nxt) { if (bi_pred(*it, *nxt)) @@ -155,7 +155,7 @@ namespace boost { BOOST_ASSERT( current != this->end().base() ); - current = to_valid(next(current), this->end().base(), m_bi_pred, m_default_pass); + current = to_valid(::boost::next(current), this->end().base(), m_bi_pred, m_default_pass); } private: From 39d77206e1fba0a0f7785e05c52bf92fbcb99a22 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 19:31:43 +0000 Subject: [PATCH 86/92] Boost.Range fixed C++0x problem due to accidental argument dependent lookup in the const_ranges unit test. [SVN r61025] --- test/const_ranges.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) mode change 100755 => 100644 test/const_ranges.cpp diff --git a/test/const_ranges.cpp b/test/const_ranges.cpp old mode 100755 new mode 100644 index 6360317..cd0b06a --- a/test/const_ranges.cpp +++ b/test/const_ranges.cpp @@ -21,9 +21,6 @@ #include #include -using namespace boost; -using namespace std; - template< class T > const T& as_const( const T& r ) { @@ -33,27 +30,23 @@ const T& as_const( const T& 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 ) ) ); + const std::string bar( "bar" ); - 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 ) ) ); + BOOST_CHECK( boost::const_begin( foo ) == boost::begin( as_const( foo ) ) ); + BOOST_CHECK( boost::const_end( foo ) == boost::end( as_const( foo ) ) ); + BOOST_CHECK( boost::const_rbegin( foo ) == boost::rbegin( as_const( foo ) ) ); + BOOST_CHECK( boost::const_rend( foo ) == boost::rend( as_const( foo ) ) ); + + BOOST_CHECK( boost::const_begin( bar ) == boost::begin( as_const( bar ) ) ); + BOOST_CHECK( boost::const_end( bar ) == boost::end( as_const( bar ) ) ); + BOOST_CHECK( boost::const_rbegin( bar ) == boost::rbegin( as_const( bar ) ) ); + BOOST_CHECK( boost::const_rend( bar ) == boost::rend( as_const( bar ) ) ); } - - -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); test->add( BOOST_TEST_CASE( &check_const_ranges ) ); From f8f29ae7d3f782c050146d29f23d1ef667a86949 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 20:10:16 +0000 Subject: [PATCH 87/92] Boost.Range improvements for compiler compatibility, especially C++0x compilers. [SVN r61026] --- include/boost/range/concepts.hpp | 60 ++++++++++---------- test/iterator_pair.cpp | 75 ++++++++++++------------ test/iterator_range.cpp | 97 +++++++++++++++----------------- test/reversible_range.cpp | 49 ++++++++-------- test/std_container.cpp | 49 ++++++++-------- 5 files changed, 157 insertions(+), 173 deletions(-) mode change 100755 => 100644 test/iterator_pair.cpp mode change 100755 => 100644 test/iterator_range.cpp mode change 100755 => 100644 test/reversible_range.cpp mode change 100755 => 100644 test/std_container.cpp diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index b70c586..cc039aa 100644 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -74,10 +74,10 @@ namespace boost { // Ultimately modeling the range concepts using composition // with the Boost.Iterator concepts would render the library // incompatible with many common Boost.Lambda expressions. - template + template struct IncrementableIteratorConcept : CopyConstructible { - typedef typename iterator_traversal::type traversal_category; + typedef BOOST_DEDUCED_TYPENAME iterator_traversal::type traversal_category; BOOST_CONCEPT_ASSERT(( Convertible< @@ -94,42 +94,42 @@ namespace boost { Iterator i; }; - template + template struct SinglePassIteratorConcept : IncrementableIteratorConcept , EqualityComparable { BOOST_CONCEPT_ASSERT(( Convertible< - typename SinglePassIteratorConcept::traversal_category, + BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category, single_pass_traversal_tag >)); }; - template + template struct ForwardIteratorConcept : SinglePassIteratorConcept , DefaultConstructible { - typedef typename boost::detail::iterator_traits::difference_type difference_type; + typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::difference_type difference_type; BOOST_MPL_ASSERT((is_integral)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); BOOST_CONCEPT_ASSERT(( Convertible< - typename ForwardIteratorConcept::traversal_category, + BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category, forward_traversal_tag >)); }; - template + template struct BidirectionalIteratorConcept : ForwardIteratorConcept { BOOST_CONCEPT_ASSERT(( Convertible< - typename BidirectionalIteratorConcept::traversal_category, + BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept::traversal_category, bidirectional_traversal_tag >)); @@ -142,13 +142,13 @@ namespace boost { Iterator i; }; - template + template struct RandomAccessIteratorConcept : BidirectionalIteratorConcept { BOOST_CONCEPT_ASSERT(( Convertible< - typename RandomAccessIteratorConcept::traversal_category, + BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::traversal_category, random_access_traversal_tag >)); @@ -162,7 +162,7 @@ namespace boost { n = i - j; } private: - typename RandomAccessIteratorConcept::difference_type n; + BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n; Iterator i; Iterator j; }; @@ -170,11 +170,11 @@ namespace boost { } // namespace range_detail //! Check if a type T models the SinglePassRange range concept. - template + template struct SinglePassRangeConcept { - typedef typename range_iterator::type const_iterator; - typedef typename range_iterator::type iterator; + typedef BOOST_DEDUCED_TYPENAME range_iterator::type const_iterator; + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator; BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); @@ -211,17 +211,17 @@ namespace boost { }; //! Check if a type T models the ForwardRange range concept. - template + template struct ForwardRangeConcept : SinglePassRangeConcept { - BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); - BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); + BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); + BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); }; - template + template struct WriteableRangeConcept { - typedef typename range_iterator::type iterator; + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator; BOOST_CONCEPT_USAGE(WriteableRangeConcept) { @@ -229,11 +229,11 @@ namespace boost { } private: iterator i; - typename range_value::type v; + BOOST_DEDUCED_TYPENAME range_value::type v; }; //! Check if a type T models the WriteableForwardRange range concept. - template + template struct WriteableForwardRangeConcept : ForwardRangeConcept , WriteableRangeConcept @@ -241,15 +241,15 @@ namespace boost { }; //! Check if a type T models the BidirectionalRange range concept. - template + template struct BidirectionalRangeConcept : ForwardRangeConcept { - BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); - BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); + BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); + BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); }; //! Check if a type T models the WriteableBidirectionalRange range concept. - template + template struct WriteableBidirectionalRangeConcept : BidirectionalRangeConcept , WriteableRangeConcept @@ -257,15 +257,15 @@ namespace boost { }; //! Check if a type T models the RandomAccessRange range concept. - template + template struct RandomAccessRangeConcept : BidirectionalRangeConcept { - BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); - BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); + BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); + BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); }; //! Check if a type T models the WriteableRandomAccessRange range concept. - template + template struct WriteableRandomAccessRangeConcept : RandomAccessRangeConcept , WriteableRangeConcept diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp old mode 100755 new mode 100644 index 2546817..495bd6f --- a/test/iterator_pair.cpp +++ b/test/iterator_pair.cpp @@ -23,8 +23,6 @@ #include #include -using namespace boost; - void check_iterator_pair() { typedef std::vector vec_t; @@ -35,57 +33,56 @@ void check_iterator_pair() 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 ) ); + pair_t pair = std::make_pair( boost::begin( vec ), boost::end( vec ) ); + const_pair_t const_pair = std::make_pair( boost::begin( vec ), boost::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_iterator::type, pair_t::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_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(( boost::is_same< boost::range_value::type, + boost::detail::iterator_traits::value_type>::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_const_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, + boost::detail::iterator_traits::difference_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, std::size_t >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, pair_t::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_t::first_type >::value )); + + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, + boost::detail::iterator_traits::value_type>::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); // // This behavior is not supported with v2. //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_iterator::type, const_pair_tt::first_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_iterator::type, const_pair_tt::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, + boost::detail::iterator_traits::difference_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, std::size_t >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_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::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::distance( const_pair.first, const_pair.second ) ); + BOOST_CHECK( boost::begin( pair ) == pair.first ); + BOOST_CHECK( boost::end( pair ) == pair.second ); + BOOST_CHECK( boost::empty( pair ) == (pair.first == pair.second) ); + BOOST_CHECK( boost::size( pair ) == std::distance( pair.first, 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::distance( constness_pair.first, constness_pair.second ) ); + BOOST_CHECK( boost::begin( const_pair ) == const_pair.first ); + BOOST_CHECK( boost::end( const_pair ) == const_pair.second ); + BOOST_CHECK( boost::empty( const_pair ) == (const_pair.first == const_pair.second) ); + BOOST_CHECK( boost::size( const_pair ) == std::distance( const_pair.first, const_pair.second ) ); + + BOOST_CHECK( boost::begin( constness_pair ) == constness_pair.first ); + BOOST_CHECK( boost::end( constness_pair ) == constness_pair.second ); + BOOST_CHECK( boost::empty( constness_pair ) == (constness_pair.first == const_pair.second) ); + BOOST_CHECK( boost::size( constness_pair ) == 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[] ) +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); test->add( BOOST_TEST_CASE( &check_iterator_pair ) ); diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp old mode 100755 new mode 100644 index db531d3..47bc565 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -19,32 +19,29 @@ #include #include -#include +#include #include #include #include #include -using namespace boost; -using namespace std; - void check_reference_type(); 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 ); - + + typedef std::string::iterator iterator; + typedef std::string::const_iterator const_iterator; + typedef boost::iterator_range irange; + typedef boost::iterator_range cirange; + std::string str = "hello world"; + const std::string cstr = "const world"; + irange r = boost::make_iterator_range( str ); + r = boost::make_iterator_range( str.begin(), str.end() ); + cirange r2 = boost::make_iterator_range( cstr ); + r2 = boost::make_iterator_range( cstr.begin(), cstr.end() ); + r2 = boost::make_iterator_range( str ); + BOOST_CHECK( !r.empty() ); BOOST_CHECK( !r2.empty() ); @@ -53,7 +50,7 @@ void check_iterator_range() // BOOST_CHECK( false ); // if( !(bool)r2 ) // BOOST_CHECK( false ); -//#else +//#else if( !r ) BOOST_CHECK( false ); if( !r2 ) @@ -62,55 +59,53 @@ void check_iterator_range() 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; - + BOOST_CHECK_EQUAL( std::distance( r.begin(), r.end() ), + std::distance( begin( r2 ), end( r2 ) ) ); + std::cout << r << r2; + + #ifndef BOOST_NO_STD_WSTRING - wcout << make_iterator_range( wstring( L"a wide string" ) ) - << make_iterator_range( L"another wide string" ); -#endif - - string res = copy_range( r ); - BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) ); + std::wcout << boost::make_iterator_range( std::wstring( L"a wide string" ) ) + << boost::make_iterator_range( L"another wide string" ); +#endif - irange rr = make_iterator_range( str ); + std::string res = boost::copy_range( r ); + BOOST_CHECK_EQUAL_COLLECTIONS( res.begin(), res.end(), r.begin(), r.end() ); + + irange rr = boost::make_iterator_range( str ); BOOST_CHECK( rr.equal( r ) ); - rr = make_iterator_range( str.begin(), str.begin() + 5 ); - BOOST_CHECK( rr == as_literal("hello") ); - BOOST_CHECK( rr != as_literal("hell") ); - BOOST_CHECK( rr < as_literal("hello dude") ); - BOOST_CHECK( as_literal("hello") == rr ); - BOOST_CHECK( as_literal("hell") != rr ); - BOOST_CHECK( ! (as_literal("hello dude") < rr ) ); + rr = boost::make_iterator_range( str.begin(), str.begin() + 5 ); + BOOST_CHECK( rr == boost::as_literal("hello") ); + BOOST_CHECK( rr != boost::as_literal("hell") ); + BOOST_CHECK( rr < boost::as_literal("hello dude") ); + BOOST_CHECK( boost::as_literal("hello") == rr ); + BOOST_CHECK( boost::as_literal("hell") != rr ); + BOOST_CHECK( ! (boost::as_literal("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 ); + const irange cr = boost::make_iterator_range( str ); BOOST_CHECK_EQUAL( cr.front(), 'h' ); BOOST_CHECK_EQUAL( cr.back(), 'd' ); BOOST_CHECK_EQUAL( cr[1], 'e' ); BOOST_CHECK_EQUAL( cr(1), 'e' ); - rrr = make_iterator_range( str, 1, -1 ); - BOOST_CHECK( rrr == as_literal("ello worl") ); - rrr = make_iterator_range( rrr, -1, 1 ); + rrr = boost::make_iterator_range( str, 1, -1 ); + BOOST_CHECK( rrr == boost::as_literal("ello worl") ); + rrr = boost::make_iterator_range( rrr, -1, 1 ); BOOST_CHECK( rrr == str ); check_reference_type(); } -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); test->add( BOOST_TEST_CASE( &check_iterator_range ) ); @@ -122,16 +117,16 @@ test_suite* init_unit_test_suite( int argc, char* argv[] ) // // Check that constness is propgated correct from // the iterator types. -// +// // Test contributed by Larry Evans. -// +// template< class Container > int test_iter_range( Container& a_cont ) { - typedef BOOST_DEDUCED_TYPENAME range_iterator::type citer_type; - typedef iterator_range riter_type; - riter_type a_riter( make_iterator_range( a_cont ) ); + typedef BOOST_DEDUCED_TYPENAME boost::range_iterator::type citer_type; + typedef boost::iterator_range riter_type; + riter_type a_riter( boost::make_iterator_range( a_cont ) ); a_riter.front(); a_riter.back(); int i = a_riter[0]; @@ -142,7 +137,7 @@ int test_iter_range( Container& a_cont ) void check_reference_type() { - typedef vector veci_type; + typedef std::vector veci_type; veci_type a_vec; a_vec.push_back( 999 ); test_iter_range(a_vec); diff --git a/test/reversible_range.cpp b/test/reversible_range.cpp old mode 100755 new mode 100644 index 9dfe8d0..98cc423 --- a/test/reversible_range.cpp +++ b/test/reversible_range.cpp @@ -27,44 +27,39 @@ #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; - + typedef std::vector vec_t; + typedef vec_t::iterator iterator; + typedef std::pair pair_t; + typedef boost::range_reverse_iterator::type rev_iterator; + typedef std::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 ) ); + pair_t p = std::make_pair( vec.begin(), vec.end() ); + rev_pair_t rp = std::make_pair( boost::rbegin( p ), boost::rend( p ) ); int a[] = {1,2,3,4,5,6,7,8,9,10}; - const int ca[] = {1,2,3,4,5,6,7,8,9,10,11,12}; - 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 ) ) ); + const int ca[] = {1,2,3,4,5,6,7,8,9,10,11,12}; + BOOST_CHECK( boost::rbegin( vec ) == boost::range_reverse_iterator::type( vec.end() ) ); + BOOST_CHECK( boost::rend( vec ) == boost::range_reverse_iterator::type( vec.begin() ) ); + BOOST_CHECK( std::distance( boost::rbegin( vec ), boost::rend( vec ) ) == std::distance( boost::begin( vec ), boost::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( boost::rbegin( p ) == boost::begin( rp ) ); + BOOST_CHECK( boost::rend( p ) == boost::end( rp ) ); + BOOST_CHECK( std::distance( boost::rbegin( p ), boost::rend( p ) ) == std::distance( boost::begin( rp ), boost::end( rp ) ) ); + BOOST_CHECK( std::distance( boost::begin( p ), boost::end( p ) ) == std::distance( boost::rbegin( rp ), boost::rend( rp ) ) ); - 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( &*boost::begin( a ), &*( boost::rend( a ) - 1 ) ); + BOOST_CHECK_EQUAL( &*( boost::end( a ) - 1 ), &*boost::rbegin( a ) ); + BOOST_CHECK_EQUAL( &*boost::begin( ca ), &*( boost::rend( ca ) - 1 ) ); + BOOST_CHECK_EQUAL( &*( boost::end( ca ) - 1 ), &*boost::rbegin( ca ) ); } -using boost::unit_test::test_suite; - -test_suite* init_unit_test_suite( int argc, char* argv[] ) +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); test->add( BOOST_TEST_CASE( &check_iterator ) ); diff --git a/test/std_container.cpp b/test/std_container.cpp old mode 100755 new mode 100644 index e2ee692..9b8f284 --- a/test/std_container.cpp +++ b/test/std_container.cpp @@ -24,46 +24,43 @@ #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 ); + 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_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_iterator::type, vec_t::iterator >::value )); - BOOST_STATIC_ASSERT(( is_same< range_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_difference::type, vec_t::difference_type >::value )); - BOOST_STATIC_ASSERT(( is_same< range_size::type, vec_t::size_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, vec_t::value_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, vec_t::iterator >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, vec_t::const_iterator >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, vec_t::difference_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, vec_t::size_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, vec_t::iterator >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, vec_t::const_iterator >::value )); - BOOST_CHECK( begin( vec ) == vec.begin() ); - BOOST_CHECK( end( vec ) == vec.end() ); - BOOST_CHECK( empty( vec ) == vec.empty() ); - 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( (std::size_t)size( cvec ) == cvec.size() ); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, vec_t::value_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, vec_t::difference_type >::value )); + BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, vec_t::size_type >::value )); + + BOOST_CHECK( boost::begin( vec ) == vec.begin() ); + BOOST_CHECK( boost::end( vec ) == vec.end() ); + BOOST_CHECK( boost::empty( vec ) == vec.empty() ); + BOOST_CHECK( static_cast(boost::size( vec )) == vec.size() ); + + BOOST_CHECK( boost::begin( cvec ) == cvec.begin() ); + BOOST_CHECK( boost::end( cvec ) == cvec.end() ); + BOOST_CHECK( boost::empty( cvec ) == cvec.empty() ); + BOOST_CHECK( static_cast(boost::size( cvec )) == cvec.size() ); } #include -using boost::unit_test::test_suite; -test_suite* init_unit_test_suite( int argc, char* argv[] ) +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); test->add( BOOST_TEST_CASE( &check_std_container ) ); From d0544400af26fd688fe6ac238edd9d7410dfa3f5 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 21:00:56 +0000 Subject: [PATCH 88/92] Boost.Range fixes for compilers that were having problems picking between const and mutable range overloads of range algorithms. [SVN r61028] --- doc/reference/algorithm/find.qbk | 14 +-- doc/reference/algorithm/find_end.qbk | 32 +------ doc/reference/algorithm/find_first_of.qbk | 30 ------ doc/reference/algorithm/find_if.qbk | 12 --- doc/reference/algorithm/lower_bound.qbk | 12 --- doc/reference/algorithm/upper_bound.qbk | 14 +-- include/boost/range/algorithm/find.hpp | 18 ---- include/boost/range/algorithm/find_end.hpp | 59 +----------- .../boost/range/algorithm/find_first_of.hpp | 55 ----------- include/boost/range/algorithm/find_if.hpp | 18 ---- include/boost/range/algorithm/lower_bound.hpp | 36 ------- include/boost/range/algorithm/upper_bound.hpp | 36 ------- test/algorithm_test/find.cpp | 4 + test/sub_range.cpp | 94 +++++++++---------- 14 files changed, 54 insertions(+), 380 deletions(-) mode change 100755 => 100644 test/sub_range.cpp diff --git a/doc/reference/algorithm/find.qbk b/doc/reference/algorithm/find.qbk index 50b47c0..38d5507 100644 --- a/doc/reference/algorithm/find.qbk +++ b/doc/reference/algorithm/find.qbk @@ -7,10 +7,6 @@ template typename range_iterator::type find(SinglePassRange& rng, Value val); -template -typename range_iterator::type -find(const SinglePassRange& rng, Value val); - template< range_return_value re, class SinglePassRange, @@ -18,20 +14,12 @@ template< > typename range_return::type find(SinglePassRange& rng, Value val); - -template< - range_return_value re, - class SinglePassRange, - class Value - > -typename range_return::type -find(const SinglePassRange& rng, Value val); `` [heading Description] The versions of `find` that return an iterator, returns the first iterator in the range `rng` such that `*i == value`. `end(rng)` is returned if no such iterator exists. -The versions of find that return a `range_return`, defines `found` in the same manner as the returned iterator described above. +The versions of find that return a `range_return`, defines `found` in the same manner as the returned iterator described above. [heading Definition] diff --git a/doc/reference/algorithm/find_end.qbk b/doc/reference/algorithm/find_end.qbk index 237f21a..a5999ce 100644 --- a/doc/reference/algorithm/find_end.qbk +++ b/doc/reference/algorithm/find_end.qbk @@ -7,10 +7,6 @@ template typename range_iterator::type find_end(ForwardRange1& rng1, const ForwardRange2& rng2); -template -typename range_iterator::type -find_end(const ForwardRange1& rng1, const ForwardRange2& rng2); - template< class ForwardRange1, class ForwardRange2, @@ -19,15 +15,6 @@ template< typename range_iterator::type find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); -template< - class ForwardRange1, - class ForwardRange2, - class BinaryPredicate - > -typename range_iterator::type -find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); - - template< range_return_value re, class ForwardRange1, @@ -36,14 +23,6 @@ template< typename range_return::type find_end(ForwardRange1& rng1, const ForwardRange2& rng2); -template< - range_return_value re, - class ForwardRange1, - class ForwardRange2 - > -typename range_return::type -find_end(const ForwardRange1& rng1, const ForwardRange2& rng2); - template< range_return_value re, class ForwardRange1, @@ -52,22 +31,13 @@ template< > typename range_return::type find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); - -template< - range_return_value re, - class ForwardRange1, - class ForwardRange2, - class BinaryPredicate - > -typename range_return::type -find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); `` [heading Description] The versions of `find_end` that return an iterator, return an iterator to the beginning of the last sub-sequence equal to `rng2` within `rng1`. Equality is determined by `operator==` for non-predicate versions of `find_end`, and by satisfying `pred` in the predicate versions. The versions of `find_end` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. - + [heading Definition] Defined in the header file `boost/range/algorithm/find_end.hpp` diff --git a/doc/reference/algorithm/find_first_of.qbk b/doc/reference/algorithm/find_first_of.qbk index bd8b856..a6af825 100644 --- a/doc/reference/algorithm/find_first_of.qbk +++ b/doc/reference/algorithm/find_first_of.qbk @@ -7,10 +7,6 @@ template typename range_iterator::type find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2); -template -typename range_iterator::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2); - template< class SinglePassRange1, class ForwardRange2, @@ -19,15 +15,6 @@ template< typename range_iterator::type find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); -template< - class SinglePassRange1, - class ForwardRange2, - class BinaryPredicate - > -typename range_iterator::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); - - template< range_return_value re, class SinglePassRange1, @@ -36,14 +23,6 @@ template< typename range_return::type find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2); -template< - range_return_value re, - class SinglePassRange1, - class ForwardRange2 - > -typename range_return::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2); - template< range_return_value re, class SinglePassRange1, @@ -52,15 +31,6 @@ template< > typename range_return::type find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); - -template< - range_return_value re, - class SinglePassRange1, - class ForwardRange2, - class BinaryPredicate - > -typename range_return::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred); `` [heading Description] diff --git a/doc/reference/algorithm/find_if.qbk b/doc/reference/algorithm/find_if.qbk index 81ba4c3..862d8a1 100644 --- a/doc/reference/algorithm/find_if.qbk +++ b/doc/reference/algorithm/find_if.qbk @@ -7,10 +7,6 @@ template typename range_iterator::type find_if(SinglePassRange& rng, UnaryPredicate pred); -template -typename range_iterator::type -find_if(const SinglePassRange& rng, UnaryPredicate pred); - template< range_return_value re, class SinglePassRange, @@ -18,14 +14,6 @@ template< > typename range_return::type find_if(SinglePassRange& rng, UnaryPredicate pred); - -template< - range_return_value re, - class SinglePassRange, - class UnaryPredicate - > -typename range_return::type -find_if(const SinglePassRange& rng, UnaryPredicate pred); `` [heading Description] diff --git a/doc/reference/algorithm/lower_bound.qbk b/doc/reference/algorithm/lower_bound.qbk index 26b5ab1..6228928 100644 --- a/doc/reference/algorithm/lower_bound.qbk +++ b/doc/reference/algorithm/lower_bound.qbk @@ -7,10 +7,6 @@ template typename range_iterator::type lower_bound(ForwardRange& rng, Value val); -template -typename range_iterator::type -lower_bound(const ForwardRange& rng, Value val); - template< range_return_value re, class ForwardRange, @@ -18,14 +14,6 @@ template< > typename range_return::type lower_bound(ForwardRange& rng, Value val); - -template< - range_return_value re, - class ForwardRange, - class Value - > -typename range_return::type -lower_bound(const ForwardRange& rng, Value val); `` [heading Description] diff --git a/doc/reference/algorithm/upper_bound.qbk b/doc/reference/algorithm/upper_bound.qbk index 43ea642..7882410 100644 --- a/doc/reference/algorithm/upper_bound.qbk +++ b/doc/reference/algorithm/upper_bound.qbk @@ -7,10 +7,6 @@ template typename range_iterator::type upper_bound(ForwardRange& rng, Value val); -template -typename range_iterator::type -upper_bound(const ForwardRange& rng, Value val); - template< range_return_value re, class ForwardRange, @@ -18,14 +14,6 @@ template< > typename range_return::type upper_bound(ForwardRange& rng, Value val); - -template< - range_return_value re, - class ForwardRange, - class Value - > -typename range_return::type -upper_bound(const ForwardRange& rng, Value val); `` [heading Description] @@ -36,7 +24,7 @@ with predicate - `pred(val, *i)` is `true`. `end(rng)` is returned if no such iterator exists. -The versions of `upper_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. +The versions of `upper_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. [heading Definition] diff --git a/include/boost/range/algorithm/find.hpp b/include/boost/range/algorithm/find.hpp index d9d5b14..df39efe 100755 --- a/include/boost/range/algorithm/find.hpp +++ b/include/boost/range/algorithm/find.hpp @@ -33,14 +33,6 @@ find( SinglePassRange& rng, const Value& val ) BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::find(boost::begin(rng), boost::end(rng), val); } -/// \overload -template< class SinglePassRange, class Value > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -find( const SinglePassRange& rng, const Value& val ) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return std::find(boost::begin(rng), boost::end(rng), val); -} // range_return overloads @@ -54,16 +46,6 @@ find( SinglePassRange& rng, const Value& val ) pack(std::find(boost::begin(rng), boost::end(rng), val), rng); } -/// \overload -template< range_return_value re, class SinglePassRange, class Value > -inline BOOST_DEDUCED_TYPENAME range_return::type -find( const SinglePassRange& rng, const Value& val ) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return range_return:: - pack(std::find(boost::begin(rng), boost::end(rng), val), - rng); -} } // namespace range using range::find; diff --git a/include/boost/range/algorithm/find_end.hpp b/include/boost/range/algorithm/find_end.hpp index aaf4888..5f4fada 100755 --- a/include/boost/range/algorithm/find_end.hpp +++ b/include/boost/range/algorithm/find_end.hpp @@ -30,7 +30,7 @@ namespace boost /// \pre BinaryPredicate is a model of the BinaryPredicateConcept template< class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type -find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2) +find_end(ForwardRange1 & rng1, const ForwardRange2& rng2) { BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); @@ -39,23 +39,10 @@ find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2) boost::begin(rng2),boost::end(rng2)); } -/// \overload -template< class ForwardRange1, class ForwardRange2 > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2) -{ - - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return std::find_end(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); -} - /// \overload template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type -find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) +find_end(ForwardRange1 & rng1, const ForwardRange2& rng2, BinaryPredicate pred) { BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); @@ -64,18 +51,6 @@ find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) boost::begin(rng2),boost::end(rng2),pred); } -/// \overload -template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return std::find_end(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); -} - /// \overload template< range_return_value re, class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_return::type @@ -90,20 +65,6 @@ find_end(ForwardRange1& rng1, const ForwardRange2& rng2) rng1); } -/// \overload -template< range_return_value re, class ForwardRange1, class ForwardRange2 > -inline BOOST_DEDUCED_TYPENAME range_return::type -find_end(const ForwardRange1& rng1, const ForwardRange2& rng2) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return range_return:: - pack(std::find_end(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)), - rng1); -} - /// \overload template< range_return_value re, class ForwardRange1, class ForwardRange2, class BinaryPredicate > @@ -119,22 +80,6 @@ find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) rng1); } -/// \overload -template< range_return_value re, class ForwardRange1, class ForwardRange2, - class BinaryPredicate > -inline BOOST_DEDUCED_TYPENAME range_return::type -find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return range_return:: - pack(std::find_end(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), pred), - rng1); -} - } // namespace range using range::find_end; } // namespace boost diff --git a/include/boost/range/algorithm/find_first_of.hpp b/include/boost/range/algorithm/find_first_of.hpp index 3902cd0..4bd304e 100755 --- a/include/boost/range/algorithm/find_first_of.hpp +++ b/include/boost/range/algorithm/find_first_of.hpp @@ -39,18 +39,6 @@ find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2) boost::begin(rng2),boost::end(rng2)); } -/// \overload -template< class SinglePassRange1, class ForwardRange2 > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -find_first_of(SinglePassRange1 const & rng1, ForwardRange2 const & rng2) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return std::find_first_of(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2)); -} - /// \overload template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type @@ -63,19 +51,6 @@ find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredica boost::begin(rng2),boost::end(rng2),pred); } -/// \overload -template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return std::find_first_of(boost::begin(rng1),boost::end(rng1), - boost::begin(rng2),boost::end(rng2),pred); -} - // range return overloads /// \overload template< range_return_value re, class SinglePassRange1, class ForwardRange2 > @@ -91,20 +66,6 @@ find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2) rng1); } -/// \overload -template< range_return_value re, class SinglePassRange1, class ForwardRange2 > -inline BOOST_DEDUCED_TYPENAME range_return::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return range_return:: - pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2)), - rng1); -} - /// \overload template< range_return_value re, class SinglePassRange1, class ForwardRange2, class BinaryPredicate > @@ -121,22 +82,6 @@ find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2, rng1); } -/// \overload -template< range_return_value re, class SinglePassRange1, class ForwardRange2, - class BinaryPredicate > -inline BOOST_DEDUCED_TYPENAME range_return::type -find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, - BinaryPredicate pred) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - - return range_return:: - pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2),pred), - rng1); -} - } // namespace range using range::find_first_of; } // namespace boost diff --git a/include/boost/range/algorithm/find_if.hpp b/include/boost/range/algorithm/find_if.hpp index f36c4e5..1a42e3a 100755 --- a/include/boost/range/algorithm/find_if.hpp +++ b/include/boost/range/algorithm/find_if.hpp @@ -34,14 +34,6 @@ find_if( SinglePassRange& rng, UnaryPredicate pred ) BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::find_if(boost::begin(rng), boost::end(rng), pred); } -/// \overload -template< class SinglePassRange, class UnaryPredicate > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -find_if( const SinglePassRange& rng, UnaryPredicate pred ) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return std::find_if(boost::begin(rng), boost::end(rng), pred); -} // range_return overloads @@ -55,16 +47,6 @@ find_if( SinglePassRange& rng, UnaryPredicate pred ) pack(std::find_if(boost::begin(rng), boost::end(rng), pred), rng); } -/// \overload -template< range_return_value re, class SinglePassRange, class UnaryPredicate > -inline BOOST_DEDUCED_TYPENAME range_return::type -find_if( const SinglePassRange& rng, UnaryPredicate pred ) -{ - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return range_return:: - pack(std::find_if(boost::begin(rng), boost::end(rng), pred), - rng); -} } // namespace range using range::find_if; diff --git a/include/boost/range/algorithm/lower_bound.hpp b/include/boost/range/algorithm/lower_bound.hpp index 682ba36..8a954b3 100755 --- a/include/boost/range/algorithm/lower_bound.hpp +++ b/include/boost/range/algorithm/lower_bound.hpp @@ -34,14 +34,6 @@ lower_bound( ForwardRange& rng, Value val ) return std::lower_bound(boost::begin(rng), boost::end(rng), val); } /// \overload -template< class ForwardRange, class Value > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -lower_bound( const ForwardRange& rng, Value val ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::lower_bound(boost::begin(rng), boost::end(rng), val); -} -/// \overload template< class ForwardRange, class Value, class SortPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) @@ -50,14 +42,6 @@ lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); } /// \overload -template< class ForwardRange, class Value, class SortPredicate > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); -} -/// \overload template< range_return_value re, class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type lower_bound( ForwardRange& rng, Value val ) @@ -68,16 +52,6 @@ lower_bound( ForwardRange& rng, Value val ) rng); } /// \overload -template< range_return_value re, class ForwardRange, class Value > -inline BOOST_DEDUCED_TYPENAME range_return::type -lower_bound( const ForwardRange& rng, Value val ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return range_return:: - pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), - rng); -} -/// \overload template< range_return_value re, class ForwardRange, class Value, class SortPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) @@ -87,16 +61,6 @@ lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), rng); } -/// \overload -template< range_return_value re, class ForwardRange, class Value, class SortPredicate > -inline BOOST_DEDUCED_TYPENAME range_return::type -lower_bound( const ForwardRange& rng, Value val, SortPredicate pred ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return range_return:: - pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), - rng); -} } // namespace range using range::lower_bound; diff --git a/include/boost/range/algorithm/upper_bound.hpp b/include/boost/range/algorithm/upper_bound.hpp index e11acad..fa755c1 100755 --- a/include/boost/range/algorithm/upper_bound.hpp +++ b/include/boost/range/algorithm/upper_bound.hpp @@ -34,13 +34,6 @@ upper_bound( ForwardRange& rng, Value val ) return std::upper_bound(boost::begin(rng), boost::end(rng), val); } /// \overload -template< class ForwardRange, class Value > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -upper_bound( const ForwardRange& rng, Value val ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::upper_bound(boost::begin(rng), boost::end(rng), val); -} /// \overload template< class ForwardRange, class Value, class SortPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type @@ -50,14 +43,6 @@ upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); } /// \overload -template< class ForwardRange, class Value, class SortPredicate > -inline BOOST_DEDUCED_TYPENAME range_iterator::type -upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); -} -/// \overload template< range_return_value re, class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type upper_bound( ForwardRange& rng, Value val ) @@ -68,16 +53,6 @@ upper_bound( ForwardRange& rng, Value val ) rng); } /// \overload -template< range_return_value re, class ForwardRange, class Value > -inline BOOST_DEDUCED_TYPENAME range_return::type -upper_bound( const ForwardRange& rng, Value val ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return range_return:: - pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), - rng); -} -/// \overload template< range_return_value re, class ForwardRange, class Value, class SortPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type @@ -88,17 +63,6 @@ upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), rng); } -/// \overload -template< range_return_value re, class ForwardRange, class Value, - class SortPredicate > -inline BOOST_DEDUCED_TYPENAME range_return::type -upper_bound( const ForwardRange& rng, Value val, SortPredicate pred ) -{ - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - return range_return:: - pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), - rng); -} } // namespace range using range::upper_bound; diff --git a/test/algorithm_test/find.cpp b/test/algorithm_test/find.cpp index e0607f0..6b3d532 100644 --- a/test/algorithm_test/find.cpp +++ b/test/algorithm_test/find.cpp @@ -86,6 +86,10 @@ namespace boost test_find_container< const std::vector >(); test_find_container< const std::list >(); test_find_container< const std::deque >(); + + std::vector vi; + const std::vector& cvi = vi; + std::vector::const_iterator it = boost::find(vi, 0); } } } diff --git a/test/sub_range.cpp b/test/sub_range.cpp old mode 100755 new mode 100644 index 7d5bf05..80c942f --- a/test/sub_range.cpp +++ b/test/sub_range.cpp @@ -17,51 +17,48 @@ #endif #include -#include +#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; + + typedef std::string::iterator iterator; + typedef std::string::const_iterator const_iterator; + typedef boost::iterator_range irange; + typedef boost::iterator_range cirange; + std::string str = "hello world"; + const std::string cstr = "const world"; + irange r = boost::make_iterator_range( str ); + r = boost::make_iterator_range( str.begin(), str.end() ); + cirange r2 = boost::make_iterator_range( cstr ); + r2 = boost::make_iterator_range( cstr.begin(), cstr.end() ); + r2 = boost::make_iterator_range( str ); + + typedef boost::sub_range srange; + typedef boost::sub_range csrange; srange s = r; BOOST_CHECK( r == r ); BOOST_CHECK( s == r ); - s = make_iterator_range( str ); + s = boost::make_iterator_range( str ); csrange s2 = r; s2 = r2; - s2 = make_iterator_range( cstr ); + s2 = boost::make_iterator_range( cstr ); BOOST_CHECK( r2 == r2 ); BOOST_CHECK( s2 != r2 ); - s2 = make_iterator_range( str ); + s2 = boost::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 ); @@ -70,7 +67,7 @@ void check_sub_range() // if( !(bool)s ) // BOOST_CHECK( false ); // if( !(bool)s2 ) -// BOOST_CHECK( false ); +// BOOST_CHECK( false ); //#else if( !r ) BOOST_CHECK( false ); @@ -80,13 +77,13 @@ void check_sub_range() BOOST_CHECK( false ); if( !s2 ) BOOST_CHECK( false ); -//#endif +//#endif + + std::cout << r << r2 << s << s2; + + std::string res = boost::copy_range( r ); + BOOST_CHECK_EQUAL_COLLECTIONS( res.begin(), res.end(), r.begin(), r.end() ); - 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(); @@ -107,44 +104,43 @@ void check_sub_range() //BOOST_CHECK( empty( singular_srange ) ); // - srange rr = make_iterator_range( str ); + srange rr = boost::make_iterator_range( str ); BOOST_CHECK( rr.equal( r ) ); - rr = make_iterator_range( str.begin(), str.begin() + 5 ); - BOOST_CHECK( rr == as_literal("hello") ); - BOOST_CHECK( rr != as_literal("hell") ); - BOOST_CHECK( rr < as_literal("hello dude") ); - BOOST_CHECK( as_literal("hello") == rr ); - BOOST_CHECK( as_literal("hell") != rr ); - BOOST_CHECK( ! (as_literal("hello dude") < rr ) ); - + rr = boost::make_iterator_range( str.begin(), str.begin() + 5 ); + BOOST_CHECK( rr == boost::as_literal("hello") ); + BOOST_CHECK( rr != boost::as_literal("hell") ); + BOOST_CHECK( rr < boost::as_literal("hello dude") ); + BOOST_CHECK( boost::as_literal("hello") == rr ); + BOOST_CHECK( boost::as_literal("hell") != rr ); + BOOST_CHECK( ! (boost::as_literal("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 ); + const irange cr = boost::make_iterator_range( str ); BOOST_CHECK_EQUAL( cr.front(), 'h' ); BOOST_CHECK_EQUAL( cr.back(), 'd' ); BOOST_CHECK_EQUAL( cr[1], 'e' ); BOOST_CHECK_EQUAL( cr(1), 'e' ); - rrr = make_iterator_range( str, 1, -1 ); - BOOST_CHECK( rrr == as_literal("ello worl") ); - rrr = make_iterator_range( rrr, -1, 1 ); + rrr = boost::make_iterator_range( str, 1, -1 ); + BOOST_CHECK( rrr == boost::as_literal("ello worl") ); + rrr = boost::make_iterator_range( rrr, -1, 1 ); BOOST_CHECK( rrr == str ); rrr.front() = 'H'; rrr.back() = 'D'; rrr[1] = 'E'; - BOOST_CHECK( rrr == as_literal("HEllo worlD") ); -} + BOOST_CHECK( rrr == boost::as_literal("HEllo worlD") ); +} #include -using boost::unit_test::test_suite; -test_suite* init_unit_test_suite( int argc, char* argv[] ) +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); + boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); test->add( BOOST_TEST_CASE( &check_sub_range ) ); From 71c2ca614cb2ad09a0432b7911dad595bfb79fe0 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sat, 3 Apr 2010 22:09:29 +0000 Subject: [PATCH 89/92] Boost.Range Fix for trac issue #3110 - Multi_array and iterator_range interaction. This has been fixed by reusing the well proven iterator_facade operator[] mechanism. [SVN r61029] --- include/boost/range/iterator_range_core.hpp | 214 ++++++++++---------- 1 file changed, 109 insertions(+), 105 deletions(-) diff --git a/include/boost/range/iterator_range_core.hpp b/include/boost/range/iterator_range_core.hpp index 7514c81..571bf7d 100755 --- a/include/boost/range/iterator_range_core.hpp +++ b/include/boost/range/iterator_range_core.hpp @@ -19,7 +19,8 @@ #endif #include -#include +#include +#include #include #include #include @@ -31,13 +32,13 @@ #include /*! \file - Defines the \c iterator_class and related functions. + Defines the \c iterator_class and related functions. \c iterator_range is a simple wrapper of iterator pair idiom. It provides a rich subset of Container interface. */ -namespace boost +namespace boost { namespace iterator_range_detail { @@ -45,14 +46,14 @@ namespace boost // The functions adl_begin and adl_end are implemented in a separate // class for gcc-2.9x // - template + template struct iterator_range_impl { template< class ForwardRange > static IteratorT adl_begin( ForwardRange& r ) { return IteratorT( boost::begin( r ) ); } - + template< class ForwardRange > static IteratorT adl_end( ForwardRange& r ) { @@ -62,11 +63,11 @@ namespace boost template< class Left, class Right > inline bool less_than( const Left& l, const Right& r ) - { - return std::lexicographical_compare( boost::begin(l), - boost::end(l), - boost::begin(r), - boost::end(r) ); + { + return std::lexicographical_compare( boost::begin(l), + boost::end(l), + boost::begin(r), + boost::end(r) ); } // This version is maintained since it is used in other boost libraries @@ -76,7 +77,7 @@ namespace boost { return boost::equal(l, r); } - + struct range_tag { }; struct const_range_tag { }; @@ -86,22 +87,22 @@ namespace boost //! iterator_range class /*! - An \c iterator_range delimits a range in a sequence by beginning and ending iterators. - An iterator_range can be passed to an algorithm which requires a sequence as an input. - For example, the \c toupper() function may be used most frequently on strings, - but can also be used on iterator_ranges: - + An \c iterator_range delimits a range in a sequence by beginning and ending iterators. + An iterator_range can be passed to an algorithm which requires a sequence as an input. + For example, the \c toupper() function may be used most frequently on strings, + but can also be used on iterator_ranges: + \code boost::tolower( find( s, "UPPERCASE STRING" ) ); \endcode - Many algorithms working with sequences take a pair of iterators, - delimiting a working range, as an arguments. The \c iterator_range class is an - encapsulation of a range identified by a pair of iterators. - It provides a collection interface, - so it is possible to pass an instance to an algorithm requiring a collection as an input. + Many algorithms working with sequences take a pair of iterators, + delimiting a working range, as an arguments. The \c iterator_range class is an + encapsulation of a range identified by a pair of iterators. + It provides a collection interface, + so it is possible to pass an instance to an algorithm requiring a collection as an input. */ - template + template class iterator_range { protected: // Used by sub_range @@ -112,15 +113,15 @@ namespace boost //! this type typedef iterator_range type; //BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type); - + //! Encapsulated value type - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME iterator_value::type value_type; //! Difference type - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME iterator_difference::type difference_type; - + //! Size type typedef std::size_t size_type; // note: must be unsigned @@ -129,81 +130,81 @@ namespace boost //! Reference type // - // Needed because value-type is the same for + // Needed because value-type is the same for // const and non-const iterators // typedef BOOST_DEDUCED_TYPENAME iterator_reference::type reference; - + //! const_iterator type - /*! + /*! There is no distinction between const_iterator and iterator. These typedefs are provides to fulfill container interface - */ + */ typedef IteratorT const_iterator; //! iterator type typedef IteratorT iterator; private: // for return value of operator()() - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< boost::is_abstract, reference, value_type >::type abstract_value_type; public: iterator_range() : m_Begin( iterator() ), m_End( iterator() ) { } - + //! Constructor from a pair of iterators template< class Iterator > - iterator_range( Iterator Begin, Iterator End ) : + iterator_range( Iterator Begin, Iterator End ) : m_Begin(Begin), m_End(End) {} //! Constructor from a Range template< class Range > - iterator_range( const Range& r ) : - m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - {} - - //! Constructor from a Range - template< class Range > - iterator_range( Range& r ) : + iterator_range( const Range& r ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) {} //! Constructor from a Range template< class Range > - iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : + iterator_range( Range& r ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) {} //! Constructor from a Range template< class Range > - iterator_range( Range& r, iterator_range_detail::range_tag ) : + iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : + m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) + {} + + //! Constructor from a Range + template< class Range > + iterator_range( Range& r, iterator_range_detail::range_tag ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) {} #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - this_type& operator=( const this_type& r ) + this_type& operator=( const this_type& r ) { - m_Begin = r.begin(); + m_Begin = r.begin(); m_End = r.end(); return *this; } #endif - + template< class Iterator > - iterator_range& operator=( const iterator_range& r ) + iterator_range& operator=( const iterator_range& r ) { - m_Begin = r.begin(); + m_Begin = r.begin(); m_End = r.end(); return *this; } - + template< class ForwardRange > iterator_range& operator=( ForwardRange& r ) { - m_Begin = impl::adl_begin( r ); + m_Begin = impl::adl_begin( r ); m_End = impl::adl_end( r ); return *this; } @@ -211,37 +212,37 @@ namespace boost template< class ForwardRange > iterator_range& operator=( const ForwardRange& r ) { - m_Begin = impl::adl_begin( r ); + m_Begin = impl::adl_begin( r ); m_End = impl::adl_end( r ); return *this; } - IteratorT begin() const - { - return m_Begin; + IteratorT begin() const + { + return m_Begin; } - IteratorT end() const - { - return m_End; - } + IteratorT end() const + { + return m_End; + } difference_type size() const - { + { return m_End - m_Begin; } - + bool empty() const { return m_Begin == m_End; } -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) operator bool() const { return !empty(); - } -#else + } +#else typedef iterator (iterator_range::*unspecified_bool_type) () const; operator unspecified_bool_type() const { @@ -272,7 +273,7 @@ namespace boost return iterator_range_detail::less_than( *this, r ); } -#endif +#endif public: // convenience reference front() const @@ -280,29 +281,32 @@ namespace boost BOOST_ASSERT( !empty() ); return *m_Begin; } - + reference back() const { BOOST_ASSERT( !empty() ); IteratorT last( m_End ); return *--last; } - - reference operator[]( difference_type at ) const + + BOOST_DEDUCED_TYPENAME boost::detail::operator_brackets_result::type + operator[]( difference_type at ) const { BOOST_ASSERT( at >= 0 && at < size() ); - return m_Begin[at]; + + typedef boost::detail::use_operator_brackets_proxy use_proxy; + return boost::detail::make_operator_brackets_result(m_Begin + at, use_proxy()); } // // When storing transform iterators, operator[]() // fails because it returns by reference. Therefore // operator()() is provided for these cases. - // - abstract_value_type operator()( difference_type at ) const + // + abstract_value_type operator()( difference_type at ) const { BOOST_ASSERT( at >= 0 && at < size() ); - return m_Begin[at]; + return m_Begin[at]; } iterator_range& advance_begin( difference_type n ) @@ -310,13 +314,13 @@ namespace boost std::advance( m_Begin, n ); return *this; } - + iterator_range& advance_end( difference_type n ) { std::advance( m_End, n ); return *this; } - + private: // begin and end iterators IteratorT m_Begin; @@ -337,21 +341,21 @@ namespace boost ///////////////////////////////////////////////////////////////////// template< class IteratorT, class ForwardRange > - inline bool operator==( const ForwardRange& l, + inline bool operator==( const ForwardRange& l, const iterator_range& r ) { return boost::equal( l, r ); } template< class IteratorT, class ForwardRange > - inline bool operator!=( const ForwardRange& l, + inline bool operator!=( const ForwardRange& l, const iterator_range& r ) { return !boost::equal( l, r ); } template< class IteratorT, class ForwardRange > - inline bool operator<( const ForwardRange& l, + inline bool operator<( const ForwardRange& l, const iterator_range& r ) { return iterator_range_detail::less_than( l, r ); @@ -360,14 +364,14 @@ namespace boost #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING #else template< class Iterator1T, class Iterator2T > - inline bool operator==( const iterator_range& l, + inline bool operator==( const iterator_range& l, const iterator_range& r ) { return boost::equal( l, r ); } template< class IteratorT, class ForwardRange > - inline bool operator==( const iterator_range& l, + inline bool operator==( const iterator_range& l, const ForwardRange& r ) { return boost::equal( l, r ); @@ -375,39 +379,39 @@ namespace boost template< class Iterator1T, class Iterator2T > - inline bool operator!=( const iterator_range& l, + inline bool operator!=( const iterator_range& l, const iterator_range& r ) { return !boost::equal( l, r ); } - + template< class IteratorT, class ForwardRange > - inline bool operator!=( const iterator_range& l, + inline bool operator!=( const iterator_range& l, const ForwardRange& r ) { return !boost::equal( l, r ); } - + template< class Iterator1T, class Iterator2T > - inline bool operator<( const iterator_range& l, + inline bool operator<( const iterator_range& l, const iterator_range& r ) { return iterator_range_detail::less_than( l, r ); } template< class IteratorT, class ForwardRange > - inline bool operator<( const iterator_range& l, + inline bool operator<( const iterator_range& l, const ForwardRange& r ) - { + { return iterator_range_detail::less_than( l, r ); } #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING - + // iterator range utilities -----------------------------------------// - //! iterator_range construct helper + //! iterator_range construct helper /*! Construct an \c iterator_range from a pair of iterators @@ -416,22 +420,22 @@ namespace boost \return iterator_range object */ template< typename IteratorT > - inline iterator_range< IteratorT > - make_iterator_range( IteratorT Begin, IteratorT End ) - { + inline iterator_range< IteratorT > + make_iterator_range( IteratorT Begin, IteratorT End ) + { return iterator_range( Begin, End ); } - + #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< typename Range > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( Range& r ) - { + make_iterator_range( Range& r ) + { return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > ( boost::begin( r ), boost::end( r ) ); } - + #else //! iterator_range construct helper /*! @@ -440,16 +444,16 @@ namespace boost */ template< class ForwardRange > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( ForwardRange& r ) - { + make_iterator_range( ForwardRange& r ) + { return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > ( r, iterator_range_detail::range_tag() ); } template< class ForwardRange > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( const ForwardRange& r ) - { + make_iterator_range( const ForwardRange& r ) + { return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > ( r, iterator_range_detail::const_range_tag() ); } @@ -457,10 +461,10 @@ namespace boost #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING namespace iterator_range_detail - { + { template< class Range > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_range_impl( Range& r, + make_range_impl( Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) { @@ -471,7 +475,7 @@ namespace boost // return make_iterator_range( r ); // - BOOST_DEDUCED_TYPENAME range_iterator::type + BOOST_DEDUCED_TYPENAME range_iterator::type new_begin = boost::begin( r ), new_end = boost::end( r ); std::advance( new_begin, advance_begin ); @@ -479,12 +483,12 @@ namespace boost return make_iterator_range( new_begin, new_end ); } } - + #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING template< class Range > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( Range& r, + make_iterator_range( Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) { @@ -496,7 +500,7 @@ namespace boost template< class Range > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( Range& r, + make_iterator_range( Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) { @@ -506,7 +510,7 @@ namespace boost template< class Range > inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator::type > - make_iterator_range( const Range& r, + make_iterator_range( const Range& r, BOOST_DEDUCED_TYPENAME range_difference::type advance_begin, BOOST_DEDUCED_TYPENAME range_difference::type advance_end ) { @@ -532,7 +536,7 @@ namespace boost } // namespace 'boost' -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) #pragma warning( pop ) #endif From debce93f6317d5477f2820ab04953cff9d65a2ee Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 4 Apr 2010 10:47:21 +0000 Subject: [PATCH 90/92] Boost.Range is modified to conditionally compile concept assertions. This has been configured to disable concept assertions in Boost.Range for known broken compilers. [SVN r61035] --- .../boost/range/algorithm/adjacent_find.hpp | 22 ++--- .../boost/range/algorithm/binary_search.hpp | 4 +- include/boost/range/algorithm/copy.hpp | 2 +- .../boost/range/algorithm/copy_backward.hpp | 2 +- include/boost/range/algorithm/count.hpp | 4 +- include/boost/range/algorithm/count_if.hpp | 4 +- include/boost/range/algorithm/equal.hpp | 8 +- include/boost/range/algorithm/equal_range.hpp | 8 +- include/boost/range/algorithm/fill.hpp | 2 +- include/boost/range/algorithm/fill_n.hpp | 2 +- include/boost/range/algorithm/find.hpp | 4 +- include/boost/range/algorithm/find_end.hpp | 16 ++-- .../boost/range/algorithm/find_first_of.hpp | 16 ++-- include/boost/range/algorithm/find_if.hpp | 4 +- include/boost/range/algorithm/for_each.hpp | 4 +- include/boost/range/algorithm/generate.hpp | 4 +- .../boost/range/algorithm/heap_algorithm.hpp | 32 ++++---- .../boost/range/algorithm/inplace_merge.hpp | 8 +- .../algorithm/lexicographical_compare.hpp | 8 +- include/boost/range/algorithm/lower_bound.hpp | 8 +- include/boost/range/algorithm/max_element.hpp | 16 ++-- include/boost/range/algorithm/merge.hpp | 8 +- include/boost/range/algorithm/min_element.hpp | 16 ++-- include/boost/range/algorithm/mismatch.hpp | 32 ++++---- include/boost/range/algorithm/nth_element.hpp | 8 +- .../boost/range/algorithm/partial_sort.hpp | 8 +- .../range/algorithm/partial_sort_copy.hpp | 16 ++-- include/boost/range/algorithm/partition.hpp | 8 +- include/boost/range/algorithm/permutation.hpp | 16 ++-- .../boost/range/algorithm/random_shuffle.hpp | 8 +- include/boost/range/algorithm/remove.hpp | 8 +- include/boost/range/algorithm/remove_copy.hpp | 2 +- include/boost/range/algorithm/remove_if.hpp | 8 +- include/boost/range/algorithm/replace.hpp | 4 +- .../boost/range/algorithm/replace_copy.hpp | 2 +- .../boost/range/algorithm/replace_copy_if.hpp | 2 +- include/boost/range/algorithm/replace_if.hpp | 4 +- include/boost/range/algorithm/reverse.hpp | 4 +- .../boost/range/algorithm/reverse_copy.hpp | 4 +- include/boost/range/algorithm/rotate.hpp | 4 +- include/boost/range/algorithm/rotate_copy.hpp | 2 +- include/boost/range/algorithm/search.hpp | 32 ++++---- include/boost/range/algorithm/search_n.hpp | 24 +++--- .../boost/range/algorithm/set_algorithm.hpp | 40 +++++----- include/boost/range/algorithm/sort.hpp | 8 +- .../range/algorithm/stable_partition.hpp | 8 +- include/boost/range/algorithm/stable_sort.hpp | 8 +- include/boost/range/algorithm/swap_ranges.hpp | 4 +- include/boost/range/algorithm/transform.hpp | 6 +- include/boost/range/algorithm/unique.hpp | 16 ++-- include/boost/range/algorithm/unique_copy.hpp | 4 +- include/boost/range/algorithm/upper_bound.hpp | 8 +- .../boost/range/algorithm_ext/is_sorted.hpp | 8 +- include/boost/range/concepts.hpp | 80 ++++++++++++++++--- include/boost/range/join.hpp | 8 +- 55 files changed, 325 insertions(+), 271 deletions(-) diff --git a/include/boost/range/algorithm/adjacent_find.hpp b/include/boost/range/algorithm/adjacent_find.hpp index c42e5ee..1b88dae 100755 --- a/include/boost/range/algorithm/adjacent_find.hpp +++ b/include/boost/range/algorithm/adjacent_find.hpp @@ -32,7 +32,7 @@ template< typename ForwardRange > inline typename range_iterator::type adjacent_find(ForwardRange & rng) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return std::adjacent_find(boost::begin(rng),boost::end(rng)); } @@ -41,7 +41,7 @@ template< typename ForwardRange > inline typename range_iterator::type adjacent_find(const ForwardRange& rng) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return std::adjacent_find(boost::begin(rng),boost::end(rng)); } @@ -50,8 +50,8 @@ template< typename ForwardRange, typename BinaryPredicate > inline typename range_iterator::type adjacent_find(ForwardRange & rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); @@ -62,8 +62,8 @@ template< typename ForwardRange, typename BinaryPredicate > inline typename range_iterator::type adjacent_find(const ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); return std::adjacent_find(boost::begin(rng),boost::end(rng),pred); @@ -76,7 +76,7 @@ template< range_return_value re, typename ForwardRange > inline typename range_return::type adjacent_find(ForwardRange & rng) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return range_return:: pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), rng); @@ -87,7 +87,7 @@ template< range_return_value re, typename ForwardRange > inline typename range_return::type adjacent_find(const ForwardRange& rng) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return range_return:: pack(std::adjacent_find(boost::begin(rng),boost::end(rng)), rng); @@ -98,8 +98,8 @@ template< range_return_value re, typename ForwardRange, typename BinaryPredicate inline typename range_return::type adjacent_find(ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); return range_return:: @@ -112,7 +112,7 @@ template< range_return_value re, typename ForwardRange, typename BinaryPredicate inline typename range_return::type adjacent_find(const ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return range_return:: pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred), rng); diff --git a/include/boost/range/algorithm/binary_search.hpp b/include/boost/range/algorithm/binary_search.hpp index 41860a5..bb64ec8 100755 --- a/include/boost/range/algorithm/binary_search.hpp +++ b/include/boost/range/algorithm/binary_search.hpp @@ -29,7 +29,7 @@ namespace boost template inline bool binary_search(const ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::binary_search(boost::begin(rng), boost::end(rng), val); } @@ -38,7 +38,7 @@ template inline bool binary_search(const ForwardRange& rng, const Value& val, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::binary_search(boost::begin(rng), boost::end(rng), val, pred); } diff --git a/include/boost/range/algorithm/copy.hpp b/include/boost/range/algorithm/copy.hpp index b097d00..dc5a0c3 100644 --- a/include/boost/range/algorithm/copy.hpp +++ b/include/boost/range/algorithm/copy.hpp @@ -30,7 +30,7 @@ namespace boost template< class SinglePassRange, class OutputIterator > inline OutputIterator copy(const SinglePassRange& rng, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::copy(boost::begin(rng),boost::end(rng),out); } diff --git a/include/boost/range/algorithm/copy_backward.hpp b/include/boost/range/algorithm/copy_backward.hpp index fddd0a8..52dc922 100755 --- a/include/boost/range/algorithm/copy_backward.hpp +++ b/include/boost/range/algorithm/copy_backward.hpp @@ -32,7 +32,7 @@ inline BidirectionalTraversalWriteableIterator copy_backward(const BidirectionalRange& rng, BidirectionalTraversalWriteableIterator out) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::copy_backward(boost::begin(rng), boost::end(rng), out); } diff --git a/include/boost/range/algorithm/count.hpp b/include/boost/range/algorithm/count.hpp index ab4fdd1..8316ce0 100755 --- a/include/boost/range/algorithm/count.hpp +++ b/include/boost/range/algorithm/count.hpp @@ -30,7 +30,7 @@ template< class SinglePassRange, class Value > inline BOOST_DEDUCED_TYPENAME range_difference::type count(SinglePassRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::count(boost::begin(rng), boost::end(rng), val); } @@ -39,7 +39,7 @@ template< class SinglePassRange, class Value > inline BOOST_DEDUCED_TYPENAME range_difference::type count(const SinglePassRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::count(boost::begin(rng), boost::end(rng), val); } diff --git a/include/boost/range/algorithm/count_if.hpp b/include/boost/range/algorithm/count_if.hpp index 611312c..ae17b0e 100755 --- a/include/boost/range/algorithm/count_if.hpp +++ b/include/boost/range/algorithm/count_if.hpp @@ -31,7 +31,7 @@ template< class SinglePassRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME boost::range_difference::type count_if(SinglePassRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::count_if(boost::begin(rng), boost::end(rng), pred); } @@ -40,7 +40,7 @@ template< class SinglePassRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME boost::range_difference::type count_if(const SinglePassRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::count_if(boost::begin(rng), boost::end(rng), pred); } diff --git a/include/boost/range/algorithm/equal.hpp b/include/boost/range/algorithm/equal.hpp index e9a16fd..e210ef5 100755 --- a/include/boost/range/algorithm/equal.hpp +++ b/include/boost/range/algorithm/equal.hpp @@ -159,8 +159,8 @@ namespace boost template< class SinglePassRange1, class SinglePassRange2 > inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::equal( ::boost::begin(rng1), ::boost::end(rng1), @@ -172,8 +172,8 @@ namespace boost inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::equal( ::boost::begin(rng1), ::boost::end(rng1), diff --git a/include/boost/range/algorithm/equal_range.hpp b/include/boost/range/algorithm/equal_range.hpp index 0643701..4aa4a54 100755 --- a/include/boost/range/algorithm/equal_range.hpp +++ b/include/boost/range/algorithm/equal_range.hpp @@ -33,7 +33,7 @@ inline std::pair< > equal_range(ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::equal_range(boost::begin(rng), boost::end(rng), val); } @@ -45,7 +45,7 @@ inline std::pair< > equal_range(const ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::equal_range(boost::begin(rng), boost::end(rng), val); } @@ -57,7 +57,7 @@ inline std::pair< > equal_range(ForwardRange& rng, const Value& val, SortPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); } @@ -69,7 +69,7 @@ inline std::pair< > equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::equal_range(boost::begin(rng), boost::end(rng), val, pred); } diff --git a/include/boost/range/algorithm/fill.hpp b/include/boost/range/algorithm/fill.hpp index 4d4d750..72c5d58 100755 --- a/include/boost/range/algorithm/fill.hpp +++ b/include/boost/range/algorithm/fill.hpp @@ -28,7 +28,7 @@ namespace boost template< class ForwardRange, class Value > inline ForwardRange& fill(ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::fill(boost::begin(rng), boost::end(rng), val); return rng; } diff --git a/include/boost/range/algorithm/fill_n.hpp b/include/boost/range/algorithm/fill_n.hpp index a6c32bd..f827135 100755 --- a/include/boost/range/algorithm/fill_n.hpp +++ b/include/boost/range/algorithm/fill_n.hpp @@ -29,7 +29,7 @@ namespace boost template< class ForwardRange, class Size, class Value > inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); BOOST_ASSERT( static_cast(std::distance(boost::begin(rng), boost::end(rng))) >= n ); std::fill_n(boost::begin(rng), n, val); return rng; diff --git a/include/boost/range/algorithm/find.hpp b/include/boost/range/algorithm/find.hpp index df39efe..b4bf6d9 100755 --- a/include/boost/range/algorithm/find.hpp +++ b/include/boost/range/algorithm/find.hpp @@ -30,7 +30,7 @@ template< class SinglePassRange, class Value > inline BOOST_DEDUCED_TYPENAME range_iterator::type find( SinglePassRange& rng, const Value& val ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::find(boost::begin(rng), boost::end(rng), val); } @@ -41,7 +41,7 @@ template< range_return_value re, class SinglePassRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type find( SinglePassRange& rng, const Value& val ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return range_return:: pack(std::find(boost::begin(rng), boost::end(rng), val), rng); diff --git a/include/boost/range/algorithm/find_end.hpp b/include/boost/range/algorithm/find_end.hpp index 5f4fada..864d4b0 100755 --- a/include/boost/range/algorithm/find_end.hpp +++ b/include/boost/range/algorithm/find_end.hpp @@ -32,8 +32,8 @@ template< class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type find_end(ForwardRange1 & rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::find_end(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)); @@ -44,8 +44,8 @@ template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type find_end(ForwardRange1 & rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::find_end(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2),pred); @@ -56,8 +56,8 @@ template< range_return_value re, class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_return::type find_end(ForwardRange1& rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::find_end(boost::begin(rng1), boost::end(rng1), @@ -71,8 +71,8 @@ template< range_return_value re, class ForwardRange1, class ForwardRange2, inline BOOST_DEDUCED_TYPENAME range_return::type find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::find_end(boost::begin(rng1), boost::end(rng1), diff --git a/include/boost/range/algorithm/find_first_of.hpp b/include/boost/range/algorithm/find_first_of.hpp index 4bd304e..f7543b7 100755 --- a/include/boost/range/algorithm/find_first_of.hpp +++ b/include/boost/range/algorithm/find_first_of.hpp @@ -32,8 +32,8 @@ template< class SinglePassRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_iterator::type find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::find_first_of(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)); @@ -44,8 +44,8 @@ template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::find_first_of(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2),pred); @@ -57,8 +57,8 @@ template< range_return_value re, class SinglePassRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_return::type find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), @@ -73,8 +73,8 @@ inline BOOST_DEDUCED_TYPENAME range_return::type find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::find_first_of(boost::begin(rng1), boost::end(rng1), diff --git a/include/boost/range/algorithm/find_if.hpp b/include/boost/range/algorithm/find_if.hpp index 1a42e3a..3254d8c 100755 --- a/include/boost/range/algorithm/find_if.hpp +++ b/include/boost/range/algorithm/find_if.hpp @@ -31,7 +31,7 @@ template< class SinglePassRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type find_if( SinglePassRange& rng, UnaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::find_if(boost::begin(rng), boost::end(rng), pred); } @@ -42,7 +42,7 @@ template< range_return_value re, class SinglePassRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type find_if( SinglePassRange& rng, UnaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return range_return:: pack(std::find_if(boost::begin(rng), boost::end(rng), pred), rng); diff --git a/include/boost/range/algorithm/for_each.hpp b/include/boost/range/algorithm/for_each.hpp index 5145432..cc65e6e 100755 --- a/include/boost/range/algorithm/for_each.hpp +++ b/include/boost/range/algorithm/for_each.hpp @@ -29,7 +29,7 @@ namespace boost template< class SinglePassRange, class UnaryFunction > inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::for_each(boost::begin(rng),boost::end(rng),fun); } @@ -37,7 +37,7 @@ inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun) template< class SinglePassRange, class UnaryFunction > inline UnaryFunction for_each(SinglePassRange const & rng, UnaryFunction fun) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::for_each(boost::begin(rng),boost::end(rng),fun); } diff --git a/include/boost/range/algorithm/generate.hpp b/include/boost/range/algorithm/generate.hpp index 7b7dde7..97a0d9d 100755 --- a/include/boost/range/algorithm/generate.hpp +++ b/include/boost/range/algorithm/generate.hpp @@ -28,7 +28,7 @@ namespace boost template< class ForwardRange, class Generator > inline ForwardRange& generate( ForwardRange& rng, Generator gen ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::generate(boost::begin(rng), boost::end(rng), gen); return rng; } @@ -37,7 +37,7 @@ inline ForwardRange& generate( ForwardRange& rng, Generator gen ) template< class ForwardRange, class Generator > inline const ForwardRange& generate(const ForwardRange& rng, Generator gen) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::generate(boost::begin(rng), boost::end(rng), gen); return rng; } diff --git a/include/boost/range/algorithm/heap_algorithm.hpp b/include/boost/range/algorithm/heap_algorithm.hpp index 05c9013..857a30f 100755 --- a/include/boost/range/algorithm/heap_algorithm.hpp +++ b/include/boost/range/algorithm/heap_algorithm.hpp @@ -29,7 +29,7 @@ namespace boost template inline void push_heap(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::push_heap(boost::begin(rng), boost::end(rng)); } @@ -37,7 +37,7 @@ inline void push_heap(RandomAccessRange& rng) template inline void push_heap(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::push_heap(boost::begin(rng), boost::end(rng)); } @@ -45,7 +45,7 @@ inline void push_heap(const RandomAccessRange& rng) template inline void push_heap(RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -53,7 +53,7 @@ inline void push_heap(RandomAccessRange& rng, Compare comp_pred) template inline void push_heap(const RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -66,7 +66,7 @@ inline void push_heap(const RandomAccessRange& rng, Compare comp_pred) template inline void pop_heap(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::pop_heap(boost::begin(rng), boost::end(rng)); } @@ -74,7 +74,7 @@ inline void pop_heap(RandomAccessRange& rng) template inline void pop_heap(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::pop_heap(boost::begin(rng),boost::end(rng)); } @@ -82,7 +82,7 @@ inline void pop_heap(const RandomAccessRange& rng) template inline void pop_heap(RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -90,7 +90,7 @@ inline void pop_heap(RandomAccessRange& rng, Compare comp_pred) template inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -103,7 +103,7 @@ inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred) template inline void make_heap(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::make_heap(boost::begin(rng), boost::end(rng)); } @@ -111,7 +111,7 @@ inline void make_heap(RandomAccessRange& rng) template inline void make_heap(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::make_heap(boost::begin(rng),boost::end(rng)); } @@ -119,7 +119,7 @@ inline void make_heap(const RandomAccessRange& rng) template inline void make_heap(RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -127,7 +127,7 @@ inline void make_heap(RandomAccessRange& rng, Compare comp_pred) template inline void make_heap(const RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -140,7 +140,7 @@ inline void make_heap(const RandomAccessRange& rng, Compare comp_pred) template inline void sort_heap(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort_heap(boost::begin(rng), boost::end(rng)); } @@ -148,7 +148,7 @@ inline void sort_heap(RandomAccessRange& rng) template inline void sort_heap(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort_heap(boost::begin(rng), boost::end(rng)); } @@ -156,7 +156,7 @@ inline void sort_heap(const RandomAccessRange& rng) template inline void sort_heap(RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); } @@ -164,7 +164,7 @@ inline void sort_heap(RandomAccessRange& rng, Compare comp_pred) template inline void sort_heap(const RandomAccessRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); } diff --git a/include/boost/range/algorithm/inplace_merge.hpp b/include/boost/range/algorithm/inplace_merge.hpp index 867b70c..dfadbaa 100755 --- a/include/boost/range/algorithm/inplace_merge.hpp +++ b/include/boost/range/algorithm/inplace_merge.hpp @@ -30,7 +30,7 @@ template inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type middle) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); return rng; } @@ -40,7 +40,7 @@ template inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); std::inplace_merge(boost::begin(rng), middle, boost::end(rng)); return rng; } @@ -51,7 +51,7 @@ inline BidirectionalRange& inplace_merge(BidirectionalRange& rng, BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); return rng; } @@ -62,7 +62,7 @@ inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng, BOOST_DEDUCED_TYPENAME boost::range_iterator::type middle, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred); return rng; } diff --git a/include/boost/range/algorithm/lexicographical_compare.hpp b/include/boost/range/algorithm/lexicographical_compare.hpp index 9c72526..c6e4bc8 100755 --- a/include/boost/range/algorithm/lexicographical_compare.hpp +++ b/include/boost/range/algorithm/lexicographical_compare.hpp @@ -30,8 +30,8 @@ template inline bool lexicographical_compare(const SinglePassRange1& rng1, const SinglePassRange2& rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::lexicographical_compare( boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2)); @@ -44,8 +44,8 @@ inline bool lexicographical_compare(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::lexicographical_compare( boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), pred); diff --git a/include/boost/range/algorithm/lower_bound.hpp b/include/boost/range/algorithm/lower_bound.hpp index 8a954b3..5d3945e 100755 --- a/include/boost/range/algorithm/lower_bound.hpp +++ b/include/boost/range/algorithm/lower_bound.hpp @@ -30,7 +30,7 @@ template< class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_iterator::type lower_bound( ForwardRange& rng, Value val ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::lower_bound(boost::begin(rng), boost::end(rng), val); } /// \overload @@ -38,7 +38,7 @@ template< class ForwardRange, class Value, class SortPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred); } /// \overload @@ -46,7 +46,7 @@ template< range_return_value re, class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type lower_bound( ForwardRange& rng, Value val ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::lower_bound(boost::begin(rng), boost::end(rng), val), rng); @@ -56,7 +56,7 @@ template< range_return_value re, class ForwardRange, class Value, class SortPred inline BOOST_DEDUCED_TYPENAME range_return::type lower_bound( ForwardRange& rng, Value val, SortPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred), rng); diff --git a/include/boost/range/algorithm/max_element.hpp b/include/boost/range/algorithm/max_element.hpp index 3e4df5f..a0c1ffd 100755 --- a/include/boost/range/algorithm/max_element.hpp +++ b/include/boost/range/algorithm/max_element.hpp @@ -31,7 +31,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::max_element(boost::begin(rng), boost::end(rng)); } @@ -40,7 +40,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(const ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::max_element(boost::begin(rng), boost::end(rng)); } @@ -49,7 +49,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::max_element(boost::begin(rng), boost::end(rng), pred); } @@ -58,7 +58,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(const ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::max_element(boost::begin(rng), boost::end(rng), pred); } @@ -69,7 +69,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type max_element(ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::max_element(boost::begin(rng), boost::end(rng)), rng); @@ -80,7 +80,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type max_element(const ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::max_element(boost::begin(rng), boost::end(rng)), rng); @@ -91,7 +91,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type max_element(ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::max_element(boost::begin(rng), boost::end(rng), pred), rng); @@ -102,7 +102,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type max_element(const ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::max_element(boost::begin(rng), boost::end(rng), pred), rng); diff --git a/include/boost/range/algorithm/merge.hpp b/include/boost/range/algorithm/merge.hpp index 7f6030c..c81b8c7 100755 --- a/include/boost/range/algorithm/merge.hpp +++ b/include/boost/range/algorithm/merge.hpp @@ -34,8 +34,8 @@ inline OutputIterator merge(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::merge(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out); } @@ -48,8 +48,8 @@ inline OutputIterator merge(const SinglePassRange1& rng1, OutputIterator out, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::merge(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out, pred); } diff --git a/include/boost/range/algorithm/min_element.hpp b/include/boost/range/algorithm/min_element.hpp index 1fb0f24..c966b1e 100755 --- a/include/boost/range/algorithm/min_element.hpp +++ b/include/boost/range/algorithm/min_element.hpp @@ -31,7 +31,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::min_element(boost::begin(rng), boost::end(rng)); } @@ -40,7 +40,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(const ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::min_element(boost::begin(rng), boost::end(rng)); } @@ -49,7 +49,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::min_element(boost::begin(rng), boost::end(rng), pred); } @@ -58,7 +58,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(const ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::min_element(boost::begin(rng), boost::end(rng), pred); } @@ -69,7 +69,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type min_element(ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::min_element(boost::begin(rng), boost::end(rng)), rng); @@ -80,7 +80,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type min_element(const ForwardRange& rng) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::min_element(boost::begin(rng), boost::end(rng)), rng); @@ -91,7 +91,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type min_element(ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::min_element(boost::begin(rng), boost::end(rng), pred), rng); @@ -102,7 +102,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type min_element(const ForwardRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::min_element(boost::begin(rng), boost::end(rng), pred), rng); diff --git a/include/boost/range/algorithm/mismatch.hpp b/include/boost/range/algorithm/mismatch.hpp index c1cfa87..2819c33 100755 --- a/include/boost/range/algorithm/mismatch.hpp +++ b/include/boost/range/algorithm/mismatch.hpp @@ -74,8 +74,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -89,8 +89,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -104,8 +104,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -119,8 +119,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -135,8 +135,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -150,8 +150,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -165,8 +165,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), @@ -180,8 +180,8 @@ inline std::pair< BOOST_DEDUCED_TYPENAME range_iterator::type > mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return ::boost::range_detail::mismatch_impl( ::boost::begin(rng1), ::boost::end(rng1), diff --git a/include/boost/range/algorithm/nth_element.hpp b/include/boost/range/algorithm/nth_element.hpp index 431aa23..3e06baf 100755 --- a/include/boost/range/algorithm/nth_element.hpp +++ b/include/boost/range/algorithm/nth_element.hpp @@ -30,7 +30,7 @@ template inline void nth_element(RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type nth) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::nth_element(boost::begin(rng), nth, boost::end(rng)); } @@ -39,7 +39,7 @@ template inline void nth_element(const RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type nth) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::nth_element(boost::begin(rng),nth,boost::end(rng)); } @@ -49,7 +49,7 @@ inline void nth_element(RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type nth, BinaryPredicate sort_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred); } @@ -59,7 +59,7 @@ inline void nth_element(const RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type nth, BinaryPredicate sort_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::nth_element(boost::begin(rng),nth,boost::end(rng), sort_pred); } diff --git a/include/boost/range/algorithm/partial_sort.hpp b/include/boost/range/algorithm/partial_sort.hpp index 2881bd4..e38c4be 100755 --- a/include/boost/range/algorithm/partial_sort.hpp +++ b/include/boost/range/algorithm/partial_sort.hpp @@ -30,7 +30,7 @@ template inline void partial_sort(RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type middle) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::partial_sort(boost::begin(rng), middle, boost::end(rng)); } @@ -39,7 +39,7 @@ template inline void partial_sort(const RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type middle) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::partial_sort(boost::begin(rng), middle, boost::end(rng)); } @@ -49,7 +49,7 @@ inline void partial_sort(RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type middle, BinaryPredicate sort_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred); } @@ -60,7 +60,7 @@ inline void partial_sort(const RandomAccessRange& rng, BOOST_DEDUCED_TYPENAME range_iterator::type middle, BinaryPredicate sort_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred); } diff --git a/include/boost/range/algorithm/partial_sort_copy.hpp b/include/boost/range/algorithm/partial_sort_copy.hpp index d95cf27..8cf3510 100755 --- a/include/boost/range/algorithm/partial_sort_copy.hpp +++ b/include/boost/range/algorithm/partial_sort_copy.hpp @@ -32,10 +32,10 @@ template inline typename range_iterator::type partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2) { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); - BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); - BOOST_CONCEPT_ASSERT((LessThanComparableConcept::type>)); + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); + BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept::type>)); return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2)); @@ -48,10 +48,10 @@ inline typename range_iterator::type partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); - BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((range_detail::SameTypeConcept::type, typename range_value::type>)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), pred); diff --git a/include/boost/range/algorithm/partition.hpp b/include/boost/range/algorithm/partition.hpp index f7dfbbb..05f41da 100755 --- a/include/boost/range/algorithm/partition.hpp +++ b/include/boost/range/algorithm/partition.hpp @@ -30,7 +30,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type partition(ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::partition(boost::begin(rng),boost::end(rng),pred); } @@ -39,7 +39,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type partition(const ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::partition(boost::begin(rng),boost::end(rng),pred); } @@ -51,7 +51,7 @@ template< range_return_value re, class ForwardRange, inline BOOST_DEDUCED_TYPENAME range_return::type partition(ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return boost::range_return:: pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); } @@ -62,7 +62,7 @@ template< range_return_value re, class ForwardRange, inline BOOST_DEDUCED_TYPENAME range_return::type partition(const ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return boost::range_return:: pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng); } diff --git a/include/boost/range/algorithm/permutation.hpp b/include/boost/range/algorithm/permutation.hpp index 6a80ef8..75388cc 100755 --- a/include/boost/range/algorithm/permutation.hpp +++ b/include/boost/range/algorithm/permutation.hpp @@ -29,7 +29,7 @@ namespace boost template inline bool next_permutation(BidirectionalRange& rng) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::next_permutation(boost::begin(rng), boost::end(rng)); } @@ -37,7 +37,7 @@ inline bool next_permutation(BidirectionalRange& rng) template inline bool next_permutation(const BidirectionalRange& rng) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::next_permutation(boost::begin(rng), boost::end(rng)); } @@ -45,7 +45,7 @@ inline bool next_permutation(const BidirectionalRange& rng) template inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::next_permutation(boost::begin(rng), boost::end(rng), comp_pred); } @@ -55,7 +55,7 @@ template inline bool next_permutation(const BidirectionalRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::next_permutation(boost::begin(rng), boost::end(rng), comp_pred); } @@ -69,7 +69,7 @@ inline bool next_permutation(const BidirectionalRange& rng, template inline bool prev_permutation(BidirectionalRange& rng) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::prev_permutation(boost::begin(rng), boost::end(rng)); } @@ -77,7 +77,7 @@ inline bool prev_permutation(BidirectionalRange& rng) template inline bool prev_permutation(const BidirectionalRange& rng) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::prev_permutation(boost::begin(rng), boost::end(rng)); } @@ -85,7 +85,7 @@ inline bool prev_permutation(const BidirectionalRange& rng) template inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::prev_permutation(boost::begin(rng), boost::end(rng), comp_pred); } @@ -95,7 +95,7 @@ template inline bool prev_permutation(const BidirectionalRange& rng, Compare comp_pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::prev_permutation(boost::begin(rng), boost::end(rng), comp_pred); } diff --git a/include/boost/range/algorithm/random_shuffle.hpp b/include/boost/range/algorithm/random_shuffle.hpp index b90bdd1..eeae3d7 100755 --- a/include/boost/range/algorithm/random_shuffle.hpp +++ b/include/boost/range/algorithm/random_shuffle.hpp @@ -29,7 +29,7 @@ namespace boost template inline RandomAccessRange& random_shuffle(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::random_shuffle(boost::begin(rng), boost::end(rng)); return rng; } @@ -38,7 +38,7 @@ inline RandomAccessRange& random_shuffle(RandomAccessRange& rng) template inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::random_shuffle(boost::begin(rng),boost::end(rng)); return rng; } @@ -47,7 +47,7 @@ inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng) template inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::random_shuffle(boost::begin(rng), boost::end(rng), gen); return rng; } @@ -56,7 +56,7 @@ inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen) template inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::random_shuffle(boost::begin(rng), boost::end(rng), gen); return rng; } diff --git a/include/boost/range/algorithm/remove.hpp b/include/boost/range/algorithm/remove.hpp index ed4dad0..699a7cd 100755 --- a/include/boost/range/algorithm/remove.hpp +++ b/include/boost/range/algorithm/remove.hpp @@ -30,7 +30,7 @@ template< class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_iterator::type remove(ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::remove(boost::begin(rng),boost::end(rng),val); } @@ -39,7 +39,7 @@ template< class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_iterator::type remove(const ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::remove(boost::begin(rng),boost::end(rng),val); } @@ -50,7 +50,7 @@ template< range_return_value re, class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type remove(ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::remove(boost::begin(rng), boost::end(rng), val), rng); @@ -61,7 +61,7 @@ template< range_return_value re, class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type remove(const ForwardRange& rng, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::remove(boost::begin(rng), boost::end(rng), val), rng); diff --git a/include/boost/range/algorithm/remove_copy.hpp b/include/boost/range/algorithm/remove_copy.hpp index 1568240..0d3d83d 100755 --- a/include/boost/range/algorithm/remove_copy.hpp +++ b/include/boost/range/algorithm/remove_copy.hpp @@ -33,7 +33,7 @@ template< class SinglePassRange, class OutputIterator, class Value > inline OutputIterator remove_copy(SinglePassRange& rng, OutputIterator out_it, const Value& val) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val); } diff --git a/include/boost/range/algorithm/remove_if.hpp b/include/boost/range/algorithm/remove_if.hpp index 5a51d13..babcddc 100755 --- a/include/boost/range/algorithm/remove_if.hpp +++ b/include/boost/range/algorithm/remove_if.hpp @@ -31,7 +31,7 @@ template< class ForwardRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type remove_if(ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::remove_if(boost::begin(rng), boost::end(rng), pred); } @@ -40,7 +40,7 @@ template< class ForwardRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME boost::range_iterator::type remove_if(const ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::remove_if(boost::begin(rng),boost::end(rng),pred); } @@ -51,7 +51,7 @@ template< range_return_value re, class ForwardRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type remove_if(ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::remove_if(boost::begin(rng), boost::end(rng), pred), rng); @@ -62,7 +62,7 @@ template< range_return_value re, class ForwardRange, class UnaryPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type remove_if(const ForwardRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( std::remove_if(boost::begin(rng), boost::end(rng), pred), rng); diff --git a/include/boost/range/algorithm/replace.hpp b/include/boost/range/algorithm/replace.hpp index 2d1d537..44d3e4c 100755 --- a/include/boost/range/algorithm/replace.hpp +++ b/include/boost/range/algorithm/replace.hpp @@ -30,7 +30,7 @@ inline ForwardRange& replace(ForwardRange& rng, const Value& what, const Value& with_what) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::replace(boost::begin(rng), boost::end(rng), what, with_what); return rng; } @@ -41,7 +41,7 @@ inline const ForwardRange& replace(const ForwardRange& rng, const Value& what, const Value& with_what) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::replace(boost::begin(rng), boost::end(rng), what, with_what); return rng; } diff --git a/include/boost/range/algorithm/replace_copy.hpp b/include/boost/range/algorithm/replace_copy.hpp index cfdd2d5..36c91ce 100755 --- a/include/boost/range/algorithm/replace_copy.hpp +++ b/include/boost/range/algorithm/replace_copy.hpp @@ -30,7 +30,7 @@ inline OutputIterator replace_copy(ForwardRange& rng, OutputIterator out_it, const Value& what, const Value& with_what) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::replace_copy(boost::begin(rng), boost::end(rng), out_it, what, with_what); } diff --git a/include/boost/range/algorithm/replace_copy_if.hpp b/include/boost/range/algorithm/replace_copy_if.hpp index ba34e38..5d4bfb6 100755 --- a/include/boost/range/algorithm/replace_copy_if.hpp +++ b/include/boost/range/algorithm/replace_copy_if.hpp @@ -34,7 +34,7 @@ inline OutputIterator replace_copy_if(ForwardRange& rng, OutputIterator out_it, Predicate pred, const Value& with_what) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it, pred, with_what); } diff --git a/include/boost/range/algorithm/replace_if.hpp b/include/boost/range/algorithm/replace_if.hpp index 211e895..93d5a1f 100755 --- a/include/boost/range/algorithm/replace_if.hpp +++ b/include/boost/range/algorithm/replace_if.hpp @@ -31,7 +31,7 @@ inline ForwardRange& replace_if(ForwardRange& rng, UnaryPredicate pred, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::replace_if(boost::begin(rng), boost::end(rng), pred, val); return rng; } @@ -42,7 +42,7 @@ inline const ForwardRange& replace_if(const ForwardRange& rng, UnaryPredicate pred, const Value& val) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::replace_if(boost::begin(rng), boost::end(rng), pred, val); return rng; } diff --git a/include/boost/range/algorithm/reverse.hpp b/include/boost/range/algorithm/reverse.hpp index bc6d960..20a7eb1 100755 --- a/include/boost/range/algorithm/reverse.hpp +++ b/include/boost/range/algorithm/reverse.hpp @@ -29,7 +29,7 @@ namespace boost template inline BidirectionalRange& reverse(BidirectionalRange& rng) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); std::reverse(boost::begin(rng), boost::end(rng)); return rng; } @@ -38,7 +38,7 @@ inline BidirectionalRange& reverse(BidirectionalRange& rng) template inline const BidirectionalRange& reverse(const BidirectionalRange& rng) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); std::reverse(boost::begin(rng), boost::end(rng)); return rng; } diff --git a/include/boost/range/algorithm/reverse_copy.hpp b/include/boost/range/algorithm/reverse_copy.hpp index 47b1337..381f157 100755 --- a/include/boost/range/algorithm/reverse_copy.hpp +++ b/include/boost/range/algorithm/reverse_copy.hpp @@ -29,7 +29,7 @@ namespace boost template inline OutputIterator reverse_copy(BidirectionalRange& rng, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::reverse_copy(boost::begin(rng), boost::end(rng), out); } @@ -37,7 +37,7 @@ inline OutputIterator reverse_copy(BidirectionalRange& rng, OutputIterator out) template inline OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::reverse_copy(boost::begin(rng), boost::end(rng), out); } diff --git a/include/boost/range/algorithm/rotate.hpp b/include/boost/range/algorithm/rotate.hpp index 8e6c377..2372a00 100755 --- a/include/boost/range/algorithm/rotate.hpp +++ b/include/boost/range/algorithm/rotate.hpp @@ -29,7 +29,7 @@ template inline ForwardRange& rotate(ForwardRange& rng, typename range_iterator::type middle) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::rotate(boost::begin(rng), middle, boost::end(rng)); return rng; } @@ -40,7 +40,7 @@ inline const ForwardRange& rotate(const ForwardRange& rng, typename range_iterator::type middle) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); std::rotate(boost::begin(rng), middle, boost::end(rng)); return rng; } diff --git a/include/boost/range/algorithm/rotate_copy.hpp b/include/boost/range/algorithm/rotate_copy.hpp index 6751101..9030f73 100755 --- a/include/boost/range/algorithm/rotate_copy.hpp +++ b/include/boost/range/algorithm/rotate_copy.hpp @@ -33,7 +33,7 @@ namespace boost OutputIterator target ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::rotate_copy(boost::begin(rng), middle, boost::end(rng), target); } diff --git a/include/boost/range/algorithm/search.hpp b/include/boost/range/algorithm/search.hpp index 70526ad..45d7ade 100755 --- a/include/boost/range/algorithm/search.hpp +++ b/include/boost/range/algorithm/search.hpp @@ -32,8 +32,8 @@ template< class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_iterator::type search(ForwardRange1& rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)); } @@ -43,8 +43,8 @@ template< class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_iterator::type search(const ForwardRange1& rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)); } @@ -54,8 +54,8 @@ template< class ForwardRange1, class ForwardRange2, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2),pred); } @@ -66,8 +66,8 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2),pred); } @@ -79,8 +79,8 @@ template< range_return_value re, class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_return::type search(ForwardRange1& rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)), @@ -92,8 +92,8 @@ template< range_return_value re, class ForwardRange1, class ForwardRange2 > inline BOOST_DEDUCED_TYPENAME range_return::type search(const ForwardRange1& rng1, const ForwardRange2& rng2) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)), @@ -106,8 +106,8 @@ template< range_return_value re, class ForwardRange1, class ForwardRange2, inline BOOST_DEDUCED_TYPENAME range_return::type search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2),pred), @@ -121,8 +121,8 @@ inline BOOST_DEDUCED_TYPENAME range_return::type search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::search(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2),pred), diff --git a/include/boost/range/algorithm/search_n.hpp b/include/boost/range/algorithm/search_n.hpp index d7b84ae..cd0340b 100755 --- a/include/boost/range/algorithm/search_n.hpp +++ b/include/boost/range/algorithm/search_n.hpp @@ -35,7 +35,7 @@ template< typename ForwardRange, typename Integer, typename Value > inline typename range_iterator::type search_n(ForwardRange& rng, Integer count, const Value& value) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return std::search_n(boost::begin(rng),boost::end(rng), count, value); } @@ -44,7 +44,7 @@ template< typename ForwardRange, typename Integer, typename Value > inline typename range_iterator::type search_n(const ForwardRange& rng, Integer count, const Value& value) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return std::search_n(boost::begin(rng), boost::end(rng), count, value); } @@ -55,8 +55,8 @@ inline typename range_iterator::type search_n(ForwardRange& rng, Integer count, const Value& value, BinaryPredicate binary_pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); return std::search_n(boost::begin(rng), boost::end(rng), count, value, binary_pred); @@ -69,8 +69,8 @@ inline typename range_iterator::type search_n(const ForwardRange& rng, Integer count, const Value& value, BinaryPredicate binary_pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); return std::search_n(boost::begin(rng), boost::end(rng), count, value, binary_pred); @@ -84,7 +84,7 @@ template< range_return_value re, typename ForwardRange, typename Integer, inline typename range_return::type search_n(ForwardRange& rng, Integer count, const Value& value) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return range_return:: pack(std::search_n(boost::begin(rng),boost::end(rng), count, value), @@ -97,7 +97,7 @@ template< range_return_value re, typename ForwardRange, typename Integer, inline typename range_return::type search_n(const ForwardRange& rng, Integer count, const Value& value) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept)); return range_return:: pack(std::search_n(boost::begin(rng), boost::end(rng), count, value), @@ -111,8 +111,8 @@ inline typename range_return::type search_n(ForwardRange& rng, Integer count, const Value& value, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); return range_return:: @@ -128,8 +128,8 @@ inline typename range_return::type search_n(const ForwardRange& rng, Integer count, const Value& value, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((ForwardRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, const Value&>)); return range_return:: diff --git a/include/boost/range/algorithm/set_algorithm.hpp b/include/boost/range/algorithm/set_algorithm.hpp index ce7e9b1..82ef8ec 100755 --- a/include/boost/range/algorithm/set_algorithm.hpp +++ b/include/boost/range/algorithm/set_algorithm.hpp @@ -31,8 +31,8 @@ template inline bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::includes(boost::begin(rng1),boost::end(rng1), boost::begin(rng2),boost::end(rng2)); } @@ -44,8 +44,8 @@ inline bool includes(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::includes(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), pred); } @@ -63,8 +63,8 @@ inline OutputIterator set_union(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_union(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out); } @@ -77,8 +77,8 @@ inline OutputIterator set_union(const SinglePassRange1& rng1, OutputIterator out, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_union(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out, pred); } @@ -96,8 +96,8 @@ inline OutputIterator set_intersection(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_intersection(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out); } @@ -110,8 +110,8 @@ inline OutputIterator set_intersection(const SinglePassRange1& rng1, OutputIterator out, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_intersection(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out, pred); @@ -130,8 +130,8 @@ inline OutputIterator set_difference(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_difference(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out); } @@ -144,8 +144,8 @@ inline OutputIterator set_difference(const SinglePassRange1& rng1, OutputIterator out, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_difference( boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out, pred); @@ -165,8 +165,8 @@ set_symmetric_difference(const SinglePassRange1& rng1, const SinglePassRange2& rng2, OutputIterator out) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out); } @@ -180,8 +180,8 @@ set_symmetric_difference(const SinglePassRange1& rng1, OutputIterator out, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::set_symmetric_difference( boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), out, pred); diff --git a/include/boost/range/algorithm/sort.hpp b/include/boost/range/algorithm/sort.hpp index 238c48d..a160907 100755 --- a/include/boost/range/algorithm/sort.hpp +++ b/include/boost/range/algorithm/sort.hpp @@ -29,7 +29,7 @@ namespace boost template inline RandomAccessRange& sort(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort(boost::begin(rng), boost::end(rng)); return rng; } @@ -38,7 +38,7 @@ inline RandomAccessRange& sort(RandomAccessRange& rng) template inline const RandomAccessRange& sort(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort(boost::begin(rng),boost::end(rng)); return rng; } @@ -47,7 +47,7 @@ inline const RandomAccessRange& sort(const RandomAccessRange& rng) template inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort(boost::begin(rng), boost::end(rng), pred); return rng; } @@ -56,7 +56,7 @@ inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred) template inline const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::sort(boost::begin(rng), boost::end(rng), pred); return rng; } diff --git a/include/boost/range/algorithm/stable_partition.hpp b/include/boost/range/algorithm/stable_partition.hpp index 46cb616..24febfc 100755 --- a/include/boost/range/algorithm/stable_partition.hpp +++ b/include/boost/range/algorithm/stable_partition.hpp @@ -31,7 +31,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type stable_partition(BidirectionalRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::stable_partition(boost::begin(rng), boost::end(rng), pred); } @@ -40,7 +40,7 @@ template inline BOOST_DEDUCED_TYPENAME range_iterator::type stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return std::stable_partition(boost::begin(rng),boost::end(rng),pred); } @@ -49,7 +49,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type stable_partition(BidirectionalRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return range_return::pack( std::stable_partition(boost::begin(rng), boost::end(rng), pred), rng); @@ -60,7 +60,7 @@ template inline BOOST_DEDUCED_TYPENAME range_return::type stable_partition(const BidirectionalRange& rng, UnaryPredicate pred) { - BOOST_CONCEPT_ASSERT(( BidirectionalRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept )); return range_return::pack( std::stable_partition(boost::begin(rng),boost::end(rng),pred), rng); diff --git a/include/boost/range/algorithm/stable_sort.hpp b/include/boost/range/algorithm/stable_sort.hpp index 700933e..d18da4d 100755 --- a/include/boost/range/algorithm/stable_sort.hpp +++ b/include/boost/range/algorithm/stable_sort.hpp @@ -29,7 +29,7 @@ namespace boost template inline RandomAccessRange& stable_sort(RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::stable_sort(boost::begin(rng), boost::end(rng)); return rng; } @@ -38,7 +38,7 @@ inline RandomAccessRange& stable_sort(RandomAccessRange& rng) template inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::stable_sort(boost::begin(rng), boost::end(rng)); return rng; } @@ -47,7 +47,7 @@ inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng) template inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate sort_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); return rng; } @@ -56,7 +56,7 @@ inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate so template inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate sort_pred) { - BOOST_CONCEPT_ASSERT(( RandomAccessRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred); return rng; } diff --git a/include/boost/range/algorithm/swap_ranges.hpp b/include/boost/range/algorithm/swap_ranges.hpp index ffc0fc8..1acee0d 100755 --- a/include/boost/range/algorithm/swap_ranges.hpp +++ b/include/boost/range/algorithm/swap_ranges.hpp @@ -70,8 +70,8 @@ template< typename SinglePassRange1, typename SinglePassRange2 > inline SinglePassRange2& swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2) { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); boost::range_detail::swap_ranges_impl( boost::begin(range1), boost::end(range1), diff --git a/include/boost/range/algorithm/transform.hpp b/include/boost/range/algorithm/transform.hpp index d12904b..28f423d 100755 --- a/include/boost/range/algorithm/transform.hpp +++ b/include/boost/range/algorithm/transform.hpp @@ -38,7 +38,7 @@ namespace boost OutputIterator out, UnaryOperation fun) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::transform(boost::begin(rng),boost::end(rng),out,fun); } @@ -82,8 +82,8 @@ namespace boost OutputIterator out, BinaryOperation fun) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return range_detail::transform_impl( boost::begin(rng1), boost::end(rng1), boost::begin(rng2), boost::end(rng2), diff --git a/include/boost/range/algorithm/unique.hpp b/include/boost/range/algorithm/unique.hpp index 43e3b82..be6eaf9 100755 --- a/include/boost/range/algorithm/unique.hpp +++ b/include/boost/range/algorithm/unique.hpp @@ -30,7 +30,7 @@ template< range_return_value re, class ForwardRange > inline BOOST_DEDUCED_TYPENAME range_return::type unique( ForwardRange& rng ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack( std::unique( boost::begin(rng), boost::end(rng)), rng ); @@ -41,7 +41,7 @@ template< range_return_value re, class ForwardRange > inline BOOST_DEDUCED_TYPENAME range_return::type unique( const ForwardRange& rng ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack( std::unique( boost::begin(rng), boost::end(rng)), rng ); @@ -51,7 +51,7 @@ template< range_return_value re, class ForwardRange, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type unique( ForwardRange& rng, BinaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::unique(boost::begin(rng), boost::end(rng), pred), rng); @@ -61,7 +61,7 @@ template< range_return_value re, class ForwardRange, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type unique( const ForwardRange& rng, BinaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::unique(boost::begin(rng), boost::end(rng), pred), rng); @@ -72,7 +72,7 @@ template< class ForwardRange > inline BOOST_DEDUCED_TYPENAME range_return::type unique( ForwardRange& rng ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return ::boost::range::unique(rng); } /// \overload @@ -80,7 +80,7 @@ template< class ForwardRange > inline BOOST_DEDUCED_TYPENAME range_return::type unique( const ForwardRange& rng ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return ::boost::range::unique(rng); } /// \overload @@ -88,7 +88,7 @@ template< class ForwardRange, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_return::type unique( ForwardRange& rng, BinaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return ::boost::range::unique(rng); } /// \overload @@ -96,7 +96,7 @@ template< class ForwardRange, class BinaryPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type unique( const ForwardRange& rng, BinaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return ::boost::range::unique(rng, pred); } diff --git a/include/boost/range/algorithm/unique_copy.hpp b/include/boost/range/algorithm/unique_copy.hpp index 909017b..0682d74 100755 --- a/include/boost/range/algorithm/unique_copy.hpp +++ b/include/boost/range/algorithm/unique_copy.hpp @@ -31,7 +31,7 @@ template< class SinglePassRange, class OutputIterator > inline OutputIterator unique_copy( const SinglePassRange& rng, OutputIterator out_it ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::unique_copy(boost::begin(rng), boost::end(rng), out_it); } /// \overload @@ -40,7 +40,7 @@ inline OutputIterator unique_copy( const SinglePassRange& rng, OutputIterator out_it, BinaryPredicate pred ) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred); } diff --git a/include/boost/range/algorithm/upper_bound.hpp b/include/boost/range/algorithm/upper_bound.hpp index fa755c1..8aa26bd 100755 --- a/include/boost/range/algorithm/upper_bound.hpp +++ b/include/boost/range/algorithm/upper_bound.hpp @@ -30,7 +30,7 @@ template< class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_iterator::type upper_bound( ForwardRange& rng, Value val ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::upper_bound(boost::begin(rng), boost::end(rng), val); } /// \overload @@ -39,7 +39,7 @@ template< class ForwardRange, class Value, class SortPredicate > inline BOOST_DEDUCED_TYPENAME range_iterator::type upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred); } /// \overload @@ -47,7 +47,7 @@ template< range_return_value re, class ForwardRange, class Value > inline BOOST_DEDUCED_TYPENAME range_return::type upper_bound( ForwardRange& rng, Value val ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::upper_bound(boost::begin(rng), boost::end(rng), val), rng); @@ -58,7 +58,7 @@ template< range_return_value re, class ForwardRange, class Value, inline BOOST_DEDUCED_TYPENAME range_return::type upper_bound( ForwardRange& rng, Value val, SortPredicate pred ) { - BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return:: pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred), rng); diff --git a/include/boost/range/algorithm_ext/is_sorted.hpp b/include/boost/range/algorithm_ext/is_sorted.hpp index fc7b522..e3e51e2 100755 --- a/include/boost/range/algorithm_ext/is_sorted.hpp +++ b/include/boost/range/algorithm_ext/is_sorted.hpp @@ -47,8 +47,8 @@ namespace boost template inline bool is_sorted(const SinglePassRange& rng) { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((LessThanComparableConcept::type>)); + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept::type>)); return range_detail::is_sorted(boost::begin(rng), boost::end(rng)); } @@ -56,8 +56,8 @@ namespace boost template inline bool is_sorted(const SinglePassRange& rng, BinaryPredicate pred) { - BOOST_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); return range_detail::is_sorted(boost::begin(rng), boost::end(rng), pred); } } diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index cc039aa..8e4d2cf 100644 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -60,6 +60,40 @@ namespace boost { namespace range_detail { +#ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT + +// List broken compiler versions here: + #ifdef __GNUC__ + // GNUC 4.2 has strange issues correctly detecting compliance with the Concepts + // hence the least disruptive approach is to turn-off the concept checking for + // this version of the compiler. + #if __GNUC__ == 4 && __GNUC_MINOR__ == 2 + #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 + #endif + #endif + + #ifdef __BORLANDC__ + #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 + #endif + + #ifdef __PATHCC__ + #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 + #endif + +// Default to using the concept asserts unless we have defined it off +// during the search for black listed compilers. + #ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT + #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 1 + #endif + +#endif + +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x ) +#else + #define BOOST_RANGE_CONCEPT_ASSERT( x ) +#endif + // Rationale for the inclusion of redefined iterator concept // classes: // @@ -77,9 +111,10 @@ namespace boost { template struct IncrementableIteratorConcept : CopyConstructible { +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT typedef BOOST_DEDUCED_TYPENAME iterator_traversal::type traversal_category; - BOOST_CONCEPT_ASSERT(( + BOOST_RANGE_CONCEPT_ASSERT(( Convertible< traversal_category, incrementable_traversal_tag @@ -92,6 +127,7 @@ namespace boost { } private: Iterator i; +#endif }; template @@ -99,11 +135,13 @@ namespace boost { : IncrementableIteratorConcept , EqualityComparable { - BOOST_CONCEPT_ASSERT(( +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + BOOST_RANGE_CONCEPT_ASSERT(( Convertible< BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category, single_pass_traversal_tag >)); +#endif }; template @@ -111,23 +149,26 @@ namespace boost { : SinglePassIteratorConcept , DefaultConstructible { +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::difference_type difference_type; BOOST_MPL_ASSERT((is_integral)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); - BOOST_CONCEPT_ASSERT(( + BOOST_RANGE_CONCEPT_ASSERT(( Convertible< BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category, forward_traversal_tag >)); +#endif }; template struct BidirectionalIteratorConcept : ForwardIteratorConcept { - BOOST_CONCEPT_ASSERT(( + #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + BOOST_RANGE_CONCEPT_ASSERT(( Convertible< BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept::traversal_category, bidirectional_traversal_tag @@ -140,13 +181,15 @@ namespace boost { } private: Iterator i; + #endif }; template struct RandomAccessIteratorConcept : BidirectionalIteratorConcept { - BOOST_CONCEPT_ASSERT(( + #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + BOOST_RANGE_CONCEPT_ASSERT(( Convertible< BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::traversal_category, random_access_traversal_tag @@ -165,6 +208,7 @@ namespace boost { BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n; Iterator i; Iterator j; + #endif }; } // namespace range_detail @@ -173,11 +217,12 @@ namespace boost { template struct SinglePassRangeConcept { +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT typedef BOOST_DEDUCED_TYPENAME range_iterator::type const_iterator; typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator; - BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); - BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); + BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); + BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept)); BOOST_CONCEPT_USAGE(SinglePassRangeConcept) { @@ -208,19 +253,23 @@ namespace boost { // T to be an abstract class. The other obvious alternative of // T& produces a warning on some compilers. T* m_range; +#endif }; //! Check if a type T models the ForwardRange range concept. template struct ForwardRangeConcept : SinglePassRangeConcept { - BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); - BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); + BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept)); +#endif }; template struct WriteableRangeConcept { +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator; BOOST_CONCEPT_USAGE(WriteableRangeConcept) @@ -230,6 +279,7 @@ namespace boost { private: iterator i; BOOST_DEDUCED_TYPENAME range_value::type v; +#endif }; //! Check if a type T models the WriteableForwardRange range concept. @@ -244,8 +294,10 @@ namespace boost { template struct BidirectionalRangeConcept : ForwardRangeConcept { - BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); - BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept)); +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + BOOST_RANGE_CONCEPT_ASSERT((BidirectionalIteratorConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BidirectionalIteratorConcept)); +#endif }; //! Check if a type T models the WriteableBidirectionalRange range concept. @@ -260,8 +312,10 @@ namespace boost { template struct RandomAccessRangeConcept : BidirectionalRangeConcept { - BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); - BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept)); +#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT + BOOST_RANGE_CONCEPT_ASSERT((RandomAccessIteratorConcept)); + BOOST_RANGE_CONCEPT_ASSERT((RandomAccessIteratorConcept)); +#endif }; //! Check if a type T models the WriteableRandomAccessRange range concept. diff --git a/include/boost/range/join.hpp b/include/boost/range/join.hpp index 5e8f064..374df86 100644 --- a/include/boost/range/join.hpp +++ b/include/boost/range/join.hpp @@ -28,8 +28,8 @@ iterator_range join(const SinglePassRange1& r1, const SinglePassRange2& r2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); typedef range_detail::join_iterator< BOOST_DEDUCED_TYPENAME range_iterator::type, @@ -50,8 +50,8 @@ iterator_range join(SinglePassRange1& r1, SinglePassRange2& r2) { - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); typedef range_detail::join_iterator< BOOST_DEDUCED_TYPENAME range_iterator::type, From 6cc4cbf1a160347d83fef4b03f7fc9189f4a360c Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 4 Apr 2010 11:38:14 +0000 Subject: [PATCH 91/92] Boost.Range a recent fix to a trac ticket causes a compilation error on Sun compilers. This commit causes the old code to be used for the operator[] of iterator_range on Sun compilers. [SVN r61038] --- include/boost/range/iterator_range_core.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/boost/range/iterator_range_core.hpp b/include/boost/range/iterator_range_core.hpp index 571bf7d..c1822fb 100755 --- a/include/boost/range/iterator_range_core.hpp +++ b/include/boost/range/iterator_range_core.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -289,6 +290,14 @@ namespace boost return *--last; } + +#ifdef __SUNPRO_CC + reference operator[]( difference_type at ) const + { + BOOST_ASSERT( at >= 0 && at < size() ); + return m_Begin[at]; + } +#else BOOST_DEDUCED_TYPENAME boost::detail::operator_brackets_result::type operator[]( difference_type at ) const { @@ -297,6 +306,7 @@ namespace boost typedef boost::detail::use_operator_brackets_proxy use_proxy; return boost::detail::make_operator_brackets_result(m_Begin + at, use_proxy()); } +#endif // // When storing transform iterators, operator[]() From cee9ffc1a87c46019c19b4b7b0b616e280dbe0da Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 4 Apr 2010 14:14:12 +0000 Subject: [PATCH 92/92] Boost.Range added unit tests for extended algorithms. Put the extended algorithms into boost::range in a similar manner to the standard algorithms. Added iota as an extended algorithm. Fixed defects in the extended algorithms brought to light by the new unit tests. [SVN r61042] --- doc/reference/algorithm_ext/iota.qbk | 28 ++++ doc/reference/algorithms.qbk | 1 + include/boost/range/algorithm/for_each.hpp | 4 +- include/boost/range/algorithm_ext.hpp | 1 + include/boost/range/algorithm_ext/copy_n.hpp | 40 +++--- include/boost/range/algorithm_ext/erase.hpp | 55 +++++--- .../boost/range/algorithm_ext/for_each.hpp | 69 ++++++---- include/boost/range/algorithm_ext/insert.hpp | 27 ++-- include/boost/range/algorithm_ext/iota.hpp | 39 ++++++ .../boost/range/algorithm_ext/is_sorted.hpp | 48 ++++--- .../boost/range/algorithm_ext/overwrite.hpp | 45 +++--- .../boost/range/algorithm_ext/push_back.hpp | 22 ++- .../boost/range/algorithm_ext/push_front.hpp | 23 +++- test/Jamfile.v2 | 9 ++ test/algorithm_ext_test/copy_n.cpp | 60 ++++++++ test/algorithm_ext_test/erase.cpp | 128 ++++++++++++++++++ test/algorithm_ext_test/for_each_ext.cpp | 98 ++++++++++++++ test/algorithm_ext_test/insert.cpp | 72 ++++++++++ test/algorithm_ext_test/iota.cpp | 70 ++++++++++ test/algorithm_ext_test/is_sorted.cpp | 62 +++++++++ test/algorithm_ext_test/overwrite.cpp | 74 ++++++++++ test/algorithm_ext_test/push_back.cpp | 72 ++++++++++ test/algorithm_ext_test/push_front.cpp | 71 ++++++++++ 23 files changed, 993 insertions(+), 125 deletions(-) create mode 100644 doc/reference/algorithm_ext/iota.qbk create mode 100644 include/boost/range/algorithm_ext/iota.hpp create mode 100644 test/algorithm_ext_test/copy_n.cpp create mode 100644 test/algorithm_ext_test/erase.cpp create mode 100644 test/algorithm_ext_test/for_each_ext.cpp create mode 100644 test/algorithm_ext_test/insert.cpp create mode 100644 test/algorithm_ext_test/iota.cpp create mode 100644 test/algorithm_ext_test/is_sorted.cpp create mode 100644 test/algorithm_ext_test/overwrite.cpp create mode 100644 test/algorithm_ext_test/push_back.cpp create mode 100644 test/algorithm_ext_test/push_front.cpp diff --git a/doc/reference/algorithm_ext/iota.qbk b/doc/reference/algorithm_ext/iota.qbk new file mode 100644 index 0000000..37aba15 --- /dev/null +++ b/doc/reference/algorithm_ext/iota.qbk @@ -0,0 +1,28 @@ +[section:for_each for_each] + +[heading Prototype] + +`` +template +iota(SinglePassRange& rng, Value x); +`` + +[heading Description] + +`iota` traverses forward through `rng`, each element `y` in `rng` is assigned a value equivalent +to `x + boost::distance(boost::begin(rng), it)` + +[heading Definition] + +Defined in the header file `boost/range/algorithm_ext/iota.hpp` + +[heading Requirements] + +# `SinglePassRange` is a model of the __single_pass_range__ Concept. +# `Value` is a model of the `Incrementable` Concept. + +[heading Complexity] + +Linear. Exactly `distance(rng)` assignments into `rng`. + +[endsect] diff --git a/doc/reference/algorithms.qbk b/doc/reference/algorithms.qbk index 9bbce12..00b3edb 100644 --- a/doc/reference/algorithms.qbk +++ b/doc/reference/algorithms.qbk @@ -144,6 +144,7 @@ and there is no need to worry about generating an invalid range. Furthermore, if [include algorithm_ext/erase.qbk] [include algorithm_ext/for_each.qbk] [include algorithm_ext/insert.qbk] +[include algorithm_ext/iota.qbk] [include algorithm_ext/overwrite.qbk] [include algorithm_ext/push_back.qbk] [include algorithm_ext/push_front.qbk] diff --git a/include/boost/range/algorithm/for_each.hpp b/include/boost/range/algorithm/for_each.hpp index cc65e6e..714a06f 100755 --- a/include/boost/range/algorithm/for_each.hpp +++ b/include/boost/range/algorithm/for_each.hpp @@ -35,10 +35,10 @@ inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun) /// \overload template< class SinglePassRange, class UnaryFunction > -inline UnaryFunction for_each(SinglePassRange const & rng, UnaryFunction fun) +inline UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - return std::for_each(boost::begin(rng),boost::end(rng),fun); + return std::for_each(boost::begin(rng), boost::end(rng), fun); } } // namespace range diff --git a/include/boost/range/algorithm_ext.hpp b/include/boost/range/algorithm_ext.hpp index 002e791..783d38a 100755 --- a/include/boost/range/algorithm_ext.hpp +++ b/include/boost/range/algorithm_ext.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/range/algorithm_ext/copy_n.hpp b/include/boost/range/algorithm_ext/copy_n.hpp index 39b7d3e..ba7ad1c 100755 --- a/include/boost/range/algorithm_ext/copy_n.hpp +++ b/include/boost/range/algorithm_ext/copy_n.hpp @@ -21,27 +21,33 @@ namespace boost { - /// \brief template function copy - /// - /// range-based version of the copy std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - /// \pre OutputIterator is a model of the OutputIteratorConcept - /// \pre 0 <= n < distance(rng) - template< class SinglePassRange, class Size, class OutputIterator > - inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out) + namespace range { - boost::function_requires< SinglePassRangeConcept >(); - BOOST_ASSERT( n < static_cast(boost::distance(rng)) ); - BOOST_ASSERT( n >= static_cast(0) ); - BOOST_DEDUCED_TYPENAME range_const_iterator::type source = boost::begin(rng); +/// \brief template function copy +/// +/// range-based version of the copy std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +/// \pre OutputIterator is a model of the OutputIteratorConcept +/// \pre 0 <= n < distance(rng) +template< class SinglePassRange, class Size, class OutputIterator > +inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_ASSERT( n < static_cast(boost::distance(rng)) ); + BOOST_ASSERT( n >= static_cast(0) ); - for (Size i = 0; i < n; ++i, ++out, ++source) - *out = *source; + BOOST_DEDUCED_TYPENAME range_iterator::type source = boost::begin(rng); - return out; - } + for (Size i = 0; i < n; ++i, ++out, ++source) + *out = *source; + + return out; } + } // namespace range + using range::copy_n; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm_ext/erase.hpp b/include/boost/range/algorithm_ext/erase.hpp index c57d14d..3b0e037 100755 --- a/include/boost/range/algorithm_ext/erase.hpp +++ b/include/boost/range/algorithm_ext/erase.hpp @@ -11,35 +11,48 @@ #define BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED #include +#include #include +#include #include #include #include namespace boost { - template< class Container > - inline void erase( Container& on, - iterator_range to_erase ) - { - on.erase( boost::begin(to_erase), boost::end(to_erase) ); - } + namespace range + { - template< class Container, class T > - inline void remove_erase( Container& on, const T& val ) - { - on.erase( - std::remove(boost::begin(on), boost::end(on), val), - boost::end(on)); - } - - template< class Container, class Pred > - inline void remove_erase_if( Container& on, Pred pred ) - { - on.erase( - std::remove_if(boost::begin(on), boost::end(on), pred), - boost::end(on)); - } +template< class Container > +inline void erase( Container& on, + iterator_range to_erase ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + on.erase( boost::begin(to_erase), boost::end(to_erase) ); } +template< class Container, class T > +inline void remove_erase( Container& on, const T& val ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + on.erase( + std::remove(boost::begin(on), boost::end(on), val), + boost::end(on)); +} + +template< class Container, class Pred > +inline void remove_erase_if( Container& on, Pred pred ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + on.erase( + std::remove_if(boost::begin(on), boost::end(on), pred), + boost::end(on)); +} + + } // namespace range + using range::erase; + using range::remove_erase; + using range::remove_erase_if; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm_ext/for_each.hpp b/include/boost/range/algorithm_ext/for_each.hpp index d18f548..6a3b35c 100755 --- a/include/boost/range/algorithm_ext/for_each.hpp +++ b/include/boost/range/algorithm_ext/for_each.hpp @@ -11,6 +11,7 @@ #define BOOST_RANGE_ALGORITHM_EXT_FOR_EACH_HPP_INCLUDED #include +#include #include #include #include @@ -33,33 +34,53 @@ namespace boost } } - template - inline Fn2 for_each(const SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn) + namespace range { - return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), fn); - } + template + inline Fn2 for_each(const SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn) + { + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - template - inline Fn2 for_each(const SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn) - { - return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), fn); - } + return ::boost::range_detail::for_each_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), fn); + } - template - inline Fn2 for_each(SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn) - { - return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), fn); - } + template + inline Fn2 for_each(const SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn) + { + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - template - inline Fn2 for_each(SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn) - { - return range_detail::for_each_impl(boost::begin(rng1), boost::end(rng1), - boost::begin(rng2), boost::end(rng2), fn); - } -} + return ::boost::range_detail::for_each_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), fn); + } + + template + inline Fn2 for_each(SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn) + { + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::for_each_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), fn); + } + + template + inline Fn2 for_each(SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn) + { + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + return ::boost::range_detail::for_each_impl( + ::boost::begin(rng1), ::boost::end(rng1), + ::boost::begin(rng2), ::boost::end(rng2), fn); + } + } // namespace range + using range::for_each; +} // namespace boost #endif // include guard diff --git a/include/boost/range/algorithm_ext/insert.hpp b/include/boost/range/algorithm_ext/insert.hpp index 4b18fea..a887f15 100755 --- a/include/boost/range/algorithm_ext/insert.hpp +++ b/include/boost/range/algorithm_ext/insert.hpp @@ -11,6 +11,7 @@ #define BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED #include +#include #include #include #include @@ -18,15 +19,23 @@ namespace boost { - template< class Container, class Range > - inline void insert( Container& on, - BOOST_DEDUCED_TYPENAME Container::iterator before, - const Range& from ) - { - BOOST_ASSERT( (void*)&on != (void*)&from && - "cannot copy from a container to itself" ); - on.insert( before, boost::begin(from), boost::end(from) ); - } + namespace range + { + +template< class Container, class Range > +inline void insert( Container& on, + BOOST_DEDUCED_TYPENAME Container::iterator before, + const Range& from ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_ASSERT( (void*)&on != (void*)&from && + "cannot copy from a container to itself" ); + on.insert( before, boost::begin(from), boost::end(from) ); } + } // namespace range + using range::insert; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm_ext/iota.hpp b/include/boost/range/algorithm_ext/iota.hpp new file mode 100644 index 0000000..4a03a59 --- /dev/null +++ b/include/boost/range/algorithm_ext/iota.hpp @@ -0,0 +1,39 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. 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/ +// +#ifndef BOOST_RANGE_ALGORITHM_EXT_IOTA_HPP_INCLUDED +#define BOOST_RANGE_ALGORITHM_EXT_IOTA_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range + { + +template< class ForwardRange, class Value > +inline void iota( ForwardRange& rng, Value x ) +{ + BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); + typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; + + iterator_t last_target = ::boost::end(rng); + for (iterator_t target = ::boost::begin(rng); target != last_target; ++target, ++x) + *target = x; +} + + } // namespace range + using range::iota; +} // namespace boost + +#endif // include guard diff --git a/include/boost/range/algorithm_ext/is_sorted.hpp b/include/boost/range/algorithm_ext/is_sorted.hpp index e3e51e2..69ead10 100755 --- a/include/boost/range/algorithm_ext/is_sorted.hpp +++ b/include/boost/range/algorithm_ext/is_sorted.hpp @@ -20,7 +20,7 @@ namespace boost { namespace range_detail { - template + template inline bool is_sorted(ForwardIterator first, ForwardIterator last) { for (ForwardIterator next = first; first != last && ++next != last; ++first) @@ -29,7 +29,7 @@ namespace boost return true; } - template + template inline bool is_sorted(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) { for (ForwardIterator next = first; first != last && ++next != last; ++first) @@ -39,27 +39,33 @@ namespace boost } } - /// \brief template function count - /// - /// range-based version of the count std algorithm - /// - /// \pre SinglePassRange is a model of the SinglePassRangeConcept - template - inline bool is_sorted(const SinglePassRange& rng) + namespace range { - BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept::type>)); - return range_detail::is_sorted(boost::begin(rng), boost::end(rng)); - } - /// \overload - template - inline bool is_sorted(const SinglePassRange& rng, BinaryPredicate pred) - { - BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); - BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, typename range_value::type>)); - return range_detail::is_sorted(boost::begin(rng), boost::end(rng), pred); - } +/// \brief template function count +/// +/// range-based version of the count std algorithm +/// +/// \pre SinglePassRange is a model of the SinglePassRangeConcept +template +inline bool is_sorted(const SinglePassRange& rng) +{ + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept::type>)); + return range_detail::is_sorted(boost::begin(rng), boost::end(rng)); } +/// \overload +template +inline bool is_sorted(const SinglePassRange& rng, BinaryPredicate pred) +{ + BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept)); + BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept::type, BOOST_DEDUCED_TYPENAME range_value::type>)); + return range_detail::is_sorted(boost::begin(rng), boost::end(rng), pred); +} + + } // namespace range + using range::is_sorted; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm_ext/overwrite.hpp b/include/boost/range/algorithm_ext/overwrite.hpp index 8035968..d2cf4ed 100755 --- a/include/boost/range/algorithm_ext/overwrite.hpp +++ b/include/boost/range/algorithm_ext/overwrite.hpp @@ -11,36 +11,47 @@ #define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED #include +#include #include +#include #include #include #include namespace boost { - template< class SinglePassRange1, class SinglePassRange2 > - inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to ) - { - BOOST_DEDUCED_TYPENAME range_iterator::type - i = boost::begin(from), e = boost::end(from); + namespace range + { + +template< class SinglePassRange1, class SinglePassRange2 > +inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + + BOOST_DEDUCED_TYPENAME range_iterator::type + i = boost::begin(from), e = boost::end(from); + + BOOST_DEDUCED_TYPENAME range_iterator::type + out = boost::begin(to); - BOOST_DEDUCED_TYPENAME range_iterator::type - out = boost::begin(to); - #ifndef NDEBUG - BOOST_DEDUCED_TYPENAME range_iterator::type - last_out = boost::end(to); + BOOST_DEDUCED_TYPENAME range_iterator::type + last_out = boost::end(to); #endif - for( ; i != e; ++out, ++i ) - { + for( ; i != e; ++out, ++i ) + { #ifndef NDEBUG - BOOST_ASSERT( out != last_out - && "out of bounds in boost::overwrite()" ); + BOOST_ASSERT( out != last_out + && "out of bounds in boost::overwrite()" ); #endif - *out = *i; - } - } + *out = *i; + } } + } // namespace range + using range::overwrite; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm_ext/push_back.hpp b/include/boost/range/algorithm_ext/push_back.hpp index 8178f5b..e52de41 100755 --- a/include/boost/range/algorithm_ext/push_back.hpp +++ b/include/boost/range/algorithm_ext/push_back.hpp @@ -11,6 +11,7 @@ #define BOOST_RANGE_ALGORITHM_EXT_PUSH_BACK_HPP_INCLUDED #include +#include #include #include #include @@ -18,14 +19,21 @@ namespace boost { - template< class Container, class Range > - inline void push_back( Container& on, const Range& from ) - { - BOOST_ASSERT( (void*)&on != (void*)&from && - "cannot copy from a container to itself" ); - on.insert( on.end(), boost::begin(from), boost::end(from) ); - } + namespace range + { +template< class Container, class Range > +inline void push_back( Container& on, const Range& from ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_ASSERT( (void*)&on != (void*)&from && + "cannot copy from a container to itself" ); + on.insert( on.end(), boost::begin(from), boost::end(from) ); } + } // namespace range + using range::push_back; +} // namespace boost + #endif // include guard diff --git a/include/boost/range/algorithm_ext/push_front.hpp b/include/boost/range/algorithm_ext/push_front.hpp index eb82cf2..6ee269b 100755 --- a/include/boost/range/algorithm_ext/push_front.hpp +++ b/include/boost/range/algorithm_ext/push_front.hpp @@ -11,6 +11,7 @@ #define BOOST_RANGE_ALGORITHM_EXT_PUSH_FRONT_HPP_INCLUDED #include +#include #include #include #include @@ -18,13 +19,21 @@ namespace boost { - template< class Container, class Range > - inline void push_front( Container& on, const Range& from ) - { - BOOST_ASSERT( (void*)&on != (void*)&from && - "cannot copy from a container to itself" ); - on.insert( on.begin(), boost::begin(from), boost::end(from) ); - } + namespace range + { + +template< class Container, class Range > +inline void push_front( Container& on, const Range& from ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_ASSERT( (void*)&on != (void*)&from && + "cannot copy from a container to itself" ); + on.insert( on.begin(), boost::begin(from), boost::end(from) ); } + } // namespace range + using range::push_front; +} // namespace boost + #endif // include guard diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8cf4d7f..97600d5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -106,6 +106,15 @@ test-suite range : [ range-test algorithm_test/transform ] [ range-test algorithm_test/unique ] [ range-test algorithm_test/upper_bound ] + [ range-test algorithm_ext_test/copy_n ] + [ range-test algorithm_ext_test/erase ] + [ range-test algorithm_ext_test/for_each_ext ] + [ range-test algorithm_ext_test/insert ] + [ range-test algorithm_ext_test/iota ] + [ range-test algorithm_ext_test/is_sorted ] + [ range-test algorithm_ext_test/overwrite ] + [ range-test algorithm_ext_test/push_back ] + [ range-test algorithm_ext_test/push_front ] [ range-test adl_conformance ] [ range-test adl_conformance_no_using ] [ range-test algorithm ] diff --git a/test/algorithm_ext_test/copy_n.cpp b/test/algorithm_ext_test/copy_n.cpp new file mode 100644 index 0000000..854962f --- /dev/null +++ b/test/algorithm_ext_test/copy_n.cpp @@ -0,0 +1,60 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_copy_n_impl() + { + std::vector source; + for (std::size_t i = 0; i < 10; ++i) + source.push_back(i); + + for (std::size_t k = 0; k < 10; ++k) + { + std::vector reference; + for (std::size_t j = 0; j < k; ++j) + reference.push_back(j); + + Container test; + boost::copy_n(source, k, std::back_inserter(test)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + } + + void test_copy_n() + { + test_copy_n_impl< std::vector >(); + test_copy_n_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.copy_n" ); + + test->add( BOOST_TEST_CASE( &test_copy_n ) ); + + return test; +} diff --git a/test/algorithm_ext_test/erase.cpp b/test/algorithm_ext_test/erase.cpp new file mode 100644 index 0000000..3bdf2da --- /dev/null +++ b/test/algorithm_ext_test/erase.cpp @@ -0,0 +1,128 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_erase_impl() + { + Container source; + for (int i = 0; i < 10; ++i) + source.push_back(i); + + Container reference(source); + Container test(source); + + typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator_t; + + iterator_t first_ref = reference.begin(); + iterator_t last_ref = reference.end(); + + boost::iterator_range< iterator_t > test_range(test.begin(), test.end()); + + reference.erase(first_ref, last_ref); + boost::erase(test, test_range); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + void test_erase() + { + test_erase_impl >(); + test_erase_impl >(); + } + + template< class Container > + void test_remove_erase_impl() + { + Container source; + for (int i = 0; i < 10; ++i) + source.push_back(i); + + Container reference(source); + Container test(source); + + boost::remove_erase(test, 5); + + reference.erase( std::find(reference.begin(), reference.end(), 5) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + void test_remove_erase() + { + test_remove_erase_impl >(); + test_remove_erase_impl >(); + } + + struct is_even + { + typedef bool result_type; + typedef int argument_type; + bool operator()(int x) const { return x % 2 == 0; } + }; + + template< class Container > + void test_remove_erase_if_impl() + { + Container source; + for (int i = 0; i < 10; ++i) + source.push_back(i); + + Container reference; + typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iterator_t; + iterator_t last_source = source.end(); + is_even pred; + for (iterator_t it_source = source.begin(); it_source != last_source; ++it_source) + { + if (!pred(*it_source)) + reference.push_back(*it_source); + } + + Container test(source); + boost::remove_erase_if(test, is_even()); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + } + + void test_remove_erase_if() + { + test_remove_erase_if_impl >(); + test_remove_erase_if_impl >(); + } + +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.erase" ); + + test->add( BOOST_TEST_CASE( &test_erase ) ); + test->add( BOOST_TEST_CASE( &test_remove_erase ) ); + test->add( BOOST_TEST_CASE( &test_remove_erase_if ) ); + + return test; +} diff --git a/test/algorithm_ext_test/for_each_ext.cpp b/test/algorithm_ext_test/for_each_ext.cpp new file mode 100644 index 0000000..9df16c5 --- /dev/null +++ b/test/algorithm_ext_test/for_each_ext.cpp @@ -0,0 +1,98 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include + +namespace +{ + struct MockBinaryFn + { + typedef void result_type; + typedef int first_argument_type; + typedef int second_argument_type; + + void operator()(int x, int y) + { + xs.push_back(x); + ys.push_back(y); + } + + std::vector xs; + std::vector ys; + }; + + template< class Range1, class Range2 > + void test_for_each_impl( Range1& rng1, Range2& rng2 ) + { + MockBinaryFn fn = boost::range::for_each(rng1, rng2, MockBinaryFn()); + + BOOST_CHECK_EQUAL_COLLECTIONS( ::boost::begin(rng1), ::boost::end(rng1), + fn.xs.begin(), fn.xs.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( ::boost::begin(rng2), ::boost::end(rng2), + fn.ys.begin(), fn.ys.end() ); + } + + template< class Collection1, class Collection2 > + void test_for_each_impl(const int max_count) + { + Collection1 c1; + for (int i = 0; i < max_count; ++i) + c1.push_back(i); + + Collection2 c2; + for (int i = 0; i < max_count; ++i) + c2.push_back(i); + + test_for_each_impl(c1, c2); + + const Collection1& const_c1 = c1; + const Collection2& const_c2 = c2; + + test_for_each_impl(c1, const_c2); + test_for_each_impl(const_c1, c2); + test_for_each_impl(const_c1, const_c2); + } + + template< class Collection1, class Collection2 > + void test_for_each_impl() + { + test_for_each_impl< Collection1, Collection2 >(0); + test_for_each_impl< Collection1, Collection2 >(1); + test_for_each_impl< Collection1, Collection2 >(10); + } + + void test_for_each() + { + test_for_each_impl< std::vector, std::vector >(); + test_for_each_impl< std::list, std::list >(); + test_for_each_impl< std::vector, std::list >(); + test_for_each_impl< std::list, std::vector >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.for_each" ); + + test->add( BOOST_TEST_CASE( &test_for_each ) ); + + return test; +} diff --git a/test/algorithm_ext_test/insert.cpp b/test/algorithm_ext_test/insert.cpp new file mode 100644 index 0000000..ff1f706 --- /dev/null +++ b/test/algorithm_ext_test/insert.cpp @@ -0,0 +1,72 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_insert_impl( int n ) + { + Container test; + boost::insert( test, test.end(), boost::irange(0, n) ); + + Container reference; + for (int i = 0; i < n; ++i) + reference.push_back(i); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + // Do it again so that we are inserting into a non-empty target + boost::insert( test, test.end(), boost::irange(0, n) ); + + for (int j = 0; j < n; ++j) + reference.push_back(j); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_insert_impl() + { + test_insert_impl< Container >(0); + test_insert_impl< Container >(1); + test_insert_impl< Container >(2); + test_insert_impl< Container >(100); + } + + void test_insert() + { + test_insert_impl< std::vector >(); + test_insert_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.insert" ); + + test->add( BOOST_TEST_CASE( &test_insert ) ); + + return test; +} diff --git a/test/algorithm_ext_test/iota.cpp b/test/algorithm_ext_test/iota.cpp new file mode 100644 index 0000000..64d9b0e --- /dev/null +++ b/test/algorithm_ext_test/iota.cpp @@ -0,0 +1,70 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_iota_impl(std::size_t n) + { + Container test; + test.resize( n ); + boost::iota( test, n ); + + Container reference; + reference.resize( n ); + std::size_t i = n; + typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator_t; + iterator_t last = reference.end(); + for (iterator_t it = reference.begin(); it != last; ++it, ++i) + { + *it = i; + } + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + } + + template< class Container > + void test_iota_impl() + { + test_iota_impl< Container >(0); + test_iota_impl< Container >(1); + test_iota_impl< Container >(2); + test_iota_impl< Container >(100); + } + + void test_iota() + { + test_iota_impl< std::vector >(); + test_iota_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.iota" ); + + test->add( BOOST_TEST_CASE( &test_iota ) ); + + return test; +} diff --git a/test/algorithm_ext_test/is_sorted.cpp b/test/algorithm_ext_test/is_sorted.cpp new file mode 100644 index 0000000..bddc5f8 --- /dev/null +++ b/test/algorithm_ext_test/is_sorted.cpp @@ -0,0 +1,62 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_is_sorted_impl() + { + Container ascending; + Container descending; + + // Empty ranges are regarded as sorted against any predicate. + BOOST_CHECK( boost::is_sorted(ascending) ); + BOOST_CHECK( boost::is_sorted(ascending, std::less()) ); + BOOST_CHECK( boost::is_sorted(ascending, std::greater()) ); + + for (std::size_t i = 0; i < 10; ++i) + { + ascending.push_back(i); + descending.push_back(9 - i); + } + + BOOST_CHECK( boost::is_sorted(ascending) ); + BOOST_CHECK( !boost::is_sorted(descending) ); + BOOST_CHECK( !boost::is_sorted(ascending, std::greater()) ); + BOOST_CHECK( boost::is_sorted(descending, std::greater()) ); + } + + void test_is_sorted() + { + test_is_sorted_impl< std::vector >(); + test_is_sorted_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.is_sorted" ); + + test->add( BOOST_TEST_CASE( &test_is_sorted ) ); + + return test; +} diff --git a/test/algorithm_ext_test/overwrite.cpp b/test/algorithm_ext_test/overwrite.cpp new file mode 100644 index 0000000..0d8604a --- /dev/null +++ b/test/algorithm_ext_test/overwrite.cpp @@ -0,0 +1,74 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_overwrite_impl(std::size_t n) + { + Container overwrite_source; + for (std::size_t i = 0; i < n; ++i) + overwrite_source.push_back(i); + + Container reference; + reference.resize(n); + std::copy(overwrite_source.begin(), overwrite_source.end(), reference.begin()); + + Container test; + test.resize(n); + boost::overwrite(overwrite_source, test); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + test.clear(); + test.resize(n); + const Container& const_overwrite_source = overwrite_source; + boost::overwrite(const_overwrite_source, test); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_overwrite_impl() + { + test_overwrite_impl(0); + test_overwrite_impl(1); + test_overwrite_impl(10); + } + + void test_overwrite() + { + test_overwrite_impl< std::vector >(); + test_overwrite_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.overwrite" ); + + test->add( BOOST_TEST_CASE( &test_overwrite ) ); + + return test; +} diff --git a/test/algorithm_ext_test/push_back.cpp b/test/algorithm_ext_test/push_back.cpp new file mode 100644 index 0000000..7e9d539 --- /dev/null +++ b/test/algorithm_ext_test/push_back.cpp @@ -0,0 +1,72 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_push_back_impl(std::size_t n) + { + Container reference; + for (std::size_t i = 0; i < n; ++i) + reference.push_back(i); + + Container test; + boost::push_back(test, boost::irange(0, n)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + // Do it again to push onto non-empty container + for (std::size_t j = 0; j < n; ++j) + reference.push_back(j); + + boost::push_back(test, boost::irange(0, n)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_push_back_impl() + { + test_push_back_impl< Container >(0); + test_push_back_impl< Container >(1); + test_push_back_impl< Container >(2); + test_push_back_impl< Container >(100); + } + + void test_push_back() + { + test_push_back_impl< std::vector >(); + test_push_back_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.push_back" ); + + test->add( BOOST_TEST_CASE( &test_push_back ) ); + + return test; +} diff --git a/test/algorithm_ext_test/push_front.cpp b/test/algorithm_ext_test/push_front.cpp new file mode 100644 index 0000000..ebc09a8 --- /dev/null +++ b/test/algorithm_ext_test/push_front.cpp @@ -0,0 +1,71 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. 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 + +#include +#include +#include +#include +#include + +namespace +{ + template< class Container > + void test_push_front_impl(std::size_t n) + { + Container reference; + for (std::size_t i = 0; i < n; ++i) + reference.push_back(i); + + Container test; + boost::push_front(test, boost::irange(0, n)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + + // Do it again to push onto non-empty container + reference.insert(reference.begin(), reference.begin(), reference.end()); + + boost::push_front(test, boost::irange(0, n)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + + template< class Container > + void test_push_front_impl() + { + test_push_front_impl< Container >(0); + test_push_front_impl< Container >(1); + test_push_front_impl< Container >(2); + test_push_front_impl< Container >(100); + } + + void test_push_front() + { + test_push_front_impl< std::vector >(); + test_push_front_impl< std::list >(); + } +} + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.push_front" ); + + test->add( BOOST_TEST_CASE( &test_push_front ) ); + + return test; +}