|
Boost : |
Subject: Re: [boost] [Thread] Win32 exception handling
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2008-11-25 18:42:42
"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?
regards,
alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk