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

proposal for the EnumSet template #3623

Closed
wants to merge 8 commits into from
Closed

proposal for the EnumSet template #3623

wants to merge 8 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 2, 2015

proposal for the EnumSet template

An EnumSet allows to create a bitfield using the members of an enum, whatever is the members type or the members values. In other languages this is often used to define a set of options, easily identifiable in the code.

This proposal contains a comprehensive template that covers the concept in a D flavor

  • type safety: constraints.
  • efficiency: the set is packed in a value type that's efficient to use as parameter (e.g as ref)
  • inclusion, exclusion, constructor using several parameter kinds, input range to iterate the members that are included and much more.
  • well tested.

Code, it's part of a bigger library. It's kept in sync with this PR.
Doc, rendered with harbored.

@quickfur
Copy link
Member

quickfur commented Sep 2, 2015

Isn't this what std.typecons.BitFlags already does?

@ghost
Copy link
Author

ghost commented Sep 2, 2015

It's related but EnumSet if focused on enum.

Try to reproduce the EnumSet example with BitFlag and you'll see.

@ghost
Copy link
Author

ghost commented Sep 2, 2015

EnumSet passes all the tests. Time to review.

@dnadlinger
Copy link
Member

@bbasile: Unrelated, but the b.asile Skype account, which I assume is you, keeps sending me spam links. Is one of your systems/accounts maybe compromised?

@DmitryOlshansky
Copy link
Member

An EnumSet allows to create a bitfield using the members of an enum, whatever is the members type or the members values. In other languages this is often used to define a set of options, easily identifiable in the code.

Truth be told it looks like small bitset (fits in one ubyte, ushort, uint ...) with slots labeled by enum members.

@ghost ghost closed this Sep 26, 2015
This pull request was closed.
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.

3 participants