diff --git a/sprout/algorithm/fixed/generate_n.hpp b/sprout/algorithm/fixed/generate_n.hpp index 91c06e95..6566c0c6 100644 --- a/sprout/algorithm/fixed/generate_n.hpp +++ b/sprout/algorithm/fixed/generate_n.hpp @@ -32,7 +32,20 @@ namespace sprout { } } // namespace fixed - using sprout::fixed::generate_n; + template< + typename Container, typename Size, typename Generator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + generate_n(Container const& cont, Size n, Generator const& gen) { + return sprout::fixed::generate_n(cont, n, gen); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + generate_n(Size n, Generator const& gen) { + return sprout::fixed::generate_n(n, gen); + } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_GENERATE_N_HPP diff --git a/sprout/algorithm/generate.hpp b/sprout/algorithm/generate.hpp index 3115eefa..38fc1721 100644 --- a/sprout/algorithm/generate.hpp +++ b/sprout/algorithm/generate.hpp @@ -9,6 +9,20 @@ #define SPROUT_ALGORITHM_GENERATE_HPP #include + +namespace sprout { + // + // 25.3.7 Generate + // + template + inline SPROUT_CXX14_CONSTEXPR void + generate(ForwrdIterator first, ForwrdIterator last, Generator gen) { + while (first != last) { + *first++ = gen(); + } + } +} // namespace sprout + #include #include diff --git a/sprout/algorithm/generate_n.hpp b/sprout/algorithm/generate_n.hpp index a865f6ac..20ad4393 100644 --- a/sprout/algorithm/generate_n.hpp +++ b/sprout/algorithm/generate_n.hpp @@ -9,6 +9,24 @@ #define SPROUT_ALGORITHM_GENERATE_N_HPP #include + +namespace sprout { + // + // 25.3.7 Generate + // + template< + typename OutputIterator, typename Size, typename Generator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + generate_n(OutputIterator first, Size n, Generator gen) { + while (n-- > 0) { + *first++ = gen(); + } + return first; + } +} // namespace sprout + #include #include