Skip to content

Typed enumerations for C++ #690

@manuka89

Description

@manuka89

When generating enumerations for C++, is it possible to generate typed enumerations?

I mean to generate:

enum Color : uint8_t
{
BLUE = 0,
GREEN = 1,
...
}

instead of

enum Color
{
BLUE = (std::uint8_t)0,
GREEN = (std::uint8_t)1,
...
}

Activity

tmontgomery

tmontgomery commented on Jun 11, 2019

@tmontgomery
Contributor

Sure. Send a PR and I will look at it.

manuka89

manuka89 commented on Jun 11, 2019

@manuka89
Author

You mean PR=Pull Request?

tmontgomery

tmontgomery commented on Jun 11, 2019

@tmontgomery
Contributor

Yes

rigtorp

rigtorp commented on Aug 26, 2019

@rigtorp
Contributor

@tmontgomery Does this project require C++11 or higher? Because that is needed for enum classes.

If we do require C++11 or higher we could remove the SBE_NOEXCEPT and SBE_CONSTEXPR macro.

tmontgomery

tmontgomery commented on Aug 26, 2019

@tmontgomery
Contributor

Not all C++11 compilers are equal. Such as various older releases of Visual Studio (right after 11 started showing up) and gcc that don't fully support every piece of the standard.

So, while C++11 is suggested, we try to make it as optional as possible to have the broadest base.

rigtorp

rigtorp commented on Aug 26, 2019

@rigtorp
Contributor

Sure, that's why it's better to target some common platforms (Ubuntu LTS, Centos, SUSE, whatever is common non-EOL VS) and run CI against them. I'm pretty sure all of them have compilers with enum class support.

Using enum class could improve type safety in the C++ API. It would also be a API breakage.Something to consider for the future.

I will create a separate issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rigtorp@tmontgomery@manuka89

        Issue actions

          Typed enumerations for C++ · Issue #690 · aeron-io/simple-binary-encoding