
11 Jun
2012
11 Jun
'12
11:02 a.m.
On 10/06/2012 22:38, Ion GaztaƱaga wrote:
When thinking in solutions to this pass by value/reference issues, I feel C++ is missing some language feature so that a function can detect (at runtime, avoiding instantiations) if the output parameter is already constructed.
An output parameter is never constructed. This is important for exception safety.
Usage:
//RVO is used for all parameters //default initialization syntax used //inside "function" [A a; B b; C c] = function(a, b, c, 0);
Your best bet is probably to use expressions templates so that A a; B b; tie(a, b) = function(c, 0); is evaluated as a function that takes inputs and outputs.