Quote:it can eliminate virtual calls to a target class altogether if that virtual can be made constexpr?
That's about right. Peter Dimov and Vassil Vassilev started this one with: Allowing Virtual Function Calls in Constant Expressions
Their key argument was: Since in a constant expression the dynamic type of the object is required to be known (in order to, for example, diagnose undefined behavior in casts), the restriction is unnecessary and artificial.
This argument will probably propagate to all corners of the language were it applies, because that only makes sense.
Quote:I don't know if I should be elated or terrified for what they've done to C++
While not every (if any?) compiler implementation currently provide full C++ 20 support, things are improving.
Compile-time expression evaluation and meta-template programming are immensely useful, but until now you could only do useful stuff in ways that were hard to understand, requiring all sorts of template trickery.
With C++ 20 I can do meta-template programming more easily, and even more important: easily explain what I do to other people.
With constexpr functions, the need for most of the template trickery that has evolved over the last decades goes away, and once that door was opened people started to ask reasonable questions, such as:
I know that the compiler knows which implementation of a virtual function will be called at runtime, and if that is the case, it would be awfully nice if I could use that function in a constant evaluated context, so how about we put that into the standard?
And, now that we have ranges, I guess many C++ developers will do pretty sophisticated meta-template programming without even realizing it - and suddenly it will not be scary anymore, because we are all doing it.
Senior Architect - Ulriken Consulting AS
The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.Edsger W.Dijkstra
modified 13-Mar-21 19:30pm.