tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
destroy_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_MEMORY_DESTROY_N_HPP
5#define TETL_MEMORY_DESTROY_N_HPP
6
7#include <etl/_memory/addressof.hpp>
8#include <etl/_memory/destroy_at.hpp>
9
10namespace etl {
11
12/// \brief Destroys the n objects in the range starting at first.
13template <typename ForwardIt, typename Size>
14constexpr auto destroy_n(ForwardIt first, Size n) -> ForwardIt
15{
16 for (; n > 0; (void)++first, --n) {
17 etl::destroy_at(etl::addressof(*first));
18 }
19 return first;
20}
21
22} // namespace etl
23
24#endif // TETL_MEMORY_DESTROY_N_HPP
Definition adjacent_find.hpp:9
constexpr auto destroy_n(ForwardIt first, Size n) -> ForwardIt
Destroys the n objects in the range starting at first.
Definition destroy_n.hpp:14