Re:Overview: What are Cpp2 and cppfront? How do I get and bu...
by gumby on Sunday March 31, 2024 @06:42PM
(#39888820)
I don't think of pimpl as a tool for speeding up compilation, but for black box encapsulation.
If the compile time (when adding a method) is really an issue you can chop up and reconfigure your include files. A pain, but perhaps saves you time in the long run.
Of course (waves hands) modules will magically improve things...someday.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu...
by colonwqbang on Sunday March 31, 2024 @06:51PM
(#39888912)
I think it can be both things.
Haven't you ever seen someone do
struct Thing;
struct OtherThing;
in lieu of just including "thing.h"? I see it frequently in real life code bases and I can't see a reason for it other than compilation time optimisation.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu...
by gumby on Sunday March 31, 2024 @06:59PM
(#39888972)
Sure, I do that all the time too. But you can't call a method (or look inside Thing, or pass it as an argument, only a pointer to it) without including the definition.
Hmm, there might be some interesting linker hacks to patch things up post compilation. But then you'd want some way to do the forward declaration for cases where Thing could have been passed in registers...
Re:Overview: What are Cpp2 and cppfront? How do I get and bu...
by DerekL on Sunday March 31, 2024 @09:08PM
(#39889884)
This is sometimes required to break dependency cycles. Also, you can use this to rearrange declarations in the same file.
Re:Overview: What are Cpp2 and cppfront? How do I get and bu...
by germandiago on Monday April 01, 2024 @06:03AM
(#39892428)
Pimpl is both. I use it as black box also, but it does both things.
There are workarounds like pimpl (aka. C style encapsulation). But this requires extra boilerplate and indirection. C++ modules might fix it at some point, but after 35 years of not having them in C++ most real life codebases aren't set up that way and may never be.