Hacker News new | ask | show | jobs
by gpderetta 1153 days ago
It would be extremely hard to implement templates with dynamic dispatch while maintaining the correct semantics.
2 comments

Right. For starters, from the very beginning C++ has supported function templates which take native types. So you don't even necessarily have any kind of pointer you could add a vtable to even if you wanted to. Then add to that the guarantee[1] about pod types being directly compatible with C which as you say I don't see how it owuld be possible to do.

[1] which has always been strong even before there was an actual ISO/ANSI standard

templates don’t exist after the front end. there is no ABI that allows them to exist in any object file. there is no object file format they could be embedded in, sans a string representation of the source they came from.

extremely hard is underselling it somewhat :)