MemViz v1.0.0
C++ Memory Layout Inspector
Loading...
Searching...
No Matches
Macros.hpp File Reference
#include <tuple>

Go to the source code of this file.

Macros

#define MEMVIZ_REGISTER(Type, Tuple)
 Registers a user-defined type for reflection in MemViz.
 

Macro Definition Documentation

◆ MEMVIZ_REGISTER

#define MEMVIZ_REGISTER (   Type,
  Tuple 
)
Value:
namespace memviz { \
template <> struct MemberInfo<Type> { \
using type = decltype(Tuple); \
static constexpr auto get() { return Tuple; } \
}; \
}
Definition BitCaster.hpp:5

Registers a user-defined type for reflection in MemViz.

This macro specializes the memviz::MemberInfo<T> struct for the given type Type, enabling compile-time reflection over its member variables.

The macro should be used in the same translation unit where the type is visible, and before any calls to dumpLayout<T>() or getMembers<T>().

Parameters
TypeThe type (class/struct) to register.
TupleA std::tuple containing std::pair<const char*, T member_ptr> for each field.
Note
This macro must be used at global scope.
Requires C++20 support for structured bindings and templates.
See also
getMembers
dumpLayout
struct Person {
int age;
char gender;
double height;
};
MEMVIZ_REGISTER(Person, std::make_tuple(
std::make_pair("age", &Person::age),
std::make_pair("gender", &Person::gender),
std::make_pair("height", &Person::height)
));
#define MEMVIZ_REGISTER(Type, Tuple)
Registers a user-defined type for reflection in MemViz.
Definition Macros.hpp:38