
----- Original Message ----- From: "Alexander Terekhov" <terekhov@web.de> To: <boost@lists.boost.org> Sent: Wednesday, November 26, 2008 12:42 AM Subject: Re: [boost] [Thread] Win32 exception handling
"vicente.botet" wrote: [...]
Why do you associate an exception to a broken program state?
Example:
Suppose that your operation's documentation says that it may need heap unless the caller provides X() amount of memory via void * parameter to be used instead of heap (void * p is not zero).
#include <new>
void operation(void * p) throw (std::bad_alloc); // may throw if p == 0
size_t X();
#include <new>
int main() { if (void * const p = new(std::nothrow) char [X()]) { // ... nothrow operation(p); } else { // ... nothrow } // ... nothrow }
What if your operation still throws std::bad_alloc?
Why the operation can throw std::bad_alloc? You have used std::nothrow, so Vicente