Closed Bug 1266404 Opened 4 years ago Closed 4 years ago

Allow construction of an EnumSet<T> using an initializer list

Categories

(Core :: MFBT, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(1 file)

Following on from bug 1266402, add a constructor that takes an initializer list, so we can construct sets in a convenient way.
Attachment #8743845 - Flags: review?(jwalden+bmo)
Blocks: 1266406
Comment on attachment 8743845 [details] [diff] [review]
enum-set-initializer-list

Review of attachment 8743845 [details] [diff] [review]:
-----------------------------------------------------------------

::: mfbt/EnumSet.h
@@ +55,5 @@
> +  EnumSet(std::initializer_list<T> list)
> +   : mBitField(0)
> +  {
> +    for (auto value : list)
> +      (*this) += value;

Braindead style rules require this be braced.

::: mfbt/tests/TestEnumSet.cpp
@@ +270,5 @@
> +    MOZ_RELEASE_ASSERT(someBirds.size() == 3);
> +    MOZ_RELEASE_ASSERT(someBirds.contains(SKIMMER));
> +    MOZ_RELEASE_ASSERT(someBirds.contains(GULL));
> +    MOZ_RELEASE_ASSERT(someBirds.contains(BOOBY));
> +}

Indentation is off.
Attachment #8743845 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/fded1097567f
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in before you can comment on or make changes to this bug.