3#ifndef TETL_MEMORY_POINTER_LIKE_TRAITS_HPP
4#define TETL_MEMORY_POINTER_LIKE_TRAITS_HPP
20 [[nodiscard]]
static auto get_as_void_pointer(T* p) ->
void* {
return p; }
22 [[nodiscard]]
static auto get_from_void_pointer(
void* p) -> T* {
return static_cast<T*
>(p); }
24 static constexpr size_t free_bits =
ilog2(
alignof(T));
34 return non_const::get_as_void_pointer(p);
40 return non_const::get_from_void_pointer(
const_cast<void*
>(p));
43 static constexpr size_t free_bits = non_const::free_bits;
53 return non_const::get_as_void_pointer(
const_cast<T*
>(p));
58 return non_const::get_from_void_pointer(
const_cast<void*
>(p));
61 static constexpr size_t free_bits = non_const::free_bits;
constexpr auto bit_cast(From const &src) noexcept -> To
Obtain a value of type To by reinterpreting the object representation of from. Every bit in the value...
Definition bit_cast.hpp:38
Definition adjacent_find.hpp:8
TETL_BUILTIN_UINTPTR uintptr_t
Unsigned integer type capable of holding a pointer.
Definition uintptr_t.hpp:11
constexpr auto ilog2(Int x) noexcept -> Int
Definition ilog2.hpp:11
static constexpr size_t free_bits
Definition pointer_like_traits.hpp:43
pointer_like_traits< T > non_const
Definition pointer_like_traits.hpp:30
static auto get_as_void_pointer(T const p) -> void const *
Definition pointer_like_traits.hpp:32
static auto get_from_void_pointer(void const *p) -> T const
Definition pointer_like_traits.hpp:38
static auto get_from_void_pointer(void const *p) -> T const *
Definition pointer_like_traits.hpp:56
static constexpr size_t free_bits
Definition pointer_like_traits.hpp:61
static auto get_as_void_pointer(T const *p) -> void const *
Definition pointer_like_traits.hpp:51
pointer_like_traits< T * > non_const
Definition pointer_like_traits.hpp:49
static constexpr size_t free_bits
Definition pointer_like_traits.hpp:72
static auto get_from_void_pointer(void *p) -> uintptr_t
Definition pointer_like_traits.hpp:69
static auto get_as_void_pointer(uintptr_t p) -> void *
Definition pointer_like_traits.hpp:67
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
Definition pointer_like_traits.hpp:15