I sometimes wonder how Memory location of return values of functions is handled. This question is mainly because some techniques in functional programming (std::function & std::bind, and lambda) entails chains of function calls. As you know, if argument type of functions has large data size, it makes overhead due to copy operations. Therefore, It is desirable to use reference argument. However, I wonder if return values in chains of function calls are available for such a reference argument (only pass by value)?
After all, I am worried about whether huge overhead occurs when size of return value is large (c.f. stl containers etc).
If you are familiar with such a problem,
I would appreciate it if you could advise me.
(Is there technique to avoid such a overhead?)
I am worried about whether huge overhead occurs when size of return value is large
Typically there is no such problem, because in most cases, the compiler will place a function's return value exactly where it is required, without incurring any unavoidable copies.