12#ifndef VM_VALUE_USERTYPE_HPP
13#define VM_VALUE_USERTYPE_HPP
26 static inline uint16_t
id = 0;
56 std::ostream& (*ostream_func)(std::ostream&,
const UserType&) =
nullptr;
85 [[nodiscard]]
void*
data() const noexcept
106 template <
typename T>
107 [[nodiscard]]
bool is() const noexcept
118 template <
typename T>
121 return *
static_cast<T*
>(
m_data);
130 template <
typename T>
131 const T&
as() const noexcept
133 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