[Development] Question about QCoreApplicationData::*_libpaths

Matthew Woehlke mwoehlke.floss at gmail.com
Thu Jan 21 17:54:33 CET 2016


On 2016-01-20 23:27, 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?

Sure... and for the same reason you gave; out of memory. Some classes
have an invariant that involves owning some allocated memory. Thus, even
the move ctor must allocate memory (which is then exchanged with the
instance being moved from) in order to maintain invariants. (This is, of
course, why we need destructive move; we can eliminate the need to
allocate when the moved-from object is also destroyed, because we can
just *take* its memory in that case and not worry about the class
invariants.)

-- 
Matthew




More information about the Development mailing list