Boost.RangeEx merged into Boost.Range

[SVN r60897]
This commit is contained in:
Neil Groves
2010-03-28 16:08:35 +00:00
parent 1461479a17
commit b0d1db7c2e
471 changed files with 48610 additions and 2065 deletions

View File

@ -0,0 +1,119 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function adjacent_find
///
/// range-based version of the adjacent_find std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< typename ForwardRange >
inline typename range_iterator<ForwardRange>::type
adjacent_find(ForwardRange & rng)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return std::adjacent_find(boost::begin(rng),boost::end(rng));
}
/// \overload
template< typename ForwardRange >
inline typename range_iterator<const ForwardRange>::type
adjacent_find(const ForwardRange& rng)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return std::adjacent_find(boost::begin(rng),boost::end(rng));
}
/// \overload
template< typename ForwardRange, typename BinaryPredicate >
inline typename range_iterator<ForwardRange>::type
adjacent_find(ForwardRange & rng, BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<ForwardRange>::type,
typename range_value<ForwardRange>::type>));
return std::adjacent_find(boost::begin(rng),boost::end(rng),pred);
}
/// \overload
template< typename ForwardRange, typename BinaryPredicate >
inline typename range_iterator<const ForwardRange>::type
adjacent_find(const ForwardRange& rng, BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<const ForwardRange>::type,
typename range_value<const ForwardRange>::type>));
return std::adjacent_find(boost::begin(rng),boost::end(rng),pred);
}
// range_return overloads
/// \overload
template< range_return_value re, typename ForwardRange >
inline typename range_return<ForwardRange,re>::type
adjacent_find(ForwardRange & rng)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_return<ForwardRange,re>::
pack(std::adjacent_find(boost::begin(rng),boost::end(rng)),
rng);
}
/// \overload
template< range_return_value re, typename ForwardRange >
inline typename range_return<const ForwardRange,re>::type
adjacent_find(const ForwardRange& rng)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_return<const ForwardRange,re>::
pack(std::adjacent_find(boost::begin(rng),boost::end(rng)),
rng);
}
/// \overload
template< range_return_value re, typename ForwardRange, typename BinaryPredicate >
inline typename range_return<ForwardRange,re>::type
adjacent_find(ForwardRange& rng, BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<ForwardRange>::type,
typename range_value<ForwardRange>::type>));
return range_return<ForwardRange,re>::
pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred),
rng);
}
/// \overload
template< range_return_value re, typename ForwardRange, typename BinaryPredicate >
inline typename range_return<const ForwardRange,re>::type
adjacent_find(const ForwardRange& rng, BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_return<const ForwardRange,re>::
pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,43 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_BINARY_SEARCH_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_BINARY_SEARCH_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function binary_search
///
/// range-based version of the binary_search std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class ForwardRange, class Value>
inline bool binary_search(const ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::binary_search(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template<class ForwardRange, class Value, class BinaryPredicate>
inline bool binary_search(const ForwardRange& rng, const Value& val,
BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::binary_search(boost::begin(rng), boost::end(rng), val, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,35 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/iterator_range.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function copy
///
/// range-based version of the copy std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre OutputIterator is a model of the OutputIteratorConcept
template< class SinglePassRange, class OutputIterator >
inline OutputIterator copy(const SinglePassRange& rng, OutputIterator out)
{
//BOOST_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
return std::copy(boost::begin(rng),boost::end(rng),out);
}
}
#endif // include guard

View File

@ -0,0 +1,37 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_COPY_BACKWARD_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_COPY_BACKWARD_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function copy_backward
///
/// range-based version of the copy_backwards std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
/// \pre BidirectionalTraversalWriteableIterator is a model of the BidirectionalIteratorConcept
/// \pre BidirectionalTraversalWriteableIterator is a model of the WriteableIteratorConcept
template< class BidirectionalRange, class BidirectionalTraversalWriteableIterator >
inline BidirectionalTraversalWriteableIterator
copy_backward(const BidirectionalRange& rng,
BidirectionalTraversalWriteableIterator out)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
return std::copy_backward(boost::begin(rng), boost::end(rng), out);
}
}
#endif // include guard

View File

@ -0,0 +1,44 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/difference_type.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function count
///
/// range-based version of the count std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
template< class SinglePassRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
count(SinglePassRange& rng, const Value& val)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::count(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template< class SinglePassRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange const>::type
count(const SinglePassRange& rng, const Value& val)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::count(boost::begin(rng), boost::end(rng), val);
}
}
#endif // include guard

View File

@ -0,0 +1,45 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_COUNT_IF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_COUNT_IF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/difference_type.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function count_if
///
/// range-based version of the count_if std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
template< class SinglePassRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME boost::range_difference<SinglePassRange>::type
count_if(SinglePassRange& rng, UnaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::count_if(boost::begin(rng), boost::end(rng), pred);
}
/// \overload
template< class SinglePassRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME boost::range_difference<const SinglePassRange>::type
count_if(const SinglePassRange& rng, UnaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::count_if(boost::begin(rng), boost::end(rng), pred);
}
}
#endif // include guard

View File

@ -0,0 +1,182 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED
#include <boost/config.hpp>
#include <boost/range/concepts.hpp>
#include <iterator>
namespace boost
{
namespace range_detail
{
// An implementation of equality comparison that is optimized for iterator
// traversal categories less than RandomAccessTraversal.
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class IteratorCategoryTag1,
class IteratorCategoryTag2 >
inline bool equal_impl( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
IteratorCategoryTag1,
IteratorCategoryTag2 )
{
do
{
// If we have reached the end of the left range then this is
// the end of the loop. They are equal if and only if we have
// simultaneously reached the end of the right range.
if (first1 == last1)
return first2 == last2;
// If we have reached the end of the right range at this line
// it indicates that the right range is shorter than the left
// and hence the result is false.
if (first2 == last2)
return false;
// continue looping if and only if the values are equal
} while(*first1++ == *first2++);
// Reaching this line in the algorithm indicates that a value
// inequality has been detected.
return false;
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class IteratorCategoryTag1,
class IteratorCategoryTag2,
class BinaryPredicate >
inline bool equal_impl( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
BinaryPredicate pred,
IteratorCategoryTag1,
IteratorCategoryTag2 )
{
do
{
// If we have reached the end of the left range then this is
// the end of the loop. They are equal if and only if we have
// simultaneously reached the end of the right range.
if (first1 == last1)
return first2 == last2;
// If we have reached the end of the right range at this line
// it indicates that the right range is shorter than the left
// and hence the result is false.
if (first2 == last2)
return false;
// continue looping if and only if the values are equal
} while(pred(*first1++, *first2++));
// Reaching this line in the algorithm indicates that a value
// inequality has been detected.
return false;
}
// An implementation of equality comparison that is optimized for
// random access iterators.
template< class RandomAccessTraversalReadableIterator1,
class RandomAccessTraversalReadableIterator2 >
inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
RandomAccessTraversalReadableIterator1 last1,
RandomAccessTraversalReadableIterator2 first2,
RandomAccessTraversalReadableIterator2 last2,
std::random_access_iterator_tag,
std::random_access_iterator_tag )
{
return ((last1 - first1) == (last2 - first2))
&& std::equal(first1, last1, first2);
}
template< class RandomAccessTraversalReadableIterator1,
class RandomAccessTraversalReadableIterator2,
class BinaryPredicate >
inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
RandomAccessTraversalReadableIterator1 last1,
RandomAccessTraversalReadableIterator2 first2,
RandomAccessTraversalReadableIterator2 last2,
BinaryPredicate pred )
{
return ((last1 - first1) == (last2 - first2))
&& std::equal(first1, last1, first2, pred);
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2 >
inline bool equal( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2 )
{
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1;
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2;
return equal_impl(first1, last1, first2, last2, tag1, tag2);
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class BinaryPredicate >
inline bool equal( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
BinaryPredicate pred )
{
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1;
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2;
return equal_impl(first1, last1, first2, last2, pred, tag1, tag2);
}
}
/// \brief template function equal
///
/// range-based version of the equal std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class SinglePassRange1, class SinglePassRange2 >
inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::equal(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2) );
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
BinaryPredicate pred )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::equal(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2),
pred);
}
}
#endif // include guard

View File

@ -0,0 +1,74 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_EQUAL_RANGE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_EQUAL_RANGE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function equal_range
///
/// range-based version of the equal_range std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre SortPredicate is a model of the BinaryPredicateConcept
template<class ForwardRange, class Value>
inline std::pair<
BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type,
BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
>
equal_range(ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::equal_range(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template<class ForwardRange, class Value>
inline std::pair<
BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type,
BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
>
equal_range(const ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::equal_range(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template<class ForwardRange, class Value, class SortPredicate>
inline std::pair<
BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type,
BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
>
equal_range(ForwardRange& rng, const Value& val, SortPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::equal_range(boost::begin(rng), boost::end(rng), val, pred);
}
/// \overload
template<class ForwardRange, class Value, class SortPredicate>
inline std::pair<
BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type,
BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
>
equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::equal_range(boost::begin(rng), boost::end(rng), val, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,34 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function fill
///
/// range-based version of the fill std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class Value >
inline ForwardRange& fill(ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::fill(boost::begin(rng), boost::end(rng), val);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,36 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FILL_N_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FILL_N_HPP_INCLUDED
#include <boost/assert.hpp>
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function fill_n
///
/// range-based version of the fill_n std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class Size, class Value >
inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
BOOST_ASSERT( static_cast<Size>(std::distance(boost::begin(rng), boost::end(rng))) >= n );
std::fill_n(boost::begin(rng), n, val);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,66 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function find
///
/// range-based version of the find std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
template< class SinglePassRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type
find( SinglePassRange& rng, const Value& val )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::find(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template< class SinglePassRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type
find( const SinglePassRange& rng, const Value& val )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::find(boost::begin(rng), boost::end(rng), val);
}
// range_return overloads
/// \overload
template< range_return_value re, class SinglePassRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<SinglePassRange,re>::type
find( SinglePassRange& rng, const Value& val )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return range_return<SinglePassRange,re>::
pack(std::find(boost::begin(rng), boost::end(rng), val),
rng);
}
/// \overload
template< range_return_value re, class SinglePassRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange,re>::type
find( const SinglePassRange& rng, const Value& val )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return range_return<const SinglePassRange,re>::
pack(std::find(boost::begin(rng), boost::end(rng), val),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,136 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function find_end
///
/// range-based version of the find_end std algorithm
///
/// \pre ForwardRange1 is a model of the ForwardRangeConcept
/// \pre ForwardRange2 is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type
find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_end(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template< class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_end(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
find_end(ForwardRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_end(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred);
}
/// \overload
template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
find_end(ForwardRange1 const & rng1, ForwardRange2 const & rng2, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_end(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
find_end(ForwardRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<ForwardRange1,re>::
pack(std::find_end(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2)),
rng1);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
find_end(const ForwardRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<const ForwardRange1,re>::
pack(std::find_end(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2)),
rng1);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2,
class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<ForwardRange1,re>::
pack(std::find_end(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred),
rng1);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2,
class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
find_end(const ForwardRange1& rng1, const ForwardRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<const ForwardRange1,re>::
pack(std::find_end(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred),
rng1);
}
}
#endif // include guard

View File

@ -0,0 +1,139 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FIND_FIRST_OF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FIND_FIRST_OF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function find_first_of
///
/// range-based version of the find_first_of std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre ForwardRange2 is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class SinglePassRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type
find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_first_of(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template< class SinglePassRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
find_first_of(SinglePassRange1 const & rng1, ForwardRange2 const & rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_first_of(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type
find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_first_of(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred);
}
/// \overload
template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::find_first_of(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred);
}
// range return overloads
/// \overload
template< range_return_value re, class SinglePassRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_return<SinglePassRange1,re>::type
find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<SinglePassRange1,re>::
pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2)),
rng1);
}
/// \overload
template< range_return_value re, class SinglePassRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange1,re>::type
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<const SinglePassRange1,re>::
pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2)),
rng1);
}
/// \overload
template< range_return_value re, class SinglePassRange1, class ForwardRange2,
class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<SinglePassRange1,re>::type
find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<SinglePassRange1,re>::
pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred),
rng1);
}
/// \overload
template< range_return_value re, class SinglePassRange1, class ForwardRange2,
class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange1,re>::type
find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<const SinglePassRange1,re>::
pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2),pred),
rng1);
}
}
#endif // include guard

View File

@ -0,0 +1,69 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FIND_IF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FIND_IF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function find_if
///
/// range-based version of the find_if std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
template< class SinglePassRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type
find_if( SinglePassRange& rng, UnaryPredicate pred )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::find_if(boost::begin(rng), boost::end(rng), pred);
}
/// \overload
template< class SinglePassRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type
find_if( const SinglePassRange& rng, UnaryPredicate pred )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::find_if(boost::begin(rng), boost::end(rng), pred);
}
// range_return overloads
/// \overload
template< range_return_value re, class SinglePassRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<SinglePassRange,re>::type
find_if( SinglePassRange& rng, UnaryPredicate pred )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return range_return<SinglePassRange,re>::
pack(std::find_if(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template< range_return_value re, class SinglePassRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange,re>::type
find_if( const SinglePassRange& rng, UnaryPredicate pred )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return range_return<const SinglePassRange,re>::
pack(std::find_if(boost::begin(rng), boost::end(rng), pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,42 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function for_each
///
/// range-based version of the for_each std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre UnaryFunction is a model of the UnaryFunctionConcept
template< class SinglePassRange, class UnaryFunction >
inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun)
{
boost::function_requires< SinglePassRangeConcept< SinglePassRange > >();
return std::for_each(boost::begin(rng),boost::end(rng),fun);
}
/// \overload
template< class SinglePassRange, class UnaryFunction >
inline UnaryFunction for_each(SinglePassRange const & rng, UnaryFunction fun)
{
boost::function_requires< SinglePassRangeConcept< SinglePassRange > >();
return std::for_each(boost::begin(rng),boost::end(rng),fun);
}
} // namespace boost
#endif // include guard

View File

@ -0,0 +1,44 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_GENERATE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_GENERATE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function generate
///
/// range-based version of the generate std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre Generator is a model of the UnaryFunctionConcept
template< class ForwardRange, class Generator >
inline ForwardRange& generate( ForwardRange& rng, Generator gen )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::generate(boost::begin(rng), boost::end(rng), gen);
return rng;
}
/// \overload
template< class ForwardRange, class Generator >
inline const ForwardRange& generate(const ForwardRange& rng, Generator gen)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::generate(boost::begin(rng), boost::end(rng), gen);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,169 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function push_heap
///
/// range-based version of the push_heap std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void push_heap(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::push_heap(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class RandomAccessRange>
inline void push_heap(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::push_heap(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void push_heap(RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void push_heap(const RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \brief template function pop_heap
///
/// range-based version of the pop_heap std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void pop_heap(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::pop_heap(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class RandomAccessRange>
inline void pop_heap(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::pop_heap(boost::begin(rng),boost::end(rng));
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void pop_heap(RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \brief template function make_heap
///
/// range-based version of the make_heap std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void make_heap(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::make_heap(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class RandomAccessRange>
inline void make_heap(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::make_heap(boost::begin(rng),boost::end(rng));
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void make_heap(RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void make_heap(const RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \brief template function sort_heap
///
/// range-based version of the sort_heap std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void sort_heap(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort_heap(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class RandomAccessRange>
inline void sort_heap(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort_heap(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void sort_heap(RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void sort_heap(const RandomAccessRange& rng, Compare comp_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
}
}
#endif // include guard

View File

@ -0,0 +1,68 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_INPLACE_MERGE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_INPLACE_MERGE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function inplace_merge
///
/// range-based version of the inplace_merge std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class BidirectionalRange>
inline BidirectionalRange& inplace_merge(BidirectionalRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type middle)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
std::inplace_merge(boost::begin(rng), middle, boost::end(rng));
return rng;
}
/// \overload
template<class BidirectionalRange>
inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng,
BOOST_DEDUCED_TYPENAME boost::range_iterator<const BidirectionalRange>::type middle)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
std::inplace_merge(boost::begin(rng), middle, boost::end(rng));
return rng;
}
/// \overload
template<class BidirectionalRange, class BinaryPredicate>
inline BidirectionalRange& inplace_merge(BidirectionalRange& rng,
BOOST_DEDUCED_TYPENAME boost::range_iterator<BidirectionalRange>::type middle,
BinaryPredicate pred)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred);
return rng;
}
/// \overload
template<class BidirectionalRange, class BinaryPredicate>
inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng,
BOOST_DEDUCED_TYPENAME boost::range_iterator<const BidirectionalRange>::type middle,
BinaryPredicate pred)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,52 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function lexicographic_compare
///
/// range-based version of the lexicographic_compare std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
template<class SinglePassRange1, class SinglePassRange2>
inline bool lexicographical_compare(const SinglePassRange1& rng1,
const SinglePassRange2& rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::lexicographical_compare(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class BinaryPredicate>
inline bool lexicographical_compare(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::lexicographical_compare(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
}
#endif // include guard

View File

@ -0,0 +1,99 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function lower_bound
///
/// range-based version of the lower_bound std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
lower_bound( ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::lower_bound(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template< class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
lower_bound( const ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::lower_bound(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template< class ForwardRange, class Value, class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
lower_bound( ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred);
}
/// \overload
template< class ForwardRange, class Value, class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
lower_bound( const ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
lower_bound( ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::
pack(std::lower_bound(boost::begin(rng), boost::end(rng), val),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
lower_bound( const ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::
pack(std::lower_bound(boost::begin(rng), boost::end(rng), val),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value, class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
lower_bound( ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::
pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value, class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
lower_bound( const ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::
pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,109 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function max_element
///
/// range-based version of the max_element std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
max_element(ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::max_element(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
max_element(const ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::max_element(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
max_element(ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::max_element(boost::begin(rng), boost::end(rng), pred);
}
/// \overload
template<class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
max_element(const ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::max_element(boost::begin(rng), boost::end(rng), pred);
}
// range_return overloads
/// \overload
template<range_return_value re, class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
max_element(ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::pack(
std::max_element(boost::begin(rng), boost::end(rng)),
rng);
}
/// \overload
template<range_return_value re, class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
max_element(const ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::pack(
std::max_element(boost::begin(rng), boost::end(rng)),
rng);
}
/// \overload
template<range_return_value re, class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
max_element(ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::pack(
std::max_element(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template<range_return_value re, class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
max_element(const ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::pack(
std::max_element(boost::begin(rng), boost::end(rng), pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,55 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_MERGE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_MERGE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function merge
///
/// range-based version of the merge std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
///
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator>
inline OutputIterator merge(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::merge(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out);
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator, class BinaryPredicate>
inline OutputIterator merge(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::merge(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,109 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function min_element
///
/// range-based version of the min_element std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
min_element(ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::min_element(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
min_element(const ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::min_element(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
min_element(ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::min_element(boost::begin(rng), boost::end(rng), pred);
}
/// \overload
template<class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
min_element(const ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::min_element(boost::begin(rng), boost::end(rng), pred);
}
// range_return overloads
/// \overload
template<range_return_value re, class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
min_element(ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::pack(
std::min_element(boost::begin(rng), boost::end(rng)),
rng);
}
/// \overload
template<range_return_value re, class ForwardRange>
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
min_element(const ForwardRange& rng)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::pack(
std::min_element(boost::begin(rng), boost::end(rng)),
rng);
}
/// \overload
template<range_return_value re, class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
min_element(ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::pack(
std::min_element(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template<range_return_value re, class ForwardRange, class BinaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
min_element(const ForwardRange& rng, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::pack(
std::min_element(boost::begin(rng), boost::end(rng), pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,182 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_MISMATCH_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_MISMATCH_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/difference_type.hpp>
#include <algorithm>
namespace boost
{
namespace range_detail
{
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2 >
inline std::pair<SinglePassTraversalReadableIterator1,
SinglePassTraversalReadableIterator2>
mismatch_impl(SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2)
{
while (first1 != last1 && first2 != last2 && *first1 == *first2)
{
++first1;
++first2;
}
return std::pair<SinglePassTraversalReadableIterator1,
SinglePassTraversalReadableIterator2>(first1, first2);
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class BinaryPredicate >
inline std::pair<SinglePassTraversalReadableIterator1,
SinglePassTraversalReadableIterator2>
mismatch_impl(SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
BinaryPredicate pred)
{
while (first1 != last1 && first2 != last2 && pred(*first1, *first2))
{
++first1;
++first2;
}
return std::pair<SinglePassTraversalReadableIterator1,
SinglePassTraversalReadableIterator2>(first1, first2);
}
}
/// \brief template function mismatch
///
/// range-based version of the mismatch std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class SinglePassRange1, class SinglePassRange2 >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2 >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2 >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2 >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
inline std::pair<
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::mismatch_impl(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
}
#endif // include guard

View File

@ -0,0 +1,64 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_NTH_ELEMENT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_NTH_ELEMENT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function nth_element
///
/// range-based version of the nth_element std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void nth_element(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type nth)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::nth_element(boost::begin(rng), nth, boost::end(rng));
}
/// \overload
template<class RandomAccessRange>
inline void nth_element(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type nth)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::nth_element(boost::begin(rng),nth,boost::end(rng));
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void nth_element(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type nth,
BinaryPredicate sort_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred);
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void nth_element(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type nth,
BinaryPredicate sort_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::nth_element(boost::begin(rng),nth,boost::end(rng), sort_pred);
}
}
#endif // include guard

View File

@ -0,0 +1,65 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function partial_sort
///
/// range-based version of the partial_sort std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void partial_sort(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::partial_sort(boost::begin(rng), middle, boost::end(rng));
}
/// \overload
template<class RandomAccessRange>
inline void partial_sort(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::partial_sort(boost::begin(rng), middle, boost::end(rng));
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void partial_sort(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle,
BinaryPredicate sort_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::partial_sort(boost::begin(rng), middle, boost::end(rng),
sort_pred);
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void partial_sort(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle,
BinaryPredicate sort_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred);
}
}
#endif // include guard

View File

@ -0,0 +1,58 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/value_type.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function partial_sort_copy
///
/// range-based version of the partial_sort_copy std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre RandomAccessRange is a model of the Mutable_RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<typename SinglePassRange, typename RandomAccessRange>
inline typename range_iterator<RandomAccessRange>::type
partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2)
{
BOOST_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange>));
BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept<RandomAccessRange>));
BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept<typename range_value<SinglePassRange>::type, typename range_value<RandomAccessRange>::type>));
BOOST_CONCEPT_ASSERT((LessThanComparableConcept<typename range_value<SinglePassRange>::type>));
return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2));
}
/// \overload
template<typename SinglePassRange, typename RandomAccessRange,
typename BinaryPredicate>
inline typename range_iterator<RandomAccessRange>::type
partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2,
BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange>));
BOOST_CONCEPT_ASSERT((WriteableRandomAccessRangeConcept<RandomAccessRange>));
BOOST_CONCEPT_ASSERT((range_detail::SameTypeConcept<typename range_value<SinglePassRange>::type, typename range_value<RandomAccessRange>::type>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate, typename range_value<RandomAccessRange>::type, typename range_value<RandomAccessRange>::type>));
return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
}
#endif // include guard

View File

@ -0,0 +1,68 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_PARTITION__HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_PARTITION__HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function partition
///
/// range-based version of the partition std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template<class ForwardRange, class UnaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
partition(ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::partition(boost::begin(rng),boost::end(rng),pred);
}
/// \overload
template<class ForwardRange, class UnaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
partition(const ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::partition(boost::begin(rng),boost::end(rng),pred);
}
// range_return overloads
/// \overload
template< range_return_value re, class ForwardRange,
class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
partition(ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return boost::range_return<ForwardRange,re>::
pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng);
}
/// \overload
template< range_return_value re, class ForwardRange,
class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
partition(const ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return boost::range_return<const ForwardRange,re>::
pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng);
}
}
#endif // include guard

View File

@ -0,0 +1,117 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function next_permutation
///
/// range-based version of the next_permutation std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class BidirectionalRange>
inline bool next_permutation(BidirectionalRange& rng)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::next_permutation(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class BidirectionalRange>
inline bool next_permutation(const BidirectionalRange& rng)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::next_permutation(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class BidirectionalRange, class Compare>
inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::next_permutation(boost::begin(rng), boost::end(rng),
comp_pred);
}
/// \overload
template<class BidirectionalRange, class Compare>
inline bool next_permutation(const BidirectionalRange& rng,
Compare comp_pred)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::next_permutation(boost::begin(rng), boost::end(rng),
comp_pred);
}
/// \brief template function prev_permutation
///
/// range-based version of the prev_permutation std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class BidirectionalRange>
inline bool prev_permutation(BidirectionalRange& rng)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::prev_permutation(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class BidirectionalRange>
inline bool prev_permutation(const BidirectionalRange& rng)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::prev_permutation(boost::begin(rng), boost::end(rng));
}
/// \overload
template<class BidirectionalRange, class Compare>
inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::prev_permutation(boost::begin(rng), boost::end(rng),
comp_pred);
}
/// \overload
template<class BidirectionalRange, class Compare>
inline bool prev_permutation(const BidirectionalRange& rng,
Compare comp_pred)
{
boost::function_requires<
BidirectionalRangeConcept<BidirectionalRange> >();
return std::prev_permutation(boost::begin(rng), boost::end(rng),
comp_pred);
}
}
#endif // include guard

View File

@ -0,0 +1,62 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function random_shuffle
///
/// range-based version of the random_shuffle std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Generator is a model of the UnaryFunctionConcept
template<class RandomAccessRange>
inline RandomAccessRange& random_shuffle(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::random_shuffle(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::random_shuffle(boost::begin(rng),boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class Generator>
inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
return rng;
}
/// \overload
template<class RandomAccessRange, class Generator>
inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,70 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function remove
///
/// range-based version of the remove std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
remove(ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::remove(boost::begin(rng),boost::end(rng),val);
}
/// \overload
template< class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
remove(const ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::remove(boost::begin(rng),boost::end(rng),val);
}
// range_return overloads
/// \overload
template< range_return_value re, class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
remove(ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::pack(
std::remove(boost::begin(rng), boost::end(rng), val),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
remove(const ForwardRange& rng, const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::pack(
std::remove(boost::begin(rng), boost::end(rng), val),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,38 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function remove_copy
///
/// range-based version of the remove_copy std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre OutputIterator is a model of the OutputIteratorConcept
/// \pre Value is a model of the EqualityComparableConcept
/// \pre Objects of type Value can be compared for equality with objects of
/// InputIterator's value type.
template< class SinglePassRange, class OutputIterator, class Value >
inline OutputIterator
remove_copy(SinglePassRange& rng, OutputIterator out_it, const Value& val)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val);
}
}
#endif // include guard

View File

@ -0,0 +1,38 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function remove_copy_if
///
/// range-based version of the remove_copy_if std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre OutputIterator is a model of the OutputIteratorConcept
/// \pre Predicate is a model of the PredicateConcept
/// \pre InputIterator's value type is convertible to Predicate's argument type
/// \pre out_it is not an iterator in the range rng
template< class SinglePassRange, class OutputIterator, class Predicate >
inline OutputIterator
remove_copy_if(SinglePassRange& rng, OutputIterator out_it, Predicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,70 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REMOVE_IF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REMOVE_IF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function remove_if
///
/// range-based version of the remove_if std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
template< class ForwardRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
remove_if(ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::remove_if(boost::begin(rng), boost::end(rng), pred);
}
/// \overload
template< class ForwardRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
remove_if(const ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::remove_if(boost::begin(rng),boost::end(rng),pred);
}
// range_return overloads
/// \overload
template< range_return_value re, class ForwardRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
remove_if(ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::pack(
std::remove_if(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class UnaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
remove_if(const ForwardRange& rng, UnaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::pack(
std::remove_if(boost::begin(rng), boost::end(rng), pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,47 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REPLACE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REPLACE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function replace
///
/// range-based version of the replace std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class Value >
inline ForwardRange&
replace(ForwardRange& rng, const Value& what,
const Value& with_what)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::replace(boost::begin(rng), boost::end(rng), what, with_what);
return rng;
}
/// \overload
template< class ForwardRange, class Value >
inline const ForwardRange&
replace(const ForwardRange& rng, const Value& what,
const Value& with_what)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::replace(boost::begin(rng), boost::end(rng), what, with_what);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,36 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REPLACE_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function replace_copy
///
/// range-based version of the replace_copy std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class OutputIterator, class Value >
inline OutputIterator
replace_copy(ForwardRange& rng, OutputIterator out_it, const Value& what,
const Value& with_what)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::replace_copy(boost::begin(rng), boost::end(rng), out_it,
what, with_what);
}
}
#endif // include guard

View File

@ -0,0 +1,40 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function replace_copy_if
///
/// range-based version of the replace_copy_if std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre Predicate is a model of the PredicateConcept
/// \pre Value is convertible to Predicate's argument type
/// \pre Value is Assignable
/// \pre Value is convertible to a type in OutputIterator's set of value types.
template< class ForwardRange, class OutputIterator, class Predicate, class Value >
inline OutputIterator
replace_copy_if(ForwardRange& rng, OutputIterator out_it, Predicate pred,
const Value& with_what)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it,
pred, with_what);
}
}
#endif // include guard

View File

@ -0,0 +1,49 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REPLACE_IF_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REPLACE_IF_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function replace_if
///
/// range-based version of the replace_if std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
template< class ForwardRange, class UnaryPredicate, class Value >
inline ForwardRange&
replace_if(ForwardRange& rng, UnaryPredicate pred,
const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::replace_if(boost::begin(rng), boost::end(rng), pred, val);
return rng;
}
/// \overload
template< class ForwardRange, class UnaryPredicate, class Value >
inline const ForwardRange&
replace_if(const ForwardRange& rng, UnaryPredicate pred,
const Value& val)
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
std::replace_if(boost::begin(rng), boost::end(rng), pred, val);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,44 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function reverse
///
/// range-based version of the reverse std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
template<class BidirectionalRange>
inline BidirectionalRange& reverse(BidirectionalRange& rng)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
std::reverse(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class BidirectionalRange>
inline const BidirectionalRange& reverse(const BidirectionalRange& rng)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
std::reverse(boost::begin(rng), boost::end(rng));
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,42 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_REVERSE_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_REVERSE_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/iterator/iterator_concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function reverse_copy
///
/// range-based version of the reverse_copy std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
template<typename BidirectionalRange, typename OutputIterator>
inline OutputIterator reverse_copy(BidirectionalRange& rng, OutputIterator out)
{
BOOST_CONCEPT_ASSERT((BidirectionalRangeConcept<BidirectionalRange>));
return std::reverse_copy(boost::begin(rng), boost::end(rng), out);
}
/// \overload
template<typename BidirectionalRange, typename OutputIterator>
inline OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out)
{
BOOST_CONCEPT_ASSERT((BidirectionalRangeConcept<BidirectionalRange>));
return std::reverse_copy(boost::begin(rng), boost::end(rng), out);
}
}
#endif // include guard

View File

@ -0,0 +1,46 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_ROTATE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_ROTATE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function rotate
///
/// range-based version of the rotate std algorithm
///
/// \pre Rng meets the requirements for a Forward range
template<typename ForwardRange>
inline ForwardRange& rotate(ForwardRange& rng,
typename range_iterator<ForwardRange>::type middle)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
std::rotate(boost::begin(rng), middle, boost::end(rng));
return rng;
}
/// \overload
template<typename ForwardRange>
inline const ForwardRange&
rotate(const ForwardRange& rng,
typename range_iterator<const ForwardRange>::type middle)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
std::rotate(boost::begin(rng), middle, boost::end(rng));
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,38 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/iterator.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function rotate
///
/// range-based version of the rotate std algorithm
///
/// \pre Rng meets the requirements for a Forward range
template<typename ForwardRange, typename OutputIterator>
inline OutputIterator rotate_copy(
const ForwardRange& rng,
typename range_iterator<const ForwardRange>::type middle,
OutputIterator target
)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return std::rotate_copy(boost::begin(rng), middle, boost::end(rng), target);
}
}
#endif // include guard

View File

@ -0,0 +1,131 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function search
///
/// range-based version of the search std algorithm
///
/// \pre ForwardRange1 is a model of the ForwardRangeConcept
/// \pre ForwardRange2 is a model of the ForwardRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
search(ForwardRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template< class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
search(const ForwardRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred);
}
/// \overload
template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
search(const ForwardRange1& rng1, const ForwardRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred);
}
// range_return overloads
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
search(ForwardRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<ForwardRange1,re>::
pack(std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2)),
rng1);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2 >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
search(const ForwardRange1& rng1, const ForwardRange2& rng2)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<const ForwardRange1,re>::
pack(std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2)),
rng1);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2,
class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<ForwardRange1,re>::
pack(std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred),
rng1);
}
/// \overload
template< range_return_value re, class ForwardRange1, class ForwardRange2,
class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
search(const ForwardRange1& rng1, const ForwardRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< ForwardRangeConcept<ForwardRange1> >();
boost::function_requires< ForwardRangeConcept<ForwardRange2> >();
return range_return<const ForwardRange1,re>::
pack(std::search(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2),pred),
rng1);
}
}
#endif // include guard

View File

@ -0,0 +1,140 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_SEARCH_N_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_SEARCH_N_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <boost/range/value_type.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function search
///
/// range-based version of the search std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre Integer is an integral type
/// \pre Value is a model of the EqualityComparableConcept
/// \pre ForwardRange's value type is a model of the EqualityComparableConcept
/// \pre Object's of ForwardRange's value type can be compared for equality with Objects of type Value
template< typename ForwardRange, typename Integer, typename Value >
inline typename range_iterator<ForwardRange>::type
search_n(ForwardRange& rng, Integer count, const Value& value)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return std::search_n(boost::begin(rng),boost::end(rng), count, value);
}
/// \overload
template< typename ForwardRange, typename Integer, typename Value >
inline typename range_iterator<const ForwardRange>::type
search_n(const ForwardRange& rng, Integer count, const Value& value)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return std::search_n(boost::begin(rng), boost::end(rng), count, value);
}
/// \overload
template< typename ForwardRange, typename Integer, class Value,
typename BinaryPredicate >
inline typename range_iterator<ForwardRange>::type
search_n(ForwardRange& rng, Integer count, const Value& value,
BinaryPredicate binary_pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<ForwardRange>::type, const Value&>));
return std::search_n(boost::begin(rng), boost::end(rng),
count, value, binary_pred);
}
/// \overload
template< typename ForwardRange, typename Integer, typename Value,
typename BinaryPredicate >
inline typename range_iterator<const ForwardRange>::type
search_n(const ForwardRange& rng, Integer count, const Value& value,
BinaryPredicate binary_pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<const ForwardRange>::type, const Value&>));
return std::search_n(boost::begin(rng), boost::end(rng),
count, value, binary_pred);
}
// range_return overloads
/// \overload
template< range_return_value re, typename ForwardRange, typename Integer,
typename Value >
inline typename range_return<ForwardRange,re>::type
search_n(ForwardRange& rng, Integer count, const Value& value)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_return<ForwardRange,re>::
pack(std::search_n(boost::begin(rng),boost::end(rng),
count, value),
rng);
}
/// \overload
template< range_return_value re, typename ForwardRange, typename Integer,
class Value >
inline typename range_return<const ForwardRange,re>::type
search_n(const ForwardRange& rng, Integer count, const Value& value)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_return<const ForwardRange,re>::
pack(std::search_n(boost::begin(rng), boost::end(rng),
count, value),
rng);
}
/// \overload
template< range_return_value re, typename ForwardRange, typename Integer,
typename Value, typename BinaryPredicate >
inline typename range_return<ForwardRange,re>::type
search_n(ForwardRange& rng, Integer count, const Value& value,
BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<ForwardRange>::type,
const Value&>));
return range_return<ForwardRange,re>::
pack(std::search_n(boost::begin(rng), boost::end(rng),
count, value, pred),
rng);
}
/// \overload
template< range_return_value re, typename ForwardRange, typename Integer,
typename Value, typename BinaryPredicate >
inline typename range_return<const ForwardRange,re>::type
search_n(const ForwardRange& rng, Integer count, const Value& value,
BinaryPredicate pred)
{
BOOST_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
typename range_value<const ForwardRange>::type,
const Value&>));
return range_return<const ForwardRange,re>::
pack(std::search_n(boost::begin(rng), boost::end(rng),
count, value, pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,188 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function includes
///
/// range-based version of the includes std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class SinglePassRange1, class SinglePassRange2>
inline bool includes(const SinglePassRange1& rng1,
const SinglePassRange2& rng2)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::includes(boost::begin(rng1),boost::end(rng1),
boost::begin(rng2),boost::end(rng2));
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class BinaryPredicate>
inline bool includes(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::includes(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), pred);
}
/// \brief template function set_union
///
/// range-based version of the set_union std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator>
inline OutputIterator set_union(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_union(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out);
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator, class BinaryPredicate>
inline OutputIterator set_union(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_union(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out, pred);
}
/// \brief template function set_intersection
///
/// range-based version of the set_intersection std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator>
inline OutputIterator set_intersection(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_intersection(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out);
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator, class BinaryPredicate>
inline OutputIterator set_intersection(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_intersection(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2),
out, pred);
}
/// \brief template function set_difference
///
/// range-based version of the set_difference std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator>
inline OutputIterator set_difference(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_difference(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out);
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator, class BinaryPredicate>
inline OutputIterator set_difference(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_difference(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out, pred);
}
/// \brief template function set_symmetric_difference
///
/// range-based version of the set_symmetric_difference std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator>
inline OutputIterator
set_symmetric_difference(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out);
}
/// \overload
template<class SinglePassRange1, class SinglePassRange2,
class OutputIterator, class BinaryPredicate>
inline OutputIterator
set_symmetric_difference(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out,
BinaryPredicate pred)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return std::set_symmetric_difference(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2), out, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,63 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_SORT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_SORT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function sort
///
/// range-based version of the sort std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline RandomAccessRange& sort(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline const RandomAccessRange& sort(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort(boost::begin(rng),boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort(boost::begin(rng), boost::end(rng), pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::sort(boost::begin(rng), boost::end(rng), pred);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,68 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_STABLE_PARTITION_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_STABLE_PARTITION_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function stable_partition
///
/// range-based version of the stable_partition std algorithm
///
/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
template<class BidirectionalRange, class UnaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type
stable_partition(BidirectionalRange& rng, UnaryPredicate pred)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
return std::stable_partition(boost::begin(rng), boost::end(rng), pred);
}
/// \overload
template<class BidirectionalRange, class UnaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_iterator<const BidirectionalRange>::type
stable_partition(const BidirectionalRange& rng, UnaryPredicate pred)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
return std::stable_partition(boost::begin(rng),boost::end(rng),pred);
}
// range_return overloads
template<range_return_value re, class BidirectionalRange, class UnaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_return<BidirectionalRange,re>::type
stable_partition(BidirectionalRange& rng, UnaryPredicate pred)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
return range_return<BidirectionalRange,re>::pack(
std::stable_partition(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template<range_return_value re, class BidirectionalRange, class UnaryPredicate>
inline BOOST_DEDUCED_TYPENAME range_return<const BidirectionalRange,re>::type
stable_partition(const BidirectionalRange& rng, UnaryPredicate pred)
{
boost::function_requires< BidirectionalRangeConcept<BidirectionalRange> >();
return range_return<const BidirectionalRange,re>::pack(
std::stable_partition(boost::begin(rng),boost::end(rng),pred),
rng);
}
}
#endif // include guard

View File

@ -0,0 +1,62 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_STABLE_SORT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_STABLE_SORT_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function stable_sort
///
/// range-based version of the stable_sort std algorithm
///
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline RandomAccessRange& stable_sort(RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::stable_sort(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::stable_sort(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate sort_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate sort_pred)
{
boost::function_requires< RandomAccessRangeConcept<RandomAccessRange> >();
std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred);
return rng;
}
}
#endif // include guard

View File

@ -0,0 +1,81 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED
#include <boost/assert.hpp>
#include <boost/concept_check.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/iterator.hpp>
#include <algorithm>
namespace boost
{
namespace range_detail
{
template<typename Iterator1, typename Iterator2>
void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
Iterator2 it2, Iterator2 last2,
single_pass_traversal_tag,
single_pass_traversal_tag)
{
ignore_unused_variable_warning(last2);
for (; it1 != last1; ++it1, ++it2)
{
BOOST_ASSERT( it2 != last2 );
std::iter_swap(it1, it2);
}
}
template<typename Iterator1, typename Iterator2>
void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
Iterator2 it2, Iterator2 last2,
random_access_traversal_tag,
random_access_traversal_tag)
{
ignore_unused_variable_warning(last2);
BOOST_ASSERT( last2 - it2 >= last1 - it1 );
std::swap_ranges(it1, last1, it2);
}
template<typename Iterator1, typename Iterator2>
void swap_ranges_impl(Iterator1 first1, Iterator1 last1,
Iterator2 first2, Iterator2 last2)
{
swap_ranges_impl(first1, last1, first2, last2,
typename iterator_traversal<Iterator1>::type(),
typename iterator_traversal<Iterator2>::type());
}
} // namespace range_detail
/// \brief template function swap_ranges
///
/// range-based version of the swap_ranges std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
template< typename SinglePassRange1, typename SinglePassRange2 >
inline SinglePassRange2&
swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2)
{
BOOST_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange1>));
BOOST_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange2>));
boost::range_detail::swap_ranges_impl(
boost::begin(range1), boost::end(range1),
boost::begin(range2), boost::end(range2));
return range2;
}
}
#endif // include guard

View File

@ -0,0 +1,85 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED
#include <boost/assert.hpp>
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function transform
///
/// range-based version of the transform std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre OutputIterator is a model of the OutputIteratorConcept
/// \pre UnaryOperation is a model of the UnaryFunctionConcept
/// \pre BinaryOperation is a model of the BinaryFunctionConcept
template< class SinglePassRange1,
class OutputIterator,
class UnaryOperation >
inline OutputIterator
transform(const SinglePassRange1& rng,
OutputIterator out,
UnaryOperation fun)
{
return std::transform(boost::begin(rng),boost::end(rng),out,fun);
}
namespace range_detail
{
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class OutputIterator,
class BinaryFunction >
inline OutputIterator
transform_impl(SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
OutputIterator out,
BinaryFunction fn)
{
for (; first1 != last1; ++first1, ++first2)
{
BOOST_ASSERT( first2 != last2 );
*out = fn(*first1, *first2);
++out;
}
return out;
}
}
/// \overload
template< class SinglePassRange1,
class SinglePassRange2,
class OutputIterator,
class BinaryOperation >
inline OutputIterator
transform(const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
OutputIterator out,
BinaryOperation fun)
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
return range_detail::transform_impl(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2),
out, fun);
}
}
#endif // include guard

View File

@ -0,0 +1,101 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_UNIQUE_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_UNIQUE_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function unique
///
/// range-based version of the unique std algorithm
///
/// \pre Rng meets the requirements for a Forward range
template< range_return_value re, class ForwardRange >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
unique( ForwardRange& rng )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::
pack( std::unique( boost::begin(rng),
boost::end(rng)), rng );
}
/// \overload
template< range_return_value re, class ForwardRange >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
unique( const ForwardRange& rng )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::
pack( std::unique( boost::begin(rng),
boost::end(rng)), rng );
}
/// \overload
template< range_return_value re, class ForwardRange, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
unique( ForwardRange& rng, BinaryPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::
pack(std::unique(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
unique( const ForwardRange& rng, BinaryPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::
pack(std::unique(boost::begin(rng), boost::end(rng), pred),
rng);
}
/// \overload
template< class ForwardRange >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange, return_begin_found>::type
unique( ForwardRange& rng )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return boost::unique<return_begin_found>(rng);
}
/// \overload
template< class ForwardRange >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange, return_begin_found>::type
unique( const ForwardRange& rng )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return boost::unique<return_begin_found>(rng);
}
/// \overload
template< class ForwardRange, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange, return_begin_found>::type
unique( ForwardRange& rng, BinaryPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return boost::unique<return_begin_found>(rng);
}
/// \overload
template< class ForwardRange, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
unique( const ForwardRange& rng, BinaryPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return boost::unique<return_begin_found>(rng, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,45 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_UNIQUE_COPY_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_UNIQUE_COPY_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function unique_copy
///
/// range-based version of the unique_copy std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
/// \pre OutputIterator is a model of the OutputIteratorConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class SinglePassRange, class OutputIterator >
inline OutputIterator
unique_copy( const SinglePassRange& rng, OutputIterator out_it )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::unique_copy(boost::begin(rng), boost::end(rng), out_it);
}
/// \overload
template< class SinglePassRange, class OutputIterator, class BinaryPredicate >
inline OutputIterator
unique_copy( const SinglePassRange& rng, OutputIterator out_it,
BinaryPredicate pred )
{
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred);
}
}
#endif // include guard

View File

@ -0,0 +1,101 @@
// 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/
//
#ifndef BOOST_RANGE_ALGORITHM_UPPER_BOUND_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_UPPER_BOUND_HPP_INCLUDED
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
/// \brief template function upper_bound
///
/// range-based version of the upper_bound std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
template< class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
upper_bound( ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::upper_bound(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template< class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
upper_bound( const ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::upper_bound(boost::begin(rng), boost::end(rng), val);
}
/// \overload
template< class ForwardRange, class Value, class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
upper_bound( ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred);
}
/// \overload
template< class ForwardRange, class Value, class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
upper_bound( const ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
upper_bound( ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::
pack(std::upper_bound(boost::begin(rng), boost::end(rng), val),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
upper_bound( const ForwardRange& rng, Value val )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::
pack(std::upper_bound(boost::begin(rng), boost::end(rng), val),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value,
class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
upper_bound( ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<ForwardRange,re>::
pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred),
rng);
}
/// \overload
template< range_return_value re, class ForwardRange, class Value,
class SortPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
upper_bound( const ForwardRange& rng, Value val, SortPredicate pred )
{
boost::function_requires< ForwardRangeConcept<ForwardRange> >();
return range_return<const ForwardRange,re>::
pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred),
rng);
}
}
#endif // include guard