> > Now that GCC 3.4 has precompiled headers, I'm thinking I can stop
using pimpls to speed up development time, as it may make life
easier (declaring pimpls takes a long time...)
What are the views of the experienced users of various C++
implementations? Do precompiled headers allow pimpls to be
avoided while maintaining the same speed up of development time?
"Pimpl" is an idiom that one refactors into existing code to compile faster.
"Pimpl" has at least an additional advantage as discussed by Herb Sutter:
It can lead to exception safe assignment. No precompiled header system
can do this.
C++ was designed
to permit compilation firewalls based on abstract types;
In my opinion, this only holds if you supplement your concrete, derived class
with a factory function - otherwise you've to include the header file
of your derived class into each file, where you create an instance, though
besides this creation step you only need the declaration of the base class.
Personally, I'd prefer Pimpl over precompiled headers because of two
reasons:
- The precompiled header system of many compilers is limited and would
cause additional considerations on usage.
- Often it is sufficient to reduce compile time not to include unnecessary header
files. With precompiled headers commenting out inclusion somewhere doesn't
necessarily causes a compile error, if the file is needed, so you have less
support by your compiler.
Cheers,
Philipp.