以下代码将无法在大多数编译器上编译:
#include <type_traits>
class Foo
{
public:
Foo() noexcept {}
~Foo() noexcept(false) {}
};
static_assert(std::is_nothrow_default_constructible_v<Foo>);
CppReference 还指出这在编译器实现中很常见,但没有提供替代方案。如何在没有析构函数影响结果的情况下测试构造函数是否为 noexcept?