On Friday, October 21, 2016 at 12:25:19 PM UTC+2, Juha Nieminen wrote:
> For std::vector to use the move constructor of its elements, said
> constructor must have been declared 'noexcept'. However, does the
> destructor of the element also need to be 'noexcept'?
It should be in general. Destructors that throw exceptions are usually
difficult to deal with correctly and best be avoided.
This doesn't have anything to do with moving, though. Moving objects
around instead of copying them doesn't change the number of destructor
invocations. vector<T> might require T to have a no except dtor, I
don't know. I wouldn't be surprized if a throwing ~T would invoke
udefined behaviour when used in vector<T>. But I'd have to check that.
Cheers!
SG