Your stdlib implementation matters more than the dispatch pattern (opens in new tab)
std::variant went from 28% slower than virtual dispatch on GCC 11 to 50% faster on GCC 12. Nothing changed but the compiler.
Read the original articlestd::variant went from 28% slower than virtual dispatch on GCC 11 to 50% faster on GCC 12. Nothing changed but the compiler.
Read the original article