Boost.RangeEx merged into Boost.Range

[SVN r60897]
This commit is contained in:
Neil Groves
2010-03-28 16:08:35 +00:00
parent 1461479a17
commit b0d1db7c2e
471 changed files with 48610 additions and 2065 deletions

67
test/adl_conformance.cpp Executable file → Normal file
View File

@ -27,38 +27,41 @@ enum adl_types
global_namespace
};
namespace boost
// Use boost_test rather than boost as the namespace for this test
// to allow the test framework to use boost::begin() etc. without
// violating the One Defintion Rule.
namespace boost_test
{
namespace range_detail
{
template< class Range >
inline typename Range::iterator begin( Range& r )
{
return boost_namespace;
return boost_namespace;
}
template< class Range >
inline typename Range::iterator begin( const Range& r )
{
return boost_namespace;
return boost_namespace;
}
}
template< class Range >
inline typename Range::iterator begin( Range& r )
{
using range_detail::begin; // create ADL hook
return begin( r );
}
template< class Range >
inline typename Range::iterator begin( const Range& r )
{
using range_detail::begin; // create ADL hook
return begin( r );
}
}
} // 'boost_test'
namespace find_templated
@ -74,7 +77,7 @@ namespace find_templated
iterator end() { return unused; }
iterator end() const { return unused; }
};
//
// A fully generic version here will create
// ambiguity.
@ -84,7 +87,7 @@ namespace find_templated
{
return templated_namespace;
}
template< class T >
inline typename range<T>::iterator begin( const range<T>& r )
{
@ -98,20 +101,20 @@ namespace find_non_templated
struct range
{
typedef adl_types iterator;
range() { /* allow const objects */ }
iterator begin() { return unused; }
iterator begin() const { return unused; }
iterator end() { return unused; }
iterator end() const { return unused; }
};
inline range::iterator begin( range& r )
{
return non_templated_namespace;
}
inline range::iterator begin( const range& r )
{
return non_templated_namespace;
@ -132,12 +135,12 @@ struct range
inline range::iterator begin( range& r )
{
return global_namespace;
}
}
inline range::iterator begin( const range& r )
{
return global_namespace;
}
}
void check_adl_conformance()
{
@ -147,29 +150,29 @@ void check_adl_conformance()
const find_non_templated::range r4;
range r5;
const range r6;
//
// Notice how ADL kicks in even when we have qualified
// Notice how ADL kicks in even when we have qualified
// notation!
//
BOOST_CHECK( boost::begin( r ) != boost_namespace );
BOOST_CHECK( boost::begin( r2 ) != boost_namespace );
BOOST_CHECK( boost::begin( r3 ) != boost_namespace );
BOOST_CHECK( boost::begin( r4 ) != boost_namespace );
BOOST_CHECK( boost::begin( r5 ) != boost_namespace );
BOOST_CHECK( boost::begin( r6 ) != boost_namespace );
BOOST_CHECK_EQUAL( boost::begin( r ), templated_namespace ) ;
BOOST_CHECK_EQUAL( boost::begin( r2 ), templated_namespace );
BOOST_CHECK_EQUAL( boost::begin( r3 ), non_templated_namespace );
BOOST_CHECK_EQUAL( boost::begin( r4 ), non_templated_namespace );
BOOST_CHECK_EQUAL( boost::begin( r5 ), global_namespace );
BOOST_CHECK_EQUAL( boost::begin( r6 ), global_namespace );
BOOST_CHECK( boost_test::begin( r ) != boost_namespace );
BOOST_CHECK( boost_test::begin( r2 ) != boost_namespace );
BOOST_CHECK( boost_test::begin( r3 ) != boost_namespace );
BOOST_CHECK( boost_test::begin( r4 ) != boost_namespace );
BOOST_CHECK( boost_test::begin( r5 ) != boost_namespace );
BOOST_CHECK( boost_test::begin( r6 ) != boost_namespace );
BOOST_CHECK_EQUAL( boost_test::begin( r ), templated_namespace ) ;
BOOST_CHECK_EQUAL( boost_test::begin( r2 ), templated_namespace );
BOOST_CHECK_EQUAL( boost_test::begin( r3 ), non_templated_namespace );
BOOST_CHECK_EQUAL( boost_test::begin( r4 ), non_templated_namespace );
BOOST_CHECK_EQUAL( boost_test::begin( r5 ), global_namespace );
BOOST_CHECK_EQUAL( boost_test::begin( r6 ), global_namespace );
}
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/test/included/unit_test_framework.hpp>
using boost::unit_test_framework::test_suite;