Boost logo

Boost Users :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2003-02-18 06:02:36


On Monday 17 February 2003 19:21, Ivan Vecerina wrote:
> The second copy will be avoided by the compiler if you use
> construction of a new variable instead of assignment:
> matrix<double> r1 = foo(); // shall avoid 2nd copy
> or:
> matrix<double> const& r2 = foo(); // always optimized
> // but can trigger a VC7 bug

Here you're taking a const-reference to a temporary.
>From the moment you're using r2 you have 'undefined behaviour' IMHO.

t


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net