Boost logo

Boost :

Subject: Re: [boost] rvalue ref best practices?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-06-11 07:02:52


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk