Is there any hope to call a common base class method on a std::variant efficiently?
问题 The way std::variant dispatches to different visitor methods when std::visit is called is pretty reasonable when the variant alternatives are completely different types. Essentially a visitor-specific vtable is built at compile-time and after some error checking 1 the appropriate visitor function is looked by indexing the table based the current index() which resolves to something like an indirect jump on most platforms. If the alternatives share a common base class, however, calling a (non