๐Ÿงฉ Design Patterns with C++
Home Chapters Examples Diagrams Bibliography GitHub โ†—
  1. Home
  2. Idiomatic C++ Expressions
Part 8 3 chapters

Idiomatic C++ Expressions

CRTP and policy-based design, type erasure alongside PImpl, and expression templates, serialization, and prototype registries.

Chapter 21

CRTP and policy-based design

Two idiomatic C++ expressions of static polymorphism on the shipping-rate domain: a CRTP base that resolves a derived type's method at compile time, a reusable CRTP mixin across unrelated types, and a host class composed from compile-time policies with no runtime dispatch.

30 minRead โ†’
Chapter 22

Type erasure and PImpl

Type erasure as a value-semantic wrapper around a hand-written concept/model pair that holds unrelated quoters with no shared base class, and PImpl as a compilation firewall: correct special members, ABI stability, and when each idiom earns its cost.

30 minRead โ†’
Chapter 23

Expression templates and generic idioms

Expression templates that build a compile-time expression tree so a+b+c evaluates in one pass with no intermediate objects, plus two supporting idioms from the same freight-route domain: a self-registering Prototype registry and a single describe hook that drives both serialize() and deserialize().

30 minRead โ†’
โ† Previous part Coordinating and Traversing Next part โ†’ Patterns in the Wild
Design Patterns with C++
Tutorial content: CC BY 4.0. Sample code: Apache 2.0.
Source on GitHub โ†—  ยท  File an issue โ†—