forked from boostorg/range
*** empty log message ***
[SVN r24122]
This commit is contained in:
@ -58,11 +58,11 @@ namespace boost {
|
|||||||
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
|
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
|
||||||
|
|
||||||
//! Encapsulated value type
|
//! Encapsulated value type
|
||||||
typedef BOOST_DEDUCED_TYPENAME boost::
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
iterator_value<IteratorT>::type value_type;
|
iterator_value<IteratorT>::type value_type;
|
||||||
|
|
||||||
//! Difference type
|
//! Difference type
|
||||||
typedef BOOST_DEDUCED_TYPENAME boost::
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
iterator_difference<IteratorT>::type difference_type;
|
iterator_difference<IteratorT>::type difference_type;
|
||||||
//! Size type
|
//! Size type
|
||||||
typedef std::size_t size_type; // note: must be unsigned
|
typedef std::size_t size_type; // note: must be unsigned
|
||||||
@ -86,12 +86,12 @@ namespace boost {
|
|||||||
//! Constructor from a Range
|
//! Constructor from a Range
|
||||||
template< class Range >
|
template< class Range >
|
||||||
iterator_range( const Range& r ) :
|
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
|
//! Constructor from a Range
|
||||||
template< class Range >
|
template< class Range >
|
||||||
iterator_range( Range& r ) :
|
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
|
//! Copy constructor -- default OK
|
||||||
|
|
||||||
@ -241,6 +241,17 @@ namespace boost {
|
|||||||
return iterator_range<IteratorT>( Begin, End );
|
return iterator_range<IteratorT>( Begin, End );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||||
|
|
||||||
|
template< typename Range >
|
||||||
|
inline iterator_range< BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type >
|
||||||
|
make_iterator_range( Range& r )
|
||||||
|
{
|
||||||
|
return iterator_range< BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type >
|
||||||
|
( begin( r ), end( r ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
//! iterator_range construct helper
|
//! iterator_range construct helper
|
||||||
/*!
|
/*!
|
||||||
Construct an \c iterator_range from a \c Range containing the begin
|
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<Range>::type >
|
return iterator_range< BOOST_DEDUCED_TYPENAME const_iterator_of<Range>::type >
|
||||||
( r );
|
( r );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//! copy a range into a sequence
|
//! copy a range into a sequence
|
||||||
/*!
|
/*!
|
||||||
|
@ -36,6 +36,12 @@ test-suite range
|
|||||||
:
|
:
|
||||||
: iterator_range
|
: iterator_range
|
||||||
]
|
]
|
||||||
|
[ run
|
||||||
|
sub_range.cpp
|
||||||
|
: :
|
||||||
|
:
|
||||||
|
: sub_range
|
||||||
|
]
|
||||||
|
|
||||||
[ run
|
[ run
|
||||||
partial_workaround.cpp
|
partial_workaround.cpp
|
||||||
|
@ -84,3 +84,5 @@ Yes.
|
|||||||
|
|
||||||
15. More concepts: random-access range: which have constant
|
15. More concepts: random-access range: which have constant
|
||||||
time size(); Cpm matthews latest article.
|
time size(); Cpm matthews latest article.
|
||||||
|
|
||||||
|
16. use typetraits for broken compilers...will probably make array work for buitins!
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/range/iterator_range.hpp>
|
#include <boost/range/iterator_range.hpp>
|
||||||
#include <boost/range/sub_range.hpp>
|
#include <boost/range/functions.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -34,6 +34,7 @@ struct add_one
|
|||||||
|
|
||||||
void check_iterator_range()
|
void check_iterator_range()
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef string::iterator iterator;
|
typedef string::iterator iterator;
|
||||||
typedef string::const_iterator const_iterator;
|
typedef string::const_iterator const_iterator;
|
||||||
typedef iterator_range<iterator> irange;
|
typedef iterator_range<iterator> irange;
|
||||||
@ -45,40 +46,25 @@ void check_iterator_range()
|
|||||||
cirange r2 = make_iterator_range( cstr );
|
cirange r2 = make_iterator_range( cstr );
|
||||||
r2 = make_iterator_range( cstr.begin(), cstr.end() );
|
r2 = make_iterator_range( cstr.begin(), cstr.end() );
|
||||||
r2 = make_iterator_range( str );
|
r2 = make_iterator_range( str );
|
||||||
|
|
||||||
typedef sub_range<string> srange;
|
BOOST_CHECK( !r.empty() );
|
||||||
typedef sub_range<const string> csrange;
|
BOOST_CHECK( !r2.empty() );
|
||||||
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() );
|
|
||||||
|
|
||||||
if( !r )
|
if( !r )
|
||||||
BOOST_CHECK( false );
|
BOOST_CHECK( false );
|
||||||
if( !r2 )
|
if( !r2 )
|
||||||
BOOST_CHECK( false );
|
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<string>( r );
|
string res = copy_range<string>( r );
|
||||||
BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) );
|
BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) );
|
||||||
string res2 = transform_range<string>( s2, add_one() );
|
|
||||||
BOOST_CHECK( !equal( s2.begin(), s2.end(), res2.begin() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user