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 1d20c7da0b8833ffda7dfff2066205ea1af7e771)

Change-Id: I35b2a5b99fe87d63f1d0a0c01fba03e7b2f9a58b
Reviewed-on: https://chromium-review.googlesource.com/941982
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
4 files changed