Embedded Problems? Code Bloat? Type Erasure? Solutions?

virtual Is Bad. Is virtual Bad? (Type Erasure)

Type erasure appears to be a C++ hype currently. Speakers on C++ conferences beat each others in creating incomprehensible crap that solves no obvious problem. This is my personal attempt to create another solution to an unknown problem.

Showing options to eliminate virtual, landing in Type Erasure (Static vs. Dynamic Polymorphism), CRTP

See that livehacked

Another attempt is that one:

Note

TODO

  • Strip down the hacking story to a minimum. It is sufficient to

    • Show that a std::vector of (smart) pointers to polymorphic object is sub-optimal, memory-wise (and cache-performance-wise)

    • Show the final version where a std::variant holds unrelated types, and std::visit is used for dynamic dispatch.

And CRTP?

Show that CRTP creates unrelated types that cannot be held in a container.

Allocators

std::string_view

  • Use as parameters instead of std::string

  • Never as member (obviously)

More