Deriving Type Erasure

(david.alvarezrosa.com)

26 points | by dalvrosa 5 days ago ago

7 comments

  • Rubio78 4 days ago

    Great breakdown of type erasure! It's fascinating how std::any manages to hide concrete types behind a uniform interface, similar to how virtual functions enable polymorphism but with even more flexibility. The shape class example really helps demystify what's happening under the hood.

    • dalvrosa 4 days ago

      Thank you, glad that you liked it :)

  • dalvrosa 5 days ago

    Ever looked at `std::any` and wondered what's going on behind the scenes? Beneath the intimidating interface is a classic technique called type erasure: concrete types hidden behind a small, uniform wrapper.

    Starting from familiar tools like virtual functions and templates, we'll build a minimal `std::any`. By the end, you'll have a clear understanding of how type erasure works under the hood.

  • alaadeen13 4 days ago

    thanks

  • Zeeshan1231 4 days ago

    Amazing! What’s interesting is that the two rules here are actually the same rule applied to different things: maximize signal and minimize noise. Crap links are noisy content, and rude or empty comments are noisy discussion.