[Exceptional C++ Style] Item 13: A Pragmatic Look at ExceptionSpecifications

Paul Grenyer paul at paulgrenyer.co.uk
Tue Dec 7 06:37:44 EST 2004


Hi

> Don't you have the same problem you have with const that as soon as you
> enter a function that cannot throw then every function it calls must be
> defined as unable to throw anything

Yes, but I certainly don't see that as a problem with const. I also think it
would be an advantage with exception specifications.

>  void MyFunc() throw()
>  {
>       printf("Hello world"); // We know this won't throw, but can
> the compiler?
>  }

or:

void MyFunc() throw()
{
    try
    {
          std::cout << "Hello, World!" << std::endl;
    }
    catch( ... )
    {
        ...
     }
}


Regards
Paul

Paul Grenyer
email: paul at paulgrenyer.co.uk
web: http://www.paulgrenyer.co.uk
articles: http://www.paulgrenyer.dyndns.org/articles/

I put my hand upon the lever, said let it rock and let it roll.




More information about the Effective-cpp mailing list