Virtual templated methods
summary
Claim: C++ cannot have no virtual templates that mix template and virtual dispatch, so alternative patterns are required. Options shown: require types to inherit a type-erased base object (fast, one extra virtual call); write a templated front-end that serialize[s] to std::string or std::stringstream and forward to a virtual method; generate per-type derived wrappers that forward many virtual calls; or use a runtime reflection map of function pointers (works in production but adds boilerplate, lookup cost and copy/move hazards). All examples live on Godbolt.
AI-written summary · about
