tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
generate.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4
#
ifndef
TETL_ALGORITHM_GENERATE_HPP
5
#
define
TETL_ALGORITHM_GENERATE_HPP
6
7
namespace
etl
{
8
9
/// \brief Assigns each element in range `[first, last)` a value generated by
10
/// the given function object g.
11
///
12
/// \param first The range of elements to generate.
13
/// \param last The range of elements to generate.
14
/// \param g Generator function object that will be called.
15
///
16
/// https://en.cppreference.com/w/cpp/algorithm/generate
17
///
18
/// \ingroup algorithm
19
template
<
typename
ForwardIt,
typename
Generator>
20
constexpr
auto
generate
(ForwardIt first, ForwardIt last, Generator g) ->
void
21
{
22
for
(; first != last; ++first) {
23
*first = g();
24
}
25
}
26
27
}
// namespace etl
28
29
#
endif
// TETL_ALGORITHM_GENERATE_HPP
etl::generate
constexpr auto generate(ForwardIt first, ForwardIt last, Generator g) -> void
Assigns each element in range [first, last) a value generated by the given function object g.
Definition
generate.hpp:20
etl
Definition
adjacent_find.hpp:9
include
etl
_algorithm
generate.hpp
Generated on Sun Sep 7 2025 19:14:46 for tetl by
1.9.8