top | item 46636322

(no title)

Maxatar | 1 month ago

In C++ you do it the other way around, have a single class that is polymorphic over templates. The name of this technique within C++ is type-erasure (that term means something else outside of C++).

Examples of type erasure in C++ are classes like std::function and std::any, and normally you need to implement the type erasure manually, but there are some library that can automate it to a degree, such as [1], but it's fairly clumsy.

[1] https://www.boost.org/doc/libs/latest/doc/html/boost_typeera...

discuss

order

bfrog|1 month ago

It's neat this is a thing I guess, but I agree it looks fairly clumsy compared to the Rust answer.