2012-09-21 06:43:30 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_FIT_UNFOLD_HPP
|
|
|
|
#define SPROUT_ALGORITHM_FIT_UNFOLD_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/container/traits.hpp>
|
|
|
|
#include <sprout/container/functions.hpp>
|
|
|
|
#include <sprout/algorithm/fixed/unfold.hpp>
|
|
|
|
#include <sprout/algorithm/fit/result_of.hpp>
|
2013-02-07 14:12:57 +00:00
|
|
|
#include <sprout/sub_array/sub_array.hpp>
|
|
|
|
#include <sprout/sub_array/sub.hpp>
|
2012-09-21 06:43:30 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace fit {
|
|
|
|
namespace detail {
|
2012-09-28 04:15:17 +00:00
|
|
|
template<typename Container, typename Generator, typename Init>
|
2012-09-29 08:10:46 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
|
|
|
unfold_impl(
|
|
|
|
Container const& cont, 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(cont, gen, init)),
|
2012-09-21 06:43:30 +00:00
|
|
|
offset,
|
|
|
|
offset + sprout::size(cont)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// unfold
|
|
|
|
//
|
2012-09-28 04:15:17 +00:00
|
|
|
template<typename Container, typename Generator, typename Init>
|
2012-09-29 08:10:46 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
|
|
|
unfold(Container const& cont, Generator const& gen, Init const& init) {
|
|
|
|
return sprout::fit::detail::unfold_impl(cont, 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_HPP
|