/// \file // Range v3 library // // Copyright Eric Niebler 2014-present // // 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 #include #include namespace ranges { /// \addtogroup group-algorithms /// @{ template using generate_result = detail::out_fun_result; RANGES_BEGIN_NIEBLOID(generate) /// \brief function template \c generate_n template auto RANGES_FUN_NIEBLOID(generate)(O first, S last, F fun) // ->CPP_ret(generate_result)( // requires invocable && output_iterator> && sentinel_for) { for(; first != last; ++first) *first = invoke(fun); return {detail::move(first), detail::move(fun)}; } /// \overload template auto RANGES_FUN_NIEBLOID(generate)(Rng && rng, F fun) ->CPP_ret(generate_result, F>)( // requires invocable && output_range>) { return {(*this)(begin(rng), end(rng), ref(fun)).out, detail::move(fun)}; } RANGES_END_NIEBLOID(generate) namespace cpp20 { using ranges::generate; using ranges::generate_result; } // namespace cpp20 /// @} } // namespace ranges #endif // include guard