Affective C++ (@AffectiveCpp) header
Affective C++ (@AffectiveCpp) profile picture

The authoritative guide for High Quality C++! (Warning: These are all jokes.)

Joined September 2018
Photo by Affective C++ (@AffectiveCpp)Photo by Affective C++ (@AffectiveCpp)Photo by Affective C++ (@AffectiveCpp)Photo by Affective C++ (@AffectiveCpp)Photo by Affective C++ (@AffectiveCpp)
Affective C++ retweeted
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.
41
361
31
2,355
Affective C++ retweeted
Replying to @david_m_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.
2
1
2
26
Replying to @ciura_victor
Pro-tip: Commas are quicker to parse than semi-colons because there are less pixels in the character. @AffectiveCpp
2
26
Replying to @AffectiveCpp
@AffectiveCpp this is how the professionals structure projects.
Top tip: name your directories well: put all of your template metaprogramming code in a directory called "tmp". Preferably /tmp.
1
1
8
programming protip! when you see x >= 0, that's a handy shortcut for x = x > 0
24
65
15
881
The other advantage is that it forces you to keep the number of local variables down to a manageable 26 or less.
1
1
14
Affective C++ retweeted
One more for @AffectiveCpp: “Magic constants are the best gift you can leave your colleagues in a codebase. They are great because they immediately stick out and make one think/understand the code using them.” You’re welcome 🤡 #cpp
1
1
19
Affective C++ retweeted
For maximum effectiveness it is recommended to reinterpret_cast the results in to the desired memory layout to improve performance #affectivecpp
2
5
Affective C++ retweeted
C++ #protip: make your code nicer by adding some nice garlands to your variables like this *&*&*&*&*&*&var = *&*&*&*&*&*&*&a +*&*&*&*&*&*&b
4
19
2
166
for (int ı = 0; ı < max; ı++) { for (int i = 0; i < mȧx; i++) { for (int ï; ï < mäx; ï++) { /* ... */ } } }
5
26
182
Affective C++ retweeted
Replying to @AffectiveCpp
Further confirmed by this idiom called SFINAE: std::flush Intermittently Normalizes Any Errors ! #affectivecpp #cppsecrets
1
10
Replying to @AffectiveCpp
Just use: char scratchpad[256]; char * s = scratchpad; void foo() { char * p = s; s += 8; *(int *)p = 1; *((int *)p+1) = 2; ... s -= 8; } etc.
1
2
15
Affective C++ retweeted
Since it's CppCon time, we need to be reminded of this wonderful thread. xitter.cf/JamesMcNellis/status/1…
I thought a parody account was one where after you post an odd number of tweets, it would reply with a bit of a tweet.
2
2
15
Replying to @hankadusikova
For similar reason, RESTful APIs should be public member functions if they are internet-facing and private otherwise. Is this wisdom captured yet, @AffectiveCpp?
1
3
Parallelize your hello world program for better performance! #programmingtips
20
31
2
304
The nice thing about writing a library that is almost completely templates: you have really high code coverage by default. Functions are only measured if you have a test that instantiates them. If you want 100% code coverage, just delete all tests!
2
2
60
Affective C++ retweeted
The non-const version should return false because the two values aren't really equal, they are just temporarily the same. At some point they will be different. The have different futures ahead of them, thus they must be somehow inherently different even now. Whereas the const...
3
3
20
Affective C++ retweeted
Hey, cool. Google has the correct twitter account for the first result. @AffectiveCpp Hey, cool. Google also has the correct twitter account for the 2nd result... @visualc :P
6
35
Affective C++ retweeted
remember to write your include guards like this to save on compile times: #ifdef FOO_H #define FOO_H ... #endif
2
2
1
28
Affective C++ retweeted
I prefer std::wstring with XML based serialization
1
7