TypeInfo

struct TypeInfo

Runtime specification of a compile time type. Use the function type_of<T>() to obtain an instance of TypeInfo for some type T.

For example, type_of<int>().name() should return "int" and type_of<float*>().is_pointer() should return true.

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 and float* const are constant, but int and const 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 constexpr TypeInfo remove_const() const

If this type is const, returns the type without const. Similar to std::remove_const but callable at runtime.

inline constexpr TypeInfo add_const() const

If this type is not const, returns the type with const. Similar to std::add_const but callable at runtime.

Public Static Functions

template<typename T>
static inline constexpr TypeInfo of()

Returns the TypeInfo for type T.