4 ms·
I don't feel it's behind the scene at all, the behaviour is fairly straightforward and easy to understand. It seems pretty error-proof as far as I'm concerned.
by simias 13y ago
I don't feel it's behind the scene at all, the behaviour is fairly straightforward and easy to understand. It seems pretty error-proof as far as I'm concerned.
We already trust the compiler to do a lot more tricky optimisations (loop unrolling, inlining, dead branch elimination...) so it doesn't really trouble me.
- pkolaczk 13y agoLoop unrolling, inlining, dead code elimination does not change the asymptotical complexity of the program. This optimisation does.
- bstamour 13y agoIt's not an optimization: it's move semantics. And it's default behaviour for any standards-conforming compiler. Moves can be optimized away still, but by default, returning a std::vector from a function is a constant-time operation.
- Someone 13y agoConstant folding can (theoretically) turn a O(N) loop into constant-time, and may trigger further dead code elimination. Your typical template metaprogram for computing Fibonacci numbers will do the same. The time when mortals could more or less 'see' what the memory usage and execution time of a C++ code fragment are is well beyond us.