Building an Extensible Type Serialization System Using Partial Template Specialization
Recording
Abstract
As software engineers, we all prefer using performant libraries with user-friendly interfaces. But designing a template-free interface can be challenging for some C++ libraries, like serialization libraries, that need to support generic values but handle them differently based on their type.
This talk shows how we can leverage partial template specialization to implement a generic user-friendly API that can be extended to support custom user-defined types. As a proof of concept, I will showcase an extensible type serialization system, that is built on top of the FlatBuffers serialization library, and enables users to register custom serializers for their user-defined types to support their automatic serialization at runtime.
Template programming is generally known to be associated with long type names and indecipherable compile-time errors. This presentation includes examples and recommendations that help C++ engineers to create more expressive and easy-to-understand implementations. Finally, the talk describes how C++20 features like Concepts can further simplify those implementations and facilitate designing elegant user-friendly programming interfaces.