Boost.Range added unit tests for extended algorithms.

Put the extended algorithms into boost::range in a similar manner to the standard algorithms.
Added iota as an extended algorithm.
Fixed defects in the extended algorithms brought to light by the new unit tests.

[SVN r61042]
This commit is contained in:
Neil Groves
2010-04-04 14:14:12 +00:00
parent 6cc4cbf1a1
commit cee9ffc1a8
23 changed files with 993 additions and 125 deletions

View File

@ -11,35 +11,48 @@
#define BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED
#include <boost/range/config.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/assert.hpp>
namespace boost
{
template< class Container >
inline void erase( Container& on,
iterator_range<BOOST_DEDUCED_TYPENAME Container::iterator> to_erase )
{
on.erase( boost::begin(to_erase), boost::end(to_erase) );
}
namespace range
{
template< class Container, class T >
inline void remove_erase( Container& on, const T& val )
{
on.erase(
std::remove(boost::begin(on), boost::end(on), val),
boost::end(on));
}
template< class Container, class Pred >
inline void remove_erase_if( Container& on, Pred pred )
{
on.erase(
std::remove_if(boost::begin(on), boost::end(on), pred),
boost::end(on));
}
template< class Container >
inline void erase( Container& on,
iterator_range<BOOST_DEDUCED_TYPENAME Container::iterator> to_erase )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
on.erase( boost::begin(to_erase), boost::end(to_erase) );
}
template< class Container, class T >
inline void remove_erase( Container& on, const T& val )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
on.erase(
std::remove(boost::begin(on), boost::end(on), val),
boost::end(on));
}
template< class Container, class Pred >
inline void remove_erase_if( Container& on, Pred pred )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
on.erase(
std::remove_if(boost::begin(on), boost::end(on), pred),
boost::end(on));
}
} // namespace range
using range::erase;
using range::remove_erase;
using range::remove_erase_if;
} // namespace boost
#endif // include guard