MemViz v1.0.0
C++ Memory Layout Inspector
Loading...
Searching...
No Matches
MemViz Documentation

MemViz is a C++20 header-only reflection and memory layout inspection tool. It allows developers to introspect struct and class layouts at runtime, providing member offsets, type alignment, and more — all without macros inside your structs.


📦 Features

  • Compile-time reflection via MEMVIZ_REGISTER
  • Runtime layout printing with dumpLayout<T>()
  • Graceful fallback for unregistered types using requires
  • Clean and colorful terminal output
  • Fully header-only — no linking required

🚀 Quick Start

1. Define Your Type

struct Person {
int age;
char gender;
double height;
};
````
### 2. Register It

cpp MEMVIZ_REGISTER(Person, std::make_tuple( std::make_pair("age", &Person::age), std::make_pair("gender", &Person::gender), std::make_pair("height", &Person::height) ));

### 3. Dump the Layout

cpp Person p = {25, 'F', 170.5}; memviz::LayoutInspector::dumpLayout(p);

---
## 📄 Core Components
### [`MEMVIZ_REGISTER`](./MEMVIZ_REGISTER.md)
Macro used to register members of a type for reflection.
### [`dumpLayout`](./dumpLayout.md)
Prints layout details of a type and its registered members.
### [`getMembers`](./getMembers.md)
Internal helper that retrieves the reflected member tuple.
---
#### 📘 Example Output

[Layout] Type: Person Size: 16 bytes Alignment: 8 bytes Location: 0x7ffee7... Members: age: offset = 0 gender: offset = 4 height: offset = 8

### [`castAndPrint`](./castAndPrint.md)
Safe cast helper that prints the conversion between two types.
---
#### 📘 Example Output

4608083138725496834 { x: 42, y: 3.14 } ```


🔗 Related