Use strongly-typed enum flags.#340
Open
brianhou wants to merge 20 commits into
Open
Conversation
Codecov Report
@@ Coverage Diff @@
## master #340 +/- ##
=========================================
Coverage ? 77.62%
=========================================
Files ? 261
Lines ? 6592
Branches ? 0
=========================================
Hits ? 5117
Misses ? 1475
Partials ? 0
|
jslee02
previously approved these changes
Oct 13, 2018
jslee02
reviewed
Oct 13, 2018
| // clang-format off | ||
|
|
||
| #define AIKIDO_ENABLE_BITWISE_OPERATORS(X) \ | ||
| template<> \ |
Member
There was a problem hiding this comment.
Nit: template <> (a space between template and the angle brackets)
| /// Enable bitwise operators for strongly-typed enums. | ||
| /// | ||
| /// Adapted from | ||
| /// http://blog.bitwigglers.org/using-enum-classes-as-type-safe-bitmasks/ |
Member
There was a problem hiding this comment.
Nit: Maybe we want to make this as non-doxygen style comment because this comment is not specifically tied to a code but just a note?
Member
|
Just curious @brianhou @jslee02, can you implement something like the following to make that explicit boolean cast work? (See Update section) |
Contributor
|
Outdated, to consider for later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR follows the blog post above. I think the biggest annoyance with this implementation is that there's no contextual conversion to
bool, so you can't write something likeif (mOptions & Options::POSITIONS). My intermediate workaround is to requireOptions::NONE = 0and compare directly to that.I'm not entirely convinced whether this complication is worth it. @jslee02, what do you think?
Before creating a pull request
make formatBefore merging a pull request
CHANGELOG.md