1#ifndef NNGN_UTILS_POINTER_FLAG_H
2#define NNGN_UTILS_POINTER_FLAG_H
10 static constexpr uintptr_t
MASK = 0b1;
12 auto to_uint()
const {
return reinterpret_cast<uintptr_t
>(this->
p); }
27 const auto u = this->to_uint();
28 const auto off = u - (u & ~MASK);
29 auto *
const cp =
static_cast<char*
>(
static_cast<void*
>(this->p));
30 return static_cast<T*
>(
static_cast<void*
>(cp - off));
36 this->p = this->
get();
39 const auto u = this->to_uint();
41 auto *
const cp =
static_cast<char*
>(
static_cast<void*
>(this->p));
42 this->p =
static_cast<T*
>(
static_cast<void*
>(cp + off));
Definition pointer_flag.h:9
bool flag()
Definition pointer_flag.h:17
T * get()
Definition pointer_flag.h:26
static constexpr uintptr_t MASK
Definition pointer_flag.h:10
auto to_uint() const
Definition pointer_flag.h:12
void set_flag(bool b)
Definition pointer_flag.h:34
T * p
Definition pointer_flag.h:11
assert
Definition debug.lua:3
get
Definition camera.lua:46