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.
You can include a whole library to get the offsetof
macro, or you can just do this!
int offset = (int)&((StructName*)0)->Member;
bool is_either_less_than_zero = (x | y) < 0;