/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkEnumOperators_DEFINED #define SkEnumOperators_DEFINED #include "SkTLogic.h" namespace skstd { template struct is_bitmask_enum : std::false_type {}; } template SK_WHEN(skstd::is_bitmask_enum::value, E) 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) { return l = l | r; } template SK_WHEN(skstd::is_bitmask_enum::value, E) 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) { return l = l & r; } #endif // SkEnumOperators_DEFINED