From 549476357c4d620975f0fee6d26d38ab15e19177 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Tue, 6 Aug 2019 17:10:55 -0400 Subject: [PATCH] Mark SkBitmaskEnum operators constexpr. Change-Id: I498beee590ff7728f4d49da28d9a2b9909409c48 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232763 Reviewed-by: Hal Canary Commit-Queue: Ben Wagner --- include/private/SkBitmaskEnum.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/private/SkBitmaskEnum.h b/include/private/SkBitmaskEnum.h index 34ee2003f7..0f7aa15eaf 100644 --- a/include/private/SkBitmaskEnum.h +++ b/include/private/SkBitmaskEnum.h @@ -13,21 +13,21 @@ namespace skstd { template struct is_bitmask_enum : std::false_type {}; } -template SK_WHEN(skstd::is_bitmask_enum::value, E) operator|(E l, E r) { +template SK_WHEN(skstd::is_bitmask_enum::value, E) constexpr operator|(E l, E r) { using U = typename std::underlying_type::type; return static_cast(static_cast(l) | static_cast(r)); } -template SK_WHEN(skstd::is_bitmask_enum::value, E&) operator|=(E& l, E r) { +template SK_WHEN(skstd::is_bitmask_enum::value, E&) constexpr operator|=(E& l, E r) { return l = l | r; } -template SK_WHEN(skstd::is_bitmask_enum::value, E) operator&(E l, E r) { +template SK_WHEN(skstd::is_bitmask_enum::value, E) constexpr operator&(E l, E r) { using U = typename std::underlying_type::type; return static_cast(static_cast(l) & static_cast(r)); } -template SK_WHEN(skstd::is_bitmask_enum::value, E&) operator&=(E& l, E r) { +template SK_WHEN(skstd::is_bitmask_enum::value, E&) constexpr operator&=(E& l, E r) { return l = l & r; }