Empty Exception Specification

Empty Exception Specification

Some programmers tend to add an empty exception specification to constructor destructor, assignment operator, and copy constructor of a class:

 class C {public:  C() throw();  ~C() throw();  C(const C&) throw();  C& operator= (const C&); throw();};

On some implementations, this practice can improve performance, because the compiler is free not to generate extra “scaffolding” code to support exception handling. However, on other implementations, adding empty exception specifications achieves the opposite result. You should check the compiler’s documentation first to make sure that such empty exception specifications do not result in a performance penalty.

See also - an AI reverse image search platform

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist