In The C++ Programming Language (4th edition), Stroustrup shows the following snippet when discussing exceptions (corrected version taken from this errata):
template<typename T, typename A>
void vector<T,A>::reserve(size_type newalloc) // flawed first attempt
{
if (newalloc<=capacity()) return; // never decrease allocation
vector<T,A> v(newalloc); // make a vector with the new size
copy(vb.elem,vb.elem+size(),v.begin()); // copy elements
vb.space = size();
swap(*this,v); // install new value
} // implicitly release old value
He also says that "this has the nice property of providing the strong guarantee". However, a couple of pages before he mentioned that std::copy doesn't provide a strong exception guarantee. Is this a mistake, or am I missing something?