Why do C ++ need operator synonyms?

When searching for a list of C ++ statements on Wikipedia, I found an article about synonyms for statements :

C ++ defines [6] keywords to act as aliases for a number of operators: and (& &), bitand (&), and_eq (& =) or (||), bitor (|), or_eq (| =) , xor (^), xor_eq (^ =), not (!), not_eq (! =) and compl (~). They can be used in exactly the same way as the punctuation characters that they replace, since they are not the same operator under a different name, but rather simple token replacements for the name (character string) of the corresponding operator. This means that the expressions (a> 0 and the flag) and (a> 0 && flag) have the same meaning. It also means that, for example, the bitand keyword can be used to replace not only the bitwise and operator, but also the address operator, and it can even be used to specify reference types (for example, int bitand ref = n). The ISO C specification takes these keywords like preprocessor macros in the iso646.h header file. For compatibility with C, C ++ provides the ciso646 header, the inclusion of which has no effect.

Then I wonder: why do we need these operator synonyms ? It would be nice if someone provided some kind of precedent.

+5
source share
1 answer

All answers here: http://en.cppreference.com/w/cpp/language/operator_alternative

In principle, these are characters that cannot be represented in ISO 646 character codes.

+10
source

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


All Articles