5 ms·
C++'s "Curiously Recurring Template Pattern" template <typename T> class Foo {}; class Bar : public Foo<Bar> { ... }; https://en.cppreference.
by pyjarrett 4y ago
C++'s "Curiously Recurring Template Pattern"
template <typename T>
class Foo {};
class Bar : public Foo<Bar> { ... };
https://en.cppreference.com/w/cpp/language/crtp https://en.cppreference.com/w/cpp/language/crtp
- neeeeees 4y agoGood answer. OP didn’t specify “blew your mind in a good way”.
- Turing_Machine 4y agoIf "not in a good way" counts, my nominee would be discovering the hard way that a Windows C function declared as type BOOL can actually return 1,0, or -1. Now, if it had been declared int, I would probably have been on the lookout for it using something other than 1 or 0 as an error condition, but why bother to explicitly invent a BOOL type and then abuse it that way?
- dividuum 4y agoReminds me of this classic post: https://thedailywtf.com/articles/What_Is_Truth_0x3f_ https://thedailywtf.com/articles/What_Is_Truth_0x3f_