11#ifndef VM_VALUE_USERTYPE_HPP
12#define VM_VALUE_USERTYPE_HPP
25 static inline uint16_t
id = 0;
55 std::ostream& (*ostream_func)(std::ostream&,
const UserType&) =
nullptr;
84 [[nodiscard]]
void*
data() const noexcept
105 template <
typename T>
106 [[nodiscard]]
bool is() const noexcept
117 template <
typename T>
120 return *
static_cast<T*
>(
m_data);
129 template <
typename T>
130 const T&
as() const noexcept
132 return *
static_cast<T*
>(
m_data);
A class to be use C++ objects in ArkScript.
UserType(T *data=nullptr, ControlFuncs *block=nullptr) noexcept
Construct a new User Type object.
void del()
Free memory through the control functions block.
const T & as() const noexcept
Return the underlying object as a given type.
friend ARK_API std::ostream & operator<<(std::ostream &os, const UserType &A) noexcept
T & as() noexcept
Return the underlying object as a given type.
void * data() const noexcept
Get the pointer to the object.
bool is() const noexcept
Check if the object held is of a given type.
friend ARK_API bool operator==(const UserType &A, const UserType &B) noexcept
friend ARK_API bool operator<(const UserType &A, const UserType &B) noexcept
A structure holding a bunch of pointers to different useful functions related to this usertype.
static const uint16_t value