C++ defines a bunch of aliases for operators. These are kind of cool, and they can make code more readable at times – for example you can write things like:

if ((dest bitor netmask) == bcdest and protocol == udp)

But in typical C++ fashion, they chose to specify it in a completely brain-dead way. The names don’t alias the operators they’re named for, but their actual punctuation representations. That means this is valid code:

Address parse(const std::string bitand repr);

The ability to do this doesn’t really help anyone, except lazy compiler vendors who want to implement the aliases as predefined macros. But it gives us all one more WTF, and another tool in our arsenal for writing obfuscated code.

This entry was posted on Thursday, 4 February, 2010 at 9:12 pm and is filed under C, Development, Technology. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One response to “And?”

Matt says:

That is so completely wonderful, I can’t wait to get back to work on Monday to try it out (and check it in not not not)

Leave a Reply