1#ifndef NNGN_UTILS_POINTER_FLAG_H
2#define NNGN_UTILS_POINTER_FLAG_H
9template<
typename T>
class pointer_flag {
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));
bool flag()
Definition: pointer_flag.h:17
T * p
Definition: pointer_flag.h:11
auto to_uint() const
Definition: pointer_flag.h:12
constexpr pointer_flag(T *p)
static constexpr uintptr_t MASK
Definition: pointer_flag.h:10
assert
Definition: debug.lua:3
get
Definition: camera.lua:39