4 ms·
Conventional variable syntax may not create a variable either. The compiler elides as it can or sees fit. This is my point, you don’t reason about these details
by elteto 5y ago
Conventional variable syntax may not create a variable either. The compiler elides as it can or sees fit. This is my point, you don’t reason about these details today, why should constexpr be different?
- huhtenberg 5y agoBecause constexpr and variables are not the same thing? E.g. with a variable you can still always take its address. With constexpr you can't. Plus 'constexpr' is a patently ugly keyword. Also an important metric to consider :)
- elteto 5y agoMy point is that arguing about what is a variable is moot in the presence of compiler optimizations. You might think that taking and address makes a difference but if the compiler decides that it can elide it will (for example if the taken address never leaves the local scope and the variable is purely local then the compiler might be able to optimize it away). Regarding ugliness… Idk beauty is in the eye of the beholder. I happen to like constexpr ;)