https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115664
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Even if you can't use C++17, it still works like this:
if (not std::is_same<T, Object>::value)
if (dynamic_cast<T*>(this) == nullptr)
