I suggest we introduce a public base class for cetl::unbounded_variant that contains a subset of its API that is not dependent on the size, footprint, copyability, and movability properties of the class. This base class will enable certain more advanced usages that are not currently possible.
At the minimum, the polymorphic base should allow the following:
- Check if the variant
has_value.
reset the variant.
- The freestanding
get and get_if should be defined on the polymorphic base instead of the concrete type.
- Add
type() const -> type_id similarly to index() const -> std::size_t in the regular variant to enhance runtime introspection.
I think this can be retrofitted quite easily with just a few changes. @serges147 could you please confirm?
It would be super nice to support visitation similar to std::visit but I see no way to do it via the non-template base. We could perhaps do it at the implementation level but that is a lot less useful so perhaps not worth the trouble.
I suggest we introduce a public base class for
cetl::unbounded_variantthat contains a subset of its API that is not dependent on the size, footprint, copyability, and movability properties of the class. This base class will enable certain more advanced usages that are not currently possible.At the minimum, the polymorphic base should allow the following:
has_value.resetthe variant.getandget_ifshould be defined on the polymorphic base instead of the concrete type.type() const -> type_idsimilarly toindex() const -> std::size_tin the regular variant to enhance runtime introspection.I think this can be retrofitted quite easily with just a few changes. @serges147 could you please confirm?
It would be super nice to support visitation similar to
std::visitbut I see no way to do it via the non-template base. We could perhaps do it at the implementation level but that is a lot less useful so perhaps not worth the trouble.