c++ - Trusting the Return Value Optimization -


How do you use return cost optimization ?
Is there a case where I can rely on a modern compiler to use optimization, or should I always go safely and use any reference as a pointer / parameter ?

Is there any known cases where the return value can not be optimized? I think return value optimization will be quite easy for a compiler to perform.

whenever compiler optimization is enabled (and in most compilers, when optimizing disabled ), R.V.O. NRVO is a little less common, but most compilers also complete this optimization as well, at least when optimization is enabled.

You are right, optimize is quite easy for a compiler to perform, that is why compilers almost always do so only in those cases where "not created" Can be "where the optimization does not apply: RVO only applies when you return to a temporary temporary. If you want to return a designated local variable, then NRVO applies instead, and when it is slightly more complicated to implement a compiler, then it is possible, and modern compilers have no problem with it .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -