The scenario is like , I want to inherit my class from some third party library class whose destructor is noexcept(true) by default.and derived class's destructor is noexcept(false) as it can throw exception. There is following code:
class 3PP
{
public:
virtual ~3PP() {}
};
class B : public 3PP
{
public:
~B() noexcept(false)
};
I am getting this error while compilation.
error: looser throw specifier for ‘virtual B::~B() noexcept (false)’
class B : public 3PP
^
main.cpp:10:11: error: overriding ‘virtual 3PP::~3PP() noexcept’
virtual ~3PP() {}
Is there any way to inherit it from 3PP class without making its destructor noexcept(false)
I also want to understand limitation of making destructor as noexcept(false).