-
Notifications
You must be signed in to change notification settings - Fork 21
Type
Julien SOYSOUVANH edited this page Oct 24, 2021
·
1 revision
The rfk::Type class holds information about C++ types. It internally is made of a list of rfk::TypePart, and an archetype.
Each rfk::TypePart is either a pointer, a l-value reference, a r-value reference, a C-array or a value, with optional qualifiers (volatile, const).
The archetype is not nullptr only if it is reflected.
The Refureku library has a function to get the rfk::Type object of any statically known type:
rfk::Type const& intRefType = rfk::getType<int&>();
This can be used to check the type of a variable or function return type / parameter:
FUNCTION() int& getIntReference();
//...
if (rfk::getDatabase().getFileLevelFunctionByName("getIntReference")->getReturnType() == rfk::getType<int&>())
{
//getIntReference returns a int&
}
Warning: As unreflected types all have a nullptr archetype, different types might compare equal if they have the same qualifiers. In you are unsure, you might want to check whether archetype is nullptr or not.
class UnreflectedClass1 {}; class UnreflectedClass2 {}; rfk::getType<UnreflectedClass1 const&>() == rfk::getType<UnreflectedClass2 const&>(); //true