C ++: noexcept (or throw ()) virtual destructor = default;

The following code is legal?

class C
{
    virtual ~C() noexcept = default;
};

or

class C
{
    virtual ~C() throw() = default;
};

(throw () is deprecated, but my compiler does not support noexcept ;;)

+4
source share
1 answer

8.4.2 [dcl.fct.def.default] An explicit default function [...] can have an explicit exception specification only if it is compatible (15.4) with the exception specification in an implicit declaration.

15.4 / 3 [except.spec] Two exceptions - specifications are compatible if:

  • both don’t give up (see below), regardless of their shape,
  • both are of the form noexcept (constant expression), and constant expressions are equivalent, or
  • both are dynamic exception specifications that have the same set of configured types.

, , , .

, , , :

15.4/14 [except.spec] - . f - [...], [...] - T , T - , fs ; f , - , , , f , .

, , , .

, , . , ( ), , . , nothrow, except() exception(constant expression that yields true) , , .

+4

All Articles