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

Rich enums: Remove infused data support and require copyability #166

Commits on Sep 18, 2024

  1. [RichEnums] Remove support for infused/embedded data members

    1) Users expect "enums" to be small, so allowing members that can increase
    the size a lot is surprising and can lead to issues and memory waste.
    
    2) If rich enums are cheap, it is not longer necessary to try to do
    instance control which simplifies implementation and usage
    alexkaratarakis committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    22bf24a View commit details
    Browse the repository at this point in the history
  2. Require copyable rich enums, remove tests for non-copyable rich enums

    Enums are typically expected to be copyable, so rich enums should be
    as well.
    
    Now that infused/embedded data support is removed, we can rely
    on rich enums being cheap and copyable.
    alexkaratarakis committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    bcedc43 View commit details
    Browse the repository at this point in the history
  3. Rich Enum CONSTANT_NAME() now returns by value

    Now that rich enums are copyable, there is no need to enforce
    instance control or address equality.
    Note also that you can't take address of normal enum constants,
    for example `&TestEnum::ONE` fails to compile.
    alexkaratarakis committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    2709eb3 View commit details
    Browse the repository at this point in the history
  4. RichEnum::value_of() - return std::optional<V>

    ... instead of std::optional<std::reference_wrapper<const V>
    
    This also matches magic_enum::enum_cast<>()
    alexkaratarakis committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    89923df View commit details
    Browse the repository at this point in the history