Mark SkBitmaskEnum operators constexpr.
Change-Id: I498beee590ff7728f4d49da28d9a2b9909409c48 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232763 Reviewed-by: Hal Canary <halcanary@skia.org> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
593290ed75
commit
549476357c
@ -13,21 +13,21 @@ namespace skstd {
|
|||||||
template <typename T> struct is_bitmask_enum : std::false_type {};
|
template <typename T> struct is_bitmask_enum : std::false_type {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator|(E l, E r) {
|
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E) constexpr operator|(E l, E r) {
|
||||||
using U = typename std::underlying_type<E>::type;
|
using U = typename std::underlying_type<E>::type;
|
||||||
return static_cast<E>(static_cast<U>(l) | static_cast<U>(r));
|
return static_cast<E>(static_cast<U>(l) | static_cast<U>(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator|=(E& l, E r) {
|
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) constexpr operator|=(E& l, E r) {
|
||||||
return l = l | r;
|
return l = l | r;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator&(E l, E r) {
|
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E) constexpr operator&(E l, E r) {
|
||||||
using U = typename std::underlying_type<E>::type;
|
using U = typename std::underlying_type<E>::type;
|
||||||
return static_cast<E>(static_cast<U>(l) & static_cast<U>(r));
|
return static_cast<E>(static_cast<U>(l) & static_cast<U>(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator&=(E& l, E r) {
|
template <typename E> SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) constexpr operator&=(E& l, E r) {
|
||||||
return l = l & r;
|
return l = l & r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user