tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
fill_n.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_FILL_N_HPP
5#define TETL_ALGORITHM_FILL_N_HPP
6
7namespace etl {
8
9/// Assigns the given value to the first count elements in the range
10/// beginning at `first` if `count > 0`. Does nothing otherwise.
11///
12/// \returns Iterator one past the last element assigned if `count > 0`, `first`
13/// otherwise.
14///
15/// \ingroup algorithm
16template <typename OutputIt, typename Size, typename T>
17constexpr auto fill_n(OutputIt first, Size count, T const& value) -> OutputIt
18{
19 for (auto i = Size{0}; i < count; ++i) {
20 *first = value;
21 ++first;
22 }
23 return first;
24}
25
26} // namespace etl
27
28#endif // TETL_ALGORITHM_FILL_N_HPP
constexpr auto fill_n(OutputIt first, Size count, T const &value) -> OutputIt
Assigns the given value to the first count elements in the range beginning at first if count > 0....
Definition fill_n.hpp:17
Definition adjacent_find.hpp:9