Affective C++ (@affectivecpp) 's Twitter Profile
Affective C++

@affectivecpp

The authoritative guide for High Quality C++!

(Warning: These are all jokes.)

ID: 1041950022978465794

calendar_today18-09-2018 07:20:18

299 Tweet

3,3K Followers

72 Following

Affective C++ (@affectivecpp) 's Twitter Profile Photo

Item 73: If you experience seemingly random crashes and bugs in your software, simply ship it with -O0 to reduce the failure rate. (Thanks Corentin Brunel) #cplusplus #cpp #affectivecpp

cts🌸 (@gf_256) 's Twitter Profile Photo

On x86, the stack grows “down” towards lower addresses. However, this is only true in the northern hemisphere due to the Coriolis effect. In Australia, the stack grows up actually. That’s because they are all looking at their monitors upside down to avoid falling off the planet.

Affective C++ (@affectivecpp) 's Twitter Profile Photo

Item 74: std::vector<bool> is widely regarded as a bad idea. Instead, prefer using std::basic_string<bool>, which both behaves as an actual container, avoids proxy objects, and gives you a small vector optimization for free! (Thanks Martin Hořeňovský) #cplusplus #cpp #affectivecpp

Affective C++ (@affectivecpp) 's Twitter Profile Photo

Item 75: For owning pointers, use `int *variable` (star next to the variable you own), and for non-owning pointers use `int* variable` (star away from the variable) (Thanks Ólafur Waage) #cplusplus #cpp #affectivecpp

Affective C++ (@affectivecpp) 's Twitter Profile Photo

Item 76: Can't remember all the different casts? Replace them all by the more powerful unicorn_cast: template <typename T, typename U> T unicorn_cast(U&& u) { void* addr = &u; return *static_cast<T*>(addr); } (Thanks 🇺🇦 Björn @[email protected] 😷💉⁴) #cplusplus #cpp #affectivecpp

Affective C++ (@affectivecpp) 's Twitter Profile Photo

Item 77: The difference between char and wchar_t is that char is for narrow characters, and wchar_t is for wide characters. Store letters like i and j in a char, and letters like m and w in a wchar_t. (Thanks Chris Oldwood) #cplusplus #cpp #affectivecpp

Tony Van Eerd (@tvaneerd) 's Twitter Profile Photo

David Stone But `unsigned const int` is not the same as `const unsigned int` nor `unsigned int const`. For east-const builds unsigned const int makes the high bit read-only. For west-const builds it makes everything *except* the high bit read-only. We rejected central due to the ambiguity.

Affective C++ (@affectivecpp) 's Twitter Profile Photo

Item 79: Choosing the right data structure is critical. Is memset too slow? Consider memunordered_set instead, to avoid the red-black tree in favor of hashing. See also memmap for key/value, mempriority_queue, memstack, etc. (thanks JF Bastien) #cplusplus #cpp #affectivecpp