So it looks like all these: http://www.cplusplus.com/reference/clibrary/ciso646/ are keywords in c++.
My question is. Is this a part of the c++ standard?
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)?
My question is. Is this a part of the c++ standard?
Yes.
Can I rely on this to be supported by major compilers?
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
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With