class final
#include <core/reflection/type.hpp>
Type Describes a reflected type.
Holds the name of a type and the traits associated with it. Traits can be of any type, which means you can define your own custom traits.
Public static functions
Public functions
- auto name() const -> const std::string&
- Returns the name of the type.
- auto shortName() const -> const std::string&
- Returns the name of the type without any namespaces.
-
template<typename T>auto is() const -> bool
- Checks if this type represents the type
T
. -
template<typename T>auto with(T trait) -> Type&
- Adds the given trait to the type.
- auto with(const Type& type, void* trait, void(*)(void*) deleter) -> Type&
- Adds the given trait to the type.
-
template<typename T>auto has() const -> bool
- Returns whether the type has the given trait.
- auto has(const Type& type) const -> bool
- Returns whether the type has the given trait.
-
template<typename T>auto get() const -> const T&
- Returns the given trait of the type.
- auto get(const Type& type) const -> const void*
- Returns the given trait of the type.
- auto operator==(const Type& other) const -> bool
- Equality operator.
Function documentation
const std::string& cubos:: core:: reflection:: Type:: name() const
Returns the name of the type.
Returns | Name of the type. |
---|
const std::string& cubos:: core:: reflection:: Type:: shortName() const
Returns the name of the type without any namespaces.
Returns | Name of the type without any namespaces. |
---|
template<typename T>
bool cubos:: core:: reflection:: Type:: has() const
Returns whether the type has the given trait.
Template parameters | |
---|---|
T | Trait type. |
Returns | Whether the type has the given trait. |
template<typename T>
const T& cubos:: core:: reflection:: Type:: get() const
Returns the given trait of the type.
Template parameters | |
---|---|
T | Trait type. |
Returns | Reference to the trait. |
Aborts if the type does not have the given trait.
bool cubos:: core:: reflection:: Type:: operator==(const Type& other) const
Equality operator.
Parameters | |
---|---|
other | Type object to compare. |
Returns | Whether the objects have the same address, which indicates equality. |