1#pragma once
2
3#include <nn/types.h>
4
5namespace nn::gfx::detail {
6
7template <class TType, class TValue = u64>
8union Ptr {
9 typedef TValue ValueType;
10 typedef TType* PtrType;
11 typedef Ptr<TType, TValue> SelfType;
12
13 PtrType ptr;
14 // doesn't seem to exist in SMO
15 // ValueType value;
16
17 PtrType operator->() const { return ptr; }
18
19 PtrType* operator&() { return &ptr; }
20
21 operator PtrType() const { return ptr; }
22
23 template <class T>
24 operator T() const {
25 return static_cast<T>(ptr);
26 }
27
28 operator bool() const { return ptr != nullptr; }
29
30 SelfType& operator=(PtrType p) {
31 ptr = p;
32 return *this;
33 }
34};
35
36} // namespace nn::gfx::detail