 |
CppSerdes
1.0
A serialization/deserialization library designed with embedded systems in mind
|
Go to the documentation of this file. 1 #ifndef _BITCPY_SIZED_POINTER_H_
8 #define _BITCPY_SIZED_POINTER_H_
11 #include <type_traits>
18 template <
typename T_array>
41 return size *
sizeof(T_array) * 8u;
63 template <
typename T_array>
73 element_size{other.element_size} {}
81 :
value{
const_cast<void *const
>(
reinterpret_cast<volatile const void *const
>(v))},
82 size{N *
static_cast<size_t>(v !=
nullptr)},
83 element_size{
sizeof(T)} {}
89 template <
typename T,
size_t N>
91 :
value{
const_cast<void *const
>(
reinterpret_cast<volatile const void *const
>(v))},
93 element_size{
sizeof(T)}
100 return size * element_size * 8u;
108 struct is_sized_pointer : std::false_type
112 template <
typename T>
113 struct is_sized_pointer<sized_pointer<T>> : std::true_type
119 #endif // _BITCPY_SIZED_POINTER_H_
sized_pointer(T_array *const v, const size_t N) noexcept
Construct a new sized pointer object from a raw pointer and a passed size.
Definition: bitcpy_sized_pointer.h:30
Holds a pointer to a void array (with type information stored as a runtime element size paramenter) w...
Definition: bitcpy_sized_pointer.h:48
void *const value
the underlying pointer reinterpreted as a void* type
Definition: bitcpy_sized_pointer.h:51
Holds a pointer to an array (with its type information) with a constant size.
Definition: bitcpy_sized_pointer.h:19
const size_t size
size of the array (number of elements in the array)
Definition: bitcpy_sized_pointer.h:54
sized_pointer(T(&v)[N]) noexcept
Construct a new sized pointer object from the array itself.
Definition: bitcpy_sized_pointer.h:90
const size_t size
size of the array
Definition: bitcpy_sized_pointer.h:25
size_t bit_capacity() const noexcept
returns the number of bits in the array
Definition: bitcpy_sized_pointer.h:39
T_array *const value
the underlying pointer
Definition: bitcpy_sized_pointer.h:22
size_t bit_capacity() const noexcept
returns the number of bits in the array
Definition: bitcpy_sized_pointer.h:98
sized_pointer(const sized_pointer< void > &other) noexcept
Construct a new sized pointer object from a void typed sized pointer.
Definition: bitcpy_sized_pointer.h:70
sized_pointer(const sized_pointer< T_array > &other) noexcept
Construct a new sized pointer object from another sized pointer object.
Definition: bitcpy_sized_pointer.h:64
CppSerdes library namespace.
Definition: bitcpy_common.h:68
sized_pointer(T *const v, const size_t N) noexcept
Construct a new sized pointer object from a raw pointer and a passed size.
Definition: bitcpy_sized_pointer.h:80
sized_pointer(T_array(&v)[N]) noexcept
Construct a new sized pointer object from the array itself.
Definition: bitcpy_sized_pointer.h:36
const uint_fast8_t element_size
Number of bytes per element of the original array type, same as sizeof(T_original)
Definition: bitcpy_sized_pointer.h:57