I came up with the following code detecting at compile time if inherited functions are overridden in the derived class. It works with all major compilers - gcc/clang/msvc. But is this approach actually backed by the standard?
#include <type_traits>
struct B {
virtual void f1() {}
virtual void f2() {}
void f3() {}
void f4() {}
};
struct D: B {
void f1() override {}
void f3() {}
};
int main()
{
static_assert(!std::is_same_v<decltype(&B::f1), decltype(&D::f1)>, "overriden");
static_assert(std::is_same_v<decltype(&B::f2), decltype(&D::f2)>, "base");
static_assert(!std::is_same_v<decltype(&B::f3), decltype(&D::f3)>, "overriden");
static_assert(std::is_same_v<decltype(&B::f4), decltype(&D::f4)>, "base");
return 0;
}