Thread: PImpl
m0nkeymafia

Not PIMP but PImpl.
Basically a set of methodologies to make your C++ apps build a lot faster using forward declarations and hiding certain implementations.

The main premise is removing includes from your header file.

i.e. if i have a class like so
#include "a.h"

class b
{
public:
a *GetClassA() const;

private:
a * m_MyClassA;
}

In this example the a header file does not need to be included, it can be forward declared like so:
class a;

this means when you compile this header file does not depend on "a" making it much faster to compile.

Sometimes though this cannot be achieved and you need to hide implementations using a...PIMPL! Yay
i.e.
class foo
{
....
struct *PImpl;
PImpl *m_PImpl;
}

in your /.cpp file you would then flesh out the content of the PImpl i.e.
struct PImpl
{
class a;
class b;
class c;
}

Im crap at explaining so maybe a google search is in order, but very useful and drastically reduces build times!


Perkiset's Place Home   Politics @ Perkiset's