It seems that std::any works just fine in gcc and clang even when compiling with -fno-rtti.
std::any
While looking at the libc++ source I see that they just use