Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile time operators

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

like image 298
There is nothing we can do Avatar asked Feb 25 '23 21:02

There is nothing we can do


1 Answers

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.

like image 193
Steve Jessop Avatar answered Mar 02 '23 17:03

Steve Jessop