Literal "or" in a C ++ program?

I was translating a C ++ function that I wrote some time ago in python when I noticed that my C ++ code contains the following lines:

if(MIsScaledOut()) { if(DataType()==UnknownDataType or DataType()==h) Descriptor = Descriptor + DataTypeString() + "OverM"; 

There is or ! This is probably due to the fact that I previously translated from python and forgot to switch to || .

This code compiles on different operating systems, with different compilers, and I have never seen a problem with it. Is this standard, or am I just lucky and what should I worry about?

+5
source share
1 answer

After remembering the correct google word, now I see that it is listed as a C ++ keyword , as well as various similar keywords, such as and , which I have never seen (noticed?) Before in C ++. the reason why they exist is because there are encodings that do not have some of the required punctuation marks used by traditional spelling of the operator: { , } , [ , ] , # , \ , ^ , | , ~ .

As @mafso points out, alternative “registered” versions can be used in C, including the <iso646.h> header, which defines them as macros .

A question that has been marked as a duplicate also indicates the existence of digraphs and trigraphs , which can be used to replace missing characters. (This question also says “everyone knows about” them. Obviously, I don’t ...)

+8
source

Source: https://habr.com/ru/post/1206288/


All Articles