tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
destroy_at.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_AT_HPP
5
#
define
TETL_MEMORY_DESTROY_AT_HPP
6
7
#
include
<
etl
/
_memory
/
addressof
.
hpp
>
8
#
include
<
etl
/
_type_traits
/
is_array
.
hpp
>
9
10
namespace
etl
{
11
12
/// \brief If T is not an array type, calls the destructor of the object pointed
13
/// to by p, as if by p->~T(). If T is an array type, recursively destroys
14
/// elements of *p in order, as if by calling destroy(begin(*p),
15
/// end(*p)).
16
template
<
typename
T>
17
constexpr
auto
destroy_at
(T* p) ->
void
18
{
19
if
constexpr
(is_array_v<T>) {
20
for
(
auto
& elem : *p) {
21
destroy_at(addressof(elem));
22
}
23
}
else
{
24
p->~T();
25
}
26
}
27
28
}
// namespace etl
29
30
#
endif
// TETL_MEMORY_DESTROY_AT_HPP
etl
Definition
adjacent_find.hpp:9
etl::destroy_at
constexpr auto destroy_at(T *p) -> void
If T is not an array type, calls the destructor of the object pointed to by p, as if by p->~T()....
Definition
destroy_at.hpp:17
include
etl
_memory
destroy_at.hpp
Generated on Sun Sep 7 2025 19:15:11 for tetl by
1.9.8