Hacker News new | ask | show | jobs
by blt 3065 days ago
It's convoluted because the idea of forcing an object to always be allocated on the heap is convoluted. The real fix for this problem is the modules system, where the compiled module can expose an object's size without exposing its contents. Your example shows why header files suck more than anything about the core semantics of C++ as a language.
1 comments

> The real fix for this problem is the modules system, where the compiled module can expose an object's size without exposing its contents.

Exposing the object size is already too much, it's part of the ABI. The truth is : we can't have our cake (maximum perf due to stack allocation) and eat it too (hide all implementation details)

What's your point? Yes, those two goals are in conflict. Modules are still an improvement to the current situation with no downsides.
> What's your point?

My point is that if you want to be entirely safe from the ABI point of view, modules don't help you at all