porting cel/range/algoritm.hpp

This commit is contained in:
bolero-MURAKAMI 2012-04-04 17:48:02 +09:00
parent cf593ffeff
commit ba6482d1ec
51 changed files with 1908 additions and 116 deletions

View file

@ -2,7 +2,8 @@
#define SPROUT_CONTAINER_EMPTY_HPP
#include <sprout/config.hpp>
#include <sprout/container/size.hpp>
#include <sprout/container/begin.hpp>
#include <sprout/container/end.hpp>
namespace sprout {
//
@ -10,7 +11,7 @@ namespace sprout {
//
template<typename Container>
SPROUT_CONSTEXPR inline bool empty(Container const& cont) {
return sprout::size(cont) == 0;
return sprout::begin(cont) == sprout::end(cont);
}
} // namespace sprout

View file

@ -9,16 +9,16 @@ namespace sprout {
namespace detail {
// Copyright (C) 2011 RiSK (sscrisk)
template<typename Iterator>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type
distance(Iterator first, Iterator last) {
template<typename InputIterator>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last) {
return first == last ? 0
: 1 + sprout::detail::distance(sprout::next(first), last)
;
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type
distance_impl(Iterator first, Iterator last) {
template<typename InputIterator>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
distance_impl(InputIterator first, InputIterator last) {
using sprout::detail::distance;
return distance(first, last);
}
@ -26,9 +26,9 @@ namespace sprout {
//
// distance
//
template<typename Iterator>
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type
distance(Iterator first, Iterator last) {
template<typename InputIterator>
SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last) {
return sprout::detail::distance_impl(first, last);
}
} // namespace sprout

View file

@ -8,70 +8,70 @@
namespace sprout {
namespace detail {
template<typename Iterator>
template<typename RandomAccessIterator>
SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<Iterator>::type>::value,
typename std::decay<Iterator>::type
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value,
typename std::decay<RandomAccessIterator>::type
>::type next_impl(
Iterator&& it,
RandomAccessIterator&& it,
std::random_access_iterator_tag*
)
{
return sprout::forward<Iterator>(it) + 1;
return sprout::forward<RandomAccessIterator>(it) + 1;
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type next_impl(
Iterator&& it,
template<typename ForwardIterator>
SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next_impl(
ForwardIterator&& it,
void*
)
{
using std::next;
return next(sprout::forward<Iterator>(it));
return next(sprout::forward<ForwardIterator>(it));
}
template<typename Iterator>
template<typename RandomAccessIterator>
SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<Iterator>::type>::value,
typename std::decay<Iterator>::type
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value,
typename std::decay<RandomAccessIterator>::type
>::type next_impl(
Iterator&& it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n,
RandomAccessIterator&& it,
typename std::iterator_traits<typename std::decay<RandomAccessIterator>::type>::difference_type n,
std::random_access_iterator_tag*
)
{
return sprout::forward<Iterator>(it) + n;
return sprout::forward<RandomAccessIterator>(it) + n;
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type next_impl(
Iterator it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n,
template<typename ForwardIterator>
SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next_impl(
ForwardIterator it,
typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::difference_type n,
void*
)
{
using std::next;
return next(sprout::forward<Iterator>(it), n);
return next(sprout::forward<ForwardIterator>(it), n);
}
} // namespace detail
//
// next
//
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type next(Iterator&& it) {
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
template<typename ForwardIterator>
SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next(ForwardIterator&& it) {
typedef typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::iterator_category* category;
return sprout::detail::next_impl(
sprout::forward<Iterator>(it),
sprout::forward<ForwardIterator>(it),
category()
);
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type next(
Iterator&& it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n
template<typename ForwardIterator>
SPROUT_CONSTEXPR typename std::decay<ForwardIterator>::type next(
ForwardIterator&& it,
typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::difference_type n
)
{
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
typedef typename std::iterator_traits<typename std::decay<ForwardIterator>::type>::iterator_category* category;
return sprout::detail::next_impl(
sprout::forward<Iterator>(it),
sprout::forward<ForwardIterator>(it),
n,
category()
);

View file

@ -8,70 +8,70 @@
namespace sprout {
namespace detail {
template<typename Iterator>
template<typename RandomAccessIterator>
SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<Iterator>::type>::value,
typename std::decay<Iterator>::type
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value,
typename std::decay<RandomAccessIterator>::type
>::type prev_impl(
Iterator&& it,
RandomAccessIterator&& it,
std::random_access_iterator_tag*
)
{
return sprout::forward<Iterator>(it) - 1;
return sprout::forward<RandomAccessIterator>(it) - 1;
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev_impl(
Iterator&& it,
template<typename BidirectionalIterator>
SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type prev_impl(
BidirectionalIterator&& it,
void*
)
{
using std::prev;
return prev(sprout::forward<Iterator>(it));
return prev(sprout::forward<BidirectionalIterator>(it));
}
template<typename Iterator>
template<typename RandomAccessIterator>
SPROUT_CONSTEXPR typename std::enable_if<
std::is_literal_type<typename std::decay<Iterator>::type>::value,
typename std::decay<Iterator>::type
std::is_literal_type<typename std::decay<RandomAccessIterator>::type>::value,
typename std::decay<RandomAccessIterator>::type
>::type prev_impl(
Iterator&& it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n,
RandomAccessIterator&& it,
typename std::iterator_traits<typename std::decay<RandomAccessIterator>::type>::difference_type n,
std::random_access_iterator_tag*
)
{
return sprout::forward<Iterator>(it) - n;
return sprout::forward<RandomAccessIterator>(it) - n;
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev_impl(
Iterator it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n,
template<typename BidirectionalIterator>
SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type prev_impl(
BidirectionalIterator it,
typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::difference_type n,
void*
)
{
using std::prev;
return prev(sprout::forward<Iterator>(it), n);
return prev(sprout::forward<BidirectionalIterator>(it), n);
}
} // namespace detail
//
// prev
//
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev(Iterator&& it) {
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
template<typename BidirectionalIterator>
SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type prev(BidirectionalIterator&& it) {
typedef typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::iterator_category* category;
return sprout::detail::prev_impl(
sprout::forward<Iterator>(it),
sprout::forward<BidirectionalIterator>(it),
category()
);
}
template<typename Iterator>
SPROUT_CONSTEXPR typename std::decay<Iterator>::type prev(
Iterator&& it,
typename std::iterator_traits<typename std::decay<Iterator>::type>::difference_type n
template<typename BidirectionalIterator>
SPROUT_CONSTEXPR typename std::decay<BidirectionalIterator>::type prev(
BidirectionalIterator&& it,
typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::difference_type n
)
{
typedef typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category* category;
typedef typename std::iterator_traits<typename std::decay<BidirectionalIterator>::type>::iterator_category* category;
return sprout::detail::prev_impl(
sprout::forward<Iterator>(it),
sprout::forward<BidirectionalIterator>(it),
n,
category()
);

View file

@ -9,14 +9,14 @@ namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// 26.7.2 Accumulate
template<class InputIterator, typename T, typename BinaryOperation>
template<typename InputIterator, typename T, typename BinaryOperation>
SPROUT_CONSTEXPR T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) {
return first == last ? init
: sprout::accumulate(first + 1, last, binary_op(init, *first), binary_op)
: sprout::accumulate(sprout::next(first), last, binary_op(init, *first), binary_op)
;
}
template<class InputIterator, typename T>
template<typename InputIterator, typename T>
SPROUT_CONSTEXPR T accumulate(InputIterator first, InputIterator last, T init) {
return sprout::accumulate(first, last, init, NS_SSCRISK_CEL_OR_SPROUT::plus<typename std::iterator_traits<InputIterator>::value_type>());
}

View file

@ -10,7 +10,7 @@ namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// 26.7.3 Inner product
template<class InputIterator1, class InputIterator2, typename T, typename BinaryOperation1, typename BinaryOperation2>
template<typename InputIterator1, typename InputIterator2, typename T, typename BinaryOperation1, typename BinaryOperation2>
SPROUT_CONSTEXPR T inner_product(
InputIterator1 first1,
InputIterator1 last1,
@ -32,7 +32,7 @@ namespace sprout {
;
}
template<class InputIterator1, typename InputIterator2, typename T>
template<typename InputIterator1, typename InputIterator2, typename T>
SPROUT_CONSTEXPR T inner_product(
InputIterator1 first1,
InputIterator1 last1,

View file

@ -0,0 +1,67 @@
#ifndef SPROUT_RANGE_ALGORITHM_ADJACENT_FIND_HPP
#define SPROUT_RANGE_ALGORITHM_ADJACENT_FIND_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/adjacent_find.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.8 Adjacent find
template<typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
adjacent_find(Range&& range) {
return sprout::range::range_return<Range>::pack(
sprout::adjacent_find(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
adjacent_find(Range&& range, BinaryPredicate pred) {
return sprout::range::range_return<Range>::pack(
sprout::adjacent_find(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
adjacent_find(Range&& range) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::adjacent_find(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
adjacent_find(Range&& range, BinaryPredicate pred) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::adjacent_find(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_ADJACENT_FIND_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_RANGE_ALGORITHM_ALL_OF_HPP
#define SPROUT_RANGE_ALGORITHM_ALL_OF_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/all_of.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.1 All of
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR bool all_of(Range const& range, Predicate pred) {
return sprout::all_of(sprout::begin(range), sprout::end(range), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_ALL_OF_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_RANGE_ALGORITHM_ANY_OF_HPP
#define SPROUT_RANGE_ALGORITHM_ANY_OF_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/any_of.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.2 Any of
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR bool any_of(Range const& range, Predicate pred) {
return sprout::any_of(sprout::begin(range), sprout::end(range), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_ANY_OF_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_BINARY_SEARCH_HPP
#define SPROUT_RANGE_ALGORITHM_BINARY_SEARCH_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/binary_search.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.3.4 binary_search
template<typename Range, typename T>
SPROUT_CONSTEXPR bool binary_search(Range const& range, T const& value) {
return sprout::binary_search(sprout::begin(range), sprout::end(range), value);
}
template<typename Range, typename T, typename Compare>
SPROUT_CONSTEXPR bool binary_search(Range const& range, T const& value, Compare comp) {
return sprout::binary_search(sprout::begin(range), sprout::end(range), value, comp);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_BINARY_SEARCH_HPP

View file

@ -0,0 +1,22 @@
#ifndef SPROUT_RANGE_ALGORITHM_COUNT_HPP
#define SPROUT_RANGE_ALGORITHM_COUNT_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/count.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.9 Count
template<typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::container_traits<Range const>::difference_type
count(Range const& range, T const& value) {
return sprout::count(sprout::begin(range), sprout::end(range), value);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_COUNT_HPP

View file

@ -0,0 +1,22 @@
#ifndef SPROUT_RANGE_ALGORITHM_COUNT_IF_HPP
#define SPROUT_RANGE_ALGORITHM_COUNT_IF_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/count_if.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.9 Count
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR typename sprout::container_traits<Range const>::difference_type
count_if(Range const& range, Predicate pred) {
return sprout::count_if(sprout::begin(range), sprout::end(range), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_COUNT_IF_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_EQUAL_HPP
#define SPROUT_RANGE_ALGORITHM_EQUAL_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/equal.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.11 Equal
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR bool equal(Range1 const& range1, Range2 const& range2) {
return sprout::equal(sprout::begin(range1), sprout::end(range1), sprout::begin(range2));
}
template<typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR bool equal(Range1 const& range1, Range2 const& range2, BinaryPredicate pred) {
return sprout::equal(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_EQUAL_HPP

View file

@ -0,0 +1,50 @@
#ifndef SPROUT_RANGE_ALGORITHM_EQUAL_RANGE_HPP
#define SPROUT_RANGE_ALGORITHM_EQUAL_RANGE_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/lvref_range.hpp>
#include <sprout/algorithm/equal_range.hpp>
namespace sprout {
namespace range {
namespace detail {
template<typename Range, typename Pair>
SPROUT_CONSTEXPR typename sprout::range::lvref_range<Range>::type
pair_to_range(Pair const& pair) {
return {pair.first, pair.second};
}
} // namespace detail
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.3.3 equal_range
template<typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::lvref_range<Range>::type
equal_range(Range&& range, T const& value) {
return sprout::range::detail::pair_to_range<Range>(
sprout::equal_range(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
)
);
}
template<typename Range, typename T, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::lvref_range<Range>::type
equal_range(Range&& range, T const& value, Compare comp) {
return sprout::range::detail::pair_to_range<Range>(
sprout::equal_range(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value,
comp
)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_EQUAL_RANGE_HPP

View file

@ -0,0 +1,43 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/find.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.5 Find
template<typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
find(Range&& range, T const& value) {
return sprout::range::range_return<Range>::pack(
sprout::find(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
find(Range&& range, T const& value) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::find(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_HPP

View file

@ -0,0 +1,75 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_END_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_END_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/find_end.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.6 Find end
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1>::type
find_end(Range1&& range1, Range2&& range2) {
return sprout::range::range_return<Range1>::pack(
sprout::find_end(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
),
sprout::forward<Range1>(range1)
);
}
template<typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1>::type
find_end(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::range::range_return<Range1>::pack(
sprout::find_end(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
pred
),
sprout::forward<Range1>(range1)
);
}
template<sprout::range::range_return_value RetV, typename Range1, typename Range2>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1, RetV>::type
find_end(Range1&& range1, Range2&& range2) {
return sprout::range::range_return<Range1, RetV>::pack(
sprout::find_end(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
),
sprout::forward<Range1>(range1)
);
}
template<sprout::range::range_return_value RetV, typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1, RetV>::type
find_end(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::range::range_return<Range1, RetV>::pack(
sprout::find_end(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
pred
),
sprout::forward<Range1>(range1)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_END_HPP

View file

@ -0,0 +1,75 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_FIRST_OF_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_FIRST_OF_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/find_first_of.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.7 Find first
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1>::type
find_first_of(Range1&& range1, Range2&& range2) {
return sprout::range::range_return<Range1>::pack(
sprout::find_first_of(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
),
sprout::forward<Range1>(range1)
);
}
template<typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1>::type
find_first_of(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::range::range_return<Range1>::pack(
sprout::find_first_of(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
pred
),
sprout::forward<Range1>(range1)
);
}
template<sprout::range::range_return_value RetV, typename Range1, typename Range2>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1, RetV>::type
find_first_of(Range1&& range1, Range2&& range2) {
return sprout::range::range_return<Range1, RetV>::pack(
sprout::find_first_of(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
),
sprout::forward<Range1>(range1)
);
}
template<sprout::range::range_return_value RetV, typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1, RetV>::type
find_first_of(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::range::range_return<Range1, RetV>::pack(
sprout::find_first_of(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
pred
),
sprout::forward<Range1>(range1)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_FIRST_OF_HPP

View file

@ -0,0 +1,43 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_IF_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_IF_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/find_if.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.5 Find
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
find_if(Range&& range, Predicate pred) {
return sprout::range::range_return<Range>::pack(
sprout::find_if(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Predicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
find_if(Range&& range, Predicate pred) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::find_if(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_IF_HPP

View file

@ -0,0 +1,43 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_IF_NOT_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_IF_NOT_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/find_if_not.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.5 Find
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
find_if_not(Range&& range, Predicate pred) {
return sprout::range::range_return<Range>::pack(
sprout::find_if_not(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Predicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
find_if_not(Range&& range, Predicate pred) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::find_if_not(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_IF_NOT_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_INCLUDES_HPP
#define SPROUT_RANGE_ALGORITHM_INCLUDES_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/includes.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.5.1 includes
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR bool includes(Range1 const& range1, Range2 const& range2) {
return sprout::includes(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2));
}
template<typename Range1, typename Range2, typename Compare>
SPROUT_CONSTEXPR bool includes(Range1 const& range1, Range2 const& range2, Compare comp) {
return sprout::includes(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_INCLUDES_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_IS_HEAP_HPP
#define SPROUT_RANGE_ALGORITHM_IS_HEAP_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/is_heap.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.6.5 is_heap
template<typename Range>
SPROUT_CONSTEXPR bool is_heap(Range const& range) {
return sprout::is_heap(sprout::begin(range), sprout::end(range));
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR bool is_heap(Range const& range, Compare comp) {
return sprout::is_heap(sprout::begin(range), sprout::end(range), comp);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_IS_HEAP_HPP

View file

@ -0,0 +1,67 @@
#ifndef SPROUT_RANGE_ALGORITHM_IS_HEAP_UNTIL_HPP
#define SPROUT_RANGE_ALGORITHM_IS_HEAP_UNTIL_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/is_heap_until.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.6.5 is_heap
template<typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
is_heap_until(Range&& range) {
return sprout::range::range_return<Range>::pack(
sprout::is_heap_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
is_heap_until(Range&& range, Compare comp) {
return sprout::range::range_return<Range>::pack(
sprout::is_heap_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
is_heap_until(Range&& range) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::is_heap_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
is_heap_until(Range&& range, Compare comp) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::is_heap_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_IS_HEAP_UNTIL_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_RANGE_ALGORITHM_IS_PARTITIONED_HPP
#define SPROUT_RANGE_ALGORITHM_IS_PARTITIONED_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/is_partitioned.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.3.13 partitions
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR bool is_partitioned(Range const& range, Predicate pred) {
return sprout::is_partitioned(sprout::begin(range), sprout::end(range), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_IS_PARTITIONED_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_IS_PERMUTATION_HPP
#define SPROUT_RANGE_ALGORITHM_IS_PERMUTATION_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/is_permutation.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.12 Is permutation
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR bool is_permutation(Range1 const& range1, Range2 const& range2) {
return sprout::is_permutation(sprout::begin(range1), sprout::end(range1), sprout::begin(range2));
}
template<typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR bool is_permutation(Range1 const& range1, Range2 const& range2, BinaryPredicate pred) {
return sprout::is_permutation(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_IS_PERMUTATION_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_IS_SORTED_HPP
#define SPROUT_RANGE_ALGORITHM_IS_SORTED_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/is_sorted.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.1.5 is_sorted
template<typename Range>
SPROUT_CONSTEXPR bool is_sorted(Range const& range) {
return sprout::is_sorted(sprout::begin(range), sprout::end(range));
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR bool is_sorted(Range const& range, Compare comp) {
return sprout::is_sorted(sprout::begin(range), sprout::end(range), comp);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_IS_SORTED_HPP

View file

@ -0,0 +1,67 @@
#ifndef SPROUT_RANGE_ALGORITHM_IS_SORTED_UNTIL_HPP
#define SPROUT_RANGE_ALGORITHM_IS_SORTED_UNTIL_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/is_sorted_until.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.1.5 is_sorted
template<typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
is_sorted_until(Range&& range) {
return sprout::range::range_return<Range>::pack(
sprout::is_sorted_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
is_sorted_until(Range&& range, Compare comp) {
return sprout::range::range_return<Range>::pack(
sprout::is_sorted_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
is_sorted_until(Range&& range) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::is_sorted_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
is_sorted_until(Range&& range, Compare comp) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::is_sorted_until(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_IS_SORTED_UNTIL_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP
#define SPROUT_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/lexicographical_compare.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.8 Lexicographical comparison
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR bool lexicographical_compare(Range1 const& range1, Range2 const& range2) {
return sprout::lexicographical_compare(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2));
}
template<typename Range1, typename Range2, typename Compare>
SPROUT_CONSTEXPR bool lexicographical_compare(Range1 const& range1, Range2 const& range2, Compare comp) {
return sprout::lexicographical_compare(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP

View file

@ -0,0 +1,71 @@
#ifndef SPROUT_RANGE_ALGORITHM_LOWER_BOUND_HPP
#define SPROUT_RANGE_ALGORITHM_LOWER_BOUND_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/lower_bound.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.3.1 lower_bound
template<typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
lower_bound(Range&& range, T const& value) {
return sprout::range::range_return<Range>::pack(
sprout::lower_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename T, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
lower_bound(Range&& range, T const& value, Compare comp) {
return sprout::range::range_return<Range>::pack(
sprout::lower_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value,
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
lower_bound(Range&& range, T const& value) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::lower_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename T, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
lower_bound(Range&& range, T const& value, Compare comp) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::lower_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value,
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_LOWER_BOUND_HPP

View file

@ -0,0 +1,67 @@
#ifndef SPROUT_RANGE_ALGORITHM_MAX_ELEMENT_HPP
#define SPROUT_RANGE_ALGORITHM_MAX_ELEMENT_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/max_element.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.7 Minimum and maximum
template<typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
max_element(Range&& range) {
return sprout::range::range_return<Range>::pack(
sprout::max_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
max_element(Range&& range, Compare comp) {
return sprout::range::range_return<Range>::pack(
sprout::max_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
max_element(Range&& range) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::max_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
max_element(Range&& range, Compare comp) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::max_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_MAX_ELEMENT_HPP

View file

@ -0,0 +1,67 @@
#ifndef SPROUT_RANGE_ALGORITHM_MIN_ELEMENT_HPP
#define SPROUT_RANGE_ALGORITHM_MIN_ELEMENT_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/min_element.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.7 Minimum and maximum
template<typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
min_element(Range&& range) {
return sprout::range::range_return<Range>::pack(
sprout::min_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
min_element(Range&& range, Compare comp) {
return sprout::range::range_return<Range>::pack(
sprout::min_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
min_element(Range&& range) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::min_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
min_element(Range&& range, Compare comp) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::min_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_MIN_ELEMENT_HPP

View file

@ -0,0 +1,106 @@
#ifndef SPROUT_RANGE_ALGORITHM_MINMAX_ELEMENT_HPP
#define SPROUT_RANGE_ALGORITHM_MINMAX_ELEMENT_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/minmax_element.hpp>
namespace sprout {
namespace range {
namespace detail {
template<typename Range, typename Pair>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::range_return<Range>::type,
typename sprout::range::range_return<Range>::type
>
pack_pair(Pair const& pair, Range&& range) {
return {
sprout::range::range_return<Range>::pack(pair.first, sprout::forward<Range>(range)),
sprout::range::range_return<Range>::pack(pair.second, sprout::forward<Range>(range))
};
}
template<sprout::range::range_return_value RetV, typename Range, typename Pair>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::range_return<Range, RetV>::type,
typename sprout::range::range_return<Range, RetV>::type
>
pack_pair(Pair const& pair, Range&& range) {
return {
sprout::range::range_return<Range, RetV>::pack(pair.first, sprout::forward<Range>(range)),
sprout::range::range_return<Range, RetV>::pack(pair.second, sprout::forward<Range>(range))
};
}
} // namespace detail
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.7 Minimum and maximum
template<typename Range>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::range_return<Range>::type,
typename sprout::range::range_return<Range>::type
>
minmax_element(Range&& range) {
return sprout::range::detail::pack_pair<Range>(
sprout::minmax_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename Compare>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::range_return<Range>::type,
typename sprout::range::range_return<Range>::type
>
minmax_element(Range&& range, Compare comp) {
return sprout::range::detail::pack_pair<Range>(
sprout::minmax_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::range_return<Range, RetV>::type,
typename sprout::range::range_return<Range, RetV>::type
>
minmax_element(Range&& range) {
return sprout::range::detail::pack_pair<RetV, Range>(
sprout::minmax_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range))
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Compare>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::range_return<Range, RetV>::type,
typename sprout::range::range_return<Range, RetV>::type
>
minmax_element(Range&& range, Compare comp) {
return sprout::range::detail::pack_pair<RetV, Range>(
sprout::minmax_element(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_MINMAX_ELEMENT_HPP

View file

@ -0,0 +1,45 @@
#ifndef SPROUT_RANGE_ALGORITHM_MISMATCH_HPP
#define SPROUT_RANGE_ALGORITHM_MISMATCH_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/lvref_iterator.hpp>
#include <sprout/algorithm/mismatch.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.10 Mismatch
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvref_iterator<Range1>::type,
typename sprout::range::lvref_iterator<Range2>::type
>
mismatch(Range1&& range1, Range2&& range2) {
return sprout::mismatch(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2))
);
}
template<typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvref_iterator<Range1>::type,
typename sprout::range::lvref_iterator<Range2>::type
>
mismatch(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::mismatch(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
pred
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_MISMATCH_HPP

View file

@ -2,39 +2,36 @@
#define SPROUT_RANGE_ALGORITHM_NON_MODIFYIING_HPP
#include <sprout/config.hpp>
//#include <sprout/range/algorithm/all_of.hpp>
//#include <sprout/range/algorithm/any_of.hpp>
//#include <sprout/range/algorithm/none_of.hpp>
//#include <sprout/range/algorithm/find.hpp>
//#include <sprout/range/algorithm/find_if.hpp>
//#include <sprout/range/algorithm/find_if_not.hpp>
//#include <sprout/range/algorithm/find_end.hpp>
//#include <sprout/range/algorithm/find_first_of.hpp>
//#include <sprout/range/algorithm/adjacent_find.hpp>
//#include <sprout/range/algorithm/count.hpp>
//#include <sprout/range/algorithm/count_if.hpp>
//#include <sprout/range/algorithm/mismatch.hpp>
//#include <sprout/range/algorithm/equal.hpp>
//#include <sprout/range/algorithm/is_permutation.hpp>
//#include <sprout/range/algorithm/search.hpp>
//#include <sprout/range/algorithm/search_n.hpp>
//#include <sprout/range/algorithm/is_partitioned.hpp>
//#include <sprout/range/algorithm/partition_point.hpp>
//#include <sprout/range/algorithm/is_sorted.hpp>
//#include <sprout/range/algorithm/is_sorted_until.hpp>
//#include <sprout/range/algorithm/lower_bound.hpp>
//#include <sprout/range/algorithm/upper_bound.hpp>
//#include <sprout/range/algorithm/equal_range.hpp>
//#include <sprout/range/algorithm/binary_search.hpp>
//#include <sprout/range/algorithm/includes.hpp>
//#include <sprout/range/algorithm/is_heap.hpp>
//#include <sprout/range/algorithm/is_heap_until.hpp>
//#include <sprout/range/algorithm/min.hpp>
//#include <sprout/range/algorithm/max.hpp>
//#include <sprout/range/algorithm/minmax.hpp>
//#include <sprout/range/algorithm/min_element.hpp>
//#include <sprout/range/algorithm/max_element.hpp>
//#include <sprout/range/algorithm/minmax_element.hpp>
//#include <sprout/range/algorithm/lexicographical_compare.hpp>
#include <sprout/range/algorithm/all_of.hpp>
#include <sprout/range/algorithm/any_of.hpp>
#include <sprout/range/algorithm/none_of.hpp>
#include <sprout/range/algorithm/find.hpp>
#include <sprout/range/algorithm/find_if.hpp>
#include <sprout/range/algorithm/find_if_not.hpp>
#include <sprout/range/algorithm/find_end.hpp>
#include <sprout/range/algorithm/find_first_of.hpp>
#include <sprout/range/algorithm/adjacent_find.hpp>
#include <sprout/range/algorithm/count.hpp>
#include <sprout/range/algorithm/count_if.hpp>
#include <sprout/range/algorithm/mismatch.hpp>
#include <sprout/range/algorithm/equal.hpp>
#include <sprout/range/algorithm/is_permutation.hpp>
#include <sprout/range/algorithm/search.hpp>
#include <sprout/range/algorithm/search_n.hpp>
#include <sprout/range/algorithm/is_partitioned.hpp>
#include <sprout/range/algorithm/partition_point.hpp>
#include <sprout/range/algorithm/is_sorted.hpp>
#include <sprout/range/algorithm/is_sorted_until.hpp>
#include <sprout/range/algorithm/lower_bound.hpp>
#include <sprout/range/algorithm/upper_bound.hpp>
#include <sprout/range/algorithm/equal_range.hpp>
#include <sprout/range/algorithm/binary_search.hpp>
#include <sprout/range/algorithm/includes.hpp>
#include <sprout/range/algorithm/is_heap.hpp>
#include <sprout/range/algorithm/is_heap_until.hpp>
#include <sprout/range/algorithm/min_element.hpp>
#include <sprout/range/algorithm/max_element.hpp>
#include <sprout/range/algorithm/minmax_element.hpp>
#include <sprout/range/algorithm/lexicographical_compare.hpp>
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NON_MODIFYIING_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_RANGE_ALGORITHM_NONE_OF_HPP
#define SPROUT_RANGE_ALGORITHM_NONE_OF_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/none_of.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.3 None of
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR bool none_of(Range const& range, Predicate pred) {
return sprout::none_of(sprout::begin(range), sprout::end(range), pred);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NONE_OF_HPP

View file

@ -0,0 +1,30 @@
#ifndef SPROUT_RANGE_ALGORITHM_PARTITION_POINT_HPP
#define SPROUT_RANGE_ALGORITHM_PARTITION_POINT_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/partition_point.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.3.13 partitions
template<typename Range, typename Predicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
partition_point(Range&& range, Predicate pred) {
return sprout::range::range_return<Range>::pack(
sprout::partition_point(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
pred
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_PARTITION_POINT_HPP

View file

@ -0,0 +1,75 @@
#ifndef SPROUT_RANGE_ALGORITHM_SEARCH_HPP
#define SPROUT_RANGE_ALGORITHM_SEARCH_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/search.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.13 Search
template<typename Range1, typename Range2>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1>::type
search(Range1&& range1, Range2&& range2) {
return sprout::range::range_return<Range1>::pack(
sprout::search(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
),
sprout::forward<Range1>(range1)
);
}
template<typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1>::type
search(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::range::range_return<Range1>::pack(
sprout::search(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
pred
),
sprout::forward<Range1>(range1)
);
}
template<sprout::range::range_return_value RetV, typename Range1, typename Range2>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1, RetV>::type
search(Range1&& range1, Range2&& range2) {
return sprout::range::range_return<Range1, RetV>::pack(
sprout::search(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
),
sprout::forward<Range1>(range1)
);
}
template<sprout::range::range_return_value RetV, typename Range1, typename Range2, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range1, RetV>::type
search(Range1&& range1, Range2&& range2, BinaryPredicate pred) {
return sprout::range::range_return<Range1, RetV>::pack(
sprout::search(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
pred
),
sprout::forward<Range1>(range1)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_SEARCH_HPP

View file

@ -0,0 +1,75 @@
#ifndef SPROUT_RANGE_ALGORITHM_SEARCH_N_HPP
#define SPROUT_RANGE_ALGORITHM_SEARCH_N_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/search_n.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.2.13 Search
template<typename Range, typename Size, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
search_n(Range&& range, Size count, T const& value) {
return sprout::range::range_return<Range>::pack(
sprout::search_n(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
count,
value
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename Size, typename T, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
search_n(Range&& range, Size count, T const& value, BinaryPredicate pred) {
return sprout::range::range_return<Range>::pack(
sprout::search_n(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
count,
value,
pred
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Size, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
search_n(Range&& range, Size count, T const& value) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::search_n(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
count,
value
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename Size, typename T, typename BinaryPredicate>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
search_n(Range&& range, Size count, T const& value, BinaryPredicate pred) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::search_n(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
count,
value,
pred
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_SEARCH_N_HPP

View file

@ -0,0 +1,71 @@
#ifndef SPROUT_RANGE_ALGORITHM_UPPER_BOUND_HPP
#define SPROUT_RANGE_ALGORITHM_UPPER_BOUND_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/range_return.hpp>
#include <sprout/algorithm/upper_bound.hpp>
namespace sprout {
namespace range {
// Copyright (C) 2011 RiSK (sscrisk)
// 25.4.3.2 upper_bound
template<typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
upper_bound(Range&& range, T const& value) {
return sprout::range::range_return<Range>::pack(
sprout::upper_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
),
sprout::forward<Range>(range)
);
}
template<typename Range, typename T, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range>::type
upper_bound(Range&& range, T const& value, Compare comp) {
return sprout::range::range_return<Range>::pack(
sprout::upper_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value,
comp
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename T>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
upper_bound(Range&& range, T const& value) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::upper_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value
),
sprout::forward<Range>(range)
);
}
template<sprout::range::range_return_value RetV, typename Range, typename T, typename Compare>
SPROUT_CONSTEXPR typename sprout::range::range_return<Range, RetV>::type
upper_bound(Range&& range, T const& value, Compare comp) {
return sprout::range::range_return<Range, RetV>::pack(
sprout::upper_bound(
sprout::begin(sprout::forward<Range>(range)),
sprout::end(sprout::forward<Range>(range)),
value,
comp
),
sprout::forward<Range>(range)
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_UPPER_BOUND_HPP

View file

@ -0,0 +1,24 @@
#ifndef SPROUT_RANGE_LVREF_ITERATOR_HPP
#define SPROUT_RANGE_LVREF_ITERATOR_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/utility/operation_ext.hpp>
namespace sprout {
namespace range {
//
// lvref_iterator
//
template<typename Range>
struct lvref_iterator {
public:
typedef typename sprout::container_traits<
typename std::remove_reference<typename sprout::lvref<Range>::type>::type
>::iterator type;
};
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_LVREF_ITERATOR_HPP

View file

@ -0,0 +1,21 @@
#ifndef SPROUT_RANGE_LVREF_RANGE_HPP
#define SPROUT_RANGE_LVREF_RANGE_HPP
#include <sprout/config.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/lvref_iterator.hpp>
namespace sprout {
namespace range {
//
// lvref_range
//
template<typename Range>
struct lvref_range {
public:
typedef sprout::range::range_container<typename sprout::range::lvref_iterator<Range>::type> type;
};
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_LVREF_RANGE_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_RANGE_NUMERIC_ACCUMLATE_HPP
#define SPROUT_RANGE_NUMERIC_ACCUMLATE_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/accumulate.hpp>
namespace sprout {
// 26.7.2 Accumulate
template<typename Range, typename T, typename BinaryOperation>
SPROUT_CONSTEXPR T accumulate(Range const& range, T init, BinaryOperation binary_op) {
return sprout::accumulate(sprout::begin(range), sprout::end(range), init, binary_op);
}
template<typename Range, typename T>
SPROUT_CONSTEXPR T accumulate(Range const& range, T init) {
return sprout::accumulate(sprout::begin(range), sprout::end(range), init);
}
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_ACCUMLATE_HPP

View file

@ -0,0 +1,32 @@
#ifndef SPROUT_RANGE_NUMERIC_INNER_PRODUCT_HPP
#define SPROUT_RANGE_NUMERIC_INNER_PRODUCT_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/inner_product.hpp>
namespace sprout {
// 26.7.3 Inner product
template<typename Range1, typename Range2, typename T, typename BinaryOperation1, typename BinaryOperation2>
SPROUT_CONSTEXPR T inner_product(
Range1 const& range1,
Range2 const& range2,
T init,
BinaryOperation1 binary_op1,
BinaryOperation2 binary_op2
)
{
return sprout::inner_product(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), init, binary_op1, binary_op2);
}
template<typename Range1, typename Range2, typename T>
SPROUT_CONSTEXPR T inner_product(
Range1 const& range1,
Range2 const& range2,
T init
)
{
return sprout::inner_product(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), init);
}
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_INNER_PRODUCT_HPP

View file

@ -2,7 +2,7 @@
#define SPROUT_RANGE_NUMERIC_NON_MODIFYIING_HPP
#include <sprout/config.hpp>
//#include <sprout/range/numeric/accumulate.hpp>
//#include <sprout/range/numeric/inner_product.hpp>
#include <sprout/range/numeric/accumulate.hpp>
#include <sprout/range/numeric/inner_product.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_NON_MODIFYIING_HPP

View file

@ -0,0 +1,134 @@
#ifndef SPROUT_RANGE_RANGE_CONTAINER_HPP
#define SPROUT_RANGE_RANGE_CONTAINER_HPP
#include <stdexcept>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
namespace sprout {
namespace range {
//
// range_container
//
template<typename Iterator>
struct range_container
: public sprout::container_traits<Iterator>
{
public:
typedef Iterator iterator;
typedef iterator const_iterator;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
typedef typename std::remove_reference<reference>::type const& const_reference;
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
typedef typename std::make_unsigned<difference_type>::type size_type;
typedef typename std::iterator_traits<Iterator>::pointer pointer;
typedef typename std::remove_pointer<pointer>::type const* const_pointer;
private:
iterator first_;
iterator last_;
public:
// construct/copy/destroy:
range_container() = default;
SPROUT_CONSTEXPR range_container(iterator first, iterator last)
: first_(first)
, last_(last)
{}
template<typename Iterator2>
void swap(range_container<Iterator2>& other) {
using std::swap;
swap(other.first_, first_);
swap(other.last_, last_);
}
// iterators:
SPROUT_CONSTEXPR iterator begin() const {
return first_;
}
SPROUT_CONSTEXPR iterator end() const {
return last_;
}
// capacity:
SPROUT_CONSTEXPR size_type size() const {
return sprout::distance(first_, last_);
}
SPROUT_CONSTEXPR bool empty() const {
return first_ == last_;
}
// element access:
SPROUT_CONSTEXPR reference operator[](size_type i) const {
return *sprout::next(first_, i);
}
SPROUT_CONSTEXPR reference at(size_type i) const {
return i < size() ? *sprout::next(first_, i)
: (throw std::out_of_range("sprout::range::range_container<>: index out of range"), *sprout::next(first_, i))
;
}
SPROUT_CONSTEXPR reference front() const {
return *first_;
}
SPROUT_CONSTEXPR reference back() const {
return *sprout::next(first_, size() - 1);
}
// others:
template<typename Iterator2>
range_container<Iterator>& operator=(range_container<Iterator2> const& rhs) {
first_ = rhs.first_;
last_ = rhs.last_;
return *this;
}
template<typename Iterator2>
range_container<Iterator>& operator=(range_container<Iterator2>&& rhs) {
first_ = std::move(rhs.first_);
last_ = std::move(rhs.last_);
return *this;
}
};
//
// swap
//
template<typename Iterator>
inline void swap(sprout::range::range_container<Iterator>& lhs, sprout::range::range_container<Iterator>& rhs) {
lhs.swap(rhs);
}
namespace detail {
template<typename T, typename Enable = void>
struct is_range_container_impl
: public std::false_type
{};
template<typename T>
struct is_range_container_impl<
T,
typename std::enable_if<
std::is_same<
T,
sprout::range::range_container<typename T::iterator>
>::value
>::type
>
: public std::true_type
{};
} // namespace detail
//
// is_range_container
//
template<typename T>
struct is_range_container
: public sprout::range::detail::is_range_container_impl<T>
{};
} // namespace range
//
// container_traits
//
template<typename Iterator>
struct container_traits<sprout::range::range_container<Iterator> >
: public sprout::detail::container_traits_default_types<sprout::range::range_container<Iterator> >
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_RANGE_CONTAINER_HPP

View file

@ -0,0 +1,70 @@
#ifndef SPROUT_RANGE_RANGE_RETURN_HPP
#define SPROUT_RANGE_RANGE_RETURN_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/operation.hpp>
#include <sprout/range/lvref_iterator.hpp>
#include <sprout/range/lvref_range.hpp>
namespace sprout {
namespace range {
//
// range_return_value
//
enum range_return_value {
return_found,
return_found_end,
return_begin_found
};
//
// range_return
//
template<typename Range, sprout::range::range_return_value RetV = sprout::range::return_found>
struct range_return;
template<typename Range>
struct range_return<Range, sprout::range::return_found> {
public:
typedef typename sprout::range::lvref_iterator<Range>::type type;
public:
static SPROUT_CONSTEXPR type pack(
typename sprout::container_traits<Range>::iterator found,
Range&& range
)
{
return found;
}
};
template<typename Range>
struct range_return<Range, sprout::range::return_found_end> {
public:
typedef typename sprout::range::lvref_range<Range>::type type;
public:
static SPROUT_CONSTEXPR type pack(
typename sprout::container_traits<Range>::iterator found,
Range&& range
)
{
return type(found, sprout::end(sprout::forward<Range>(range)));
}
};
template<typename Range>
struct range_return<Range, sprout::range::return_begin_found> {
public:
typedef typename sprout::range::lvref_range<Range>::type type;
public:
static SPROUT_CONSTEXPR type pack(
typename sprout::container_traits<Range>::iterator found,
Range&& range
)
{
return type(sprout::begin(sprout::forward<Range>(range)), found);
}
};
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_RANGE_RETURN_HPP

View file

@ -295,7 +295,7 @@ namespace sprout {
return size();
}
SPROUT_CONSTEXPR bool empty() const {
return size() == 0;
return first_ == last_;
}
// element access:
reference operator[](size_type i) {

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_UTILITY_AS_CONST_HPP
#define SPROUT_UTILITY_AS_CONST_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// as_const
//
template<typename T>
inline T const& as_const(T& t) {
return t;
}
template<typename T>
inline SPROUT_CONSTEXPR T const& as_const(T const& t) {
return t;
}
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_AS_CONST_HPP

View file

@ -0,0 +1,29 @@
#ifndef SPROUT_UTILITY_AS_LVREF_HPP
#define SPROUT_UTILITY_AS_LVREF_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// as_lvref
//
template<typename T>
inline T& as_lvref(T& t) {
return t;
}
template<typename T>
inline SPROUT_CONSTEXPR T const& as_lvref(T const& t) {
return t;
}
//
// lvref
//
template<typename T>
struct lvref {
public:
typedef decltype(sprout::as_lvref(std::declval<T&&>())) type;
};
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_AS_LVREF_HPP

View file

@ -9,11 +9,11 @@ namespace sprout {
// forward
//
template<typename T>
SPROUT_CONSTEXPR T&& forward(typename std::remove_reference<T>::type& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T&& forward(typename std::remove_reference<T>::type& t) SPROUT_NOEXCEPT {
return static_cast<T&&>(t);
}
template<typename T>
SPROUT_CONSTEXPR T&& forward(typename std::remove_reference<T>::type&& t) SPROUT_NOEXCEPT = delete;
inline SPROUT_CONSTEXPR T&& forward(typename std::remove_reference<T>::type&& t) SPROUT_NOEXCEPT = delete;
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_FORWARD_HPP

View file

@ -9,7 +9,7 @@ namespace sprout {
// move
//
template<typename T>
SPROUT_CONSTEXPR typename std::remove_reference<T>::type&& move(T&& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR typename std::remove_reference<T>::type&& move(T&& t) SPROUT_NOEXCEPT {
return static_cast<typename std::remove_reference<T>::type&&>(t);
}
} // namespace sprout

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_UTILITY_OPERATION_EXT_HPP
#define SPROUT_UTILITY_OPERATION_EXT_HPP
#include <sprout/config.hpp>
#include <sprout/utility/as_lvref.hpp>
#include <sprout/utility/as_const.hpp>
#endif // #ifndef SPROUT_UTILITY_OPERATION_EXT_HPP