Skip to content

[feature request] scoped enums with an option #1079

@goldenbull

Description

@goldenbull

Currently pb3 applies c98 enum scoping rule for enums. This is inconvenient when we need same Identifier in different enums. I hope there will be an new option for enums as follow:

enum Status {
  option scoped = true;
  START = 0;
  STOP = 1;
  PAUSE = 2;
}

enum Action {
  option scoped = true;
  NOP = 0;
  START = 1; // note this entry has a different value from Status::START
  STOP = 2;
}

With the annotation option scoped = true the compiler can use enum class for C++11, providing better code, and we users will feel more comfortable to use proper identifiers for enums. And this is totally compatible with current implementation, all existing code will not be disturbed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions