2 ms·
I mean yeah, at a very basic level you always expect the compiler to do the most obvious optimizations but the same could be said about C or any language that's
by simias 8y ago
I mean yeah, at a very basic level you always expect the compiler to do the most obvious optimizations but the same could be said about C or any language that's higher level than assembly. It's not that you shouldn't expect the compiler to optimize your code, it's that you shouldn't be expected to write code in a sub-optimal way only to hope that the compiler will have your back.
You can choose to use classes and inheritance without using virtual calls, which means that you won't have to use vtables at all, compiler or not. You can rely on the compiler to optimize return values but you can also use a return parameter and not rely on that at all.
I'm not saying that it's a bad thing to do it any other way but I maintain that saying "just make things easy and let the compiler sort it out" is very much not how C++ has been designed so far, for better or worse.