You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
pavel-kirienko
changed the title
Provide unbounded_variant with a polymorphic base
Provide unbounded_variant with a non-template polymorphic base
May 7, 2024
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:
has_value
.reset
the variant.get
andget_if
should be defined on the polymorphic base instead of the concrete type.type() const -> type_id
similarly toindex() 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.The text was updated successfully, but these errors were encountered: