Hi, Il 22/10/18 21:40, André Pönitz ha scritto:
Which just shows it's working as intended.I have (a) no example that triggers obviously bad behaviour and (b) a bad gut feeling nevertheless.
What bad behaviour are we referring to here?
The problem is that a 'move' could be a 'swap' in practice, with the to-be-destroyed object held 'for a while', effectively turning C++'s rather deterministic destruction behaviour into something resembling garbage collection. I wouldn't be surprised if one can cause real problems with 'random' destruction orders on non-memory resources, like files. Simple memory might be safe(r), as releasing order does typically not matter.
Oh, it absolutely does. That's why in Qt we implement move assignment in terms of pure swap if and only if the only resource that a container holds is memory (e.g. QString, QByteArray). For all other cases (e.g. QVector) we implement move assignment as move-and-swap, to be sure that resources are deterministically destroyed when the move happens.
My 2 c, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development