IT lexicon › Programming › PIMPL

PIMPL Pointer to Implementation

Programming På svenska → Updated: 2026-07-29

Putting all private members behind a pointer to a type only declared in the header and defined in the source file. Also known as the compilation firewall.

Two problems disappear. The first is build times: normally every file including a class has to be recompiled when a private member changes, despite not being able to touch it — and the header must additionally pull in headers for all the member types. The second is ABI stability, which is why library authors use the pattern: the object's size doesn't change when its private contents do, so a compiled program keeps working against a new version of the library. The costs are a heap allocation per object and an indirection on every access. The trap everyone falls into at least once: the destructor must be declared in the header and defined in the source file, or unique_ptr's deleter is instantiated against an incomplete type.

← Back to the lexicon