acl/core/ptr_offset.h¶
#include "acl/core/ptr_offset.h"
An offset from a base pointer to a value of a given type.
invalid_ptr_offset¶
struct invalid_ptr_offset final
Represents an invalid pointer offset, used by ptr_offset.
ptr_offset¶
template<typename data_type, typename offset_type>
class ptr_offset
A type safe pointer offset.
This class only wraps an integer of the offset_type type and adds type safety by only casting to data_type.
ptr_offset::ptr_offset¶
constexpr constexpr ptr_offset()
Constructs a valid but empty offset.
constexpr constexpr ptr_offset(uint64_t value)
constexpr constexpr ptr_offset(int64_t value)
constexpr constexpr ptr_offset(uint32_t value)
constexpr constexpr ptr_offset(int32_t value)
constexpr constexpr ptr_offset(uint16_t value)
constexpr constexpr ptr_offset(int16_t value)
constexpr constexpr ptr_offset(uint8_t value)
constexpr constexpr ptr_offset(int8_t value)
Constructs a valid offset with the specified value. Expanded to avoid overflow warnings during assignment.
constexpr constexpr ptr_offset(const void* base, const void* ptr)
Constructs a valid offset from a base pointer and another pointer part of the same aggregate.
constexpr constexpr ptr_offset(invalid_ptr_offset)
Constructs an invalid offset.
ptr_offset::add_to¶
template<typename BaseType>
data_type* add_to(BaseType* ptr) const
template<typename BaseType>
const data_type* add_to(const BaseType* ptr) const
Adds this offset to the provided pointer.
ptr_offset::safe_add_to¶
template<typename BaseType>
data_type* safe_add_to(BaseType* ptr) const
template<typename BaseType>
const data_type* safe_add_to(const BaseType* ptr) const
Adds this offset to the provided pointer or returns nullptr if the offset is invalid.
ptr_offset::operator offset_type¶
constexpr constexpr operator offset_type() const
Coercion operator to the underlying offset_type.
ptr_offset::is_valid¶
constexpr bool is_valid() const
Returns true if the offset is valid.