On Fri, 20 Oct 2000, Jean-Marc Lasgouttes wrote:
> >>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
>
> Angus> Things are always copied on return. That's why things like
> Angus> reference counters were invented; the main class holds just a
> Angus> pointer that points to the data structure. Only the pointer is
> Angus> then copied on return.
>
> And is the vector class reference-counted? I guess the answer is no...

Well, this is a case of the blind leading the blind... the C++ gurus will 
know, but I'm pretty sure that <string> is referenced counted. My guess is 
that all STL containers are.

> Am I the only one finding that this is stupid? It should be possible
> to return an object from a function without doing a copy...

Tell me about it! Actually, someone once tried to explain to me why it was a 
good thing that this happened. Failed dismally. g++ has an extension where 
you define the return variable in the function declaration (a là Fortran90). 
Something like:

        BigData function() result BigData someData
        {
                ...
                return someData;
        }

which avoids the copy.

Angus

Reply via email to