Alternative operator representations
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
C + +(C),源代码可以写在任何非ASCII 7位字符集,其中包括ISO 646/ECMA-6不变的字符集。然而,一些C + +运算符和标点符号需要ISO 646的代码集之外的字符:
{, }, [, ], #, \, ^, |, ~
。要能够使用字符编码的其中一些或所有的这些符号做不存在,Ç+ +定义两个种的替代品:额外的关键字对应的运营商使用这些字符和特殊组合的两个或三个的ISO 646兼容的字符进行解释的如果他们是一个单一的非ISO 646的性格原文:
C++ (and C) source code may be written in any non-ASCII 7-bit character set that includes the ISO 646/ECMA-6 invariant character set. However, several C++ operators and punctuators require characters that are outside of the ISO 646 codeset:
{, }, [, ], #, \, ^, |, ~
. To be able to use character encodings where some or all of these symbols do not exist, C++ defines two kinds of alternatives: additional keywords that correspond to the operators that use these characters and special combinations of two or three ISO 646 compatible characters that are interpreted as if they were a single non-ISO 646 character.目录 |
[编辑] 替代关键字
有其他几家运营商的关键字在C + +标准定义为拼写.
原文:
There are alternative spellings for several operators defined as keywords in the C++ standard.
Primary | Alternative |
---|---|
&&
|
and
|
&=
|
and_eq
|
&
|
bitand
|
|
|
bitor
|
~
|
compl
|
!
|
not
|
!=
|
not_eq
|
|| | or |
|=
|
or_eq
|
^
|
xor
|
^=
|
xor_eq
|
[编辑] 的兼容性C
同样的话被定义在包含文件中<iso646.h>为宏在C编程语言。由于在C + +这些语言的关键字,C + +版本的<iso646.h>,以及<ciso646>,不定义任何东西.
原文:
The same words are defined in the C programming language in the include file <iso646.h> as macros. Because in C++ these are language keywords, the C++ version of <iso646.h>, as well as <ciso646>, does not define anything.
[编辑] 有向图和三字母
以下两个和三个字符的组合(有向图和三字母)替换为各自的主要特征是有效的
原文:
The following combinations of two and three characters (digraphs and trigraphs) are valid substitutions for their respective primary characters:
Primary | Digraph | Trigraph |
---|---|---|
{ |
<% |
??<
|
None } |
%> |
??>
|
[ |
<: |
??(
|
] |
:> |
??)
|
# |
%: |
??=
|
\ |
??/
| |
^ |
??'
| |
| |
??!
| |
~ |
??-
|
[编辑] 关键字
and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq
[编辑] 示例
下面的例子演示了如何使用几种可供选择的关键词
原文:
The following example demonstrates the use of several alternative keywords:
%:include <iostream> int main(int argc, char *argv<::>) <% if (argc > 1 and argv<:1:> not_eq '\0') <% std::cout << "Hello " << argv<:1:> << '\n'; %> %>