In the Microsoft Visual C++ 6.0 STL implementation
how, as a user of one of the STL classes do you determine
if the function has failed?
For example, vector::insert has these prototypes:
void insert(iterator it, size_type n, const T& x);
void insert(iterator it, const_iterator first, const_iterator last);
But there is no failure return value and there is no mention
in the documentation of an exception thrown to indicate
a failure.
Does anyone know how to test for a failure in this or
another STL class in MSVC++ 6.0 ? Thanks!
Inserting into a vector won’t fail unless the container is unable to allocate memory or your copy constructor throws an exception. In both cases, you detect the failure by catching the exception.