Define database tables as annotated C++ structs and let the ORM generate schema
Run typed CRUD queries with compile-time checked where clauses
Detect drift between a live database and your C++ model and report mismatches
Drive additive or versioned migrations from a C++ project without external tools
Requires a bleeding edge compiler with C++26 static reflection enabled via -freflection and CMake 3.30 or newer.
reflect is a C++ library that acts as an ORM, which stands for object relational mapper. An ORM lets a programmer work with database rows as if they were normal objects in their language, instead of writing SQL by hand. What sets this project apart is that it is built around C++26 static reflection, a brand new feature in the C++ language that lets code inspect the structure of types at compile time. You define a normal C++ struct, add a few small annotations to fields, and the library figures out the rest: table layout, schema creation, type-safe filters, CRUD statements, migrations, validation, and turning database rows back into structs. A short example in the README shows how this looks. The user defines a User struct with id, email, and name fields, decorated with attributes such as reflect::id, reflect::auto_increment, reflect::unique, reflect::not_null, and reflect::varchar with a size. The main function opens a SQLite database, runs db.migrate to create the table, inserts a row using brace initialization, and then runs a query with a typed where clause that checks if the email ends with a given string. The C++ model is treated as the source of truth. Features listed include support for SQLite and PostgreSQL backends, a full set of column annotations covering primary keys, indexes, defaults, foreign keys, varchar, decimal, text, JSON, UUID, blob, date, time, and timestamp. There are CRUD helpers such as insert, find_one, find_many, update, delete_many, count, and exists. Relationships are declared with has_many, has_one, and belongs_to. Transactions support nested savepoints. The library can also validate the live database against the C++ model and report drift such as missing columns, type mismatches, or nullability differences. Migrations come in two styles. Additive sync creates tables and adds missing columns, but never drops or renames anything. Versioned manual migrations are recorded in a reflect_schema_migrations table and skipped when already applied. There is also a destructive development mode that drops and recreates tables when drift is found, intended for local iteration only. The project is pre-1.0. The README has a frank section titled What Is Still Missing For A Complete V1, listing items such as generated up/down migration files, eager loading, many-to-many helpers, connection pooling, async APIs, query logging, and a migration CLI. Build requires CMake 3.30 or newer and a compiler with C++26 static reflection support enabled via -freflection.
Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.