POV-Ray : Newsgroups : povray.off-topic : Time is not free : Re: Time is not free Server Time
3 Sep 2024 21:19:19 EDT (-0400)
  Re: Time is not free  
From: Warp
Date: 13 Nov 2010 08:51:09
Message: <4cde97cc@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> I see. (I think!) So, presumably, when you copy std::vector "by value", 
> all it's actually copying is the reference to the real data?

  Actually, when you assign an std::vector object to another, whether it
performs a deep-copy of the data or if it uses some copy-on-write mechanism
to perform lazy copying depends on the library implementation, but AFAIK
most if not all library implementations use deep-copying.

  Thus, if you assign one std::vector object to another, all the data it
contains will be copied as well.

  Of course if you want copy-on-write instead, then you can create your own
"vector" which does that. (I have actually done precisely this for some
projects because of the benefits of this technique.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.