algorithm/* 実装変更

This commit is contained in:
bolero-MURAKAMI 2011-10-28 21:45:00 +09:00
parent 05e51dc01f
commit a79574f251
10 changed files with 106 additions and 484 deletions

View file

@ -81,7 +81,7 @@ namespace sprout {
)
{
return first != last && sizeof...(Args) < size
? copy_backward_impl(first, sprout::prev(last), result, size, *sprout::prev(last), args...)
? sprout::fixed::detail::copy_backward_impl(first, sprout::prev(last), result, size, *sprout::prev(last), args...)
: sprout::detail::container_complate_backward(result, args...)
;
}

View file

@ -15,8 +15,8 @@ namespace sprout {
template<typename Container, typename T, std::ptrdiff_t... Indexes>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type fill_impl(
Container const& cont,
sprout::index_tuple<Indexes...>,
T const& value,
sprout::index_tuple<Indexes...>,
typename sprout::fixed_container_traits<Container>::difference_type offset,
typename sprout::fixed_container_traits<Container>::size_type size
)
@ -42,8 +42,8 @@ namespace sprout {
{
return sprout::fixed::detail::fill_impl(
cont,
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type(),
value,
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type(),
sprout::fixed_begin_offset(cont),
sprout::size(cont)
);

View file

@ -22,8 +22,8 @@ namespace sprout {
{
return sprout::fixed::detail::fill_impl(
cont,
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type(),
value,
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type(),
sprout::fixed_begin_offset(cont),
n
);

View file

@ -113,7 +113,7 @@ namespace sprout {
)
{
return sizeof...(Args) < size
? generate_impl_1<InitSize>(cont, gen, size, args..., sprout::fixed::detail::call_gen<InitSize, Container>(gen, args...))
? sprout::fixed::detail::generate_impl_1<InitSize>(cont, gen, size, args..., sprout::fixed::detail::call_gen<InitSize, Container>(gen, args...))
: sprout::detail::container_complate(cont, args...)
;
}

View file

@ -1,49 +1,27 @@
#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP
#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
namespace sprout {
namespace fixed {
namespace detail {
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_impl_3(
Result const& result,
Args const&... args
)
{
return remove_copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename InputIterator, typename Result, typename T, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_impl_2(
>::type remove_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
T const& value,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -53,65 +31,22 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_impl_2(
>::type remove_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
T const& value,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
return first != last && sizeof...(Args) < size
? *first == value
? remove_copy_impl_2(sprout::next(first), last, result, value, offset, args...)
: remove_copy_impl_2(sprout::next(first), last, result, value, offset, args..., *first)
: remove_copy_impl_3(result, args...)
? sprout::fixed::detail::remove_copy_impl(sprout::next(first), last, result, value, size, args...)
: sprout::fixed::detail::remove_copy_impl(sprout::next(first), last, result, value, size, args..., *first)
: sprout::detail::container_complate(result, args...)
;
}
template<typename InputIterator, typename Result, typename T, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
T const& value,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename InputIterator, typename Result, typename T, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
T const& value,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? remove_copy_impl_1(first, last, result, value, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: remove_copy_impl_2(first, last, result, value, offset + sprout::size(result), args...)
;
}
template<typename InputIterator, typename Result, typename T>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type remove_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
T const& value
)
{
return remove_copy_impl_1(first, last, result, value, sprout::fixed_begin_offset(result));
}
} // namespace detail
//
// remove_copy
@ -124,7 +59,7 @@ namespace sprout {
T const& value
)
{
return sprout::fixed::detail::remove_copy_impl(first, last, result, value);
return sprout::fixed::detail::remove_copy_impl(first, last, result, value, sprout::size(result));
}
} // namespace fixed

View file

@ -1,49 +1,27 @@
#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP
#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
namespace sprout {
namespace fixed {
namespace detail {
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_if_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_if_impl_3(
Result const& result,
Args const&... args
)
{
return remove_copy_if_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename InputIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_if_impl_2(
>::type remove_copy_if_impl(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -53,65 +31,22 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_if_impl_2(
>::type remove_copy_if_impl(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
return first != last && sizeof...(Args) < size
? pred(*first)
? remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args...)
: remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
: remove_copy_if_impl_3(result, args...)
? sprout::fixed::detail::remove_copy_if_impl(sprout::next(first), last, result, pred, size, args...)
: sprout::fixed::detail::remove_copy_if_impl(sprout::next(first), last, result, pred, size, args..., *first)
: sprout::detail::container_complate(result, args...)
;
}
template<typename InputIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_if_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename InputIterator, typename Result, typename Predicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type remove_copy_if_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? remove_copy_if_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: remove_copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
;
}
template<typename InputIterator, typename Result, typename Predicate>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type remove_copy_if_impl(
InputIterator first,
InputIterator last,
Result const& result,
Predicate pred
)
{
return remove_copy_if_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result));
}
} // namespace detail
//
// remove_copy_if
@ -124,7 +59,7 @@ namespace sprout {
Predicate pred
)
{
return sprout::fixed::detail::remove_copy_if_impl(first, last, result, pred);
return sprout::fixed::detail::remove_copy_if_impl(first, last, result, pred, sprout::size(result));
}
} // namespace fixed

View file

@ -10,6 +10,7 @@
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
@ -53,37 +54,15 @@ namespace sprout {
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last)
);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type reverse_copy_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type reverse_copy_impl_3(
Result const& result,
Args const&... args
)
{
return reverse_copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename BidirectionalIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type reverse_copy_impl_2(
>::type reverse_copy_impl(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -93,59 +72,19 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type reverse_copy_impl_2(
>::type reverse_copy_impl(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? reverse_copy_impl_2(first, sprout::prev(last), result, offset, args..., *sprout::prev(last))
: reverse_copy_impl_3(result, args...)
return first != last && sizeof...(Args) < size
? sprout::fixed::detail::reverse_copy_impl(first, sprout::prev(last), result, size, args..., *sprout::prev(last))
: sprout::detail::container_complate(result, args...)
;
}
template<typename BidirectionalIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type reverse_copy_impl_1(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename BidirectionalIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type reverse_copy_impl_1(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? reverse_copy_impl_1(first, last, result, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: reverse_copy_impl_2(first, last, result, offset + sprout::size(result), args...)
;
}
template<typename BidirectionalIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type reverse_copy_impl(
BidirectionalIterator first,
BidirectionalIterator last,
Result const& result
)
{
return reverse_copy_impl_1(first, last, result, sprout::fixed_begin_offset(result));
}
template<typename BidirectionalIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type reverse_copy(
BidirectionalIterator first,
@ -154,11 +93,7 @@ namespace sprout {
void*
)
{
return sprout::fixed::detail::reverse_copy_impl(
first,
last,
result
);
return sprout::fixed::detail::reverse_copy_impl(first, last, result, sprout::size(result));
}
} // namespace detail
//
@ -172,12 +107,7 @@ namespace sprout {
)
{
typedef typename std::iterator_traits<BidirectionalIterator>::iterator_category* category;
return sprout::fixed::detail::reverse_copy(
first,
last,
result,
category()
);
return sprout::fixed::detail::reverse_copy(first, last, result, category());
}
} // namespace fixed

View file

@ -10,6 +10,7 @@
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
@ -59,104 +60,15 @@ namespace sprout {
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last)
);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_4(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_4(
Result const& result,
Args const&... args
)
{
return rotate_copy_impl_4(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
}
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_3(
ForwardIterator first,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_3(
ForwardIterator first,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? rotate_copy_impl_3(sprout::next(first), last, result, offset, args..., *first)
: rotate_copy_impl_4(result, args...)
;
}
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_2(
ForwardIterator first,
ForwardIterator middle,
ForwardIterator middle_first,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_2(
ForwardIterator first,
ForwardIterator middle,
ForwardIterator middle_first,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return middle_first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
? rotate_copy_impl_2(first, middle, sprout::next(middle_first), last, result, offset, args..., *middle_first)
: rotate_copy_impl_3(first, middle, result, offset, args...)
;
}
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_1(
ForwardIterator first,
ForwardIterator middle,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
@ -168,27 +80,51 @@ namespace sprout {
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl_1(
ForwardIterator first,
ForwardIterator middle,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? rotate_copy_impl_1(first, middle, last, result, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
: rotate_copy_impl_2(first, middle, middle, last, result, offset + sprout::size(result), args...)
return first != last && sizeof...(Args) < size
? sprout::fixed::detail::rotate_copy_impl_1(sprout::next(first), last, result, size, args..., *first)
: sprout::detail::container_complate(result, args...)
;
}
template<typename ForwardIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type rotate_copy_impl(
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl(
ForwardIterator first,
ForwardIterator middle,
ForwardIterator middle_first,
ForwardIterator last,
Result const& result
Result const& result,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return rotate_copy_impl_1(first, middle, last, result, sprout::fixed_begin_offset(result));
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename ForwardIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type rotate_copy_impl(
ForwardIterator first,
ForwardIterator middle,
ForwardIterator middle_first,
ForwardIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::size_type size,
Args const&... args
)
{
return middle_first != last && sizeof...(Args) < size
? sprout::fixed::detail::rotate_copy_impl(first, middle, sprout::next(middle_first), last, result, size, args..., *middle_first)
: sprout::fixed::detail::rotate_copy_impl_1(first, middle, result, size, args...)
;
}
template<typename ForwardIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type rotate_copy(
@ -199,12 +135,7 @@ namespace sprout {
void*
)
{
return sprout::fixed::detail::rotate_copy_impl(
first,
middle,
last,
result
);
return sprout::fixed::detail::rotate_copy_impl(first, middle, last, result, sprout::size(result));
}
} // namespace detail
//
@ -219,13 +150,7 @@ namespace sprout {
)
{
typedef typename std::iterator_traits<ForwardIterator>::iterator_category* category;
return sprout::fixed::detail::rotate_copy(
first,
middle,
last,
result,
category()
);
return sprout::fixed::detail::rotate_copy(first, middle, last, result, category());
}
} // namespace fixed

View file

@ -119,7 +119,7 @@ namespace sprout {
namespace detail {
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename Result, typename BinaryOperation, std::ptrdiff_t... Indexes>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type transform2_impl_ra(
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type transform_impl_ra(
RandomAccessIterator1 first1,
RandomAccessIterator1 last1,
RandomAccessIterator2 first2,
@ -141,7 +141,7 @@ namespace sprout {
);
}
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename Result, typename BinaryOperation>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type transform2(
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type transform(
RandomAccessIterator1 first1,
RandomAccessIterator1 last1,
RandomAccessIterator2 first2,
@ -150,7 +150,7 @@ namespace sprout {
std::random_access_iterator_tag*
)
{
return sprout::fixed::detail::transform2_impl_ra(
return sprout::fixed::detail::transform_impl_ra(
first1,
last1,
first2,
@ -166,7 +166,7 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type transform2_impl(
>::type transform_impl(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
@ -182,7 +182,7 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type transform2_impl(
>::type transform_impl(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
@ -193,12 +193,12 @@ namespace sprout {
)
{
return first1 != last1 && sizeof...(Args) < size
? sprout::fixed::detail::transform2_impl(sprout::next(first1), last1, sprout::next(first2), result, op, size, args..., op(*first1, *first2))
? sprout::fixed::detail::transform_impl(sprout::next(first1), last1, sprout::next(first2), result, op, size, args..., op(*first1, *first2))
: sprout::detail::container_complate(result, args...)
;
}
template<typename InputIterator1, typename InputIterator2, typename Result, typename BinaryOperation>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type transform2(
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type transform(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
@ -207,7 +207,7 @@ namespace sprout {
void*
)
{
return sprout::fixed::detail::transform2_impl(first1, last1, first2, result, op, sprout::size(result));
return sprout::fixed::detail::transform_impl(first1, last1, first2, result, op, sprout::size(result));
}
} // namespace detail
//
@ -223,7 +223,7 @@ namespace sprout {
)
{
typedef typename std::iterator_traits<InputIterator1>::iterator_category* category;
return sprout::fixed::detail::transform2(first1, last1, first2, result, op, category());
return sprout::fixed::detail::transform(first1, last1, first2, result, op, category());
}
} // namespace fixed

View file

@ -1,48 +1,26 @@
#ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP
#define SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/fixed_container/traits.hpp>
#include <sprout/fixed_container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/detail/container_complate.hpp>
namespace sprout {
namespace fixed {
namespace detail {
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_3(
Result const& result,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_3(
Result const& result,
Args const&... args
)
{
return unique_copy_impl_3(result, args..., *(sprout::fixed_begin(result) + sizeof...(Args)));
}
template<typename InputIterator, typename Result, typename Head, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args) + 1,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_2(
>::type unique_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Head const& head,
Args const&... args
)
@ -53,64 +31,22 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args) + 1,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_2(
>::type unique_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Head const& head,
Args const&... args
)
{
return first != last && sizeof...(Args) + 1 < static_cast<std::size_t>(offset)
return first != last && sizeof...(Args) + 1 < size
? !(head == *first)
? unique_copy_impl_2(sprout::next(first), last, result, offset, *first, args..., head)
: unique_copy_impl_2(sprout::next(first), last, result, offset, head, args...)
: unique_copy_impl_3(result, args..., head)
? unique_copy_impl(sprout::next(first), last, result, size, *first, args..., head)
: unique_copy_impl(sprout::next(first), last, result, size, head, args...)
: sprout::detail::container_complate(result, args..., head)
;
}
template<typename InputIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename InputIterator, typename Result, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? unique_copy_impl_1(first, last, result, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args)))
: first != last
? unique_copy_impl_2(sprout::next(first), last, result, offset + sprout::size(result), *first, args...)
: unique_copy_impl_3(result, args...)
;
}
template<typename InputIterator, typename Result>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type unique_copy_impl(
InputIterator first,
InputIterator last,
Result const& result
)
{
return unique_copy_impl_1(first, last, result, sprout::fixed_begin_offset(result));
}
} // namespace detail
//
// unique_copy
@ -122,7 +58,10 @@ namespace sprout {
Result const& result
)
{
return sprout::fixed::detail::unique_copy_impl(first, last, result);
return first != last
? sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, sprout::size(result), *first)
: sprout::detail::container_complate(result)
;
}
namespace detail {
@ -130,12 +69,12 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args) + 1,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_2(
>::type unique_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
BinaryPredicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Head const& head,
Args const&... args
)
@ -146,68 +85,23 @@ namespace sprout {
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args) + 1,
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_2(
>::type unique_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
BinaryPredicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
typename sprout::fixed_container_traits<Result>::size_type size,
Head const& head,
Args const&... args
)
{
return first != last && sizeof...(Args) + 1 < static_cast<std::size_t>(offset)
return first != last && sizeof...(Args) + 1 < size
? !pred(head, *first)
? unique_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args..., head)
: unique_copy_impl_2(sprout::next(first), last, result, pred, offset, head, args...)
: unique_copy_impl_3(result, args..., head)
? sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, pred, size, *first, args..., head)
: sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, pred, size, head, args...)
: sprout::detail::container_complate(result, args..., head)
;
}
template<typename InputIterator, typename Result, typename BinaryPredicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
BinaryPredicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
}
template<typename InputIterator, typename Result, typename BinaryPredicate, typename... Args>
SPROUT_CONSTEXPR inline typename std::enable_if<
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
typename sprout::fixed::result_of::algorithm<Result>::type
>::type unique_copy_impl_1(
InputIterator first,
InputIterator last,
Result const& result,
BinaryPredicate pred,
typename sprout::fixed_container_traits<Result>::difference_type offset,
Args const&... args
)
{
return sizeof...(Args) < static_cast<std::size_t>(offset)
? unique_copy_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args)))
: first != last
? unique_copy_impl_2(sprout::next(first), last, result, pred, offset + sprout::size(result), *first, args...)
: unique_copy_impl_3(result, args...)
;
}
template<typename InputIterator, typename Result, typename BinaryPredicate>
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type unique_copy_impl(
InputIterator first,
InputIterator last,
Result const& result,
BinaryPredicate pred
)
{
return unique_copy_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result));
}
} // namespace detail
//
// unique_copy
@ -220,7 +114,10 @@ namespace sprout {
BinaryPredicate pred
)
{
return sprout::fixed::detail::unique_copy_impl(first, last, result, pred);
return first != last
? sprout::fixed::detail::unique_copy_impl(sprout::next(first), last, result, pred, sprout::size(result), *first)
: sprout::detail::container_complate(result)
;
}
} // namespace fixed