mirror of
https://github.com/boostorg/range.git
synced 2025-06-27 13:01:34 +02:00
Compare commits
38 Commits
svn-branch
...
boost-1.43
Author | SHA1 | Date | |
---|---|---|---|
ccebdfb371 | |||
91d62c2c1a | |||
f9eeb5d447 | |||
a47f15a98f | |||
dfc30e334d | |||
13b748a228 | |||
eea32403ef | |||
29b2053f5c | |||
29fa877949 | |||
a39946c55d | |||
90f4eca5cd | |||
c8c808b04e | |||
deefb61ec6 | |||
12d904a5e4 | |||
26b096f65d | |||
a85afbe470 | |||
e7902d439b | |||
b4f99d66b5 | |||
d1c2c5ce3f | |||
062e820882 | |||
4d381e8564 | |||
fd00cc129f | |||
8291ce67fc | |||
dbfa1df088 | |||
5afec2b74f | |||
a33d5c22c5 | |||
901266b76a | |||
25e932149c | |||
c54e15d374 | |||
fd448ffa31 | |||
21b558fe5e | |||
33c8f3e3ec | |||
523f8a5926 | |||
3bd0d886c4 | |||
e46eae8144 | |||
12cf02586c | |||
ee024f588b | |||
8e715b3810 |
0
doc/style.css
Executable file → Normal file
0
doc/style.css
Executable file → Normal file
0
include/boost/range.hpp
Executable file → Normal file
0
include/boost/range.hpp
Executable file → Normal file
@ -30,8 +30,8 @@ namespace boost
|
||||
inline OutputIterator
|
||||
remove_copy_if(SinglePassRange& rng, OutputIterator out_it, Predicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
|
||||
return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
|
||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||
return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
|
||||
}
|
||||
}
|
||||
|
||||
|
0
include/boost/range/as_array.hpp
Executable file → Normal file
0
include/boost/range/as_array.hpp
Executable file → Normal file
@ -25,7 +25,7 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar>
|
||||
#endif
|
||||
|
||||
@ -38,41 +38,41 @@ namespace boost
|
||||
return strlen( s );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
inline std::size_t length( const wchar_t* s )
|
||||
{
|
||||
return wcslen( s );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Remark: the compiler cannot choose between T* and T[sz]
|
||||
// overloads, so we must put the T* internal to the
|
||||
// unconstrained version.
|
||||
//
|
||||
//
|
||||
|
||||
inline bool is_char_ptr( char* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool is_char_ptr( const char* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
inline bool is_char_ptr( wchar_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool is_char_ptr( const wchar_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template< class T >
|
||||
inline long is_char_ptr( T /* r */ )
|
||||
{
|
||||
@ -80,30 +80,30 @@ namespace boost
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline iterator_range<T*>
|
||||
inline iterator_range<T*>
|
||||
make_range( T* const r, bool )
|
||||
{
|
||||
return iterator_range<T*>( r, r + length(r) );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<T>::type>
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<T>::type>
|
||||
make_range( T& r, long )
|
||||
{
|
||||
return boost::make_iterator_range( r );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
|
||||
as_literal( Range& r )
|
||||
{
|
||||
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
|
||||
}
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type>
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type>
|
||||
as_literal( const Range& r )
|
||||
{
|
||||
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
|
||||
@ -112,9 +112,9 @@ namespace boost
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
|
||||
{
|
||||
return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
|
||||
return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
|
||||
}
|
||||
|
||||
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
|
||||
{
|
||||
|
0
include/boost/range/category.hpp
Executable file → Normal file
0
include/boost/range/category.hpp
Executable file → Normal file
0
include/boost/range/config.hpp
Executable file → Normal file
0
include/boost/range/config.hpp
Executable file → Normal file
0
include/boost/range/const_reverse_iterator.hpp
Executable file → Normal file
0
include/boost/range/const_reverse_iterator.hpp
Executable file → Normal file
0
include/boost/range/detail/begin.hpp
Executable file → Normal file
0
include/boost/range/detail/begin.hpp
Executable file → Normal file
0
include/boost/range/detail/collection_traits.hpp
Executable file → Normal file
0
include/boost/range/detail/collection_traits.hpp
Executable file → Normal file
0
include/boost/range/detail/collection_traits_detail.hpp
Executable file → Normal file
0
include/boost/range/detail/collection_traits_detail.hpp
Executable file → Normal file
0
include/boost/range/detail/common.hpp
Executable file → Normal file
0
include/boost/range/detail/common.hpp
Executable file → Normal file
0
include/boost/range/detail/const_iterator.hpp
Executable file → Normal file
0
include/boost/range/detail/const_iterator.hpp
Executable file → Normal file
0
include/boost/range/detail/detail_str.hpp
Executable file → Normal file
0
include/boost/range/detail/detail_str.hpp
Executable file → Normal file
0
include/boost/range/detail/difference_type.hpp
Executable file → Normal file
0
include/boost/range/detail/difference_type.hpp
Executable file → Normal file
0
include/boost/range/detail/empty.hpp
Executable file → Normal file
0
include/boost/range/detail/empty.hpp
Executable file → Normal file
0
include/boost/range/detail/end.hpp
Executable file → Normal file
0
include/boost/range/detail/end.hpp
Executable file → Normal file
14
include/boost/range/detail/implementation_help.hpp
Executable file → Normal file
14
include/boost/range/detail/implementation_help.hpp
Executable file → Normal file
@ -21,13 +21,13 @@
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template <typename T>
|
||||
inline void boost_range_silence_warning( const T& ) { }
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// end() help
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -36,7 +36,7 @@ namespace boost
|
||||
{
|
||||
return s + strlen( s );
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
|
||||
{
|
||||
@ -51,7 +51,7 @@ namespace boost
|
||||
;
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template< class Char >
|
||||
inline Char* str_end( Char* s )
|
||||
@ -64,7 +64,7 @@ namespace boost
|
||||
{
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace boost
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// size() help
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template< class Char >
|
||||
inline std::size_t str_size( const Char* const& s )
|
||||
{
|
||||
@ -96,7 +96,7 @@ namespace boost
|
||||
}
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
|
0
include/boost/range/detail/iterator.hpp
Executable file → Normal file
0
include/boost/range/detail/iterator.hpp
Executable file → Normal file
0
include/boost/range/detail/remove_extent.hpp
Executable file → Normal file
0
include/boost/range/detail/remove_extent.hpp
Executable file → Normal file
0
include/boost/range/detail/sfinae.hpp
Executable file → Normal file
0
include/boost/range/detail/sfinae.hpp
Executable file → Normal file
0
include/boost/range/detail/size.hpp
Executable file → Normal file
0
include/boost/range/detail/size.hpp
Executable file → Normal file
0
include/boost/range/detail/size_type.hpp
Executable file → Normal file
0
include/boost/range/detail/size_type.hpp
Executable file → Normal file
0
include/boost/range/detail/sizer.hpp
Executable file → Normal file
0
include/boost/range/detail/sizer.hpp
Executable file → Normal file
0
include/boost/range/detail/str_types.hpp
Executable file → Normal file
0
include/boost/range/detail/str_types.hpp
Executable file → Normal file
0
include/boost/range/detail/value_type.hpp
Executable file → Normal file
0
include/boost/range/detail/value_type.hpp
Executable file → Normal file
0
include/boost/range/detail/vc6/end.hpp
Executable file → Normal file
0
include/boost/range/detail/vc6/end.hpp
Executable file → Normal file
0
include/boost/range/detail/vc6/size.hpp
Executable file → Normal file
0
include/boost/range/detail/vc6/size.hpp
Executable file → Normal file
0
include/boost/range/difference_type.hpp
Executable file → Normal file
0
include/boost/range/difference_type.hpp
Executable file → Normal file
0
include/boost/range/distance.hpp
Executable file → Normal file
0
include/boost/range/distance.hpp
Executable file → Normal file
0
include/boost/range/empty.hpp
Executable file → Normal file
0
include/boost/range/empty.hpp
Executable file → Normal file
0
include/boost/range/functions.hpp
Executable file → Normal file
0
include/boost/range/functions.hpp
Executable file → Normal file
60
include/boost/range/iterator.hpp
Executable file → Normal file
60
include/boost/range/iterator.hpp
Executable file → Normal file
@ -25,46 +25,46 @@
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< typename C >
|
||||
struct range_iterator
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
0
include/boost/range/metafunctions.hpp
Executable file → Normal file
0
include/boost/range/metafunctions.hpp
Executable file → Normal file
0
include/boost/range/pointer.hpp
Executable file → Normal file
0
include/boost/range/pointer.hpp
Executable file → Normal file
0
include/boost/range/rbegin.hpp
Executable file → Normal file
0
include/boost/range/rbegin.hpp
Executable file → Normal file
0
include/boost/range/reference.hpp
Executable file → Normal file
0
include/boost/range/reference.hpp
Executable file → Normal file
0
include/boost/range/rend.hpp
Executable file → Normal file
0
include/boost/range/rend.hpp
Executable file → Normal file
0
include/boost/range/result_iterator.hpp
Executable file → Normal file
0
include/boost/range/result_iterator.hpp
Executable file → Normal file
0
include/boost/range/reverse_iterator.hpp
Executable file → Normal file
0
include/boost/range/reverse_iterator.hpp
Executable file → Normal file
0
include/boost/range/reverse_result_iterator.hpp
Executable file → Normal file
0
include/boost/range/reverse_result_iterator.hpp
Executable file → Normal file
2
include/boost/range/size.hpp
Executable file → Normal file
2
include/boost/range/size.hpp
Executable file → Normal file
@ -20,7 +20,7 @@
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class T >
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef BOOST_RANGE_SUB_RANGE_HPP
|
||||
#define BOOST_RANGE_SUB_RANGE_HPP
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
#endif
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class ForwardRange >
|
||||
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
|
||||
template< class ForwardRange >
|
||||
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
|
||||
typedef iterator_range< iterator_t > base;
|
||||
@ -53,40 +53,40 @@ namespace boost
|
||||
reference >::type const_reference;
|
||||
|
||||
public:
|
||||
sub_range() : base()
|
||||
sub_range() : base()
|
||||
{ }
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
||||
sub_range( const sub_range& r )
|
||||
: base( static_cast<const base&>( r ) )
|
||||
{ }
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
||||
sub_range( const sub_range& r )
|
||||
: base( static_cast<const base&>( r ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( ForwardRange2& r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
{ }
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( const ForwardRange2& r ) :
|
||||
sub_range( ForwardRange2& r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
#endif
|
||||
{ }
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( const ForwardRange2& r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
{ }
|
||||
|
||||
template< class Iter >
|
||||
sub_range( Iter first, Iter last ) :
|
||||
base( first, last )
|
||||
{ }
|
||||
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range& operator=( ForwardRange2& r )
|
||||
{
|
||||
@ -99,23 +99,23 @@ namespace boost
|
||||
{
|
||||
base::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
sub_range& operator=( const sub_range& r )
|
||||
{
|
||||
base::operator=( static_cast<const base&>(r) );
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
iterator begin() { return base::begin(); }
|
||||
const_iterator begin() const { return base::begin(); }
|
||||
iterator end() { return base::end(); }
|
||||
const_iterator end() const { return base::end(); }
|
||||
difference_type size() const { return base::size(); }
|
||||
difference_type size() const { return base::size(); }
|
||||
|
||||
|
||||
|
||||
public: // convenience
|
||||
reference front()
|
||||
{
|
||||
@ -173,7 +173,7 @@ namespace boost
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
0
include/boost/range/value_type.hpp
Executable file → Normal file
0
include/boost/range/value_type.hpp
Executable file → Normal file
@ -91,19 +91,12 @@ test-suite range :
|
||||
[ range-test algorithm_test/prev_permutation ]
|
||||
[ range-test algorithm_test/random_shuffle ]
|
||||
[ range-test algorithm_test/remove ]
|
||||
[ range-test algorithm_test/remove_copy ]
|
||||
[ range-test algorithm_test/remove_copy_if ]
|
||||
[ range-test algorithm_test/remove_if ]
|
||||
[ range-test algorithm_test/replace ]
|
||||
[ range-test algorithm_test/replace_copy ]
|
||||
[ range-test algorithm_test/replace_copy_if ]
|
||||
[ range-test algorithm_test/replace_if ]
|
||||
[ range-test algorithm_test/reverse ]
|
||||
[ range-test algorithm_test/reverse_copy ]
|
||||
[ range-test algorithm_test/rotate ]
|
||||
[ range-test algorithm_test/rotate_copy ]
|
||||
[ range-test algorithm_test/search ]
|
||||
[ range-test algorithm_test/search_n ]
|
||||
[ range-test algorithm_test/set_difference ]
|
||||
[ range-test algorithm_test/set_intersection ]
|
||||
[ range-test algorithm_test/set_symmetric_difference ]
|
||||
@ -111,10 +104,8 @@ test-suite range :
|
||||
[ range-test algorithm_test/sort ]
|
||||
[ range-test algorithm_test/stable_partition ]
|
||||
[ range-test algorithm_test/stable_sort ]
|
||||
[ range-test algorithm_test/swap_ranges ]
|
||||
[ range-test algorithm_test/transform ]
|
||||
[ range-test algorithm_test/unique ]
|
||||
[ range-test algorithm_test/unique_copy ]
|
||||
[ range-test algorithm_test/upper_bound ]
|
||||
[ range-test algorithm_ext_test/copy_n ]
|
||||
[ range-test algorithm_ext_test/erase ]
|
||||
|
0
test/adl_conformance_no_using.cpp
Executable file → Normal file
0
test/adl_conformance_no_using.cpp
Executable file → Normal file
0
test/algorithm_example.cpp
Executable file → Normal file
0
test/algorithm_example.cpp
Executable file → Normal file
@ -1,63 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/copy_n.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template< class Container >
|
||||
void test_copy_n_impl()
|
||||
{
|
||||
Container source;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t;
|
||||
|
||||
std::vector<value_t> target;
|
||||
target.resize(source.size());
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator< std::vector<value_t> >::type iterator_t;
|
||||
iterator_t it = boost::copy(source, target.begin());
|
||||
|
||||
BOOST_CHECK( it == target.end() );
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
target.begin(), target.end(),
|
||||
source.begin(), source.end()
|
||||
);
|
||||
}
|
||||
|
||||
void test_copy_n()
|
||||
{
|
||||
test_copy_n_impl< std::vector<int> >();
|
||||
test_copy_n_impl< std::list<int> >();
|
||||
test_copy_n_impl< std::set<int> >();
|
||||
test_copy_n_impl< std::multiset<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.copy_n" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &::test_copy_n ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -26,12 +26,6 @@ namespace boost
|
||||
{
|
||||
namespace
|
||||
{
|
||||
template< class Range >
|
||||
unsigned int udistance(Range& rng)
|
||||
{
|
||||
return static_cast<unsigned int>(boost::distance(rng));
|
||||
}
|
||||
|
||||
template< class SinglePassRange >
|
||||
void test_for_each_impl( SinglePassRange rng )
|
||||
{
|
||||
@ -41,12 +35,12 @@ namespace boost
|
||||
|
||||
// Test the mutable version
|
||||
fn_t result_fn = boost::for_each(rng, fn_t(rng));
|
||||
BOOST_CHECK_EQUAL( boost::udistance(rng), result_fn.invocation_count() );
|
||||
BOOST_CHECK_EQUAL( boost::distance(rng), result_fn.invocation_count() );
|
||||
|
||||
// Test the constant version
|
||||
const SinglePassRange& cref_rng = rng;
|
||||
result_fn = boost::for_each(cref_rng, fn_t(cref_rng));
|
||||
BOOST_CHECK_EQUAL( boost::udistance(cref_rng), result_fn.invocation_count() );
|
||||
BOOST_CHECK_EQUAL( boost::distance(cref_rng), result_fn.invocation_count() );
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
@ -57,7 +51,7 @@ namespace boost
|
||||
// Test empty
|
||||
Container cont;
|
||||
test_for_each_impl(cont);
|
||||
|
||||
|
||||
// Test one element
|
||||
cont += 0;
|
||||
test_for_each_impl(cont);
|
||||
@ -69,7 +63,7 @@ namespace boost
|
||||
|
||||
void test_for_each()
|
||||
{
|
||||
boost::array<int, 10> a = {{ 0,1,2,3,4,5,6,7,8,9 }};
|
||||
boost::array<int, 10> a = { 0,1,2,3,4,5,6,7,8,9 };
|
||||
test_for_each_impl(a);
|
||||
|
||||
test_for_each_t< std::vector<int> >();
|
||||
@ -85,8 +79,8 @@ init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.for_each" );
|
||||
|
||||
|
||||
test->add( BOOST_TEST_CASE( &boost::test_for_each ) );
|
||||
|
||||
|
||||
return test;
|
||||
}
|
||||
|
@ -1,98 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/remove_copy.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename Iterator, typename Value>
|
||||
void test_append(Iterator target, Value value)
|
||||
{
|
||||
*target++ = value;
|
||||
}
|
||||
|
||||
template< class Container, class Value >
|
||||
void test_remove_copy_impl( const Container& c, Value to_remove )
|
||||
{
|
||||
typedef typename boost::range_value<Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME std::vector<value_type>::iterator iterator_t;
|
||||
|
||||
test_append(
|
||||
std::remove_copy(c.begin(), c.end(),
|
||||
std::back_inserter(reference), to_remove),
|
||||
to_remove);
|
||||
|
||||
std::vector<value_type> test;
|
||||
test_append(
|
||||
boost::remove_copy(c, std::back_inserter(test), to_remove),
|
||||
to_remove);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||
test.begin(), test.end() );
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void test_remove_copy_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container cont;
|
||||
test_remove_copy_impl(cont, 0);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
test_remove_copy_impl(cont, 0);
|
||||
test_remove_copy_impl(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,1,1,1,1;
|
||||
test_remove_copy_impl(cont, 0);
|
||||
test_remove_copy_impl(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,3,4,5,6,7,8,9;
|
||||
test_remove_copy_impl(cont, 1);
|
||||
test_remove_copy_impl(cont, 9);
|
||||
test_remove_copy_impl(cont, 4);
|
||||
}
|
||||
|
||||
void test_remove_copy()
|
||||
{
|
||||
test_remove_copy_impl< std::vector<int> >();
|
||||
test_remove_copy_impl< std::list<int> >();
|
||||
test_remove_copy_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove_copy" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_remove_copy ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
@ -1,103 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/remove_copy_if.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template< class Iterator, class Value >
|
||||
void test_append(Iterator target, Value value)
|
||||
{
|
||||
*target++ = value;
|
||||
}
|
||||
|
||||
template< class Container, class UnaryPredicate >
|
||||
void test_remove_copy_if_impl( const Container& c, UnaryPredicate pred )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<const Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
|
||||
test_append(
|
||||
std::remove_copy_if(c.begin(), c.end(), std::back_inserter(reference), pred),
|
||||
value_type()
|
||||
);
|
||||
|
||||
std::vector<value_type> test;
|
||||
test_append(
|
||||
boost::remove_copy_if(c, std::back_inserter(test), pred),
|
||||
value_type()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||
test.begin(), test.end() );
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void test_remove_copy_if_( const Container& c, int to_remove )
|
||||
{
|
||||
test_remove_copy_if_impl(c, boost::bind(std::equal_to<int>(), _1, to_remove));
|
||||
test_remove_copy_if_impl(c, boost::bind(std::not_equal_to<int>(), _1, to_remove));
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void test_remove_copy_if_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container cont;
|
||||
test_remove_copy_if_(cont, 0);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
test_remove_copy_if_(cont, 0);
|
||||
test_remove_copy_if_(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,1,1,1,1;
|
||||
test_remove_copy_if_(cont, 0);
|
||||
test_remove_copy_if_(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,3,4,5,6,7,8,9;
|
||||
test_remove_copy_if_(cont, 1);
|
||||
test_remove_copy_if_(cont, 9);
|
||||
test_remove_copy_if_(cont, 4);
|
||||
}
|
||||
|
||||
inline void test_remove_copy_if()
|
||||
{
|
||||
test_remove_copy_if_impl< std::vector<int> >();
|
||||
test_remove_copy_if_impl< std::list<int> >();
|
||||
test_remove_copy_if_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.remove_copy_if" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_remove_copy_if ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/replace_copy.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename Iterator, typename Value>
|
||||
void test_append(Iterator target, Value value)
|
||||
{
|
||||
*target++ = value;
|
||||
}
|
||||
|
||||
template< class Container, class Value >
|
||||
void test_replace_copy_impl( const Container& c, Value to_replace )
|
||||
{
|
||||
const Value replace_with = to_replace * 2;
|
||||
|
||||
typedef typename boost::range_value<Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME std::vector<value_type>::iterator iterator_t;
|
||||
|
||||
test_append(
|
||||
std::replace_copy(c.begin(), c.end(),
|
||||
std::back_inserter(reference), to_replace, replace_with),
|
||||
to_replace);
|
||||
|
||||
std::vector<value_type> test;
|
||||
test_append(
|
||||
boost::replace_copy(c, std::back_inserter(test), to_replace, replace_with),
|
||||
to_replace);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||
test.begin(), test.end() );
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void test_replace_copy_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container cont;
|
||||
test_replace_copy_impl(cont, 0);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
test_replace_copy_impl(cont, 0);
|
||||
test_replace_copy_impl(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,1,1,1,1;
|
||||
test_replace_copy_impl(cont, 0);
|
||||
test_replace_copy_impl(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,3,4,5,6,7,8,9;
|
||||
test_replace_copy_impl(cont, 1);
|
||||
test_replace_copy_impl(cont, 9);
|
||||
test_replace_copy_impl(cont, 4);
|
||||
}
|
||||
|
||||
void test_replace_copy()
|
||||
{
|
||||
test_replace_copy_impl< std::vector<int> >();
|
||||
test_replace_copy_impl< std::list<int> >();
|
||||
test_replace_copy_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.replace_copy" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_replace_copy ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/replace_copy_if.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template< class Iterator, class Value >
|
||||
void test_append(Iterator target, Value value)
|
||||
{
|
||||
*target++ = value;
|
||||
}
|
||||
|
||||
template< class Container, class UnaryPredicate >
|
||||
void test_replace_copy_if_impl( const Container& c, UnaryPredicate pred )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<const Container>::type value_type;
|
||||
const value_type replace_with = value_type();
|
||||
std::vector<value_type> reference;
|
||||
|
||||
test_append(
|
||||
std::replace_copy_if(c.begin(), c.end(), std::back_inserter(reference), pred, replace_with),
|
||||
value_type()
|
||||
);
|
||||
|
||||
std::vector<value_type> test;
|
||||
test_append(
|
||||
boost::replace_copy_if(c, std::back_inserter(test), pred, replace_with),
|
||||
value_type()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
|
||||
test.begin(), test.end() );
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void test_replace_copy_if_( const Container& c, int to_replace )
|
||||
{
|
||||
test_replace_copy_if_impl(c, boost::bind(std::equal_to<int>(), _1, to_replace));
|
||||
test_replace_copy_if_impl(c, boost::bind(std::not_equal_to<int>(), _1, to_replace));
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void test_replace_copy_if_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container cont;
|
||||
test_replace_copy_if_(cont, 0);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
test_replace_copy_if_(cont, 0);
|
||||
test_replace_copy_if_(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,1,1,1,1;
|
||||
test_replace_copy_if_(cont, 0);
|
||||
test_replace_copy_if_(cont, 1);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,3,4,5,6,7,8,9;
|
||||
test_replace_copy_if_(cont, 1);
|
||||
test_replace_copy_if_(cont, 9);
|
||||
test_replace_copy_if_(cont, 4);
|
||||
}
|
||||
|
||||
inline void test_replace_copy_if()
|
||||
{
|
||||
test_replace_copy_if_impl< std::vector<int> >();
|
||||
test_replace_copy_if_impl< std::list<int> >();
|
||||
test_replace_copy_if_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.replace_copy_if" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_replace_copy_if ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/reverse_copy.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<class OutputIterator, class Value>
|
||||
void test_append(OutputIterator out, Value value)
|
||||
{
|
||||
*out++ = value;
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
void test_reverse_copy_impl(Container& cont)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
std::vector<value_type> test;
|
||||
|
||||
test_append(
|
||||
std::reverse_copy(cont.begin(), cont.end(), std::back_inserter(reference)),
|
||||
value_type()
|
||||
);
|
||||
|
||||
test_append(
|
||||
boost::reverse_copy(cont, std::back_inserter(test)),
|
||||
value_type()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
reference.begin(), reference.end(),
|
||||
test.begin(), test.end()
|
||||
);
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
void test_reverse_copy_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container cont;
|
||||
test_reverse_copy_impl(cont);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
test_reverse_copy_impl(cont);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,3,4,5,6,7,8,9;
|
||||
test_reverse_copy_impl(cont);
|
||||
}
|
||||
|
||||
void test_reverse_copy()
|
||||
{
|
||||
test_reverse_copy_impl< std::vector<int> >();
|
||||
test_reverse_copy_impl< std::list<int> >();
|
||||
test_reverse_copy_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.reverse_copy" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &::test_reverse_copy ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/rotate_copy.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<class OutputIterator, class Value>
|
||||
void test_append(OutputIterator target, Value value)
|
||||
{
|
||||
*target++ = value;
|
||||
}
|
||||
|
||||
template<class Container, class Iterator>
|
||||
void test_rotate_copy_impl(Container& cont, Iterator where_it)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
std::vector<value_type> test;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type iterator_t;
|
||||
|
||||
test_append(
|
||||
std::rotate_copy(cont.begin(), where_it, cont.end(),
|
||||
std::back_inserter(reference)),
|
||||
value_type()
|
||||
);
|
||||
|
||||
test_append(
|
||||
boost::rotate_copy(cont, where_it, std::back_inserter(test)),
|
||||
value_type()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
reference.begin(), reference.end(),
|
||||
test.begin(), test.end()
|
||||
);
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
void test_rotate_copy_impl(Container& cont)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type iterator_t;
|
||||
|
||||
iterator_t last = cont.end();
|
||||
for (iterator_t it = cont.begin(); it != last; ++it)
|
||||
{
|
||||
test_rotate_copy_impl(cont, it);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
void test_rotate_copy_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container cont;
|
||||
test_rotate_copy_impl(cont);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
test_rotate_copy_impl(cont);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,3,4,5,6,7,8,9;
|
||||
test_rotate_copy_impl(cont);
|
||||
}
|
||||
|
||||
void test_rotate_copy()
|
||||
{
|
||||
test_rotate_copy_impl< std::vector<int> >();
|
||||
test_rotate_copy_impl< std::list<int> >();
|
||||
test_rotate_copy_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.rotate_copy" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_rotate_copy ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/search_n.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template< class Container1, class Value >
|
||||
void test_search_n_impl(Container1& cont1, Value value)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::const_iterator const_iterator1_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::iterator iterator1_t;
|
||||
|
||||
const Container1& ccont1 = cont1;
|
||||
|
||||
for (std::size_t n = 0; n < cont1.size(); ++n)
|
||||
{
|
||||
iterator1_t it = boost::search_n(cont1, n, value);
|
||||
iterator1_t it2 = boost::search_n(cont1, n, value);
|
||||
const_iterator1_t cit = boost::search_n(ccont1, n, value);
|
||||
const_iterator1_t cit2 = boost::search_n(ccont1, n, value);
|
||||
|
||||
BOOST_CHECK( it == std::search_n(cont1.begin(), cont1.end(), n, value) );
|
||||
BOOST_CHECK( it2 == std::search_n(cont1.begin(), cont1.end(), n, value) );
|
||||
BOOST_CHECK( cit == std::search_n(ccont1.begin(), ccont1.end(), n, value) );
|
||||
BOOST_CHECK( cit2 == std::search_n(ccont1.begin(), ccont1.end(), n, value) );
|
||||
}
|
||||
}
|
||||
|
||||
template< class Container1, class Container2 >
|
||||
void test_search_n_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container1 cont1;
|
||||
|
||||
test_search_n_impl(cont1, 1);
|
||||
|
||||
cont1 += 1;
|
||||
test_search_n_impl(cont1, 1);
|
||||
test_search_n_impl(cont1, 0);
|
||||
|
||||
cont1.clear();
|
||||
cont1 += 1,1;
|
||||
test_search_n_impl(cont1, 1);
|
||||
test_search_n_impl(cont1, 0);
|
||||
|
||||
cont1 += 1,1,1;
|
||||
test_search_n_impl(cont1, 1);
|
||||
test_search_n_impl(cont1, 0);
|
||||
|
||||
cont1.clear();
|
||||
cont1 += 1,2,3,4,5,6,7,8,9;
|
||||
test_search_n_impl(cont1, 1);
|
||||
test_search_n_impl(cont1, 2);
|
||||
test_search_n_impl(cont1, 5);
|
||||
test_search_n_impl(cont1, 9);
|
||||
}
|
||||
|
||||
void test_search_n()
|
||||
{
|
||||
test_search_n_impl< std::list<int>, std::list<int> >();
|
||||
test_search_n_impl< std::vector<int>, std::vector<int> >();
|
||||
test_search_n_impl< std::set<int>, std::set<int> >();
|
||||
test_search_n_impl< std::list<int>, std::vector<int> >();
|
||||
test_search_n_impl< std::vector<int>, std::list<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.search_n" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_search_n ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/swap_ranges.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<class Container1, class Container2>
|
||||
void test_swap_ranges_impl(const Container1& source1, const Container2& source2)
|
||||
{
|
||||
Container1 reference1(source1);
|
||||
Container2 reference2(source2);
|
||||
std::swap_ranges(reference1.begin(), reference1.end(), reference2.begin());
|
||||
|
||||
Container1 test1(source1);
|
||||
Container2 test2(source2);
|
||||
boost::swap_ranges(test1, test2);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
reference1.begin(), reference1.end(),
|
||||
test1.begin(), test1.end()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
reference2.begin(), reference2.end(),
|
||||
test2.begin(), test2.end()
|
||||
);
|
||||
}
|
||||
|
||||
template<class Container1, class Container2>
|
||||
void test_swap_ranges_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container1 c1;
|
||||
Container2 c2;
|
||||
|
||||
test_swap_ranges_impl(c1, c2);
|
||||
|
||||
c1.clear();
|
||||
c1 += 1;
|
||||
c2.clear();
|
||||
c2 += 2;
|
||||
test_swap_ranges_impl(c1, c2);
|
||||
|
||||
c1.clear();
|
||||
c1 += 1,2,3,4,5,6,7,8,9,10;
|
||||
c2.clear();
|
||||
c2 += 10,9,8,7,6,5,4,3,2,1;
|
||||
test_swap_ranges_impl(c1, c2);
|
||||
}
|
||||
|
||||
inline void test_swap_ranges()
|
||||
{
|
||||
test_swap_ranges_impl< std::vector<int>, std::vector<int> >();
|
||||
test_swap_ranges_impl< std::vector<int>, std::list<int> >();
|
||||
test_swap_ranges_impl< std::vector<int>, std::deque<int> >();
|
||||
test_swap_ranges_impl< std::list<int>, std::vector<int> >();
|
||||
test_swap_ranges_impl< std::list<int>, std::list<int> >();
|
||||
test_swap_ranges_impl< std::list<int>, std::deque<int> >();
|
||||
test_swap_ranges_impl< std::deque<int>, std::vector<int> >();
|
||||
test_swap_ranges_impl< std::deque<int>, std::list<int> >();
|
||||
test_swap_ranges_impl< std::deque<int>, std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.swap_ranges" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_swap_ranges ) );
|
||||
|
||||
return test;
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/unique_copy.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<class OutputIterator, class Value>
|
||||
void test_append(OutputIterator target, Value value)
|
||||
{
|
||||
*target++ = value;
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
void test_unique_copy_impl(Container& c)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
std::vector<value_type> test;
|
||||
|
||||
test_append(
|
||||
std::unique_copy(c.begin(), c.end(), std::back_inserter(reference)),
|
||||
value_type()
|
||||
);
|
||||
|
||||
test_append(
|
||||
boost::unique_copy(c, std::back_inserter(test)),
|
||||
value_type()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
|
||||
test.begin(), test.end());
|
||||
}
|
||||
|
||||
template<class Container, class Pred>
|
||||
void test_unique_copy_impl(Container& c, Pred pred)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<Container>::type value_type;
|
||||
std::vector<value_type> reference;
|
||||
std::vector<value_type> test;
|
||||
|
||||
test_append(
|
||||
std::unique_copy(c.begin(), c.end(), std::back_inserter(reference), pred),
|
||||
value_type()
|
||||
);
|
||||
|
||||
test_append(
|
||||
boost::unique_copy(c, std::back_inserter(test), pred),
|
||||
value_type()
|
||||
);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(reference.begin(), reference.end(),
|
||||
test.begin(), test.end());
|
||||
}
|
||||
|
||||
template<class Container, class Pred>
|
||||
void test_unique_copy_driver(Pred pred)
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t;
|
||||
|
||||
Container cont;
|
||||
|
||||
test_unique_copy_impl(cont);
|
||||
test_unique_copy_impl(cont, pred);
|
||||
|
||||
cont.clear();
|
||||
cont += 1;
|
||||
|
||||
std::vector<value_t> temp(cont.begin(), cont.end());
|
||||
std::sort(temp.begin(), temp.end());
|
||||
cont.assign(temp.begin(), temp.end());
|
||||
test_unique_copy_impl(cont);
|
||||
|
||||
std::sort(temp.begin(), temp.end(), pred);
|
||||
cont.assign(temp.begin(), temp.end());
|
||||
test_unique_copy_impl(cont, pred);
|
||||
|
||||
cont.clear();
|
||||
cont += 1,2,2,2,2,3,4,5,6,7,8,9;
|
||||
|
||||
temp.assign(cont.begin(), cont.end());
|
||||
std::sort(temp.begin(), temp.end());
|
||||
cont.assign(temp.begin(), temp.end());
|
||||
test_unique_copy_impl(cont);
|
||||
|
||||
std::sort(temp.begin(), temp.end(), pred);
|
||||
cont.assign(temp.begin(), temp.end());
|
||||
test_unique_copy_impl(cont, pred);
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
void test_unique_copy_impl()
|
||||
{
|
||||
test_unique_copy_driver<Container>(std::less<int>());
|
||||
test_unique_copy_driver<Container>(std::greater<int>());
|
||||
}
|
||||
|
||||
void test_unique_copy()
|
||||
{
|
||||
test_unique_copy_impl< std::vector<int> >();
|
||||
test_unique_copy_impl< std::list<int> >();
|
||||
test_unique_copy_impl< std::deque<int> >();
|
||||
}
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite*
|
||||
init_unit_test_suite(int argc, char* argv[])
|
||||
{
|
||||
boost::unit_test::test_suite* test
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.algorithm.unique_copy" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &test_unique_copy ) );
|
||||
|
||||
return test;
|
||||
}
|
0
test/array.cpp
Executable file → Normal file
0
test/array.cpp
Executable file → Normal file
0
test/compat3.cpp
Executable file → Normal file
0
test/compat3.cpp
Executable file → Normal file
0
test/extension_mechanism.cpp
Executable file → Normal file
0
test/extension_mechanism.cpp
Executable file → Normal file
0
test/mfc.cpp
Executable file → Normal file
0
test/mfc.cpp
Executable file → Normal file
0
test/partial_workaround.cpp
Executable file → Normal file
0
test/partial_workaround.cpp
Executable file → Normal file
Reference in New Issue
Block a user