#ifndef SPROUT_ALGORITHM_FIXED_GENERATE_HPP #define SPROUT_ALGORITHM_FIXED_GENERATE_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace fixed { namespace detail { template SPROUT_CONSTEXPR inline typename std::enable_if< InitSize == 0, typename sprout::container_traits::value_type >::type call_gen( Generator gen, Args const&... args ) { return gen(); } template SPROUT_CONSTEXPR inline typename std::enable_if< InitSize != 0 && InitSize == sizeof...(Args) + 1, typename sprout::container_traits::value_type >::type call_gen( Generator gen, Head const& head, Args const&... args ) { return gen(head, args...); } template SPROUT_CONSTEXPR inline typename std::enable_if< InitSize != 0 && InitSize != sizeof...(Args) + 1, typename sprout::container_traits::value_type >::type call_gen( Generator gen, Head const& head, Args const&... args ) { return call_gen(gen, args...); } template SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type generate_impl_drop( Container const& cont, Generator gen, typename sprout::container_traits::size_type size ) { return sprout::detail::container_complate(cont); } template SPROUT_CONSTEXPR inline typename std::enable_if< (sprout::container_traits::static_size >= sizeof...(Inits) + 1), typename sprout::fixed::result_of::algorithm::type >::type generate_impl_drop( Container const& cont, Generator gen, typename sprout::container_traits::size_type size, Head const& head, Inits const&... inits ) { return size < sizeof...(Inits) + 1 ? sprout::fixed::detail::generate_impl_drop(cont, gen, size, inits...) : sprout::detail::container_complate(cont, head, inits...) ; } template SPROUT_CONSTEXPR inline typename std::enable_if< (sprout::container_traits::static_size < sizeof...(Inits) + 1), typename sprout::fixed::result_of::algorithm::type >::type generate_impl_drop( Container const& cont, Generator gen, typename sprout::container_traits::size_type size, Head const& head, Inits const&... inits ) { return sprout::fixed::detail::generate_impl_drop(cont, gen, size, inits...); } template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::container_traits::static_size == sizeof...(Args), typename sprout::fixed::result_of::algorithm::type >::type generate_impl_1( Container const& cont, Generator gen, typename sprout::container_traits::size_type size, Args const&... args ) { return sprout::remake(cont, sprout::size(cont), args...); } template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::container_traits::static_size != sizeof...(Args), typename sprout::fixed::result_of::algorithm::type >::type generate_impl_1( Container const& cont, Generator gen, typename sprout::container_traits::size_type size, Args const&... args ) { return sizeof...(Args) < size ? sprout::fixed::detail::generate_impl_1(cont, gen, size, args..., sprout::fixed::detail::call_gen(gen, args...)) : sprout::detail::container_complate(cont, args...) ; } template SPROUT_CONSTEXPR inline typename std::enable_if< (sprout::container_traits::static_size > sizeof...(Inits)), typename sprout::fixed::result_of::algorithm::type >::type generate_impl( Container const& cont, Generator gen, typename sprout::container_traits::size_type size, Inits const&... inits ) { return sizeof...(Inits) < size ? sprout::fixed::detail::generate_impl_1(cont, gen, size, inits...) : sprout::fixed::detail::generate_impl_drop(cont, gen, size, inits...) ; } template SPROUT_CONSTEXPR inline typename std::enable_if< (sprout::container_traits::static_size <= sizeof...(Inits)), typename sprout::fixed::result_of::algorithm::type >::type generate_impl( Container const& cont, Generator gen, typename sprout::container_traits::size_type size, Inits const&... inits ) { return sprout::fixed::detail::generate_impl_drop(cont, gen, size, inits...); } } // namespace detail // // generate // template SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm::type generate( Container const& cont, Generator gen, Inits const&... inits ) { return sprout::fixed::detail::generate_impl(cont, gen, sprout::size(cont), inits...); } } // namespace fixed using sprout::fixed::generate; } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_GENERATE_HPP