algorithm を next/prev で再実装

This commit is contained in:
bolero-MURAKAMI 2011-10-02 00:19:13 +09:00
parent 6fe7e88509
commit 628d1caa7e
50 changed files with 310 additions and 189 deletions

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -27,8 +28,8 @@ 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
? *(first + Indexes - offset) ? *sprout::next(first, Indexes - offset)
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -27,8 +28,8 @@ namespace sprout {
result, result,
sprout::size(result), sprout::size(result),
(Indexes < offset && Indexes + size >= offset && Indexes + input_size >= offset (Indexes < offset && Indexes + size >= offset && Indexes + input_size >= offset
? *(last + Indexes - offset) ? *sprout::next(last, Indexes - offset)
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -30,7 +31,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return copy_if_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return copy_if_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator, typename Result, typename Predicate, typename... Args> template<typename Iterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -62,8 +63,8 @@ namespace sprout {
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < offset
? pred(*first) ? pred(*first)
? copy_if_impl_2(first + 1, last, result, pred, offset, args..., *first) ? copy_if_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
: copy_if_impl_2(first + 1, last, result, pred, offset, args...) : copy_if_impl_2(sprout::next(first), last, result, pred, offset, args...)
: copy_if_impl_3(result, args...) : copy_if_impl_3(result, args...)
; ;
} }
@ -96,7 +97,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? copy_if_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? copy_if_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...) : copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
; ;
} }

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/copy.hpp> #include <sprout/algorithm/fixed/copy.hpp>
@ -21,7 +22,7 @@ namespace sprout {
{ {
return sprout::fixed::detail::copy_impl( return sprout::fixed::detail::copy_impl(
first, first,
first + n, sprout::next(first, n),
result, result,
typename sprout::index_range<0, sprout::fixed_container_traits<Result>::fixed_size>::type(), typename sprout::index_range<0, sprout::fixed_container_traits<Result>::fixed_size>::type(),
sprout::fixed_begin_offset(result), sprout::fixed_begin_offset(result),

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -25,7 +26,7 @@ namespace sprout {
sprout::size(cont), sprout::size(cont),
(Indexes >= offset && Indexes < offset + size (Indexes >= offset && Indexes < offset + size
? value ? value
: *(sprout::fixed_begin(cont) + Indexes) : *sprout::next(sprout::fixed_begin(cont), Indexes)
)... )...
); );
} }

View file

@ -6,6 +6,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -55,7 +56,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return generate_impl_4(cont, args..., *(sprout::fixed_begin(cont) + sizeof...(Args))); return generate_impl_4(cont, args..., *sprout::next(sprout::fixed_begin(cont), sizeof...(Args)));
} }
template<std::size_t InitSize, typename Container, typename Generator, typename... Args> template<std::size_t InitSize, typename Container, typename Generator, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -161,7 +162,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) - InitSize < offset return sizeof...(Args) - InitSize < offset
? generate_impl_1<InitSize>(cont, gen, offset, size, args..., *(sprout::fixed_begin(cont) + sizeof...(Args) - InitSize)) ? generate_impl_1<InitSize>(cont, gen, offset, size, args..., *sprout::next(sprout::fixed_begin(cont), sizeof...(Args) - InitSize))
: generate_impl_2<InitSize>(cont, gen, offset, size, InitSize, args...) : generate_impl_2<InitSize>(cont, gen, offset, size, InitSize, args...)
; ;
} }

View file

@ -5,6 +5,7 @@
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -32,10 +33,14 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::difference_type r typename sprout::fixed_container_traits<Container>::difference_type r
) )
{ {
return comp(*(sprout::fixed_begin(cont) + offset + l), *(sprout::fixed_begin(cont) + offset + r)) return comp(*sprout::next(sprout::fixed_begin(cont), offset + l), *sprout::next(sprout::fixed_begin(cont), offset + r))
? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + r)) ? comp(*sprout::next(sprout::fixed_begin(cont), offset + n), *sprout::next(sprout::fixed_begin(cont), offset + r))
? sprout::fixed::detail::make_heap_impl( ? sprout::fixed::detail::make_heap_impl(
sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + r), sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + n),
sprout::next(sprout::fixed_begin(cont), offset + r)
),
comp, comp,
offset, offset,
size, size,
@ -44,9 +49,13 @@ namespace sprout {
r * 2 + 2 r * 2 + 2
) )
: sprout::clone(cont) : sprout::clone(cont)
: comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + l)) : comp(*sprout::next(sprout::fixed_begin(cont), offset + n), *sprout::next(sprout::fixed_begin(cont), offset + l))
? sprout::fixed::detail::make_heap_impl( ? sprout::fixed::detail::make_heap_impl(
sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + l), sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + n),
sprout::next(sprout::fixed_begin(cont), offset + l)
),
comp, comp,
offset, offset,
size, size,
@ -71,11 +80,23 @@ namespace sprout {
return r > size return r > size
? sprout::clone(cont) ? sprout::clone(cont)
: r == size : r == size
? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + l)) ? comp(*sprout::next(sprout::fixed_begin(cont), offset + n), *sprout::next(sprout::fixed_begin(cont), offset + l))
? sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + l) ? sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + n),
sprout::next(sprout::fixed_begin(cont), offset + l)
)
: sprout::clone(cont) : sprout::clone(cont)
: sprout::fixed::detail::make_heap_impl_1( : sprout::fixed::detail::make_heap_impl_1(
sprout::fixed::detail::make_heap_impl(sprout::fixed::detail::make_heap_impl(cont, comp, offset, size, l, l * 2 + 1, l * 2 + 2), comp, offset, size, r, r * 2 + 1, r * 2 + 2), sprout::fixed::detail::make_heap_impl(
sprout::fixed::detail::make_heap_impl(cont, comp, offset, size, l, l * 2 + 1, l * 2 + 2),
comp,
offset,
size,
r,
r * 2 + 1,
r * 2 + 2
),
comp, comp,
offset, offset,
size, size,

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include <sprout/algorithm/fixed/pop_heap.hpp> #include <sprout/algorithm/fixed/pop_heap.hpp>
@ -25,10 +26,14 @@ namespace sprout {
) )
{ {
return n < size return n < size
? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset)) ? comp(*sprout::next(sprout::fixed_begin(cont), offset + n), *sprout::next(sprout::fixed_begin(cont), offset))
? sprout::fixed::detail::make_partial_heap_impl_1( ? sprout::fixed::detail::make_partial_heap_impl_1(
sprout::fixed::detail::pop_heap_impl( sprout::fixed::detail::pop_heap_impl(
sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset), sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + n),
sprout::next(sprout::fixed_begin(cont), offset)
),
comp, comp,
offset, offset,
middle_size middle_size

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -31,7 +32,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return merge_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return merge_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args> template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -69,11 +70,11 @@ namespace sprout {
? first1 != last1 ? first1 != last1
? first2 != last2 ? first2 != last2
? comp(*first2, *first1) ? comp(*first2, *first1)
? merge_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) ? merge_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
: merge_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) : merge_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: merge_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) : merge_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: first2 != last2 : first2 != last2
? merge_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) ? merge_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
: merge_impl_3(result, args...) : merge_impl_3(result, args...)
: merge_impl_3(result, args...) : merge_impl_3(result, args...)
; ;
@ -111,7 +112,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? merge_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? merge_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: merge_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) : merge_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
; ;
} }

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include <sprout/algorithm/fixed/make_partial_heap.hpp> #include <sprout/algorithm/fixed/make_partial_heap.hpp>
@ -22,8 +23,8 @@ namespace sprout {
{ {
return sprout::fixed::swap_element( return sprout::fixed::swap_element(
cont, cont,
sprout::fixed_begin(cont) + offset, sprout::next(sprout::fixed_begin(cont), offset),
sprout::fixed_begin(cont) + offset + nth_size sprout::next(sprout::fixed_begin(cont), offset + nth_size)
); );
} }
template<typename Container, typename Compare> template<typename Container, typename Compare>

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -30,7 +31,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return partition_copy_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return partition_copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator, typename Result, typename Predicate, typename... Args> template<typename Iterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -62,8 +63,8 @@ namespace sprout {
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < offset
? pred(*first) ? pred(*first)
? partition_copy_impl_2(first + 1, last, result, pred, offset, *first, args...) ? partition_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args...)
: partition_copy_impl_2(first + 1, last, result, pred, offset, args..., *first) : partition_copy_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
: partition_copy_impl_3(result, args...) : partition_copy_impl_3(result, args...)
; ;
} }
@ -96,7 +97,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? partition_copy_impl_1(first, last, result, pred, offset, args..., *(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

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -22,10 +23,14 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::difference_type r = 2 typename sprout::fixed_container_traits<Container>::difference_type r = 2
) )
{ {
return r < size && comp(*(sprout::fixed_begin(cont) + offset + l), *(sprout::fixed_begin(cont) + offset + r)) return r < size && comp(*sprout::next(sprout::fixed_begin(cont), offset + l), *sprout::next(sprout::fixed_begin(cont), offset + r))
? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + r)) ? comp(*sprout::next(sprout::fixed_begin(cont), offset + n), *sprout::next(sprout::fixed_begin(cont), offset + r))
? sprout::fixed::detail::pop_heap_impl( ? sprout::fixed::detail::pop_heap_impl(
sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + r), sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + n),
sprout::next(sprout::fixed_begin(cont), offset + r)
),
comp, comp,
offset, offset,
size, size,
@ -35,9 +40,13 @@ namespace sprout {
) )
: sprout::clone(cont) : sprout::clone(cont)
: l < size : l < size
? comp(*(sprout::fixed_begin(cont) + offset + n), *(sprout::fixed_begin(cont) + offset + l)) ? comp(*sprout::next(sprout::fixed_begin(cont), offset + n), *sprout::next(sprout::fixed_begin(cont), offset + l))
? sprout::fixed::detail::pop_heap_impl( ? sprout::fixed::detail::pop_heap_impl(
sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + n, sprout::fixed_begin(cont) + offset + l), sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + n),
sprout::next(sprout::fixed_begin(cont), offset + l)
),
comp, comp,
offset, offset,
size, size,

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -19,9 +20,13 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::difference_type n typename sprout::fixed_container_traits<Container>::difference_type n
) )
{ {
return n != 0 && comp(*(sprout::fixed_begin(cont) + offset + (n - 1) / 2), *(sprout::fixed_begin(cont) + offset + n)) return n != 0 && comp(*sprout::next(sprout::fixed_begin(cont), offset + (n - 1) / 2), *sprout::next(sprout::fixed_begin(cont), offset + n))
? sprout::fixed::detail::push_heap_impl( ? sprout::fixed::detail::push_heap_impl(
sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + offset + (n - 1) / 2, sprout::fixed_begin(cont) + offset + n), sprout::fixed::swap_element(
cont,
sprout::next(sprout::fixed_begin(cont), offset + (n - 1) / 2),
sprout::next(sprout::fixed_begin(cont), offset + n)
),
comp, comp,
offset, offset,
(n - 1) / 2 (n - 1) / 2

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -30,7 +31,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return remove_copy_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return remove_copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator, typename Result, typename T, typename... Args> template<typename Iterator, typename Result, typename T, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -62,8 +63,8 @@ namespace sprout {
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < offset
? *first == value ? *first == value
? remove_copy_impl_2(first + 1, last, result, value, offset, args...) ? remove_copy_impl_2(sprout::next(first), last, result, value, offset, args...)
: remove_copy_impl_2(first + 1, last, result, value, offset, args..., *first) : remove_copy_impl_2(sprout::next(first), last, result, value, offset, args..., *first)
: remove_copy_impl_3(result, args...) : remove_copy_impl_3(result, args...)
; ;
} }
@ -96,7 +97,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? remove_copy_impl_1(first, last, result, value, offset, args..., *(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

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -30,7 +31,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return remove_copy_if_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return remove_copy_if_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator, typename Result, typename Predicate, typename... Args> template<typename Iterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -62,8 +63,8 @@ namespace sprout {
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < offset
? pred(*first) ? pred(*first)
? remove_copy_if_impl_2(first + 1, last, result, pred, offset, args...) ? remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args...)
: remove_copy_if_impl_2(first + 1, last, result, pred, offset, args..., *first) : remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
: remove_copy_if_impl_3(result, args...) : remove_copy_if_impl_3(result, args...)
; ;
} }
@ -96,7 +97,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? remove_copy_if_impl_1(first, last, result, pred, offset, args..., *(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

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -29,8 +30,8 @@ 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
? *(first + Indexes - offset) == old_value ? new_value : *(first + Indexes - offset) ? *sprout::next(first, Indexes - offset) == old_value ? new_value : *sprout::next(first, Indexes - offset)
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -29,8 +30,8 @@ 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
? pred(*(first + Indexes - offset)) ? new_value : *(first + Indexes - offset) ? pred(*sprout::next(first, Indexes - offset)) ? new_value : *sprout::next(first, Indexes - offset)
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -6,7 +6,9 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.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
@ -28,8 +30,8 @@ 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
? *(last - 1 - Indexes + offset) ? *sprout::prev(last, 1 + Indexes - offset)
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -29,10 +30,10 @@ namespace sprout {
sprout::size(result), sprout::size(result),
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size (Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
? (Indexes < offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(middle, last) ? (Indexes < offset + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(middle, last)
? *(middle + Indexes - offset) ? *sprout::next(middle, Indexes - offset)
: *((first + Indexes - offset) - NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, middle)) : *sprout::prev(sprout::next(first, Indexes - offset), NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, middle))
) )
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -31,7 +32,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return set_difference_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return set_difference_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args> template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -69,13 +70,13 @@ namespace sprout {
? first1 != last1 ? first1 != last1
? first2 != last2 ? first2 != last2
? comp(*first1, *first2) ? comp(*first1, *first2)
? set_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) ? set_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: comp(*first2, *first1) : comp(*first2, *first1)
? set_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) ? set_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
: set_difference_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args...) : set_difference_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args...)
: set_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) : set_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: first2 != last2 : first2 != last2
? set_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) ? set_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
: set_difference_impl_3(result, args...) : set_difference_impl_3(result, args...)
: set_difference_impl_3(result, args...) : set_difference_impl_3(result, args...)
; ;
@ -113,7 +114,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? set_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? set_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: set_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) : set_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
; ;
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -31,7 +32,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return set_intersection_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return set_intersection_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args> template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -69,13 +70,13 @@ namespace sprout {
? first1 != last1 ? first1 != last1
? first2 != last2 ? first2 != last2
? comp(*first1, *first2) ? comp(*first1, *first2)
? set_intersection_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args...) ? set_intersection_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args...)
: comp(*first2, *first1) : comp(*first2, *first1)
? set_intersection_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) ? set_intersection_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
: set_intersection_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args..., *first1) : set_intersection_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args..., *first1)
: set_intersection_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args...) : set_intersection_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args...)
: first2 != last2 : first2 != last2
? set_intersection_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args...) ? set_intersection_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
: set_intersection_impl_3(result, args...) : set_intersection_impl_3(result, args...)
: set_intersection_impl_3(result, args...) : set_intersection_impl_3(result, args...)
; ;
@ -113,7 +114,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? set_intersection_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? set_intersection_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: set_intersection_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) : set_intersection_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
; ;
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -31,7 +32,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return set_symmetric_difference_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return set_symmetric_difference_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args> template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -69,13 +70,13 @@ namespace sprout {
? first1 != last1 ? first1 != last1
? first2 != last2 ? first2 != last2
? comp(*first1, *first2) ? comp(*first1, *first2)
? set_symmetric_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) ? set_symmetric_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: comp(*first2, *first1) : comp(*first2, *first1)
? set_symmetric_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) ? set_symmetric_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
: set_symmetric_difference_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args...) : set_symmetric_difference_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args...)
: set_symmetric_difference_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) : set_symmetric_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: first2 != last2 : first2 != last2
? set_symmetric_difference_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) ? set_symmetric_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
: set_symmetric_difference_impl_3(result, args...) : set_symmetric_difference_impl_3(result, args...)
: set_symmetric_difference_impl_3(result, args...) : set_symmetric_difference_impl_3(result, args...)
; ;
@ -113,7 +114,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? set_symmetric_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? set_symmetric_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: set_symmetric_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) : set_symmetric_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
; ;
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -31,7 +32,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return set_union_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return set_union_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args> template<typename Iterator1, typename Iterator2, typename Result, typename Compare, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -69,13 +70,13 @@ namespace sprout {
? first1 != last1 ? first1 != last1
? first2 != last2 ? first2 != last2
? comp(*first1, *first2) ? comp(*first1, *first2)
? set_union_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) ? set_union_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: comp(*first2, *first1) : comp(*first2, *first1)
? set_union_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) ? set_union_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
: set_union_impl_2(first1 + 1, last1, first2 + 1, last2, result, comp, offset, args..., *first1) : set_union_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args..., *first1)
: set_union_impl_2(first1 + 1, last1, first2, last2, result, comp, offset, args..., *first1) : set_union_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
: first2 != last2 : first2 != last2
? set_union_impl_2(first1, last1, first2 + 1, last2, result, comp, offset, args..., *first2) ? set_union_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
: set_union_impl_3(result, args...) : set_union_impl_3(result, args...)
: set_union_impl_3(result, args...) : set_union_impl_3(result, args...)
; ;
@ -113,7 +114,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? set_union_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args))) ? set_union_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: set_union_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...) : set_union_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
; ;
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -20,7 +21,7 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::difference_type end typename sprout::fixed_container_traits<Container>::difference_type end
) )
{ // pivot を選ぶ(中央の要素) { // pivot を選ぶ(中央の要素)
return *(origin + (end + start) / 2); return *sprout::next(origin, (end + start) / 2);
} }
template<typename Container, typename Iterator, typename Compare> template<typename Container, typename Iterator, typename Compare>
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::difference_type sort_find_l( SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::difference_type sort_find_l(
@ -30,7 +31,7 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::value_type const& p typename sprout::fixed_container_traits<Container>::value_type const& p
) )
{ // left を見つける { // left を見つける
return comp(*(origin + l), p) ? sort_find_l<Container>(origin, comp, l + 1, p) : l; return comp(*sprout::next(origin, l), p) ? sort_find_l<Container>(origin, comp, l + 1, p) : l;
} }
template<typename Container, typename Iterator, typename Compare> template<typename Container, typename Iterator, typename Compare>
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::difference_type sort_find_r( SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::difference_type sort_find_r(
@ -40,7 +41,7 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::value_type const& p typename sprout::fixed_container_traits<Container>::value_type const& p
) )
{ // right を見つける { // right を見つける
return comp(p, *(origin + r)) ? sort_find_r<Container>(origin, comp, r - 1, p) : r; return comp(p, *sprout::next(origin, r)) ? sort_find_r<Container>(origin, comp, r - 1, p) : r;
} }
template<typename Container> template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type swap_lr( SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type swap_lr(
@ -93,7 +94,7 @@ namespace sprout {
{ // left と right 比較して、左右に分けてソートするか、またはスワップしてこの範囲のソートを続ける { // left と right 比較して、左右に分けてソートするか、またはスワップしてこの範囲のソートを続ける
return l >= r return l >= r
? sort_part_lr(cont, start, end, comp, l, r) ? sort_part_lr(cont, start, end, comp, l, r)
: sort_lr(sprout::fixed::swap_element(cont, sprout::fixed_begin(cont) + l, sprout::fixed_begin(cont) + r), start, end, comp, l + 1, r - 1, p) : sort_lr(sprout::fixed::swap_element(cont, sprout::next(sprout::fixed_begin(cont), l), sprout::next(sprout::fixed_begin(cont), r)), start, end, comp, l + 1, r - 1, p)
; ;
} }
template<typename Container, typename Compare> template<typename Container, typename Compare>

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/algorithm/fixed/swap_element.hpp> #include <sprout/algorithm/fixed/swap_element.hpp>
#include <sprout/algorithm/fixed/pop_heap.hpp> #include <sprout/algorithm/fixed/pop_heap.hpp>
@ -24,7 +25,7 @@ namespace sprout {
? sprout::clone(cont) ? sprout::clone(cont)
: sprout::fixed::detail::sort_heap_impl( : sprout::fixed::detail::sort_heap_impl(
sprout::fixed::detail::pop_heap_impl( sprout::fixed::detail::pop_heap_impl(
sprout::fixed::swap_element(cont, sprout::begin(cont), sprout::begin(cont) + size - 1), sprout::fixed::swap_element(cont, sprout::begin(cont), sprout::next(sprout::begin(cont), size - 1)),
comp, comp,
offset, offset,
size - 1 size - 1

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {
@ -30,7 +31,7 @@ namespace sprout {
Args const&... args Args const&... args
) )
{ {
return stable_partition_copy_impl_4(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args))); return stable_partition_copy_impl_4(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
} }
template<typename Iterator, typename Result, typename Predicate, typename... Args> template<typename Iterator, typename Result, typename Predicate, typename... Args>
@ -63,8 +64,8 @@ namespace sprout {
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < offset
? !pred(*first) ? !pred(*first)
? stable_partition_copy_impl_3(first + 1, 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(first + 1, last, result, pred, offset, args...) : stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args...)
: stable_partition_copy_impl_4(result, args...) : stable_partition_copy_impl_4(result, args...)
; ;
} }
@ -101,8 +102,8 @@ namespace sprout {
{ {
return first != last && sizeof...(Args) < offset return first != last && sizeof...(Args) < offset
? pred(*first) ? pred(*first)
? stable_partition_copy_impl_2(first + 1, 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(first + 1, 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...)
; ;
} }
@ -137,7 +138,7 @@ namespace sprout {
) )
{ {
return sizeof...(Args) < offset return sizeof...(Args) < offset
? stable_partition_copy_impl_1(first, last, result, pred, offset, origin, args..., *(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...)
; ;
} }

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -31,7 +32,7 @@ namespace sprout {
sprout::index_tuple<Indexes...> sprout::index_tuple<Indexes...>
) )
{ {
return sprout::remake_clone<Container, Container>(cont, sprout::size(cont), (*(sprout::fixed_begin(cont) + Indexes))...); return sprout::remake_clone<Container, Container>(cont, sprout::size(cont), (*sprout::next(sprout::fixed_begin(cont), Indexes))...);
} }
template<typename Container, typename Compare, std::ptrdiff_t I1, std::ptrdiff_t... Indexes, std::ptrdiff_t I2, std::ptrdiff_t... SortedIndexes, std::ptrdiff_t... NextIndexes, std::ptrdiff_t... PreIndexes, std::ptrdiff_t... PostIndexes> template<typename Container, typename Compare, std::ptrdiff_t I1, std::ptrdiff_t... Indexes, std::ptrdiff_t I2, std::ptrdiff_t... SortedIndexes, std::ptrdiff_t... NextIndexes, std::ptrdiff_t... PreIndexes, std::ptrdiff_t... PostIndexes>
SPROUT_CONSTEXPR inline typename std::enable_if< SPROUT_CONSTEXPR inline typename std::enable_if<
@ -47,7 +48,7 @@ namespace sprout {
sprout::index_tuple<PostIndexes...> sprout::index_tuple<PostIndexes...>
) )
{ {
return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) return comp(*sprout::next(sprout::fixed_begin(cont), I1), *sprout::next(sprout::fixed_begin(cont), I2))
? stable_sort_impl_finish(cont, sprout::index_tuple<PreIndexes..., NextIndexes..., I1, I2, SortedIndexes..., PostIndexes...>()) ? stable_sort_impl_finish(cont, sprout::index_tuple<PreIndexes..., NextIndexes..., I1, I2, SortedIndexes..., PostIndexes...>())
: stable_sort_impl_finish(cont, sprout::index_tuple<PreIndexes..., NextIndexes..., I2, I1, SortedIndexes..., PostIndexes...>()) : stable_sort_impl_finish(cont, sprout::index_tuple<PreIndexes..., NextIndexes..., I2, I1, SortedIndexes..., PostIndexes...>())
; ;
@ -66,7 +67,7 @@ namespace sprout {
sprout::index_tuple<PostIndexes...> sprout::index_tuple<PostIndexes...>
) )
{ {
return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) return comp(*sprout::next(sprout::fixed_begin(cont), I1), *sprout::next(sprout::fixed_begin(cont), I2))
? stable_sort_impl_finish(cont, sprout::index_tuple<PreIndexes..., NextIndexes..., I1, I2, SortedIndexes..., PostIndexes...>()) ? stable_sort_impl_finish(cont, sprout::index_tuple<PreIndexes..., NextIndexes..., I1, I2, SortedIndexes..., PostIndexes...>())
: stable_sort_impl_4(cont, comp, sprout::index_tuple<I1>(), sprout::index_tuple<SortedIndexes...>(), sprout::index_tuple<NextIndexes..., I2>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>()) : stable_sort_impl_4(cont, comp, sprout::index_tuple<I1>(), sprout::index_tuple<SortedIndexes...>(), sprout::index_tuple<NextIndexes..., I2>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>())
; ;
@ -85,7 +86,7 @@ namespace sprout {
sprout::index_tuple<PostIndexes...> sprout::index_tuple<PostIndexes...>
) )
{ {
return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) return comp(*sprout::next(sprout::fixed_begin(cont), I1), *sprout::next(sprout::fixed_begin(cont), I2))
? stable_sort_impl_4(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<NextIndexes..., I1, I2, SortedIndexes...>(), sprout::index_tuple<>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>()) ? stable_sort_impl_4(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<NextIndexes..., I1, I2, SortedIndexes...>(), sprout::index_tuple<>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>())
: stable_sort_impl_4(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<NextIndexes..., I2, I1, SortedIndexes...>(), sprout::index_tuple<>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>()) : stable_sort_impl_4(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<NextIndexes..., I2, I1, SortedIndexes...>(), sprout::index_tuple<>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>())
; ;
@ -104,7 +105,7 @@ namespace sprout {
sprout::index_tuple<PostIndexes...> sprout::index_tuple<PostIndexes...>
) )
{ {
return comp(*(sprout::fixed_begin(cont) + I1), *(sprout::fixed_begin(cont) + I2)) return comp(*sprout::next(sprout::fixed_begin(cont), I1), *sprout::next(sprout::fixed_begin(cont), I2))
? stable_sort_impl_4(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<NextIndexes..., I1, I2, SortedIndexes...>(), sprout::index_tuple<>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>()) ? stable_sort_impl_4(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<NextIndexes..., I1, I2, SortedIndexes...>(), sprout::index_tuple<>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>())
: stable_sort_impl_4(cont, comp, sprout::index_tuple<I1, Indexes...>(), sprout::index_tuple<SortedIndexes...>(), sprout::index_tuple<NextIndexes..., I2>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>()) : stable_sort_impl_4(cont, comp, sprout::index_tuple<I1, Indexes...>(), sprout::index_tuple<SortedIndexes...>(), sprout::index_tuple<NextIndexes..., I2>(), sprout::index_tuple<PreIndexes...>(), sprout::index_tuple<PostIndexes...>())
; ;

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -29,12 +30,12 @@ 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
? first + Indexes - offset == pos1 ? sprout::next(first, Indexes - offset) == pos1
? *pos2 ? *pos2
: first + Indexes - offset == pos2 : sprout::next(first, Indexes - offset) == pos2
? *pos1 ? *pos1
: *(first + Indexes - offset) : *sprout::next(first, Indexes - offset)
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.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
@ -28,8 +29,8 @@ 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
? op(*(first + Indexes - offset)) ? op(*sprout::next(first, Indexes - offset))
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }
@ -75,8 +76,8 @@ 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
? op(*(first1 + Indexes - offset), *(first2 + Indexes - offset)) ? op(*sprout::next(first1, Indexes - offset), *sprout::next(first2, Indexes - offset))
: *(sprout::fixed_begin(result) + Indexes) : *sprout::next(sprout::fixed_begin(result), Indexes)
)... )...
); );
} }

View file

@ -5,6 +5,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp> #include <sprout/algorithm/fixed/result_of.hpp>
namespace sprout { namespace sprout {

View file

@ -275,17 +275,17 @@ namespace std {
// //
template<std::size_t I, typename T, std::size_t N> template<std::size_t I, typename T, std::size_t N>
T& get(sprout::array<T, N>& arr) SPROUT_NOEXCEPT { T& get(sprout::array<T, N>& arr) SPROUT_NOEXCEPT {
static_assert(I < N, "tuple_element<>: index out of range"); static_assert(I < N, "get: index out of range");
return arr[I]; return arr[I];
} }
template<std::size_t I, typename T, std::size_t N> template<std::size_t I, typename T, std::size_t N>
SPROUT_CONSTEXPR T const& get(sprout::array<T, N> const& arr) SPROUT_NOEXCEPT { SPROUT_CONSTEXPR T const& get(sprout::array<T, N> const& arr) SPROUT_NOEXCEPT {
static_assert(I < N, "tuple_element<>: index out of range"); static_assert(I < N, "get: index out of range");
return arr[I]; return arr[I];
} }
template<std::size_t I, typename T, std::size_t N> template<std::size_t I, typename T, std::size_t N>
T&& get(sprout::array<T, N>&& arr) SPROUT_NOEXCEPT { T&& get(sprout::array<T, N>&& arr) SPROUT_NOEXCEPT {
return std::move(get<I>(arr)); return std::move(std::get<I>(arr));
} }
} // namespace std } // namespace std

View file

@ -3,6 +3,7 @@
#include <iterator> #include <iterator>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
namespace detail { namespace detail {
@ -42,7 +43,7 @@ namespace sprout {
{ {
return first == last return first == last
? 0 ? 0
: (*first == value ? 1 : 0) + sprout::detail::count(first + 1, last, value) : (*first == value ? 1 : 0) + sprout::detail::count(sprout::next(first), last, value)
; ;
} }
@ -58,7 +59,7 @@ namespace sprout {
{ {
return first == last return first == last
? 0 ? 0
: (pred(*first) ? 1 : 0) + sprout::detail::count_if(first + 1, last, pred); : (pred(*first) ? 1 : 0) + sprout::detail::count_if(sprout::next(first), last, pred);
} }
// //
@ -73,7 +74,7 @@ namespace sprout {
{ {
return first1 == last1 return first1 == last1
? true ? true
: *first1 == *first2 && sprout::detail::equal(first1 + 1, last1, first2 + 1) : *first1 == *first2 && sprout::detail::equal(sprout::next(first1), last1, sprout::next(first2))
; ;
} }
template<typename Iterator1, typename Iterator2, typename Predicate> template<typename Iterator1, typename Iterator2, typename Predicate>
@ -86,7 +87,7 @@ namespace sprout {
{ {
return first1 == last1 return first1 == last1
? true ? true
: pred(*first1, *first2) && sprout::detail::equal(first1 + 1, last1, first2 + 1, pred); : pred(*first1, *first2) && sprout::detail::equal(sprout::next(first1), last1, sprout::next(first2), pred);
} }
// //
@ -106,7 +107,7 @@ namespace sprout {
? true ? true
: *first2 < *first1 : *first2 < *first1
? false ? false
: sprout::detail::lexicographical_compare(first1 + 1, last1, first2 + 1, last2); : sprout::detail::lexicographical_compare(sprout::next(first1), last1, sprout::next(first2), last2);
} }
template<typename Iterator1, typename Iterator2, typename Compare> template<typename Iterator1, typename Iterator2, typename Compare>
SPROUT_CONSTEXPR bool lexicographical_compare( SPROUT_CONSTEXPR bool lexicographical_compare(
@ -123,7 +124,7 @@ namespace sprout {
? true ? true
: comp(*first2, *first1) : comp(*first2, *first1)
? false ? false
: sprout::detail::lexicographical_compare(first1 + 1, last1, first2 + 1, last2, comp); : sprout::detail::lexicographical_compare(sprout::next(first1), last1, sprout::next(first2), last2, comp);
} }
} // namespace detail } // namespace detail
} // namespace sprout } // namespace sprout

View file

@ -3,6 +3,7 @@
#include <iterator> #include <iterator>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
namespace detail { namespace detail {
@ -15,7 +16,7 @@ namespace sprout {
Iterator last Iterator last
) )
{ {
return first == last ? 0 : 1 + sprout::detail::distance(first + 1, last); return first == last ? 0 : 1 + sprout::detail::distance(sprout::next(first), last);
} }
template<typename Iterator> template<typename Iterator>
@ -30,7 +31,7 @@ namespace sprout {
? current ? current
: first2 == last : first2 == last
? -current ? -current
: sprout::detail::bidirectional_distance_impl(first1 + 1, first2 - 1, last, current + 1) : sprout::detail::bidirectional_distance_impl(sprout::next(first1), sprout::prev(first2), last, current + 1)
; ;
} }
// //
@ -42,7 +43,7 @@ namespace sprout {
Iterator last Iterator last
) )
{ {
return first == last ? 0 : sprout::detail::bidirectional_distance_impl(first + 1, first - 1, last); return first == last ? 0 : sprout::detail::bidirectional_distance_impl(sprout::next(first), sprout::prev(first), last);
} }
} // namespace detail } // namespace detail
} // namespace sprout } // namespace sprout

View file

@ -3,6 +3,7 @@
#include <iterator> #include <iterator>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
namespace detail { namespace detail {
@ -17,8 +18,8 @@ namespace sprout {
return first == last return first == last
? 0 ? 0
: *first == value : *first == value
? 1 + sprout::detail::overlap_count_impl(first + 1, last, value) ? 1 + sprout::detail::overlap_count_impl(sprout::next(first), last, value)
: sprout::detail::overlap_count_impl(first + 1, last, *first) : sprout::detail::overlap_count_impl(sprout::next(first), last, *first)
; ;
} }
// //
@ -32,7 +33,7 @@ namespace sprout {
{ {
return first == last return first == last
? 0 ? 0
: sprout::detail::overlap_count_impl(first + 1, last, *first) : sprout::detail::overlap_count_impl(sprout::next(first), last, *first)
; ;
} }
@ -47,8 +48,8 @@ namespace sprout {
return first == last return first == last
? 0 ? 0
: pred(*first, value) : pred(*first, value)
? 1 + sprout::detail::overlap_count_impl(first + 1, last, pred, value) ? 1 + sprout::detail::overlap_count_impl(sprout::next(first), last, pred, value)
: sprout::detail::overlap_count_impl(first + 1, last, pred, *first) : sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first)
; ;
} }
// //
@ -63,7 +64,7 @@ namespace sprout {
{ {
return first == last return first == last
? 0 ? 0
: sprout::detail::overlap_count_impl(first + 1, last, pred, *first) : sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first)
; ;
} }
} // namespace detail } // namespace detail

View file

@ -3,6 +3,7 @@
#include <iterator> #include <iterator>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
namespace detail { namespace detail {
@ -20,10 +21,10 @@ namespace sprout {
{ {
return first1 != last1 && first2 != last2 return first1 != last1 && first2 != last2
? comp(*first1, *first2) ? comp(*first1, *first2)
? sprout::detail::overlap_count_2(first1 + 1, last1, first2, last2, comp) ? sprout::detail::overlap_count_2(sprout::next(first1), last1, first2, last2, comp)
: comp(*first2, *first1) : comp(*first2, *first1)
? sprout::detail::overlap_count_2(first1, last1, first2 + 1, last2, comp) ? sprout::detail::overlap_count_2(first1, last1, sprout::next(first2), last2, comp)
: 1 + sprout::detail::overlap_count_2(first1 + 1, last1, first2 + 1, last2, comp) : 1 + sprout::detail::overlap_count_2(sprout::next(first1), last1, sprout::next(first2), last2, comp)
: 0 : 0
; ;
} }
@ -40,10 +41,10 @@ namespace sprout {
{ {
return first1 != last1 && first2 != last2 return first1 != last1 && first2 != last2
? *first1 < *first2 ? *first1 < *first2
? sprout::detail::overlap_count_2(first1 + 1, last1, first2, last2) ? sprout::detail::overlap_count_2(sprout::next(first1), last1, first2, last2)
: *first2 < *first1 : *first2 < *first1
? sprout::detail::overlap_count_2(first1, last1, first2 + 1, last2) ? sprout::detail::overlap_count_2(first1, last1, sprout::next(first2), last2)
: 1 + sprout::detail::overlap_count_2(first1 + 1, last1, first2 + 1, last2) : 1 + sprout::detail::overlap_count_2(sprout::next(first1), last1, sprout::next(first2), last2)
: 0 : 0
; ;
} }

View file

@ -4,6 +4,7 @@
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/functional/hash/hash_fwd.hpp> #include <sprout/functional/hash/hash_fwd.hpp>
namespace sprout { namespace sprout {
@ -162,7 +163,7 @@ namespace sprout {
template<typename Iterator> template<typename Iterator>
SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, Iterator first, Iterator last) { SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, Iterator first, Iterator last) {
return first != last return first != last
? sprout::hash_range(sprout::hash_combine(seed, *first), first + 1, last) ? sprout::hash_range(sprout::hash_combine(seed, *first), sprout::next(first), last)
: seed : seed
; ;
} }

View file

@ -2,8 +2,7 @@
#define SPROUT_ITERATOR_HPP #define SPROUT_ITERATOR_HPP
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/iterator/next.hpp> #include <sprout/iterator/operation.hpp>
#include <sprout/iterator/prev.hpp>
#include <sprout/iterator/reverse_iterator.hpp> #include <sprout/iterator/reverse_iterator.hpp>
#endif // #ifndef SPROUT_ITERATOR_HPP #endif // #ifndef SPROUT_ITERATOR_HPP

View file

@ -1,5 +1,6 @@
#ifndef SPROUT_ITERATOR_NEXT_HPP #ifndef SPROUT_ITERATOR_NEXT_HPP
#define SPROUT_ITERATOR_NEXT_HPP #define SPROUT_ITERATOR_NEXT_HPP
#include <iterator> #include <iterator>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
@ -59,6 +60,18 @@ namespace sprout {
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr) static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
); );
} }
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
)
{
return sprout::detail::next_impl(
sprout::forward<Iterator>(it),
n,
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
);
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_NEXT_HPP #endif // #ifndef SPROUT_ITERATOR_NEXT_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_ITERATOR_OPERATION_HPP
#define SPROUT_ITERATOR_OPERATION_HPP
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/prev.hpp>
#endif // #ifndef SPROUT_ITERATOR_OPERATION_HPP

View file

@ -60,6 +60,18 @@ namespace sprout {
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr) static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
); );
} }
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
)
{
return sprout::detail::prev_impl(
sprout::forward<Iterator>(it),
n,
static_cast<typename std::iterator_traits<typename std::decay<Iterator>::type>::iterator_category*>(nullptr)
);
}
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_PREV_HPP #endif // #ifndef SPROUT_ITERATOR_PREV_HPP

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout { namespace sprout {
@ -40,10 +41,10 @@ namespace sprout {
sprout::size(cont) + sprout::size(input), sprout::size(cont) + sprout::size(input),
(Indexes < sprout::fixed_container_traits<Container>::fixed_size + size (Indexes < sprout::fixed_container_traits<Container>::fixed_size + size
? (Indexes < pos ? (Indexes < pos
? *(sprout::fixed_begin(cont) + Indexes) ? *sprout::next(sprout::fixed_begin(cont), Indexes)
: Indexes < pos + size : Indexes < pos + size
? *(sprout::begin(input) + Indexes - pos) ? *sprout::next(sprout::begin(input), Indexes - pos)
: *(sprout::fixed_begin(cont) + Indexes - size) : *sprout::next(sprout::fixed_begin(cont), Indexes - size)
) )
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
@ -81,7 +82,7 @@ namespace sprout {
return sprout::fixed::detail::append_impl<typename sprout::fixed::result_of::append<Container, Input>::type>( return sprout::fixed::detail::append_impl<typename sprout::fixed::result_of::append<Container, Input>::type>(
cont, cont,
typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::append<Container, Input>::type>::fixed_size>::type(), typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::append<Container, Input>::type>::fixed_size>::type(),
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos), NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::next(sprout::begin(cont), pos)),
sprout::size(input), sprout::size(input),
input input
); );

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout { namespace sprout {
@ -39,8 +40,8 @@ namespace sprout {
sprout::size(cont) - 1, sprout::size(cont) - 1,
(Indexes < sprout::fixed_container_traits<Container>::fixed_size - 1 (Indexes < sprout::fixed_container_traits<Container>::fixed_size - 1
? (Indexes < pos ? (Indexes < pos
? *(sprout::fixed_begin(cont) + Indexes) ? *sprout::next(sprout::fixed_begin(cont), Indexes)
: *(sprout::fixed_begin(cont) + Indexes + 1) : *sprout::next(sprout::fixed_begin(cont), Indexes + 1)
) )
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
@ -74,7 +75,7 @@ namespace sprout {
return sprout::fixed::detail::erase_impl<typename sprout::fixed::result_of::erase<Container>::type>( return sprout::fixed::detail::erase_impl<typename sprout::fixed::result_of::erase<Container>::type>(
cont, cont,
typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::erase<Container>::type>::fixed_size>::type(), typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::erase<Container>::type>::fixed_size>::type(),
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos) NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::next(sprout::begin(cont), pos))
); );
} }
} // namespace fixed } // namespace fixed

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout { namespace sprout {
@ -39,8 +40,8 @@ namespace sprout {
sprout::size(cont) - N, sprout::size(cont) - N,
(Indexes < sprout::fixed_container_traits<Container>::fixed_size - N (Indexes < sprout::fixed_container_traits<Container>::fixed_size - N
? (Indexes < pos ? (Indexes < pos
? *(sprout::fixed_begin(cont) + Indexes) ? *sprout::next(sprout::fixed_begin(cont), Indexes)
: *(sprout::fixed_begin(cont) + Indexes + N) : *sprout::next(sprout::fixed_begin(cont), Indexes + N)
) )
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
@ -74,7 +75,7 @@ namespace sprout {
return sprout::fixed::detail::erase_n_impl<N, typename sprout::fixed::result_of::erase_n<N, Container>::type>( return sprout::fixed::detail::erase_n_impl<N, typename sprout::fixed::result_of::erase_n<N, Container>::type>(
cont, cont,
typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::erase_n<N, Container>::type>::fixed_size>::type(), typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::erase_n<N, Container>::type>::fixed_size>::type(),
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos) NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::next(sprout::begin(cont), pos))
); );
} }
} // namespace fixed } // namespace fixed

View file

@ -7,6 +7,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/detail/param_at.hpp> #include <sprout/detail/param_at.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -42,10 +43,10 @@ namespace sprout {
sprout::size(cont) + 1 + sizeof...(Values), sprout::size(cont) + 1 + sizeof...(Values),
(Indexes < sprout::fixed_container_traits<Container>::fixed_size + 1 + sizeof...(Values) (Indexes < sprout::fixed_container_traits<Container>::fixed_size + 1 + sizeof...(Values)
? (Indexes < pos ? (Indexes < pos
? *(sprout::fixed_begin(cont) + Indexes) ? *sprout::next(sprout::fixed_begin(cont), Indexes)
: Indexes < pos + 1 + sizeof...(Values) : Indexes < pos + 1 + sizeof...(Values)
? sprout::detail::param_at<typename sprout::fixed_container_traits<Result>::value_type>(Indexes - pos, v, values...) ? sprout::detail::param_at<typename sprout::fixed_container_traits<Result>::value_type>(Indexes - pos, v, values...)
: *(sprout::fixed_begin(cont) + Indexes - (1 + sizeof...(Values))) : *sprout::next(sprout::fixed_begin(cont), Indexes - (1 + sizeof...(Values)))
) )
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
@ -85,7 +86,7 @@ namespace sprout {
return sprout::fixed::detail::insert_impl<typename sprout::fixed::result_of::insert<Container, T, Values...>::type>( return sprout::fixed::detail::insert_impl<typename sprout::fixed::result_of::insert<Container, T, Values...>::type>(
cont, cont,
typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::insert<Container, T, Values...>::type>::fixed_size>::type(), typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::insert<Container, T, Values...>::type>::fixed_size>::type(),
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos), NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::next(sprout::begin(cont), pos)),
v, v,
values... values...
); );

View file

@ -7,6 +7,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/operation/fixed/insert.hpp> #include <sprout/operation/fixed/insert.hpp>
#include <sprout/detail/param_at.hpp> #include <sprout/detail/param_at.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -46,7 +47,7 @@ namespace sprout {
? *(sprout::fixed_begin(cont) + Indexes) ? *(sprout::fixed_begin(cont) + Indexes)
: Indexes < pos + (1 + sizeof...(Values)) * N : Indexes < pos + (1 + sizeof...(Values)) * N
? sprout::detail::param_at<typename sprout::fixed_container_traits<Result>::value_type>((Indexes - pos) % (1 + sizeof...(Values)), v, values...) ? sprout::detail::param_at<typename sprout::fixed_container_traits<Result>::value_type>((Indexes - pos) % (1 + sizeof...(Values)), v, values...)
: *(sprout::fixed_begin(cont) + Indexes - (1 + sizeof...(Values)) * N) : *sprout::next(sprout::fixed_begin(cont), Indexes - (1 + sizeof...(Values)) * N)
) )
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
@ -86,7 +87,7 @@ namespace sprout {
return sprout::fixed::detail::insert_n_impl<N, typename sprout::fixed::result_of::insert_n<N, Container, T, Values...>::type>( return sprout::fixed::detail::insert_n_impl<N, typename sprout::fixed::result_of::insert_n<N, Container, T, Values...>::type>(
cont, cont,
typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::insert_n<N, Container, T, Values...>::type>::fixed_size>::type(), typename sprout::index_range<0, sprout::fixed_container_traits<typename sprout::fixed::result_of::insert_n<N, Container, T, Values...>::type>::fixed_size>::type(),
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::begin(cont) + pos), NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::next(sprout::begin(cont), pos)),
v, v,
values... values...
); );

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -31,7 +32,7 @@ namespace sprout {
{ {
return sprout::make_clone<Result>( return sprout::make_clone<Result>(
(Indexes < size (Indexes < size
? *(sprout::begin(cont) + Indexes) ? *sprout::next(sprout::begin(cont), Indexes)
: v : v
)... )...
); );
@ -64,7 +65,7 @@ namespace sprout {
{ {
return sprout::make_clone<Result>( return sprout::make_clone<Result>(
(Indexes < size (Indexes < size
? *(sprout::begin(cont) + Indexes) ? *sprout::next(sprout::begin(cont), Indexes)
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
); );

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout { namespace sprout {
namespace fixed { namespace fixed {
@ -35,7 +36,7 @@ namespace sprout {
{ {
return sprout::make_clone<Result>( return sprout::make_clone<Result>(
(Indexes < size (Indexes < size
? *(sprout::begin(cont) + Indexes) ? *sprout::next(sprout::begin(cont), Indexes)
: v : v
)... )...
); );
@ -68,7 +69,7 @@ namespace sprout {
{ {
return sprout::make_clone<Result>( return sprout::make_clone<Result>(
(Indexes < size (Indexes < size
? *(sprout::begin(cont) + Indexes) ? *sprout::next(sprout::begin(cont), Indexes)
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
); );

View file

@ -6,6 +6,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/operation/fixed/resize.hpp> #include <sprout/operation/fixed/resize.hpp>
namespace sprout { namespace sprout {
@ -32,7 +33,7 @@ namespace sprout {
{ {
return sprout::make_clone<Result>( return sprout::make_clone<Result>(
(Indexes >= offset && Indexes < offset + size (Indexes >= offset && Indexes < offset + size
? *(sprout::begin(cont) + Indexes - offset) ? *sprout::next(sprout::begin(cont), Indexes - offset)
: v : v
)... )...
); );
@ -70,7 +71,7 @@ namespace sprout {
{ {
return sprout::make_clone<Result>( return sprout::make_clone<Result>(
(Indexes >= offset && Indexes < offset + size (Indexes >= offset && Indexes < offset + size
? *(sprout::begin(cont) + Indexes - offset) ? *sprout::next(sprout::begin(cont), Indexes - offset)
: typename sprout::fixed_container_traits<Result>::value_type() : typename sprout::fixed_container_traits<Result>::value_type()
)... )...
); );

View file

@ -851,17 +851,17 @@ namespace std {
// //
template<std::size_t I, typename T, std::size_t N, typename Traits> template<std::size_t I, typename T, std::size_t N, typename Traits>
T& get(sprout::basic_string<T, N, Traits>& arr) SPROUT_NOEXCEPT { T& get(sprout::basic_string<T, N, Traits>& arr) SPROUT_NOEXCEPT {
static_assert(I < N, "tuple_element<>: index out of range"); static_assert(I < N, "get: index out of range");
return arr[I]; return arr[I];
} }
template<std::size_t I, typename T, std::size_t N, typename Traits> template<std::size_t I, typename T, std::size_t N, typename Traits>
SPROUT_CONSTEXPR T const& get(sprout::basic_string<T, N, Traits> const& arr) SPROUT_NOEXCEPT { SPROUT_CONSTEXPR T const& get(sprout::basic_string<T, N, Traits> const& arr) SPROUT_NOEXCEPT {
static_assert(I < N, "tuple_element<>: index out of range"); static_assert(I < N, "get: index out of range");
return arr[I]; return arr[I];
} }
template<std::size_t I, typename T, std::size_t N, typename Traits> template<std::size_t I, typename T, std::size_t N, typename Traits>
T&& get(sprout::basic_string<T, N, Traits>&& arr) SPROUT_NOEXCEPT { T&& get(sprout::basic_string<T, N, Traits>&& arr) SPROUT_NOEXCEPT {
return std::move(get<I>(arr)); return std::move(std::get<I>(arr));
} }
} // namespace std } // namespace std

View file

@ -9,6 +9,7 @@
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/fixed_container/traits.hpp> #include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp> #include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/detail/if.hpp> #include <sprout/detail/if.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
@ -290,48 +291,48 @@ namespace sprout {
} }
} }
iterator begin() { iterator begin() {
return sprout::begin(get_array()) + first_; return sprout::next(sprout::begin(get_array()), first_);
} }
SPROUT_CONSTEXPR const_iterator begin() const { SPROUT_CONSTEXPR const_iterator begin() const {
return sprout::begin(get_array()) + first_; return sprout::next(sprout::begin(get_array()), first_);
} }
SPROUT_CONSTEXPR const_iterator cbegin() const { SPROUT_CONSTEXPR const_iterator cbegin() const {
return sprout::begin(get_array()) + first_; return sprout::next(sprout::begin(get_array()), first_);
} }
iterator end() { iterator end() {
return sprout::begin(get_array()) + last_; return sprout::next(sprout::begin(get_array()), last_);
} }
SPROUT_CONSTEXPR const_iterator end() const { SPROUT_CONSTEXPR const_iterator end() const {
return sprout::begin(get_array()) + last_; return sprout::next(sprout::begin(get_array()), last_);
} }
SPROUT_CONSTEXPR const_iterator cend() const { SPROUT_CONSTEXPR const_iterator cend() const {
return sprout::begin(get_array()) + last_; return sprout::next(sprout::begin(get_array()), last_);
} }
reference operator[](size_type i) { reference operator[](size_type i) {
return *(sprout::begin(get_array()) + first_ + i); return *sprout::next(sprout::begin(get_array()), first_ + i);
} }
SPROUT_CONSTEXPR const_reference operator[](size_type i) const { SPROUT_CONSTEXPR const_reference operator[](size_type i) const {
return *(sprout::begin(get_array()) + first_ + i); return *sprout::next(sprout::begin(get_array()), first_ + i);
} }
reference at(size_type i) { reference at(size_type i) {
rangecheck(i); rangecheck(i);
return *(sprout::begin(get_array()) + first_ + i); return *sprout::next(sprout::begin(get_array()), first_ + i);
} }
const_reference at(size_type i) const { const_reference at(size_type i) const {
rangecheck(i); rangecheck(i);
return *(sprout::begin(get_array()) + first_ + i); return *sprout::next(sprout::begin(get_array()), first_ + i);
} }
reference front() { reference front() {
return *(sprout::begin(get_array()) + first_); return *sprout::next(sprout::begin(get_array()), first_);
} }
SPROUT_CONSTEXPR const_reference front() const { SPROUT_CONSTEXPR const_reference front() const {
return *(sprout::begin(get_array()) + first_); return *sprout::next(sprout::begin(get_array()), first_);
} }
reference back() { reference back() {
return *(sprout::begin(get_array()) + (last_ - 1)); return *sprout::next(sprout::begin(get_array()), last_ - 1);
} }
SPROUT_CONSTEXPR const_reference back() const { SPROUT_CONSTEXPR const_reference back() const {
return *(sprout::begin(get_array()) + (last_ - 1)); return *sprout::next(sprout::begin(get_array()), last_ - 1);
} }
pointer data() { pointer data() {
return get_array().data() + first_; return get_array().data() + first_;
@ -506,8 +507,8 @@ namespace sprout {
{ {
return clone_type( return clone_type(
cloned, cloned,
sprout::begin(cloned) + sprout::fixed_begin_offset(other), sprout::next(sprout::begin(cloned), sprout::fixed_begin_offset(other)),
sprout::begin(cloned) + sprout::fixed_begin_offset(other) + size sprout::next(sprout::begin(cloned), sprout::fixed_begin_offset(other) + size)
); );
} }
template<typename Other> template<typename Other>
@ -519,8 +520,8 @@ namespace sprout {
{ {
return clone_type( return clone_type(
cloned, cloned,
sprout::begin(cloned) + sprout::fixed_begin_offset(other), sprout::next(sprout::begin(cloned), sprout::fixed_begin_offset(other)),
sprout::begin(cloned) + sprout::fixed_begin_offset(other) + size sprout::next(sprout::begin(cloned), sprout::fixed_begin_offset(other) + size)
); );
} }
public: public:
@ -770,7 +771,11 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::difference_type last typename sprout::fixed_container_traits<Container>::difference_type last
) )
{ {
return sprout::sub_array<typename Container::fixed_container_type const&>(arr.get_array(), sprout::begin(arr) + first, sprout::begin(arr) + last); return sprout::sub_array<typename Container::fixed_container_type const&>(
arr.get_array(),
sprout::next(sprout::begin(arr), first),
sprout::next(sprout::begin(arr), last)
);
} }
template<typename Container> template<typename Container>
SPROUT_CONSTEXPR inline typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::fixed_container_type const&> >::type csub( SPROUT_CONSTEXPR inline typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::fixed_container_type const&> >::type csub(
@ -859,7 +864,11 @@ namespace sprout {
typename sprout::fixed_container_traits<Container>::difference_type last typename sprout::fixed_container_traits<Container>::difference_type last
) )
{ {
return sprout::sub_array<typename Container::fixed_container_type>(arr.get_array(), sprout::begin(arr) + first, sprout::begin(arr) + last); return sprout::sub_array<typename Container::fixed_container_type>(
arr.get_array(),
sprout::next(sprout::begin(arr), first),
sprout::next(sprout::begin(arr), last)
);
} }
template<typename Container> template<typename Container>
SPROUT_CONSTEXPR inline typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::fixed_container_type> >::type sub_copy( SPROUT_CONSTEXPR inline typename std::enable_if<sprout::is_sub_array<Container>::value, sprout::sub_array<typename Container::fixed_container_type> >::type sub_copy(
@ -918,18 +927,18 @@ namespace std {
// get // get
// //
template<std::size_t I, typename T, typename Container> template<std::size_t I, typename T, typename Container>
T& get(sprout::sub_array<Container>& arr) SPROUT_NOEXCEPT { T& get(sprout::sub_array<Container>& arr) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*sprout::next(sprout::fixed_begin(arr), I))) {
static_assert(I < sprout::fixed_container_traits<sprout::sub_array<Container> >::fixed_size, "tuple_element<>: index out of range"); static_assert(I < sprout::fixed_container_traits<sprout::sub_array<Container> >::fixed_size, "get: index out of range");
return *(sprout::fixed_begin(arr) + I); return *sprout::next(sprout::fixed_begin(arr), I);
} }
template<std::size_t I, typename T, typename Container> template<std::size_t I, typename T, typename Container>
SPROUT_CONSTEXPR T const& get(sprout::sub_array<Container> const& arr) SPROUT_NOEXCEPT { SPROUT_CONSTEXPR T const& get(sprout::sub_array<Container> const& arr) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(*sprout::next(sprout::fixed_begin(arr), I))) {
static_assert(I < sprout::fixed_container_traits<sprout::sub_array<Container> >::fixed_size, "tuple_element<>: index out of range"); static_assert(I < sprout::fixed_container_traits<sprout::sub_array<Container> >::fixed_size, "get: index out of range");
return *(sprout::fixed_begin(arr) + I); return *sprout::next(sprout::fixed_begin(arr), I);
} }
template<std::size_t I, typename T, typename Container> template<std::size_t I, typename T, typename Container>
T&& get(sprout::sub_array<Container>&& arr) SPROUT_NOEXCEPT { T&& get(sprout::sub_array<Container>&& arr) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::move(std::get<I>(arr)))) {
return std::move(get<I>(arr)); return std::move(std::get<I>(arr));
} }
} // namespace std } // namespace std