by divbzero · 4y ago · 0 comments
#define and &&
#define and_eq &=
#define bitand &
#define bitor |
#define compl ~
#define not !
#define not_eq !=
#define or ||
#define or_eq |=
#define xor ^
#define xor_eq ^=
I suppose that allows for code like this: if (x or not y or not z) {
return 1;
}
https://en.wikipedia.org/wiki/C_alternative_tokens template <typename T>
void print(T const bitand foo) {
std::cout << foo << std::endl;
} void print(auto const bitand foo) {
std::cout << foo << std::endl;
}
Since C++20.It made for some amusing group projects when I got to university, when classmates had never seen those operators and were trying to figure out where they were coming from and why I would write such silly things. I trolled them by replacing all my brackets with `begin` and `end` in the next assignment before moving to the standard use of C operators for the rest of the class.