EDIT: I should've mentioned, I was looking at the documentation for Boost's ptr_sequence_adapter
and it claims that their adapter for template< class U > void push_back( ::std::auto_ptr<U> x );
is equivalent to doing vec.push_back(autoPtr.release());
and also provides the strong exception guarantee. And then I realized I was confusing their description of the effect of the implementation for what the implementation actually was, and so this question is semi-nonsensical. I'm just leaving it here for posterity.
To me, it seems the call to std::auto_ptr<t>
would succeed, and then the call to std::vector<t*>::push_back
could throw an exception, and the pointer would be leaked.
It seems like you'd have to do this instead:
vec.push_back(0); //Attempts to allocate space in vector, could throw bad_alloc
vec.back() = autoPtr.release(); //Provides nothrow