c++syntaxkeyworddigraphstrigraphs

When were the 'and' and 'or' alternative tokens introduced in C++?


I've just read this nice piece from Reddit.

They mention and and or being "Alternative Tokens" to && and ||

I was really unaware of these until now. Of course, everybody knows about the di-graphs and tri-graphs, but and and or? Since when? Is this a recent addition to the standard?

I've just checked it with Visual C++ 2008 and it doesn't seem to recognize these as anything other than a syntax error. What's going on?


Solution

  • MSVC supports them as keywords only if you use the /Za option to disable extensions; this is true from at least VC7.1 (VS2003).

    You can get them supported as macros by including iso646.h.

    My guess is they believe that making them keywords by default would break too much existing code (and I wouldn't be surprised if they are right).