From 2f4e6004f3c75af14b3188f61f2c751ba938b95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 27 Jul 2004 17:53:15 +0000 Subject: [PATCH] *** empty log message *** [SVN r24122] --- include/boost/range/iterator_range.hpp | 20 +++++++++++--- test/Jamfile | 6 ++++ test/TODO | 2 ++ test/iterator_range.cpp | 38 ++++++++------------------ 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index 3938a6b..b264bc0 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -58,11 +58,11 @@ namespace boost { //BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type); //! Encapsulated value type - typedef BOOST_DEDUCED_TYPENAME boost:: + typedef BOOST_DEDUCED_TYPENAME iterator_value::type value_type; //! Difference type - typedef BOOST_DEDUCED_TYPENAME boost:: + typedef BOOST_DEDUCED_TYPENAME iterator_difference::type difference_type; //! Size type typedef std::size_t size_type; // note: must be unsigned @@ -86,12 +86,12 @@ namespace boost { //! Constructor from a Range template< class Range > iterator_range( const Range& r ) : - m_Begin( boost::begin( r ) ), m_End( boost::end( r ) ) {} + m_Begin( begin( r ) ), m_End( end( r ) ) {} //! Constructor from a Range template< class Range > iterator_range( Range& r ) : - m_Begin( boost::begin( r ) ), m_End( boost::end( r ) ) {} + m_Begin( begin( r ) ), m_End( end( r ) ) {} //! Copy constructor -- default OK @@ -241,6 +241,17 @@ namespace boost { return iterator_range( Begin, End ); } +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + template< typename Range > + inline iterator_range< BOOST_DEDUCED_TYPENAME result_iterator_of::type > + make_iterator_range( Range& r ) + { + return iterator_range< BOOST_DEDUCED_TYPENAME result_iterator_of::type > + ( begin( r ), end( r ) ); + } + +#else //! iterator_range construct helper /*! Construct an \c iterator_range from a \c Range containing the begin @@ -261,6 +272,7 @@ namespace boost { return iterator_range< BOOST_DEDUCED_TYPENAME const_iterator_of::type > ( r ); } +#endif //! copy a range into a sequence /*! diff --git a/test/Jamfile b/test/Jamfile index c791598..f946a17 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -36,6 +36,12 @@ test-suite range : : iterator_range ] + [ run + sub_range.cpp + : : + : + : sub_range + ] [ run partial_workaround.cpp diff --git a/test/TODO b/test/TODO index e6f8058..c3e46d2 100644 --- a/test/TODO +++ b/test/TODO @@ -84,3 +84,5 @@ Yes. 15. More concepts: random-access range: which have constant time size(); Cpm matthews latest article. + +16. use typetraits for broken compilers...will probably make array work for buitins! diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 79ec34a..77030da 100755 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -9,7 +9,7 @@ // #include -#include +#include #include #include #include @@ -34,6 +34,7 @@ struct add_one void check_iterator_range() { + typedef string::iterator iterator; typedef string::const_iterator const_iterator; typedef iterator_range irange; @@ -45,40 +46,25 @@ void check_iterator_range() 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; - srange s = r; - BOOST_CHECK( r == s ); - s = make_iterator_range( str ); - csrange s2 = r; - s2 = r2; - s2 = make_iterator_range( cstr ); - BOOST_CHECK( r != s2 ); - s2 = make_iterator_range( str ); - - 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() ); + + BOOST_CHECK( !r.empty() ); + BOOST_CHECK( !r2.empty() ); if( !r ) BOOST_CHECK( false ); if( !r2 ) BOOST_CHECK( false ); - if( !s ) - BOOST_CHECK( false ); - if( !s2 ) - BOOST_CHECK( false ); - cout << r << r2 << s << s2; + 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; string res = copy_range( r ); BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) ); - string res2 = transform_range( s2, add_one() ); - BOOST_CHECK( !equal( s2.begin(), s2.end(), res2.begin() ) ); + }