Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Static Public Member Functions
mrpt::typemeta::TTypeName< T > Struct Template Reference

Detailed Description

template<typename T>
struct mrpt::typemeta::TTypeName< T >

A template to obtain the type of its argument as a string at compile time.

It works with all classes derived from CObject, plus many specializations for the plain data types (bool, double, uint8_t, etc...) For example:

cout << TTypeName<double>::get() << endl; // "double"
cout << TTypeName<CPose2D>::get() << endl; // "CPose2D"

Users can extend this for custom structs/classes with the macro DECLARE_CUSTOM_TTYPENAME:

class MyClass { ... };
cout << TTypeName<MyClass>::get() << endl; // "MyClass"

or alternatively, to avoid adding out-of-class macros:

namespace MyNS {
class MyClass {
};
}
cout << TTypeName<MyNS::MyClass>::get() << endl; // "MyNS::MyClass"

The following types are NOT ALLOWED since they have platform-dependant sizes:

Examples
typemeta_TTypeName/test.cpp.

Definition at line 65 of file TTypeName.h.

#include <mrpt/typemeta/TTypeName.h>

Static Public Member Functions

constexpr static auto get ()
 

Member Function Documentation

◆ get()

template<typename T >
constexpr static auto mrpt::typemeta::TTypeName< T >::get ( )
inlinestaticconstexpr
MyNS
[example-define-class]
Definition: rtti_unittest.cpp:13
DECLARE_TTYPENAME_CLASSNAME
#define DECLARE_TTYPENAME_CLASSNAME(_CLASSNAME)
Like DECLARE_CUSTOM_TTYPENAME(), but for use within the class declaration body.
Definition: TTypeName.h:100
DECLARE_CUSTOM_TTYPENAME
#define DECLARE_CUSTOM_TTYPENAME(_TYPE)
Identical to MRPT_DECLARE_TTYPENAME but intended for user code.
Definition: TTypeName.h:86



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST