A quick note: inheriting from an empty struct doesn't increase `sizeof` (because of "empty base optimization"). However, adding a member always increases `sizeof`.
I haven't used it myself, but as of C++20, there is now the no_unique_address attribute to specify no storage for empty members (msvc::no_unique_address in msvc, unfortunately).
@@VincentZalzal Wow, thanks, I didn't actually know about that. It seems that with C++ no matter how many years or decades of experience you've got, you still learn about new features... I actually have a place in mind, where I could use that...
I don't know if anyone else will agree, but I dislike redundant syntax. For my own language, which no one will use, specializing on no arguments would just be the class name without an empty template specifier list.
You already work with templates if you use STL. If you go out of your way to avoid templates you will write A LOT of repetitive code. Templates require a mindshift but they are immensely powerful.
The C++ language, when wielded properly, can really hit the sweet spot between engineering and creative art.
A quick note: inheriting from an empty struct doesn't increase `sizeof` (because of "empty base optimization"). However, adding a member always increases `sizeof`.
I haven't used it myself, but as of C++20, there is now the no_unique_address attribute to specify no storage for empty members (msvc::no_unique_address in msvc, unfortunately).
@@VincentZalzal Wow, thanks, I didn't actually know about that. It seems that with C++ no matter how many years or decades of experience you've got, you still learn about new features... I actually have a place in mind, where I could use that...
Loved the switcheroo at the end.
The attempt to add a member dynamically (at compile time) reminded me of the mix-in pattern
see std::tuple
I don't know if anyone else will agree, but I dislike redundant syntax. For my own language, which no one will use, specializing on no arguments would just be the class name without an empty template specifier list.
Hope i never have to work with templates
You already work with templates if you use STL.
If you go out of your way to avoid templates you will write A LOT of repetitive code.
Templates require a mindshift but they are immensely powerful.