*** empty log message ***

[SVN r24118]
This commit is contained in:
Thorsten Jørgen Ottosen
2004-07-27 14:16:38 +00:00
parent 716d34097b
commit ec8b51b82b

View File

@ -8,7 +8,8 @@
// For more information, see http://www.boost.org/libs/range/ // For more information, see http://www.boost.org/libs/range/
// //
#include <boost/range.hpp> #include <boost/range/functions.hpp>
#include <boost/range/types.hpp>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
@ -16,16 +17,16 @@
namespace namespace
{ {
template< typename ExternalCollection, typename T > template< typename ExternalRange, typename T >
inline typename boost::iterator_of<ExternalCollection>::type inline typename boost::iterator_of<ExternalRange>::type
find( ExternalCollection& c, const T& value ) find( ExternalRange& c, const T& value )
{ {
return std::find( boost::begin( c ), boost::end( c ), value ); return std::find( boost::begin( c ), boost::end( c ), value );
} }
template< typename ExternalCollection, typename T > template< typename ExternalRange, typename T >
inline typename boost::const_iterator_of<ExternalCollection>::type inline typename boost::const_iterator_of<ExternalRange>::type
find( const ExternalCollection& c, const T& value ) find( const ExternalRange& c, const T& value )
{ {
return std::find( boost::begin( c ), boost::end( c ), value ); return std::find( boost::begin( c ), boost::end( c ), value );
} }
@ -33,11 +34,11 @@ namespace
// //
// replace first value and return its index // replace first value and return its index
// //
template< typename EC, typename T > template< typename ER, typename T >
inline typename boost::size_type_of< EC >::type inline typename boost::size_type_of< ER >::type
my_generic_replace( EC& c, const T& value, const T& replacement ) my_generic_replace( ER& c, const T& value, const T& replacement )
{ {
typename boost::iterator_of<EC>::type found = find( c, value ); typename boost::iterator_of<ER>::type found = find( c, value );
if( found != boost::end( c ) ) if( found != boost::end( c ) )
*found = replacement; *found = replacement;
@ -46,13 +47,12 @@ namespace
} }
int main() int main()
{ {
const int N = 5; const int N = 5;
int v[] = { 1,2,3,4,5,6,6,7,8,9 };
std::vector<int> my_vector; std::vector<int> my_vector;
my_vector.assign( boost::begin( v ), boost::end( v ) ); int values[] = { 1,2,3,4,5,6,7,8,9 };
my_vector.assign( values, values + 9 );
typedef std::vector<int>::iterator iterator; typedef std::vector<int>::iterator iterator;
std::pair<iterator,iterator> my_view( boost::begin( my_vector ), std::pair<iterator,iterator> my_view( boost::begin( my_vector ),
boost::begin( my_vector ) + N ); boost::begin( my_vector ) + N );