|
Boost : |
Subject: Re: [boost] [exception] Incompatibility betweenboost::throwexception and throw prototype declarations
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-09-06 05:56:25
----- Original Message -----
From: "Andrey Semashev" <andrey.semashev_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, September 06, 2008 8:59 AM
Subject: Re: [boost] [exception] Incompatibility
betweenboost::throwexception and throw prototype declarations
>
> On Sat, Sep 6, 2008 at 9:16 AM, vicente.botet
> <vicente.botet_at_[hidden]>wrote:
>
>> ----- Original Message ----- From: "Emil Dotchevski" <
>> emil_at_[hidden]>
>> To: <boost_at_[hidden]>
>> Sent: Saturday, September 06, 2008 6:52 AM
>> Subject: Re: [boost] [exception] Incompatibility between
>> boost::throwexception and throw prototype declarations
>>
>> If G throws the excp using the boost::throw(excep) on 1.15 I was able to
>> write
>>
>> void F() thows (excp) {
>> // ...
>> G();
>> // ...
>> }
>>
>> With 1.136 this code do not compile any more because
>> boost::throw_exception
>> throws an unspecified exception. So what can I write instead of
>> --unspecified--
>>
>> void F() thows (excp, --unspecified--) {
>> // ...
>> G();
>> // ...
>> }
>>
>> I hope this answer your question, let me know if it is not the case.
>>
>
> If I'm not mistaken, you are safe to add base classes to the exception
> specification list. Since the "unspecified" exception derives from the
> "excep" (otherwise you wouldn't be able to catch it), I assume you don't
> need to change your code.
I have tried with a simple example that confirm what you said.
#include <boost/throw_exception.hpp>
#include <iostream>
struct excp : std::exception {};
void G() {
boost::throw_exception(excp());
}
void F() throw (excp) {
try {
G();
} catch (excp& e) {
std::cout << __LINE__ << std::endl;
throw;
} catch (...) {
std::cout << __LINE__ << std::endl;
throw;
}
}
int main() {
try {
F();
} catch (excp& e) {
std::cout << __LINE__ << std::endl;
}
return 0;
}
and compiled it with both versions. Everything is OK.
Sorry for the noice,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk