Compile-time reflection, Serialization and ORM

Play Compile-time reflection, Serialization and ORM
Sign in to queue


We will discuss what reflection is and how it can be implemented in Modern C++. The techniques used will include a mix of C++11/14 features (void_t, tuple, index_sequence, variadic templates, auto functions, decltype(auto), constexpr, type_traits, etc), classic C++ features, and macros. We’ll use a couple of example libraries to show the essence and power of compile-time reflection and show how to simplify and improve their implementation with C++17 features such as inline variables, constexpr if, structure binding, fold expressions, and string_view. The first example is a library that can serialize a struct into any of a variety of data formats, such as JSON, XML, MessagePack, or a custom format. We’ll then apply the same techniques to implement an Object-Relational Mapping (ORM) library to serialize structs into the tables of any of a variety of databases, such as SQLite, MySQL, Postgres, etc. We’ll discuss some of the challenges and limitations of these techniques and what features could be added to C++ to improve support for compile-time reflection.



Session Type:






Right click to download this episode

Download captions

The Discussion

Add Your 2 Cents