3 ms·
There’s a good C++ alternative to PIMPL, pure abstract interfaces. The consumer code then can use std::unique_ptr<iSomething> (the interface needs a virtual de
by Const-me 6y ago
There’s a good C++ alternative to PIMPL, pure abstract interfaces.
The consumer code then can use std::unique_ptr<iSomething> (the interface needs a virtual destructor for that) without including the implementation.
Just like PIMPL, this allows to replace implementation without breaking the ABI. Requires much less boilerplate compared to PIMPL. Compiler will automatically setup these function pointers without requiring to manually write the wrappers for public methods. As a nice bonus, compiler forces you to fully implement the interface or the std::make_unique line won’t compile.