12#ifndef VM_VALUE_USERTYPE_HPP
13#define VM_VALUE_USERTYPE_HPP
28 static inline uint16_t
id = 0;
58 std::ostream& (*ostream_func)(std::ostream&,
const UserType&) =
nullptr;
86 void*
data() const noexcept
107 template <
typename T>
108 bool is() const noexcept
119 template <
typename T>
122 return *
reinterpret_cast<T*
>(
m_data);
125 template <
typename T>
126 const T&
as() const noexcept
128 return *
reinterpret_cast<T*
>(
m_data);
A class to be use C++ objects in ArkScript.
friend ARK_API bool operator<(const UserType &A, const UserType &B) noexcept
UserType(T *data=nullptr, ControlFuncs *block=nullptr) noexcept
Construct a new User Type object.
void del()
Free memory through the control functions block.
friend ARK_API bool operator==(const UserType &A, const UserType &B) noexcept
const T & as() const noexcept
T & as() noexcept
Return the underlying object as a given type.
friend ARK_API std::ostream & operator<<(std::ostream &os, const UserType &A) noexcept
void * data() const noexcept
Get the pointer to the object.
bool is() const noexcept
Check if the object held is of a given type.
A structure holding a bunch of pointers to different useful functions related to this usertype.
static const uint16_t value