/// \file // Range v3 library // // Copyright Eric Niebler 2014 // // Use, modification and distribution is subject to 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) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_ALGORITHM_GENERATE_HPP #define RANGES_V3_ALGORITHM_GENERATE_HPP #include #include #include #include #include #include #include #include #include namespace ranges { inline namespace v3 { /// \addtogroup group-algorithms /// @{ struct generate_fn { template() && OutputIterator>() && Sentinel())> tagged_pair operator()(O begin, S end, F fun) const { for(; begin != end; ++begin) *begin = invoke(fun); return {detail::move(begin), detail::move(fun)}; } template, CONCEPT_REQUIRES_(Invocable() && OutputRange>())> tagged_pair), tag::fun(F)> operator()(Rng &&rng, F fun) const { return {(*this)(begin(rng), end(rng), ref(fun)).out(), detail::move(fun)}; } }; /// \sa `generate_fn` /// \ingroup group-algorithms RANGES_INLINE_VARIABLE(with_braced_init_args, generate) /// @} } // namespace v3 } // namespace ranges #endif // include guard