> And is the vector class reference-counted? I guess the answer is no... 

I think I have seen no reqiurement that it be not reference counted,
but I have never seen a reference counted implementation either.

> Am I the only one finding that this is stupid?

No. It is so common that it even got a name: "return value optimization"

> It should be possible
> to return an object from a function without doing a copy...

Most modern compilers are able to optimize that extraneous copy away.
g++ has a special extension to give the compiler a hint:

big_object func() return r;
//                ^^^^^^^^ !!!
{
        big_object r;
        //...
        return r;
}

I do, however, not encourage this kind of compiler specific syntax since
it opposes quite a few principles I honour more...

Andre' 


PS: I have to check, but -O2 should to the trick for short functions on g++
2.95...

-- 
Andre' Poenitz ........................................ [EMAIL PROTECTED]

Reply via email to