News for hackers. Stuff that matters.
Re:C++ Headers are Expensive by repsilat on Monday January 07, 2019 @10:31PM (#18852888)
Hmm... if you were a horrible person you could declare a `char[n]` member instead of a pointer. Then you could placement-new the impl in the constructor, and static-assert that `sizeof(impl)>=n`... No more cache misses :-).

:-(

Re:C++ Headers are Expensive by yuushi on Tuesday January 08, 2019 @02:27AM (#18853928)
This doesn't take into account the alignment of the type though (you'd want to use std::aligned_storage<sizeof(T), alignof(T)>), but that requires knowing enough about T to be able to use sizeof() and alignof(), which means no incomplete types, bringing us back to where we started.
Re:C++ Headers are Expensive by vnorilo on Tuesday January 08, 2019 @04:35AM (#18854430)
When you need this, use aligned storage: https://en.cppreference.com/w/cpp/types/aligned_storage
Re:C++ Headers are Expensive by shereadsthenews on Monday January 07, 2019 @11:34PM (#18853170)
That’s not that gross. There are types in Abseil that do it.
Re:C++ Headers are Expensive by blt on Monday January 07, 2019 @11:37PM (#18853185)
That's basically how modules would work, at least if you ignore LTCG.