Glaze 7.2 - C++26 Reflection | YAML, CBOR, MessagePack, TOML and more
[Glaze](
https://github.com/stephenberry/glaze) is a high-performance C++23 serialization library with compile-time reflection. It has grown to support many more formats and features, and in v7.2.0 C++26 Reflection support has been merged!
GitHub: [
https://github.com/stephenberry/glaze](https://github.com/stephenberry/glaze) | [Docs](
https://stephenberry.github.io/glaze/)
# C++26 Reflection (P2996)
Glaze now supports C++26 reflection with experimental GCC and Clang compilers. GCC 16 will soon be released with this support. When enabled, Glaze replaces the traditional `__PRETTY_FUNCTION__` parsing and structured binding tricks with proper compile-time reflection primitives (`std::meta`).
The API doesn't change at all. You just get much more powerful automatic reflection that still works with Glaze overrides! Glaze was designed with automatic reflection in mind and still lets you customize reflection metadata using `glz::meta` on top of what `std::meta` provides via defaults.
# What C++26 unlocks
* **Unlimited struct members** — Glaze used to be capped at 128 members via structured binding limits.
* **Non-aggregate types** — Classes with custom constructors, virtual functions, and private members can all be reflected automatically.
* **Automatic inheritance** — Base class members are included automatically. No `glz::meta` specialization needed.
* **Automatic enum serialization** — Enums serialize as strings without any metadata.
Here's an example of non-aggregate types working out of the box:
class ConstructedClass {
public:
std::string name;
int value;
ConstructedClass() : name("default"), value(0) {}
ConstructedClass(std::string n, int v) : name(std::move(n)), value(v) {}
};
// Just works with P2996 — no glz::meta needed
std::string json;
glz::write_json(ConstructedClass{"test", 42}, json);
// {"name":"test","value":42}
Inheritance is also automatic:
class Base {
public:
std::string name;
int id;
};
class Derived : public Base {
public:
std::string extra;
};
std::string json;
glz::write_json(Derived{}, json);
// {"name":"","id":0,"extra":""}
constexpr auto names = glz::member_names<Derived>;
// {"name", "id", "extra"}
# New Data Formats
Since my last post about Glaze, we've added four new serialization formats. All of them share the same `glz::meta` compile-time reflection, so if your types already work with `glz::write_json`/`glz::read_json`, they work with every format. And these formats are directly supported in Glaze without wrapping other libraries.
# YAML (1.2 Core Schema)
struct server_config {
std::string host = "
127.0.0.1";
int port = 8080;
std::vector<std::string> features = {"metrics", "logging"};
};
server_config config{};
std::string yaml;
glz::write_yaml(config, yaml);
Produces:
host: "
127.0.0.1"
port: 8080
features:
- "metrics"
- "logging"
Supports anchors/aliases, block and flow styles, full escape sequences, and tag validation.
# CBOR (RFC 8949)
Concise Binary Object Representation. Glaze's implementation supports RFC 8746 typed arrays for bulk memory operations on numeric arrays, multi-dimensional arrays, Eigen matrix integration, and complex number serialization.
# MessagePack
Includes timestamp extension support with nanosecond precision and `std::chrono` integration.
# TOML (1.1)
struct product {
std::string name;
int sku;
};
struct catalog {
std::string store_name;
std::vector<product> products;
};
std::string toml;
glz::write_toml(catalog{"Hardware Store", {{"Hammer", 738594937}}}, toml);
Produces:
store_name = "Hardware Store"
[[products]]
name = "Hammer"
sku = 738594937
Native `std::chrono` datetime support, array of tables, inline table control, and enum handling.
# Lazy JSON (and Lazy