Commit bdfc8281 authored by Aaron Wood's avatar Aaron Wood Committed by chrome-bot
Browse files

libbrillo: Bitwise operator templates for enums

When an enum is used to define bitwise flags that are meant to be
combined (FLAG_ONE | FLAG_TWO), the resultant value needs to be cast
back to the enum type in order to be stored in a variable of the same
type as the enum (as the result is a value of underlying_type of the
enum).

This adds a macro that allows templated bitwise operators to be defined
so that the enumerators can be used more cleanly in code, while
preserving type-safety.

BUG=b:37434548
BUG=chromium:815356
TEST=unittests
(cherry picked from commit 1d20c7da)

Change-Id: I35b2a5b99fe87d63f1d0a0c01fba03e7b2f9a58b
Reviewed-on: https://chromium-review.googlesource.com/941982


Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: default avatarAmin Hassani <ahassani@chromium.org>
Reviewed-by: default avatarAmin Hassani <ahassani@chromium.org>
parent 037e08da
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment