forked from boostorg/range
Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
@ -36,7 +37,7 @@ namespace
|
||||
}
|
||||
|
||||
template< typename Range, typename T >
|
||||
inline typename boost::range_const_iterator<Range>::type
|
||||
inline typename boost::range_iterator<Range>::type
|
||||
find( const Range& c, const T& value )
|
||||
{
|
||||
return std::find( boost::begin( c ), boost::end( c ), value );
|
||||
@ -46,7 +47,7 @@ namespace
|
||||
// replace first value and return its index
|
||||
//
|
||||
template< class Range, class T >
|
||||
inline typename boost::range_size<Range>::type
|
||||
inline typename boost::range_difference<Range>::type
|
||||
my_generic_replace( Range& c, const T& value, const T& replacement )
|
||||
{
|
||||
typename boost::range_iterator<Range>::type found = find( c, value );
|
||||
@ -63,19 +64,15 @@ void check_algorithm()
|
||||
//
|
||||
// usage
|
||||
//
|
||||
const unsigned N = 5;
|
||||
const int N = 5;
|
||||
std::vector<int> my_vector;
|
||||
int values[] = { 1,2,3,4,5,6,7,8,9 };
|
||||
my_vector.assign( values, values + 9 );
|
||||
typedef std::vector<int>::iterator iterator;
|
||||
std::pair<iterator,iterator> my_view( boost::begin( my_vector ),
|
||||
boost::begin( my_vector ) + N );
|
||||
char str_val[] = "a string";
|
||||
char* str = str_val;
|
||||
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3u );
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3 );
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( my_view, 4, 2 ), N );
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( str, 'a', 'b' ), 0u );
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user