On 14-03-2012 01:43, Andrej Mitrovic wrote:
On 3/14/12, Jonathan M Davis<jmdavisp...@gmx.com>  wrote:
As I understand it, auto ref is supposed to work with _any_ function. The
_compiler_ decides whether it's best to use a ref or a value.

I never really understood the need for 'const ref' with structures. If
the compiler knows the size of a structure shouldn't it be able to
automatically figure out if it's faster to pass a struct by value or
by pointer? But maybe there's more to it than that?

struct S { int i; }

void foo(S s) // compiler decides to pass by ref
{
    s = S(2);
}

S s = S(1);
foo(s);

assert(s.i == 1); // fails - wat?

--
- Alex

Reply via email to