Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Thank you for the links David.

I understand this design :
- avoids duplication
- guarantees that the new object can be completely built before swapping
from old to new one

But  I still don't know at which moment do we delete old resources ? Or more
precisely, it seems it doesn't remove anything so how can't it be a leak ?

Other things I read :
1)
"The one thing to be careful of is to make sure that the swap method is a
true swap, and not the default std::swap which uses the copy constructor and
assignment operator itself.

Typically a memberwise swap is used. std::swap works and is 'no-throw'
guaranteed with all basic types and pointer types. Most smart pointers can
also be swapped with a no-throw guarantee."
(from
http://stackoverflow.com/questions/1734628/copy-constructor-and-operator-overload-in-c-is-a-common-function-possible/1734640#1734640
)

2) All the subtleties from 
http://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom/3279550#3279550
which ends with other things again to take into account C++11

To sum up, it's very interesting but clearly it's too complicated for me.
Perhaps by reading it several times, I'll fully understand it (let's be
optimistic :-) )

Julien

--
View this message in context: 
http://nabble.documentfoundation.org/PATCH-cleaning-before-assignment-lotuswordpro-source-filter-xfilter-xfparastyle-cxx-tp3995480p3996129.html
Sent from the Dev mailing list archive at Nabble.com.

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.