diff --git a/doc/example.cpp b/doc/example.cpp index 7b5197f..afe448f 100644 --- a/doc/example.cpp +++ b/doc/example.cpp @@ -3,106 +3,106 @@ 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. - // - /* - template< class T > - struct range_value< Foo::Pair > - { - typedef typename std::iterator_traits::value_type type; - }; - */ + // + // Specialize metafunctions. We must include the range.hpp header. + // We must open the 'boost' namespace. + // + /* + template< class T > + struct range_value< Foo::Pair > + { + typedef typename std::iterator_traits::value_type type; + }; + */ - template< class T > - struct range_iterator< Foo::Pair > - { - typedef T type; - }; + 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_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_difference< Foo::Pair > - { - typedef typename std::iterator_traits::difference_type type; - }; - */ + struct range_difference< Foo::Pair > + { + typedef typename std::iterator_traits::difference_type type; + }; + */ - template< class T > + template< class T > struct range_size< Foo::Pair > - { - int static_assertion[ sizeof( std::size_t ) >= - sizeof( typename range_difference< Foo::Pair >::type ) ]; - typedef std::size_t type; - }; + { + int static_assertion[ sizeof( std::size_t ) >= + sizeof( typename range_difference< Foo::Pair >::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& 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& x ) + { + return x.first; + } template< class T > - inline T boost_range_begin( const Pair& x ) - { - return x.first; - } + inline T boost_range_begin( const Pair& x ) + { + return x.first; + } - template< class T > + template< class T > inline T boost_range_end( Pair& x ) - { - return x.last; - } + { + return x.last; + } - template< class T > + template< class T > inline T boost_range_end( const Pair& x ) - { - return x.last; - } + { + 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); - } + 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' @@ -110,32 +110,32 @@ namespace Foo int main() { - typedef std::vector::iterator iter; - std::vector vec; - vec.push_back( 42 ); - 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 ); - - // - // Test metafunctions - // + typedef std::vector::iterator iter; + std::vector vec; + vec.push_back( 42 ); + 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 ); - boost::range_value< Foo::Pair >::type - v = *boost::begin(pair); + // + // Test metafunctions + // - boost::range_difference< Foo::Pair >::type - d = boost::end(pair) - boost::begin(pair); + boost::range_value< Foo::Pair >::type + v = *boost::begin(pair); + + boost::range_difference< Foo::Pair >::type + d = boost::end(pair) - boost::begin(pair); } diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp index e7e03f4..57ee344 100755 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -47,8 +47,8 @@ namespace range_detail } template< typename C > - inline BOOST_DEDUCED_TYPENAME range_iterator< - typename remove_const::type >::type + inline BOOST_DEDUCED_TYPENAME range_iterator< + typename remove_const::type >::type boost_range_begin( C& c ) { return c.begin(); @@ -142,8 +142,8 @@ 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< + typename remove_const::type >::type begin( T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ diff --git a/include/boost/range/difference_type.hpp b/include/boost/range/difference_type.hpp index e498ebb..33c56e3 100755 --- a/include/boost/range/difference_type.hpp +++ b/include/boost/range/difference_type.hpp @@ -21,13 +21,13 @@ 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 + { + typedef BOOST_DEDUCED_TYPENAME iterator_difference< + BOOST_DEDUCED_TYPENAME range_const_iterator::type >::type + type; + }; } //#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION @@ -43,13 +43,13 @@ namespace boost ////////////////////////////////////////////////////////////////////////// // default ////////////////////////////////////////////////////////////////////////// - + template< typename C > struct range_difference { typedef BOOST_DEDUCED_TYPENAME C::difference_type type; }; - + ////////////////////////////////////////////////////////////////////////// // pair ////////////////////////////////////////////////////////////////////////// @@ -57,14 +57,14 @@ namespace boost template< typename Iterator > struct range_difference< std::pair > { - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME iterator_difference::type type; }; - + template< typename Iterator > struct range_difference< const std::pair > { - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME iterator_difference::type type; }; diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp index 5907ed3..f7eb2f8 100755 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -26,35 +26,35 @@ #include #include -namespace boost +namespace boost { - + #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ - /**/ + /**/ namespace range_detail { -#endif +#endif ////////////////////////////////////////////////////////////////////// // 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 + inline BOOST_DEDUCED_TYPENAME range_iterator< + typename remove_const::type >::type boost_range_end( C& c ) { return c.end(); } - + ////////////////////////////////////////////////////////////////////// // pair ////////////////////////////////////////////////////////////////////// @@ -64,13 +64,13 @@ namespace range_detail { return p.second; } - + template< typename Iterator > inline Iterator boost_range_end( std::pair& p ) { return p.second; } - + ////////////////////////////////////////////////////////////////////// // array ////////////////////////////////////////////////////////////////////// @@ -78,13 +78,13 @@ namespace range_detail template< typename T, std::size_t sz > inline const T* boost_range_end( const T (&array)[sz] ) { - return range_detail::array_end( array ); + return range_detail::array_end( array ); } - + template< typename T, std::size_t sz > inline T* boost_range_end( T (&array)[sz] ) { - return range_detail::array_end( array ); + return range_detail::array_end( array ); } ////////////////////////////////////////////////////////////////////// @@ -136,19 +136,19 @@ namespace range_detail #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ - /**/ + /**/ } // 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< + typename remove_const::type >::type end( T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ using namespace range_detail; -#endif +#endif return boost_range_end( r ); } @@ -159,7 +159,7 @@ inline BOOST_DEDUCED_TYPENAME range_const_iterator::type end( const T& r ) !BOOST_WORKAROUND(__GNUC__, < 3) \ /**/ using namespace range_detail; -#endif +#endif return boost_range_end( r ); } diff --git a/include/boost/range/rbegin.hpp b/include/boost/range/rbegin.hpp index 99d6558..f87717a 100755 --- a/include/boost/range/rbegin.hpp +++ b/include/boost/range/rbegin.hpp @@ -26,7 +26,7 @@ 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_result_iterator::type rbegin( C& c ) { return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator::type( end( c ) ); @@ -35,18 +35,18 @@ rbegin( C& c ) #else template< class C > -inline BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type +inline BOOST_DEDUCED_TYPENAME range_reverse_iterator< + typename remove_const::type >::type rbegin( C& c ) { - typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type + typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator< + typename remove_const::type >::type iter_type; return iter_type( end( c ) ); } template< class C > -inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type +inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type rbegin( const C& c ) { typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type diff --git a/include/boost/range/rend.hpp b/include/boost/range/rend.hpp index a235271..e654c60 100755 --- a/include/boost/range/rend.hpp +++ b/include/boost/range/rend.hpp @@ -22,31 +22,31 @@ 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_result_iterator::type rend( C& c ) { return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator::type( 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< + typename remove_const::type >::type rend( C& c ) { - typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator< - typename remove_const::type >::type + typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator< + typename remove_const::type >::type iter_type; return iter_type( begin( c ) ); } template< class C > -inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type +inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type rend( const C& c ) { typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator::type diff --git a/include/boost/range/size_type.hpp b/include/boost/range/size_type.hpp index 0c15f29..57f191d 100755 --- a/include/boost/range/size_type.hpp +++ b/include/boost/range/size_type.hpp @@ -21,47 +21,47 @@ namespace boost { - namespace range_detail - { - template< class T > - struct add_unsigned; + 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 short type; + }; - template<> - struct add_unsigned - { - typedef unsigned long 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; - }; + + 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; - }; + template< class T > + struct range_size + { + typedef BOOST_DEDUCED_TYPENAME range_detail::add_unsigned< + BOOST_DEDUCED_TYPENAME range_difference::type >::type + type; + }; } */ @@ -77,13 +77,13 @@ namespace boost ////////////////////////////////////////////////////////////////////////// // default ////////////////////////////////////////////////////////////////////////// - + template< typename C > struct range_size { typedef BOOST_DEDUCED_TYPENAME C::size_type type; }; - + ////////////////////////////////////////////////////////////////////////// // pair ////////////////////////////////////////////////////////////////////////// @@ -93,7 +93,7 @@ namespace boost { typedef std::size_t type; }; - + template< typename Iterator > struct range_size< const std::pair > { diff --git a/include/boost/range/value_type.hpp b/include/boost/range/value_type.hpp index 2072d62..15537b0 100755 --- a/include/boost/range/value_type.hpp +++ b/include/boost/range/value_type.hpp @@ -26,13 +26,13 @@ namespace boost { - template< class T > + template< class T > struct range_value - { - typedef BOOST_DEDUCED_TYPENAME iterator_value< - BOOST_DEDUCED_TYPENAME range_iterator::type >::type - type; - }; + { + typedef BOOST_DEDUCED_TYPENAME iterator_value< + BOOST_DEDUCED_TYPENAME range_iterator::type >::type + type; + }; } /* @@ -45,13 +45,13 @@ namespace boost ////////////////////////////////////////////////////////////////////////// // default ////////////////////////////////////////////////////////////////////////// - + template< typename C > struct range_value { typedef BOOST_DEDUCED_TYPENAME C::value_type type; }; - + ////////////////////////////////////////////////////////////////////////// // pair ////////////////////////////////////////////////////////////////////////// @@ -59,15 +59,15 @@ namespace boost template< typename Iterator > struct range_value< std::pair > { - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME iterator_value::type type; }; - - + + template< typename Iterator > struct range_value< const std::pair > { - typedef BOOST_DEDUCED_TYPENAME + typedef BOOST_DEDUCED_TYPENAME iterator_value::type type; }; @@ -86,7 +86,7 @@ namespace boost { typedef const T type; }; - + ////////////////////////////////////////////////////////////////////////// // string ////////////////////////////////////////////////////////////////////////// diff --git a/test/extension_mechanism.cpp b/test/extension_mechanism.cpp index 8692d9d..0a272c3 100755 --- a/test/extension_mechanism.cpp +++ b/test/extension_mechanism.cpp @@ -27,72 +27,72 @@ template< class Rng > typename boost::range_result_iterator::type foo_algo( Rng& r ) { - // - // This will only compile for Rng = UDT if the qualified calls - // find boost_range_XXX via ADL. - // - return boost::size(r) == 0u ? boost::begin(r) : boost::end(r); + // + // This will only compile for Rng = UDT if the qualified calls + // find boost_range_XXX via ADL. + // + return boost::size(r) == 0u ? boost::begin(r) : boost::end(r); } namespace Foo { - // - // Our sample UDT - // - struct X - { - typedef std::vector data_t; - typedef data_t::iterator iterator; - typedef data_t::const_iterator const_iterator; - typedef data_t::size_type size_type; + // + // Our sample UDT + // + struct X + { + 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; + data_t vec; - void push_back( int i ) - { vec.push_back(i); } - }; + void push_back( int i ) + { vec.push_back(i); } + }; - // - // The required functions. No type-traits need - // to be defined because X defines the proper set of - // nested types. - // - inline X::iterator boost_range_begin( X& x ) - { - return x.vec.begin(); - } + // + // The required functions. No type-traits need + // to be defined because X defines the proper set of + // nested types. + // + inline X::iterator boost_range_begin( X& x ) + { + return x.vec.begin(); + } + + + inline X::const_iterator boost_range_begin( const X& x ) + { + return x.vec.begin(); + } - - inline X::const_iterator boost_range_begin( const X& x ) - { - return x.vec.begin(); - } - inline X::iterator boost_range_end( X& x ) - { - return x.vec.end(); - } + { + return x.vec.end(); + } - inline X::const_iterator boost_range_end( const X& x ) - { - return x.vec.end(); - } + inline X::const_iterator boost_range_end( const X& x ) + { + return x.vec.end(); + } - inline X::size_type boost_range_size( const X& x ) - { - return x.vec.size(); - } + inline X::size_type boost_range_size( const X& x ) + { + return x.vec.size(); + } } void check_extension() { - Foo::X x; - x.push_back(3); - const Foo::X x2; + Foo::X x; + x.push_back(3); + const Foo::X x2; - foo_algo( x ); - foo_algo( x2 ); + foo_algo( x ); + foo_algo( x2 ); } using boost::unit_test::test_suite;