When were the 'and' and 'or' alter

2019-01-01 16:09发布

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?

8条回答
梦醉为红颜
2楼-- · 2019-01-01 16:28

You may be surprised to learn about the rest of them:

and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq

List from C++ Keywords.

I believe recent versions of GCC support these keywords.

查看更多
若你有天会懂
3楼-- · 2019-01-01 16:35

Although the question is old, I'd want to provide it with more or less full answer: Alternative tokens were already a part of the currently withdrawn C++98 (ISO/IEC 14882:1998, which, I believe, was the first ISO standard for C++). While not a proof in itself (and I don't own a copy of ISO for c++98), here's a link - see C++ section.

As mentioned in the other answers, MSVC compiler is violating [lex.digraph] section of the standard when /Za flag is not specified.

查看更多
登录 后发表回答