I just read the answer to
const vs constexpr on variables
and am watching this Google Tech Talk about C++11/14 features , in which it is said that, well, constexpr might not be necessary in the future when it comes to functions, since compilers will evolve to figure it out on their own. Finally, I know that Java compilers and JVMs work hard to figure out that classes (or any variable maybe) are immutable after construction - without you explicitly saying so - and doing all sorts of wicked optimization based on this fact.
So, here's the question: Is the fate of const and constexpr to eventually be the same thing? That is, even though a compiler is not guaranteed to do runtime initialization etc., will it not eventually do so whenever possible (basically)? And when that happens, won't one of the keywords be redundant? (Just like inline is becoming, maybe)?
constvariable, but not aconstexproneconstexpr int i = 10; cout << &i << endl;. The variable has an address. Compiled with g++/clang++ -pedanticconstandconstexpris (only) about optimizations. It is not. Especiallyconstexpr, which is a portability help: The specification ensures every conforming C++ compiler must be able to compute the value at compile-time. (From a programmer's perspective: you can use those values where a constant expression is required.) That's probably also why we started with relatively restricted constant expressions and getting more relaxations.