range/numeric.hpp 追加

algorithm/* fix
This commit is contained in:
bolero-MURAKAMI 2011-10-21 20:36:19 +09:00
parent 510a265ea5
commit 42d73cc4d5
18 changed files with 407 additions and 131 deletions

View file

@ -1,6 +1,7 @@
#ifndef SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP #ifndef SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP
#define SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP #define SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP
#include <cstddef>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
@ -61,7 +62,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? pred(*first) ? pred(*first)
? partition_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args...) ? partition_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args...)
: partition_copy_impl_2(sprout::next(first), last, result, pred, offset, args..., *first) : partition_copy_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
@ -96,7 +97,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < static_cast<std::size_t>(offset)
? partition_copy_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args))) ? partition_copy_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), args...) : partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
; ;

View file

@ -1,6 +1,7 @@
#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP #ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP
#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP #define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP
#include <cstddef>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
@ -61,7 +62,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? *first == value ? *first == value
? remove_copy_impl_2(sprout::next(first), last, result, value, offset, args...) ? remove_copy_impl_2(sprout::next(first), last, result, value, offset, args...)
: remove_copy_impl_2(sprout::next(first), last, result, value, offset, args..., *first) : remove_copy_impl_2(sprout::next(first), last, result, value, offset, args..., *first)
@ -96,7 +97,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < static_cast<std::size_t>(offset)
? remove_copy_impl_1(first, last, result, value, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args))) ? remove_copy_impl_1(first, last, result, value, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: remove_copy_impl_2(first, last, result, value, offset + sprout::size(result), args...) : remove_copy_impl_2(first, last, result, value, offset + sprout::size(result), args...)
; ;

View file

@ -1,6 +1,7 @@
#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP #ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP
#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP #define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP
#include <cstddef>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
@ -61,7 +62,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? pred(*first) ? pred(*first)
? remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args...) ? remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args...)
: remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args..., *first) : remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
@ -96,7 +97,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < static_cast<std::size_t>(offset)
? remove_copy_if_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args))) ? remove_copy_if_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: remove_copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...) : remove_copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
; ;

View file

@ -11,6 +11,7 @@
#include <sprout/iterator/operation.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -32,7 +33,7 @@ namespace sprout {
result, result,
sprout::size(result), sprout::size(result),
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
? *sprout::next(first, Indexes - offset) == old_value ? new_value : *sprout::next(first, Indexes - offset) ? NS_SSCRISK_CEL_OR_SPROUT_DETAIL::equal_to<T>()(*sprout::next(first, Indexes - offset), old_value) ? new_value : *sprout::next(first, Indexes - offset)
: *sprout::next(sprout::fixed_begin(result), Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );

View file

@ -14,6 +14,24 @@
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
namespace detail { namespace detail {
template<typename Container, typename Compare>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_lr(
Container const& cont,
typename sprout::fixed_container_traits<Container>::difference_type start,
typename sprout::fixed_container_traits<Container>::difference_type end,
Compare comp,
typename sprout::fixed_container_traits<Container>::difference_type l,
typename sprout::fixed_container_traits<Container>::difference_type r,
typename sprout::fixed_container_traits<Container>::value_type const& p
);
template<typename Container, typename Compare>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_start(
Container const& cont,
typename sprout::fixed_container_traits<Container>::difference_type start,
typename sprout::fixed_container_traits<Container>::difference_type end,
Compare comp
);
template<typename Container, typename Iterator> template<typename Container, typename Iterator>
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::value_type const& sort_select_pivot( SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::value_type const& sort_select_pivot(
Iterator origin, Iterator origin,
@ -128,10 +146,6 @@ namespace sprout {
{ // pivot を選択してソートを開始 { // pivot を選択してソートを開始
return sort_lr(cont, start, end, comp, start, end, sort_select_pivot<Container>(sprout::fixed_begin(cont), start, end)); return sort_lr(cont, start, end, comp, start, end, sort_select_pivot<Container>(sprout::fixed_begin(cont), start, end));
} }
} // namespace detail
//
// sort
//
template<typename Container, typename Compare> template<typename Container, typename Compare>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
(sprout::fixed_container_traits<Container>::fixed_size <= 1), (sprout::fixed_container_traits<Container>::fixed_size <= 1),
@ -159,9 +173,6 @@ namespace sprout {
comp comp
); );
} }
//
// sort
//
template<typename Container> template<typename Container>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
(sprout::fixed_container_traits<Container>::fixed_size <= 1), (sprout::fixed_container_traits<Container>::fixed_size <= 1),
@ -187,6 +198,29 @@ namespace sprout {
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Container>::value_type>() NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Container>::value_type>()
); );
} }
} // namespace detail
//
// sort
//
template<typename Container, typename Compare>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort(
Container const& cont,
Compare comp
)
{
return sprout::fixed::detail::sort(cont, comp);
}
//
// sort
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort(
Container const& cont
)
{
return sprout::fixed::detail::sort(cont);
}
} // namespace fixed } // namespace fixed
using sprout::fixed::sort; using sprout::fixed::sort;

View file

@ -1,6 +1,7 @@
#ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP #ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP
#define SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP #define SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP
#include <cstddef>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
@ -34,13 +35,13 @@ namespace sprout {
return stable_partition_copy_impl_4(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args))); return stable_partition_copy_impl_4(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename InputIterator, typename Result, typename Predicate, typename... Args> template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args), sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type typename sprout::fixed::result_of::algorithm<Result>::type
>::type stable_partition_copy_impl_3( >::type stable_partition_copy_impl_3(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred, Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset, typename sprout::fixed_container_traits<Result>::difference_type offset,
@ -49,20 +50,20 @@ namespace sprout {
{ {
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...); return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
} }
template<typename InputIterator, typename Result, typename Predicate, typename... Args> template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args), sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type typename sprout::fixed::result_of::algorithm<Result>::type
>::type stable_partition_copy_impl_3( >::type stable_partition_copy_impl_3(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred, Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset, typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? !pred(*first) ? !pred(*first)
? stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args..., *first) ? stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args..., *first)
: stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args...) : stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args...)
@ -70,82 +71,82 @@ namespace sprout {
; ;
} }
template<typename InputIterator, typename Result, typename Predicate, typename... Args> template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args), sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type typename sprout::fixed::result_of::algorithm<Result>::type
>::type stable_partition_copy_impl_2( >::type stable_partition_copy_impl_2(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred, Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset, typename sprout::fixed_container_traits<Result>::difference_type offset,
InputIterator origin, BidirectionalIterator origin,
Args const&... args Args const&... args
) )
{ {
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...); return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
} }
template<typename InputIterator, typename Result, typename Predicate, typename... Args> template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args), sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type typename sprout::fixed::result_of::algorithm<Result>::type
>::type stable_partition_copy_impl_2( >::type stable_partition_copy_impl_2(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred, Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset, typename sprout::fixed_container_traits<Result>::difference_type offset,
InputIterator origin, BidirectionalIterator origin,
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? pred(*first) ? pred(*first)
? stable_partition_copy_impl_2(sprout::next(first), last, result, pred, offset, origin, args..., *first) ? stable_partition_copy_impl_2(sprout::next(first), last, result, pred, offset, origin, args..., *first)
: stable_partition_copy_impl_2(sprout::next(first), last, result, pred, offset, origin, args...) : stable_partition_copy_impl_2(sprout::next(first), last, result, pred, offset, origin, args...)
: stable_partition_copy_impl_3(origin, last, result, pred, offset, args...) : stable_partition_copy_impl_3(origin, last, result, pred, offset, args...)
; ;
} }
template<typename InputIterator, typename Result, typename Predicate, typename... Args> template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args), sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type typename sprout::fixed::result_of::algorithm<Result>::type
>::type stable_partition_copy_impl_1( >::type stable_partition_copy_impl_1(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred, Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset, typename sprout::fixed_container_traits<Result>::difference_type offset,
InputIterator origin, BidirectionalIterator origin,
Args const&... args Args const&... args
) )
{ {
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...); return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
} }
template<typename InputIterator, typename Result, typename Predicate, typename... Args> template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args), sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type typename sprout::fixed::result_of::algorithm<Result>::type
>::type stable_partition_copy_impl_1( >::type stable_partition_copy_impl_1(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred, Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset, typename sprout::fixed_container_traits<Result>::difference_type offset,
InputIterator origin, BidirectionalIterator origin,
Args const&... args Args const&... args
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < static_cast<std::size_t>(offset)
? stable_partition_copy_impl_1(first, last, result, pred, offset, origin, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args))) ? stable_partition_copy_impl_1(first, last, result, pred, offset, origin, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: stable_partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), origin, args...) : stable_partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), origin, args...)
; ;
} }
template<typename InputIterator, typename Result, typename Predicate> template<typename BidirectionalIterator, typename Result, typename Predicate>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy_impl( SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy_impl(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred Predicate pred
) )
@ -156,10 +157,10 @@ namespace sprout {
// //
// stable_partition_copy // stable_partition_copy
// //
template<typename InputIterator, typename Result, typename Predicate> template<typename BidirectionalIterator, typename Result, typename Predicate>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy( SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy(
InputIterator first, BidirectionalIterator first,
InputIterator last, BidirectionalIterator last,
Result const& result, Result const& result,
Predicate pred Predicate pred
) )

View file

@ -198,10 +198,6 @@ namespace sprout {
{ {
return stable_sort_impl_1(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<>(), sprout::index_tuple<>(), sprout::index_tuple<>()); return stable_sort_impl_1(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<>(), sprout::index_tuple<>(), sprout::index_tuple<>());
} }
} // namespace detail
//
// stable_sort
//
template<typename Container, typename Compare> template<typename Container, typename Compare>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
(sprout::fixed_container_traits<Container>::fixed_size <= 1), (sprout::fixed_container_traits<Container>::fixed_size <= 1),
@ -228,9 +224,6 @@ namespace sprout {
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type() typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type()
); );
} }
//
// stable_sort
//
template<typename Container> template<typename Container>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
(sprout::fixed_container_traits<Container>::fixed_size <= 1), (sprout::fixed_container_traits<Container>::fixed_size <= 1),
@ -255,6 +248,28 @@ namespace sprout {
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type() typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type()
); );
} }
} // namespace detail
//
// stable_sort
//
template<typename Container, typename Compare>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type stable_sort(
Container const& cont,
Compare comp
)
{
return sprout::fixed::detail::stable_sort(cont, comp);
}
//
// stable_sort
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type stable_sort(
Container const& cont
)
{
return sprout::fixed::detail::stable_sort(cont);
}
} // namespace fixed } // namespace fixed
using sprout::fixed::stable_sort; using sprout::fixed::stable_sort;

View file

@ -1,6 +1,7 @@
#ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP #ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP
#define SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP #define SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP
#include <cstddef>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
@ -46,7 +47,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...); return sprout::remake_clone<Result, Result>(result, sprout::size(result), args..., head);
} }
template<typename InputIterator, typename Result, typename Head, typename... Args> template<typename InputIterator, typename Result, typename Head, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -61,7 +62,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) + 1 < offset return first != last && sizeof...(Args) + 1 < static_cast<std::size_t>(offset)
? !(head == *first) ? !(head == *first)
? unique_copy_impl_2(sprout::next(first), last, result, offset, *first, args..., head) ? unique_copy_impl_2(sprout::next(first), last, result, offset, *first, args..., head)
: unique_copy_impl_2(sprout::next(first), last, result, offset, head, args...) : unique_copy_impl_2(sprout::next(first), last, result, offset, head, args...)
@ -94,9 +95,11 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < static_cast<std::size_t>(offset)
? unique_copy_impl_1(first, last, result, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? unique_copy_impl_1(first, last, result, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args)))
: unique_copy_impl_2(sprout::next(first), last, result, offset + sprout::size(result), *first, args...) : first != last
? unique_copy_impl_2(sprout::next(first), last, result, offset + sprout::size(result), *first, args...)
: unique_copy_impl_3(result, args...)
; ;
} }
template<typename InputIterator, typename Result> template<typename InputIterator, typename Result>
@ -137,7 +140,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...); return sprout::remake_clone<Result, Result>(result, sprout::size(result), args..., head);
} }
template<typename InputIterator, typename Result, typename BinaryPredicate, typename Head, typename... Args> template<typename InputIterator, typename Result, typename BinaryPredicate, typename Head, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -153,7 +156,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return first != last && sizeof...(Args) + 1 < offset return first != last && sizeof...(Args) + 1 < static_cast<std::size_t>(offset)
? !pred(head, *first) ? !pred(head, *first)
? unique_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args..., head) ? unique_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args..., head)
: unique_copy_impl_2(sprout::next(first), last, result, pred, offset, head, args...) : unique_copy_impl_2(sprout::next(first), last, result, pred, offset, head, args...)
@ -188,9 +191,11 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < static_cast<std::size_t>(offset)
? unique_copy_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? unique_copy_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args)))
: unique_copy_impl_2(sprout::next(first), last, result, pred, offset + sprout::size(result), *first, args...) : first != last
? unique_copy_impl_2(sprout::next(first), last, result, pred, offset + sprout::size(result), *first, args...)
: unique_copy_impl_3(result, args...)
; ;
} }
template<typename InputIterator, typename Result, typename BinaryPredicate> template<typename InputIterator, typename Result, typename BinaryPredicate>

View file

@ -6,6 +6,19 @@
namespace sprout { namespace sprout {
namespace detail { namespace detail {
//
// equal_to
//
template<typename T>
class equal_to
: public std::binary_function<T, T, bool>
{
public:
SPROUT_CONSTEXPR bool operator()(T const& lhs, T const& rhs) const {
return lhs == rhs;
}
};
// //
// less // less
// //

8
sprout/range/numeric.hpp Normal file
View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_HPP
#define SPROUT_RANGE_NUMERIC_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/fixed.hpp>
#include <sprout/range/numeric/fit.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_ADJACENT_DIFFERENCE_HPP
#define SPROUT_RANGE_NUMERIC_ADJACENT_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/fixed/adjacent_difference.hpp>
#include <sprout/range/numeric/fit/adjacent_difference.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_ADJACENT_DIFFERENCE_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_FIT_HPP
#define SPROUT_RANGE_NUMERIC_FIT_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/fit/partial_sum.hpp>
#include <sprout/range/numeric/fit/adjacent_difference.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_HPP

View file

@ -0,0 +1,40 @@
#ifndef SPROUT_RANGE_NUMERIC_FIT_ADJACENT_DIFFERENCE_HPP
#define SPROUT_RANGE_NUMERIC_FIT_ADJACENT_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/numeric/fit/adjacent_difference.hpp>
namespace sprout {
namespace range {
namespace fit {
//
// adjacent_difference
//
template<typename Input, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type adjacent_difference(
Input const& input,
Result const& result
)
{
return sprout::fit::adjacent_difference(sprout::begin(input), sprout::end(input), result);
}
//
// adjacent_difference
//
template<typename Input, typename Result, typename BinaryOperation>
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type adjacent_difference(
Input const& input,
Result const& result,
BinaryOperation binary_op
)
{
return sprout::fit::adjacent_difference(sprout::begin(input), sprout::end(input), result, binary_op);
}
} // namespace fit
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_ADJACENT_DIFFERENCE_HPP

View file

@ -0,0 +1,40 @@
#ifndef SPROUT_RANGE_NUMERIC_FIT_PARTIAL_SUM_HPP
#define SPROUT_RANGE_NUMERIC_FIT_PARTIAL_SUM_HPP
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/numeric/fit/partial_sum.hpp>
namespace sprout {
namespace range {
namespace fit {
//
// partial_sum
//
template<typename Input, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type partial_sum(
Input const& input,
Result const& result
)
{
return sprout::fit::partial_sum(sprout::begin(input), sprout::end(input), result);
}
//
// partial_sum
//
template<typename Input, typename Result, typename BinaryOperation>
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type partial_sum(
Input const& input,
Result const& result,
BinaryOperation binary_op
)
{
return sprout::fit::partial_sum(sprout::begin(input), sprout::end(input), result, binary_op);
}
} // namespace fit
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_PARTIAL_SUM_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_FIXED_HPP
#define SPROUT_RANGE_NUMERIC_FIXED_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/fixed/partial_sum.hpp>
#include <sprout/range/numeric/fixed/adjacent_difference.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_HPP

View file

@ -0,0 +1,42 @@
#ifndef SPROUT_RANGE_NUMERIC_FIXED_ADJACENT_DIFFERENCE_HPP
#define SPROUT_RANGE_NUMERIC_FIXED_ADJACENT_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/numeric/fixed/adjacent_difference.hpp>
namespace sprout {
namespace range {
namespace fixed {
//
// adjacent_difference
//
template<typename Input, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type adjacent_difference(
Input const& input,
Result const& result
)
{
return sprout::fixed::adjacent_difference(sprout::begin(input), sprout::end(input), result);
}
//
// adjacent_difference
//
template<typename Input, typename Result, typename BinaryOperation>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type adjacent_difference(
Input const& input,
Result const& result,
BinaryOperation binary_op
)
{
return sprout::fixed::adjacent_difference(sprout::begin(input), sprout::end(input), result, binary_op);
}
} // namespace fixed
using sprout::range::fixed::adjacent_difference;
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_ADJACENT_DIFFERENCE_HPP

View file

@ -0,0 +1,42 @@
#ifndef SPROUT_RANGE_NUMERIC_FIXED_PARTIAL_SUM_HPP
#define SPROUT_RANGE_NUMERIC_FIXED_PARTIAL_SUM_HPP
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/numeric/fixed/partial_sum.hpp>
namespace sprout {
namespace range {
namespace fixed {
//
// partial_sum
//
template<typename Input, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type partial_sum(
Input const& input,
Result const& result
)
{
return sprout::fixed::partial_sum(sprout::begin(input), sprout::end(input), result);
}
//
// partial_sum
//
template<typename Input, typename Result, typename BinaryOperation>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type partial_sum(
Input const& input,
Result const& result,
BinaryOperation binary_op
)
{
return sprout::fixed::partial_sum(sprout::begin(input), sprout::end(input), result, binary_op);
}
} // namespace fixed
using sprout::range::fixed::partial_sum;
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_PARTIAL_SUM_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_PARTIAL_SUM_HPP
#define SPROUT_RANGE_NUMERIC_PARTIAL_SUM_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/fixed/partial_sum.hpp>
#include <sprout/range/numeric/fit/partial_sum.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_PARTIAL_SUM_HPP