2 ms·
I wish constexpr actually asked the compiler to evaluate an expression at compile time and not just a statement.
by gumby 3y ago
I wish constexpr actually asked the compiler to evaluate an expression at compile time and not just a statement.
- WalterBright 3y agoIn D, every part of the grammar that is a constant-expression must be compiled at compile time. For example: void test() { int square(int y) { return y * y; } int x = square(3); // evaluate at square at run time enum y = square(3); // evaluate at square compile time } (Although, when the optimizer gets through inlining square(), etc., it will wind up at compile time anyway.)