|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61026 - in trunk: boost/range libs/range/test
From: neil_at_[hidden]
Date: 2010-04-03 16:10:17
Author: neilgroves
Date: 2010-04-03 16:10:16 EDT (Sat, 03 Apr 2010)
New Revision: 61026
URL: http://svn.boost.org/trac/boost/changeset/61026
Log:
Boost.Range improvements for compiler compatibility, especially C++0x compilers.
Text files modified:
trunk/boost/range/concepts.hpp | 60 ++++++++++++------------
trunk/libs/range/test/iterator_pair.cpp | 79 +++++++++++++++----------------
trunk/libs/range/test/iterator_range.cpp | 97 ++++++++++++++++++---------------------
trunk/libs/range/test/reversible_range.cpp | 51 +++++++++-----------
trunk/libs/range/test/std_container.cpp | 51 +++++++++-----------
5 files changed, 161 insertions(+), 177 deletions(-)
Modified: trunk/boost/range/concepts.hpp
==============================================================================
--- trunk/boost/range/concepts.hpp (original)
+++ trunk/boost/range/concepts.hpp 2010-04-03 16:10:16 EDT (Sat, 03 Apr 2010)
@@ -74,10 +74,10 @@
// Ultimately modeling the range concepts using composition
// with the Boost.Iterator concepts would render the library
// incompatible with many common Boost.Lambda expressions.
- template<typename Iterator>
+ template<class Iterator>
struct IncrementableIteratorConcept : CopyConstructible<Iterator>
{
- typedef typename iterator_traversal<Iterator>::type traversal_category;
+ typedef BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator>::type traversal_category;
BOOST_CONCEPT_ASSERT((
Convertible<
@@ -94,42 +94,42 @@
Iterator i;
};
- template<typename Iterator>
+ template<class Iterator>
struct SinglePassIteratorConcept
: IncrementableIteratorConcept<Iterator>
, EqualityComparable<Iterator>
{
BOOST_CONCEPT_ASSERT((
Convertible<
- typename SinglePassIteratorConcept::traversal_category,
+ BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category,
single_pass_traversal_tag
>));
};
- template<typename Iterator>
+ template<class Iterator>
struct ForwardIteratorConcept
: SinglePassIteratorConcept<Iterator>
, DefaultConstructible<Iterator>
{
- typedef typename boost::detail::iterator_traits<Iterator>::difference_type difference_type;
+ typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::difference_type difference_type;
BOOST_MPL_ASSERT((is_integral<difference_type>));
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
BOOST_CONCEPT_ASSERT((
Convertible<
- typename ForwardIteratorConcept::traversal_category,
+ BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category,
forward_traversal_tag
>));
};
- template<typename Iterator>
+ template<class Iterator>
struct BidirectionalIteratorConcept
: ForwardIteratorConcept<Iterator>
{
BOOST_CONCEPT_ASSERT((
Convertible<
- typename BidirectionalIteratorConcept::traversal_category,
+ BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept::traversal_category,
bidirectional_traversal_tag
>));
@@ -142,13 +142,13 @@
Iterator i;
};
- template<typename Iterator>
+ template<class Iterator>
struct RandomAccessIteratorConcept
: BidirectionalIteratorConcept<Iterator>
{
BOOST_CONCEPT_ASSERT((
Convertible<
- typename RandomAccessIteratorConcept::traversal_category,
+ BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::traversal_category,
random_access_traversal_tag
>));
@@ -162,7 +162,7 @@
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 range_detail
//! Check if a type T models the SinglePassRange range concept.
- template<typename T>
+ template<class T>
struct SinglePassRangeConcept
{
- typedef typename range_iterator<T const>::type const_iterator;
- typedef typename range_iterator<T>::type iterator;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<T const>::type const_iterator;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<T>::type iterator;
BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<iterator>));
BOOST_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<const_iterator>));
@@ -211,17 +211,17 @@
};
//! Check if a type T models the ForwardRange range concept.
- template<typename T>
+ template<class T>
struct ForwardRangeConcept : SinglePassRangeConcept<T>
{
- BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<typename ForwardRangeConcept::iterator>));
- BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<typename ForwardRangeConcept::const_iterator>));
+ BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::iterator>));
+ BOOST_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::const_iterator>));
};
- template<typename Range>
+ template<class Range>
struct WriteableRangeConcept
{
- typedef typename range_iterator<Range>::type iterator;
+ typedef BOOST_DEDUCED_TYPENAME range_iterator<Range>::type iterator;
BOOST_CONCEPT_USAGE(WriteableRangeConcept)
{
@@ -229,11 +229,11 @@
}
private:
iterator i;
- typename range_value<Range>::type v;
+ BOOST_DEDUCED_TYPENAME range_value<Range>::type v;
};
//! Check if a type T models the WriteableForwardRange range concept.
- template<typename T>
+ template<class T>
struct WriteableForwardRangeConcept
: ForwardRangeConcept<T>
, WriteableRangeConcept<T>
@@ -241,15 +241,15 @@
};
//! Check if a type T models the BidirectionalRange range concept.
- template<typename T>
+ template<class T>
struct BidirectionalRangeConcept : ForwardRangeConcept<T>
{
- BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept<typename BidirectionalRangeConcept::iterator>));
- BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept<typename BidirectionalRangeConcept::const_iterator>));
+ BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::iterator>));
+ BOOST_CONCEPT_ASSERT((BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::const_iterator>));
};
//! Check if a type T models the WriteableBidirectionalRange range concept.
- template<typename T>
+ template<class T>
struct WriteableBidirectionalRangeConcept
: BidirectionalRangeConcept<T>
, WriteableRangeConcept<T>
@@ -257,15 +257,15 @@
};
//! Check if a type T models the RandomAccessRange range concept.
- template<typename T>
+ template<class T>
struct RandomAccessRangeConcept : BidirectionalRangeConcept<T>
{
- BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept<typename RandomAccessRangeConcept::iterator>));
- BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept<typename RandomAccessRangeConcept::const_iterator>));
+ BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::iterator>));
+ BOOST_CONCEPT_ASSERT((RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::const_iterator>));
};
//! Check if a type T models the WriteableRandomAccessRange range concept.
- template<typename T>
+ template<class T>
struct WriteableRandomAccessRangeConcept
: RandomAccessRangeConcept<T>
, WriteableRangeConcept<T>
Modified: trunk/libs/range/test/iterator_pair.cpp
==============================================================================
--- trunk/libs/range/test/iterator_pair.cpp (original)
+++ trunk/libs/range/test/iterator_pair.cpp 2010-04-03 16:10:16 EDT (Sat, 03 Apr 2010)
@@ -23,8 +23,6 @@
#include <boost/test/test_tools.hpp>
#include <vector>
-using namespace boost;
-
void check_iterator_pair()
{
typedef std::vector<int> vec_t;
@@ -35,57 +33,56 @@
typedef std::pair<vec_t::const_iterator,vec_t::const_iterator>
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<pair_t>::type,
- detail::iterator_traits<pair_t::first_type>::value_type>::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<pair_t>::type, pair_t::first_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_const_iterator<pair_t>::type, pair_t::first_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_difference<pair_t>::type,
- detail::iterator_traits<pair_t::first_type>::difference_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_size<pair_t>::type, std::size_t >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<pair_t>::type, pair_t::first_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
-
- BOOST_STATIC_ASSERT(( is_same< range_value<const_pair_tt>::type,
- detail::iterator_traits<const_pair_t::first_type>::value_type>::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
+
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<pair_t>::type,
+ boost::detail::iterator_traits<pair_t::first_type>::value_type>::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<pair_t>::type, pair_t::first_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_const_iterator<pair_t>::type, pair_t::first_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<pair_t>::type,
+ boost::detail::iterator_traits<pair_t::first_type>::difference_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<pair_t>::type, std::size_t >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<pair_t>::type, pair_t::first_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
+
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<const_pair_tt>::type,
+ boost::detail::iterator_traits<const_pair_t::first_type>::value_type>::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
//
// This behavior is not supported with v2.
//BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_difference<const_pair_tt>::type,
- detail::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_size<const_pair_tt>::type, std::size_t >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::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( 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_STATIC_ASSERT(( boost::is_same< boost::range_difference<const_pair_tt>::type,
+ boost::detail::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<const_pair_tt>::type, std::size_t >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
+
+ 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( 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 <boost/test/unit_test.hpp>
-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 ) );
Modified: trunk/libs/range/test/iterator_range.cpp
==============================================================================
--- trunk/libs/range/test/iterator_range.cpp (original)
+++ trunk/libs/range/test/iterator_range.cpp 2010-04-03 16:10:16 EDT (Sat, 03 Apr 2010)
@@ -19,32 +19,29 @@
#include <boost/range/iterator_range.hpp>
#include <boost/range/functions.hpp>
-#include <boost/range/as_literal.hpp>
+#include <boost/range/as_literal.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
-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<iterator> irange;
- typedef iterator_range<const_iterator> 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<iterator> irange;
+ typedef boost::iterator_range<const_iterator> 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 @@
// BOOST_CHECK( false );
// if( !(bool)r2 )
// BOOST_CHECK( false );
-//#else
+//#else
if( !r )
BOOST_CHECK( false );
if( !r2 )
@@ -62,55 +59,53 @@
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<string>( 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<std::string>( 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 @@
//
// 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<Container>::type citer_type;
- typedef iterator_range<citer_type> riter_type;
- riter_type a_riter( make_iterator_range( a_cont ) );
+ typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type citer_type;
+ typedef boost::iterator_range<citer_type> 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 @@
void check_reference_type()
{
- typedef vector<int> veci_type;
+ typedef std::vector<int> veci_type;
veci_type a_vec;
a_vec.push_back( 999 );
test_iter_range<veci_type>(a_vec);
Modified: trunk/libs/range/test/reversible_range.cpp
==============================================================================
--- trunk/libs/range/test/reversible_range.cpp (original)
+++ trunk/libs/range/test/reversible_range.cpp 2010-04-03 16:10:16 EDT (Sat, 03 Apr 2010)
@@ -27,44 +27,39 @@
#include <vector>
#include <algorithm>
-using namespace boost;
-using namespace std;
-
void check_iterator()
{
- typedef vector<int> vec_t;
- typedef vec_t::iterator iterator;
- typedef pair<iterator,iterator> pair_t;
- typedef range_reverse_iterator<pair_t>::type rev_iterator;
- typedef pair<rev_iterator,rev_iterator> rev_pair_t;
-
+ typedef std::vector<int> vec_t;
+ typedef vec_t::iterator iterator;
+ typedef std::pair<iterator,iterator> pair_t;
+ typedef boost::range_reverse_iterator<pair_t>::type rev_iterator;
+ typedef std::pair<rev_iterator,rev_iterator> 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<vec_t>::type( vec.end() ) );
- BOOST_CHECK( rend( vec ) == range_reverse_iterator<vec_t>::type( vec.begin() ) );
- BOOST_CHECK( std::distance( rbegin( vec ), rend( vec ) ) == std::distance( begin( vec ), 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 ) ) );
+ const int ca[] = {1,2,3,4,5,6,7,8,9,10,11,12};
+ BOOST_CHECK( boost::rbegin( vec ) == boost::range_reverse_iterator<vec_t>::type( vec.end() ) );
+ BOOST_CHECK( boost::rend( vec ) == boost::range_reverse_iterator<vec_t>::type( vec.begin() ) );
+ BOOST_CHECK( std::distance( boost::rbegin( vec ), boost::rend( vec ) ) == std::distance( boost::begin( vec ), boost::end( vec ) ) );
+
+ 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 ) );
Modified: trunk/libs/range/test/std_container.cpp
==============================================================================
--- trunk/libs/range/test/std_container.cpp (original)
+++ trunk/libs/range/test/std_container.cpp 2010-04-03 16:10:16 EDT (Sat, 03 Apr 2010)
@@ -24,46 +24,43 @@
#include <boost/test/test_tools.hpp>
#include <vector>
-using namespace boost;
-
void check_std_container()
{
typedef std::vector<int> 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<vec_t>::type, vec_t::value_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_difference<vec_t>::type, vec_t::difference_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_size<vec_t>::type, vec_t::size_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
-
- BOOST_STATIC_ASSERT(( is_same< range_value<const vec_t>::type, vec_t::value_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_difference<const vec_t>::type, vec_t::difference_type >::value ));
- BOOST_STATIC_ASSERT(( is_same< range_size<const vec_t>::type, vec_t::size_type >::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<vec_t>::type, vec_t::value_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<vec_t>::type, vec_t::iterator >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<vec_t>::type, vec_t::difference_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<vec_t>::type, vec_t::size_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<vec_t>::type, vec_t::iterator >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
+
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<const vec_t>::type, vec_t::value_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<const vec_t>::type, vec_t::difference_type >::value ));
+ BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<const vec_t>::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<std::size_t>(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<std::size_t>(boost::size( cvec )) == cvec.size() );
}
#include <boost/test/unit_test.hpp>
-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 ) );
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk