See this code:
// copy-constructor
dumb_array(const dumb_array& other)
: mSize(other.mSize),
mArray(mSize ? new int[mSize] : 0),
{
// note that this is non-throwing, because of the data
// types being used; more attention to detail with regards
// to exceptions must be given in a more general case, however
std::copy(other.mArray, other.mArray + mSize, mArray);
}
Why Copy CTOR is considered non-throwing? What if new int[mSize]
will throw std::bad_alloc
as it is new without (nothrow)
argument. Also std::copy and throw?