|
Boost : |
From: Bo Persson (bop_at_[hidden])
Date: 2006-06-29 15:28:19
"Beman Dawes" <bdawes_at_[hidden]> skrev i meddelandet
news:e80sim$5ng$1_at_sea.gmane.org...
>
> <Oliver.Kowalke_at_[hidden]> wrote in message
> news:5D4F031442F5CB489CF88277DDBACCDD054D060B_at_drsse401.eu.infineon.com...
>> Hi,
>> shouldn't system_error::const char * what() const contain throw ()?
>
> Good question. I don't know the answer. The standard (for
> std::exception, which is the eventual base class) says:
>
> virtual const char* what() const throw();
>
> system_error::what catches exceptions, so it never throws.
>
> I afraid I still don't know the rule as to when you need to provide
> a throw() specifier rather than just documenting that a function
> never throws.
>
> Is there guidance from exception experts?
I'm not one of those, but have notice that several compilers (MSVC7.1,
Comeau) complain about virtual functions having a less strict throw
spec than the base class functions they override.
Seems to me like there would be a *real* surprise if
catch (const std::exception& e)
{
e->what();
}
actually threw another exception, even if e is a derived exception
class.
Bo Persson
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk