最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

是“not, and, or, not

网站源码admin98浏览0评论
本文介绍了是“not, and, or, not_eq.."C++ 标准的一部分?(为什么它们会在代码中使用或避免?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

所以它看起来像所有这些:http://www.cplusplus/reference/clibrary/ciso646/ 是 C++ 中的关键字.

So it looks like all these: http://www.cplusplus/reference/clibrary/ciso646/ are keywords in c++.

我的问题是.这是 C++ 标准的一部分吗?

My question is. Is this a part of the c++ standard?

我可以依靠它得到主要编译器的支持吗?我知道 gcc 确实支持这些关键字.

Can I rely on this to be supported by major compilers? I know gcc does support these keywords.

最后,也许这更像是一个偏好或风格问题,但与标准运算符(!、!=、&&...等)相比,使用关键字有什么优势吗?

Finally, perhaps this is more a preference or style question, but are there any advantages to using the keywords over the standard operators (!, !=, && ... etc)?

推荐答案

我的问题是.这是 C++ 标准的一部分吗?

My question is. Is this a part of the c++ standard?

是的.

我可以依靠它得到主要编译器的支持吗?

Can I rely on this to be supported by major compilers?

是的.但是MSVC默认不支持这个,你需要将选项 /permissive- 传递给它(或者,尽管这是错误且过时的,/Za),禁用 Microsoft 语言扩展.无论如何,为几乎所有 C++ 项目启用此选项似乎是个好主意,但默认情况下它是关闭的.

Yes. But MSVC doesn’t support this by default, you need to pass it the option /permissive- (or, though this is buggy and outdated, /Za), which disables Microsoft language extensions. It seems a good idea to enable this option for almost all C++ projects anyway, it’s just a shame it’s off by default.

但是与标准运算符相比,使用关键字有什么优势吗

but are there any advantages to using the keywords over the standard operators

一般来说,没有.但是在 andornot 的情况下,许多(虽然可能不是大多数)人发现它更具可读性.我个人建议使用它们.

In general, no. But in the case of and, or, not, many (though probably not most) people find it more readable. Personally I recommend using them.

如果您绝对希望代码在没有 /permissive- 标志的情况下在 MSVC 上编译,#include <ciso646>(这是一个标准头,在符合C++ 实现,但为 MSVC 上的运算符添加了宏).

If you absolutely want the code to compile on MSVC without the /permissive- flag, #include <ciso646> (which is a standard header that’s empty on complying C++ implementations, but adds macros for the operators on MSVC).

这篇关于是“not, and, or, not_eq.."C++ 标准的一部分?(为什么它们会在代码中使用或避免?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

发布评论

评论列表(0)

  1. 暂无评论