The C++ language, when wielded properly, can really hit the sweet spot between engineering and creative art.
@ddimin
11 ай бұрын
A quick note: inheriting from an empty struct doesn't increase `sizeof` (because of "empty base optimization"). However, adding a member always increases `sizeof`.
@VincentZalzal
11 ай бұрын
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).
@ddimin
10 ай бұрын
@@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...
@anon_y_mousse
11 ай бұрын
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.
@awawus
11 ай бұрын
The attempt to add a member dynamically (at compile time) reminded me of the mix-in pattern
@Solarbonite
11 ай бұрын
Loved the switcheroo at the end.
@thelatestartosrs
11 ай бұрын
see std::tuple
@bigzigtv706
11 ай бұрын
Hope i never have to work with templates
@graphicsRat
11 ай бұрын
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.
Пікірлер: 10