3 ms·
> This isn't just for hiding, it also gives you faster compilation. That seems unlikely. What are you basing this on?
by hvdijk 5y ago
> This isn't just for hiding, it also gives you faster compilation.
That seems unlikely. What are you basing this on?
- int_19h 5y agoIt means that the header that declares class A doesn't have to #include the header that declares class B, unless B is a part of its public interface. It doesn't sound like much, but the implementation dependency chain can be much longer in practice; and more importantly, all those savings apply to every translation unit that includes the header.
- hvdijk 5y agoAh, that's what you meant. Your previous comment reads as if an opaque class results in faster compilation than a void pointer, but those are the same as far as that goes, and you were comparing both to a non-pimpl version.
- chippiewill 5y agoThere might be a few hundred CPU cycles saved in compilation from not having to static cast the void* pointer to the implementation class.
- hvdijk 5y agoHaha, sure, and the other way around, time is spent constructing the compile-time type info for the pimpl class. Let's ignore both since the impact would be so small it would almost certainly be drowned out by all the random noise that happens all the time.
- not2b 5y agoYes, I was comparing class Foo; to #include "Foo.h" and I would not consider using a void pointer for anything other than an allocator.