TypeInfo
-
struct TypeInfo
Runtime specification of a compile time type. Use the function
type_of<T>()
to obtain an instance ofTypeInfo
for some typeT
.For example,
type_of<int>().name()
should return"int"
andtype_of<float*>().is_pointer()
should returntrue
.Public Functions
-
inline const std::string &name() const
Canonical name of this type in C++.
-
inline constexpr size_t size() const
Storage size of this type in bytes.
-
inline constexpr size_t alignment() const
Alignment of this type in bytes.
-
inline constexpr bool is_pointer() const
Is this type a pointer.
-
inline constexpr bool is_const() const
Is this type
const
. For example,const int
andfloat* const
are constant, butint
andconst float*
are not constant.
-
inline constexpr bool is_empty() const
Check if this type is empty, i.e., a class with no non-static fields. Similar to
std::is_empty
but callable at runtime.
-
inline constexpr bool is_trivially_copyable() const
Check if this type is trivial copyable, i.e., no ctor or dtor. Similar to
std::is_trivially_copyable
but callable at runtime.
-
inline constexpr TypeInfo remove_pointer() const
If this type is a pointer, returns the type pointed to by this type. Similar to
std::remove_pointer
but callable at runtime.
-
inline const std::string &name() const