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,36 +11,47 @@
#define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED
#include <boost/range/config.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/assert.hpp>
namespace boost
{
template< class SinglePassRange1, class SinglePassRange2 >
inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to )
{
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type
i = boost::begin(from), e = boost::end(from);
namespace range
{
template< class SinglePassRange1, class SinglePassRange2 >
inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to )
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
i = boost::begin(from), e = boost::end(from);
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
out = boost::begin(to);
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
out = boost::begin(to);
#ifndef NDEBUG
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
last_out = boost::end(to);
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
last_out = boost::end(to);
#endif
for( ; i != e; ++out, ++i )
{
for( ; i != e; ++out, ++i )
{
#ifndef NDEBUG
BOOST_ASSERT( out != last_out
&& "out of bounds in boost::overwrite()" );
BOOST_ASSERT( out != last_out
&& "out of bounds in boost::overwrite()" );
#endif
*out = *i;
}
}
*out = *i;
}
}
} // namespace range
using range::overwrite;
} // namespace boost
#endif // include guard