Seeing that yours static_assert
does not have a string argument, you use C ++ 17. In C ++ 17, it has noexcept
become part of the type system. This means that this:
using F = void(C::*)();
This PMF is not noexcept
. Calling this is equivalent to calling the noexcept(false)
member function . You should mark the type of function as noexcept
:
using F = void(C::*)() noexcept;
:
#include <utility>
struct C {
void f() noexcept { }
using F = void(C::*)() noexcept;
static constexpr F handler() noexcept {
return &C::f;
}
void g() noexcept(noexcept((this->*handler())())) {
}
};
int main() {
static_assert(noexcept(std::declval<C>().g()));
}
Godbolt