|
 |
Invisible <voi### [at] dev null> 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
|
 |