Add boost::get<> support to Boost.Array

[SVN r82089]
This commit is contained in:
Marshall Clow
2012-12-19 00:53:31 +00:00
parent daeb19f693
commit e02e7dcc00
7 changed files with 206 additions and 76 deletions

View File

@ -10,39 +10,32 @@
#include <boost/array.hpp>
#include <algorithm>
#include <boost/test/included/test_exec_monitor.hpp>
namespace {
unsigned int failed_tests = 0;
void fail_test( const char * reason ) {
++failed_tests;
std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
}
template< class T >
void RunTests()
{
typedef boost::array< T, 5 > test_type;
typedef T arr[5];
test_type test_case; // = { 1, 1, 2, 3, 5 };
template< class T >
void RunTests()
{
typedef boost::array< T, 5 > test_type;
typedef T arr[5];
test_type test_case; // = { 1, 1, 2, 3, 5 };
arr &aRef = get_c_array ( test_case );
if ( &*test_case.begin () != &aRef[0] )
fail_test ( "Array6: Same thing not equal?(1)" );
arr &aRef = get_c_array ( test_case );
BOOST_CHECK ( &*test_case.begin () == &aRef[0] );
const arr &caRef = get_c_array ( test_case );
typename test_type::const_iterator iter = test_case.begin ();
if ( &*iter != &caRef[0] )
fail_test ( "Array6: Same thing not equal?(2)" );
const arr &caRef = get_c_array ( test_case );
typename test_type::const_iterator iter = test_case.begin ();
BOOST_CHECK ( &*iter == &caRef[0] );
}
}
}
int main()
int test_main( int , char* [] )
{
RunTests< bool >();
RunTests< void * >();
RunTests< long double >();
RunTests< std::string >();
return failed_tests;
return 0;
}