Compile time operators

2019-06-26 04:44发布

Could someone please list a all compile time operators in available in C++?

2条回答
Animai°情兽
2楼-- · 2019-06-26 05:25

There is no such term in the standard.

But here's a list of all operators: http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B (I'm sure there are others...). It should be fairly easy to categorise them one way or the other.

查看更多
祖国的老花朵
3楼-- · 2019-06-26 05:34

There are two operators in C++ whose result can always be determined at compile-time, regardless of the operand(s), and those are sizeof[1] and ::[2].

Of course there are plenty of particular uses of other operators that can be resolved at compile-time, for example those listed in the standard for integer constant expressions.

[1] C99, unlike C++, has variable length array types. sizeof applied to a VLA can't be determined at compile-time. Some C++ compilers provide VLAs as an extension.

[2] that is, it can be determined at compile time what entity is the result of the expression. If the entity is an object, then the object's value is another matter.

查看更多
登录 后发表回答