Dirty C/C++
Here is a collection of cool snippets of C/C++ code. Updated regularly. Used to show superiority and implode the minds of my students. Also to use in my own code, of course, whenever viable.
Offset of struct member
You can include a whole library to get the offsetof
macro, or you can just do this!
int offset = (int)&((StructName*)0)->Member;
if x or y is less than zero
bool is_either_less_than_zero = (x | y) < 0;