[range] - merge the tested changes from the trunk in preparation for the 1.46 release.

[SVN r67905]
This commit is contained in:
Neil Groves
2011-01-10 06:35:02 +00:00
parent 674be9dfa0
commit 6d46ce412f
143 changed files with 5587 additions and 2015 deletions

View File

@ -24,24 +24,24 @@
namespace boost_range_extension_size_test
{
class FooWithoutMemberSize
class FooWithoutSize
{
typedef std::list<int> impl_t;
typedef impl_t::const_iterator const_iterator;
typedef impl_t::iterator iterator;
public:
friend inline const_iterator range_begin(const FooWithoutMemberSize& obj) { return obj.m_impl.begin(); }
friend inline iterator range_begin(FooWithoutMemberSize& obj) { return obj.m_impl.begin(); }
friend inline const_iterator range_end(const FooWithoutMemberSize& obj) { return obj.m_impl.end(); }
friend inline iterator range_end(FooWithoutMemberSize& obj){ return obj.m_impl.end(); }
friend inline const_iterator range_begin(const FooWithoutSize& obj) { return obj.m_impl.begin(); }
friend inline iterator range_begin(FooWithoutSize& obj) { return obj.m_impl.begin(); }
friend inline const_iterator range_end(const FooWithoutSize& obj) { return obj.m_impl.end(); }
friend inline iterator range_end(FooWithoutSize& obj){ return obj.m_impl.end(); }
private:
impl_t m_impl;
};
boost::range_difference<std::list<int> >::type
inline range_calculate_size(const FooWithoutMemberSize& rng)
inline boost::range_difference<std::list<int> >::type
range_calculate_size(const FooWithoutSize& rng)
{
return 2u;
}
@ -49,12 +49,12 @@ namespace boost_range_extension_size_test
namespace boost
{
template<> struct range_iterator<const ::boost_range_extension_size_test::FooWithoutMemberSize>
template<> struct range_iterator<const ::boost_range_extension_size_test::FooWithoutSize>
{
typedef std::list<int>::const_iterator type;
};
template<> struct range_iterator< ::boost_range_extension_size_test::FooWithoutMemberSize >
template<> struct range_iterator< ::boost_range_extension_size_test::FooWithoutSize>
{
typedef std::list<int>::iterator type;
};
@ -63,13 +63,6 @@ namespace boost
namespace
{
void check_size_works_with_less_than_random_access()
{
std::list<int> container;
container.push_back(1);
BOOST_CHECK_EQUAL( boost::size(container), 1u );
}
void check_size_works_with_random_access()
{
std::vector<int> container;
@ -77,28 +70,9 @@ void check_size_works_with_random_access()
BOOST_CHECK_EQUAL( boost::size(container), 1u );
}
class FooWithMemberSize
{
public:
typedef std::list<int> impl_t;
typedef impl_t::const_iterator const_iterator;
typedef impl_t::iterator iterator;
typedef impl_t::value_type value_type;
std::size_t size() const { return 1u; }
const_iterator begin() const { return m_impl.begin(); }
iterator begin() { return m_impl.begin(); }
const_iterator end() const { return m_impl.end(); }
iterator end() { return m_impl.end(); }
private:
std::list<int> m_impl;
};
void check_extension_size()
{
BOOST_CHECK_EQUAL( boost::size(FooWithMemberSize()), 1u );
BOOST_CHECK_EQUAL( boost::size(boost_range_extension_size_test::FooWithoutMemberSize()), 2u );
BOOST_CHECK_EQUAL( boost::size(boost_range_extension_size_test::FooWithoutSize()), 2u );
}
} // anonymous namespace
@ -109,14 +83,8 @@ 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_size_works_with_less_than_random_access ));
test->add( BOOST_TEST_CASE( &check_size_works_with_random_access ));
test->add( BOOST_TEST_CASE( &check_extension_size ) );
return test;
}