Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Loop unrolling, inlining, dead code elimination does not change the asymptotical complexity of the program. This optimisation does.


It'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.


Constant 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: