Experimenting with type erasure in C++17
summary
A C++17 SAS7BDAT reader implements external polymorphism via type erasure (template-based models, adapters, value-semantics) plus a pimpl and factory-backed unique_ptr construction. Tests use 170 files (~80 MB) exercising endian, word-size and compression variants. Python and R wrappers work by creating C++ sinks but pay conversion overhead; benchmarks compare favorably to C, python, R and Julia. Practical issues covered: ADL/free-function resolution, testable internal detail namespace, and ownership and end-of-data API fixes.
AI-written summary · about
chapters (24)
- 0:00Introduction
- 1:46Motivation for C++ SAS reader
- 3:51Type erasure and external polymorphism
- 5:17What is type erasure
- 7:43External polymorphism solution
- 9:54Type erasure for value semantics
- 11:38Data source and sink interfaces
- 13:04SAS file decoding challenges
- 14:33Formatter with type erasure
- 15:36Adding column filters
- 16:22Reader construction
- 17:49Private implementation (PIMPL)
- 19:36Reading SAS metadata
- 21:19SAS file structure
- 22:21Testing the reader
- 25:59Compiler Explorer demo
- 27:10Code walkthrough
- 30:53Extending to Python and R
- 33:22Performance optimizations
- 36:10Benchmarking readers
- 37:17Lessons learned
- 38:22Testing strategies
- 39:04Ownership of injected objects
- 40:15Q&A
related talks
51mBinary Object Serialization with Data Structure Traversal & Reconstruction in Cpp
55mBuilding an Extensible Type Serialization System Using Partial Template Specialization
01h 00mAchieving performance in financial data processing through compile time introspection
01h 02m“Lightweight Object Persistence With Relocatable Heaps in Modern C++"
36mCompile-time reflection, Serialization and ORM
55mIntroduction to C++ Containers - Know Your Data Structures
01h 13mC++ Memory Model Meets High-Update-Rate Data Structures
01h 05m“A modern database interface for C++"
