Hi,
today I noticed by chance these strange things: for example, push
(likewise pop):
void
push(const value_type& __x)
{
try
{
c.push_back(__x);
std::push_heap(c.begin(), c.end(), comp);
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
why that try/catch? Certainly I cannot find support in the Standard
for its presence and, AFAICS, can also run against reasonable user
expectations: i.e., if c.push_back throws (e.g., bad_alloc) the
user may reasonably expect that c remains unchanged! The case of
push_heap is different, more complex, but again, I don't think the
user, basing on the letter of the Standard can generally (i.e.,
portably) expect that a clear() will be invoked (supposedly to do
him the "favor" of a "consistent", read, empty! , container)
I think the try/catch is very old, coming from the HP/SGI STL,
maybe I missing historical facts which I'd like to know... Anyone
helping?