2012-09-21 06:43:30 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_FIT_UNFOLD_N_HPP
|
|
|
|
#define SPROUT_ALGORITHM_FIT_UNFOLD_N_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
|
|
|
#include <sprout/algorithm/fixed/unfold_n.hpp>
|
|
|
|
#include <sprout/algorithm/fit/result_of.hpp>
|
|
|
|
#include <sprout/sub_array.hpp>
|
|
|
|
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace fit {
|
|
|
|
namespace detail {
|
2012-09-28 04:15:17 +00:00
|
|
|
template<typename Container, typename Size, typename Generator, typename Init>
|
2012-09-29 08:10:46 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
|
|
|
unfold_n_impl(
|
|
|
|
Container const& cont, Size n, Generator const& gen, Init const& init,
|
|
|
|
typename sprout::container_traits<Container>::difference_type offset
|
2012-09-21 06:43:30 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::sub_copy(
|
2012-09-28 04:15:17 +00:00
|
|
|
sprout::get_internal(sprout::fixed::unfold_n(cont, n, gen, init)),
|
2012-09-21 06:43:30 +00:00
|
|
|
offset,
|
|
|
|
offset + NS_SSCRISK_CEL_OR_SPROUT::min(n, sprout::size(cont))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// unfold_n
|
|
|
|
//
|
2012-09-28 04:15:17 +00:00
|
|
|
template<typename Container, typename Size, typename Generator, typename Init>
|
2012-09-29 08:10:46 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
|
|
|
unfold_n(Container const& cont, Size n, Generator const& gen, Init const& init) {
|
|
|
|
return sprout::fit::detail::unfold_n_impl(cont, n, gen, init, sprout::internal_begin_offset(cont));
|
2012-09-21 06:43:30 +00:00
|
|
|
}
|
|
|
|
} // namespace fit
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ALGORITHM_FIT_UNFOLD_N_HPP
|