Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It evolved a bit in C++11 <strong>[except.spec]</strong>:</p> <blockquote> <p><strong>5/</strong> If a virtual function has an exception-specification, all declarations, including the definition, of any function that overrides that virtual function in any derived class shall only allow exceptions that are allowed by the exception-specification of the base class virtual function.</p> </blockquote> <p>So you are never actually allowed to specify a <em>looser</em> exception specification.</p> <p>However this case is tricky because the destructor is actually synthetized by the compiler itself!</p> <p>In C++03, I think the Standard was not so careful about those, and you had to write them yourself, in C++11 however we get:</p> <blockquote> <p><strong>14/</strong> An implicitly declared special member function (Clause 12) shall have an exception-specification. If <code>f</code> is an implicitly declared default constructor, copy constructor, move constructor, destructor, copy assignment operator, or move assignment operator, its implicit exception-specification specifies the type-id <code>T</code> if and only if <code>T</code> is allowed by the exception-specification of a function directly invoked by <code>f</code>’s implicit definition; <code>f</code> shall allow all exceptions if any function it directly invokes allows all exceptions, and <code>f</code> shall allow no exceptions if every function it directly invokes allows no exceptions.</p> </blockquote> <p>Where the compiler will generate the exception specification of the destructor so that it matches what can be thrown from the functions it calls (ie, the destructors of the attributes). If those destructors do not throw, then it will generate a <code>noexcept</code> destructor which will satisfy the base class constraint.</p> <p><em>Note: VS2005 is one of the least Standard compliant compiler you might find on Earth.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload