Skip to content

Comment on Type Erasure in C++ Explainedparent

Comments

However the Type Erasure described here doesn't need to know T even when you use it. E.g. it enables things like

for (auto x : vec) { x.foo(); }

And if it were in the standard there wouldn't be at least five well known libraries implementing it (including from Adobe and from Facebook): https://github.com/boost-ext/te#similar-libraries

As far as I know (I don't really follow the committee work) the latest attempt to introduce run-time duck-typing in the standard was https://github.com/andyprowl/virtual-concepts, which seems dead.

At the link, the library description says:

run-time polymorphism (type erasure)

I would argue that it's the first rather than the second.

That's because it's not type-erasure; it's essentially access through a base class pointer with some sugar on top so that it doesn't look like `x->foo()`.

Is this the thing that's called "Voldemort types" in D?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.