The Three Layers of Headers A Curious Discovery
summary
Claim: any header can be decomposed into three layers of headers — a top layer of forward declarations, a middle interface file with type and free‑function declarations, and a bottom layer of inline implementations and globals. Doing this breaks cyclical include chains (example: two classes A and B that refer to each other) and compiles cleanly, reduces unnecessary includes, and already appears in practice via iosfwd and in unit test libraries like doctest.
AI-written summary · about
chapters (12)
- 0:00Start
- 0:05The Three Layers of Headers A Curious Discovery
- 0:37fails to compile...
- 1:38What's wrong with Attempt #2?
- 1:48Let's step back...
- 2:08Let's define dependencies of types, and member functions
- 2:28There appears to be three layers
- 2:52A Library Can Be Provided by Three Headers and One Source File
- 3:54The Three Layers of a Library
- 4:04Viktor Kirilov 'doctest' vs. 'catch' Compile Times
- 4:25Library authors, refactor your
- 4:52IOStreams Provides Forward Declarations
related talks
01h 08mA Short Tour of C++ Modules - Modules Demystified and Applied
01h 02mBack to Basics: The Structure of a Program
01h 07mBack to Basics: Templates (part 2 of 2)
01h 01mCalling Functions: A Tutorial
01h 02mBack to Basics - Name Lookup and Overload Resolution in C++
01h 00mBack to Basics: Class Layout
01h 06mImplementing C++ Modules: Lessons Learned, Lessons Abandoned
01h 05mModules are coming
