On 29.04.2016 08:57, Marcel Mueller wrote:
>
> I can't get why there is a need for the new keyword and the resulting
> refactoring of library code for C++11 and above.
It means the compiler can (and must) tell you wherever you write
`constexpr` code that is beyond what can be `constexpr`, e.g.
inadvertently using dynamic allocation by involving a `std::string`.
So `constexpr` is part of the usual static type checking scheme.
Also, without it checking whether code could be evaluated at compile
time would incur some extra overhead for separate compilation (with
effectively whole program optimization invoked). Today compilers have
whole program optimization as an option. Because it has a cost, in
compilation time, size of object files, and restriction of use of features.
Cheers & hth.,
- Alf