[PATCH] cleaning before = assignment lotuswordpro/source/filter/xfilter/xfparastyle.cxx

julien2412 serval2412 at yahoo.fr
Tue Jul 17 14:52:22 PDT 2012


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.


More information about the LibreOffice mailing list