tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
to_address.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_MEMORY_TO_ADDRESS_HPP
4#define TETL_MEMORY_TO_ADDRESS_HPP
5
8
9namespace etl {
10
17template <typename Ptr>
18constexpr auto to_address(Ptr const& ptr) noexcept
19{
20 if constexpr (requires { pointer_traits<Ptr>::to_address(ptr); }) {
22 } else {
23 return to_address(ptr.operator->());
24 }
25}
26
32template <typename T>
33 requires(not is_function_v<T>)
34constexpr auto to_address(T* ptr) noexcept -> T*
35{
36 return ptr;
37}
38
39} // namespace etl
40
41#endif // TETL_MEMORY_TO_ADDRESS_HPP
Definition adjacent_find.hpp:8
constexpr auto to_address(Ptr const &ptr) noexcept
Obtain the address represented by p without forming a reference to the object pointed to by p.
Definition to_address.hpp:18
constexpr bool is_function_v
Checks whether T is a function type. Types like etl::inplace_function, lambdas, classes with overload...
Definition is_function.hpp:35
The pointer_traits class template provides the standardized way to access certain properties of point...
Definition pointer_traits.hpp:17