Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide unbounded_variant with a non-template polymorphic base #121

Open
pavel-kirienko opened this issue May 7, 2024 · 0 comments
Open
Labels
under consideration New feature or request

Comments

@pavel-kirienko
Copy link
Member

pavel-kirienko commented 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:

  • 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.

@pavel-kirienko pavel-kirienko added the under consideration New feature or request label May 7, 2024
@pavel-kirienko pavel-kirienko changed the title Provide unbounded_variant with a polymorphic base Provide unbounded_variant with a non-template polymorphic base May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under consideration New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant