, c++ 20 polymorphic_value , c++: wg21.link/p0201
Essentially, it's like std :: any, but all your types must inherit the same interface. This is a semi-regular; they decided to drop equality.
This has some overhead: one vptr in the class itself and a separate dispatch mechanism in a polymorphic value. It also has a pointer type interface instead of a type value.
However, given how easy it is to use compared to writing your own type_erased adapter, I would say that for most cases it is more than enough.
source
share