tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
generate_n.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_GENERATE_N_HPP
4#define TETL_ALGORITHM_GENERATE_N_HPP
5
6namespace etl {
7
19template <typename OutputIt, typename SizeT, typename Generator>
20constexpr auto generate_n(OutputIt first, SizeT count, Generator g) -> OutputIt
21{
22 for (; count > 0; ++first, --count) {
23 *first = g();
24 }
25 return first;
26}
27
28} // namespace etl
29
30#endif // TETL_ALGORITHM_GENERATE_N_HPP
constexpr auto generate_n(OutputIt first, SizeT count, Generator g) -> OutputIt
Assigns values, generated by given function object g, to the first count elements in the range beginn...
Definition generate_n.hpp:20
constexpr auto count(InputIt first, InputIt last, T const &value) -> typename iterator_traits< InputIt >::difference_type
Returns the number of elements in the range [first, last) satisfying specific criteria....
Definition count.hpp:21
Definition adjacent_find.hpp:8