Efficient and Reliable Wrapping of C APIs Using Modern C++
summary
Case study wraps the C LMDB API into modern C++ using RAII, unique_ptr with custom deleters, and compile‑time configuration to make a read‑only environment type that omits write methods at compile time. It uses C++20/23 features: std::span for byte views, concepts/requires for trait checks, std::to_underlying for flags, and std::expected (or configurable alternatives) for errors. Cursor access becomes an input iterator and view compatible with ranges; implementation avoids virtual calls and heap allocations and is testability‑aware.
AI-written summary · about
chapters (10)
- 0:00C API wrapping in modern C++
- 8:59Wrapper design goals for LMDB
- 13:18Error handling strategies
- 21:29Resource management with RAII
- 27:32Read-only vs read-write environments
- 34:35Type-safe serialization with traits
- 44:30Standard-compliant iterators
- 51:22Range-based iteration and views
- 54:28Runtime efficiency and testability
- 55:53Q&A
related talks
01h 16m2024 Update: Efficient and Reliable Wrapping of C APIs Using Modern C++
01h 33mSafe and Sane C++ Types
22mAwesome API Design
48mEarly Modern C++: How to Handle a C++03 Codebase in $CURRENT_YEAR
59mModern C++ for Fun and Profit: This isn’t your old C++
01h 11mC++ in the World of Embedded Systems
05mPostmodern Meta C++
01h 07mDesign Patterns in Modern C++
