tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
addressof.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_MEMORY_ADDRESSOF_HPP
4#define TETL_MEMORY_ADDRESSOF_HPP
5
6#include <etl/_config/all.hpp>
7
9
10namespace etl {
11
13template <typename T>
14 requires(is_object_v<T>)
15constexpr auto addressof(T& arg) noexcept -> T*
16{
17 return __builtin_addressof(arg);
18}
19
21template <typename T>
22 requires(not is_object_v<T>)
23constexpr auto addressof(T& arg) noexcept -> T*
24{
25 return &arg;
26}
27
28template <typename T>
29auto addressof(T const&& /*ignore*/) = delete;
30
31} // namespace etl
32
33#endif // TETL_MEMORY_ADDRESSOF_HPP
constexpr auto arg(complex< T > const &z) noexcept -> T
Definition arg.hpp:15
Definition adjacent_find.hpp:8
constexpr auto addressof(T &arg) noexcept -> T *
Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
Definition addressof.hpp:15
constexpr bool is_object_v
Definition is_object.hpp:35