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

Added indexable properties on enums #1

Merged
merged 1 commit into from
Aug 31, 2018
Merged

Added indexable properties on enums #1

merged 1 commit into from
Aug 31, 2018

Conversation

Shelim
Copy link
Owner

@Shelim Shelim commented Aug 31, 2018

  • _to_index which always return value 0... size-1
    (even if enums are not sequential)
  • _from_index used for other way around
  • _from_index_nothrow no throw version
  • _from_index_unchecked returns invalid enum
    in case arg>=size

Code and test cases added.
No documentation updates (my English is too poor for that)

Usage case:

BETTER_ENUM(Enum, int, A = 128, B = 256, C = A)
for(int i = 0; i < Enum::_size(); i++)
{
    Enum foo = Enum::_from_index_unchecked(i);
    printf("%d enum is %s \n", i, foo._to_string());
}

 - _to_index which return value 0... size-1
        (even if enums are note sequential)
 - _from_index used for other way around
 - _from_index_nothrow no throw version
 - _from_index_unchecked returns invalid enum
        in case arg>=size

Code and test cases added.
No documentation updates (my English is too poor for that)
@Shelim Shelim merged commit e3898a8 into master Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant