On Donnerstag, 21. Januar 2016 22:44:02 CET Andre Somers wrote: > On 21-1-2016 21:09, Milian Wolff wrote: > > On Donnerstag, 21. Januar 2016 07:25:21 CET André Somers wrote: > >> Op 21/01/2016 om 05:35 schreef Thiago Macieira: > >>> On Thursday 21 January 2016 05:27:50 Kevin Kofler wrote: > >>>> Thiago Macieira wrote: > >>>>> The copy constructor is called once, then the move constructor. If > >>>>> value_type's move constructor is not noexcept, then it may throw after > >>>>> the > >>>>> container resized. > >>>> > >>>> Throwing an exception in a move constructor is really, really horrible. > >>>> I > >>>> can see why a copy constructor would throw (out of memory, failure to > >>>> duplicate some other resource), but a move? > >>> > >>> Indeed. > >>> > >>> But the class in question may not have a move constructor. In the > >>> absence > >>> of one, the copy constructor gets called. > >> > >> I generally don't care. If I can't copy anymore due to running out of > >> memory, I'm pretty much done anyway. No reliable way to recover from > >> that. Might as well terminate the program. > > > > Right, _you_ don't care. But as a library one cannot usually make such > > claims. People may want to use it in conditions where they _do_ care, and > > for good reason. It would be a shame if C++ would not be applicable for > > such scenarios just because some people didn't care enough. > > So, please, enlighten me. What would be a realistic way to recover from > such an exception?
This of course heavily depends on the actual application and code path. Possible scenarios I can imagine: - drop caches to free up memory - abort current operation, assuming it will clean up after itself and went into an abnormal state, i.e. repeating it may not necessarily result in the same error - abort current operation without taking down other more important operations - abort whole application in orderly fashion (i.e. not terminate but do a real shutdown) - ... Be creative, I bet you can come up with realistic recovery situations yourself! -- Milian Wolff | milian.wo...@kdab.com | Software Engineer KDAB (Deutschland) GmbH&Co KG, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt Experts
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development