/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_NUMERIC_FIXED_IOTA_HPP #define SPROUT_NUMERIC_FIXED_IOTA_HPP #include #include #include #include #include #include #include #include #include namespace sprout { namespace fixed { namespace detail { template inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type iota_impl( Container const& cont, sprout::index_tuple, T value, typename sprout::container_traits::difference_type offset, typename sprout::container_traits::size_type size ) { return sprout::remake( cont, sprout::size(cont), (Indexes >= offset && Indexes < offset + size ? static_cast::value_type>(value + (Indexes - offset)) : *sprout::next(sprout::internal_begin(cont), Indexes) )... ); } template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::is_fixed_container::value, typename sprout::fixed::results::algorithm::type >::type iota(Container const& cont, T value) { return sprout::fixed::detail::iota_impl( cont, sprout::container_indexes::make(), value, sprout::internal_begin_offset(cont), sprout::size(cont) ); } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::is_fixed_container::value, typename sprout::fixed::results::algorithm::type >::type iota(Container const& cont, T value) { return sprout::remake( cont, sprout::size(cont), sprout::make_counting_iterator(value), sprout::next(sprout::make_counting_iterator(value), sprout::size(cont)) ); } } // namespace detail // // iota // template inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type iota(Container const& cont, T value) { return sprout::fixed::detail::iota(cont, value); } template inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm::type iota(T value) { return sprout::fixed::detail::iota(sprout::pit(), value); } } // namespace fixed using sprout::fixed::iota; } // namespace sprout #endif // #ifndef SPROUT_NUMERIC_FIXED_IOTA_HPP