我应该使用“&&”或“和”。 [英] Should I use "&&" or "and"?

查看:138
本文介绍了我应该使用“&&”或“和”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是C ++ 11,两者都是没有任何警告的编译,一个是最好的方法吗?

I'm using C++11 and both are compiling without any warning, witch one is the best way to do it?

if(a && b)

if(a and b)


推荐答案


2.6替代令牌[lex.digraph]

2.6 Alternative tokens [lex.digraph]

$ b一些运算符和标点符号16

1 Alternative token representations are provided for some operators and punctuators.16

2 在语言的所有方面,每个替代令牌分别表示

2 In all respects of the language, each alternative token behaves the same, respectively, as its primary token, except for its spelling.17 The set of alternative tokens is defined in Table 2.

相同。
如果你想尝试和说服自己一个是比另一个更好,这是你的业务。

So they are absolutely identical. If you want to try and convince yourself one is "better" than the other, that's your business. If someone else is trying to argue such, they'd better have a good reason.

编辑:上面的表2:

Table 2 — Alternative tokens
Alternative Primary
<%          {
%>          }
<:          [
:>          ]
%:          #
%:%:        ##
and         &&
bitor       |
or          ||
xor         ˆ
compl       ~
bitand      &
and_eq      &=
or_eq       |=
xor_eq      ˆ=
not         !
not_eq      !=

编辑:可能值得注意,根据 Sebastian Redl ,MS在这里违反规则。

Maybe worth noting, according to Sebastian Redl, MS break the rules here.

这篇关于我应该使用“&amp;&amp;”或“和”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆