This is an exception struct thrown as an alternative to deleting a managed object when internal memory allocation for SharedHandle or SharedLockHandle fails in their reset() method or in their constructor which takes a pointer.
More...
template<class T>
class Cgu::SharedHandleError< T >
This is an exception struct thrown as an alternative to deleting a managed object when internal memory allocation for SharedHandle or SharedLockHandle fails in their reset() method or in their constructor which takes a pointer.
- See also
- SharedHandle SharedLockHandle SharedHandleAllocFail
This is an exception struct thrown as an alternative to deleting a managed object when SharedHandle<T>::SharedHandle(T), SharedLockHandle<T>::SharedLockHandle(T), SharedHandle<T>::reset(T) or SharedLockHandle<T>::reset(T) would otherwise throw std::bad_alloc. To make those methods do that, Cgu::SharedHandleAllocFail::leave is passed as their second argument.
If the exception is thrown, the struct has a member 'obj' of type T, which is a pointer to the object or array originally passed to those methods, so the user can deal with it appropriately. This enables the result of the new expression to be passed directly as the argument to those methods without giving rise to a resource leak, as in:
try {
}
catch (std::bad_alloc&) {
...
}
...
}
...
As above, a catch block will need to deal with std::bad_alloc (if the call to the new expression when creating the T object fails) as well as SharedHandleError (if the call to the new expression in the reset() method fails after a valid T object has been constructed).