/* * 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 namespace sknonstd { template struct is_bitmask_enum : std::false_type {}; template std::enable_if_t::value, bool> constexpr Any(E e) { return static_cast>(e) != 0; } } // namespace sknonstd template std::enable_if_t::value, E> constexpr operator|(E l, E r) { using U = std::underlying_type_t; return static_cast(static_cast(l) | static_cast(r)); } template std::enable_if_t::value, E&> constexpr operator|=(E& l, E r) { return l = l | r; } template std::enable_if_t::value, E> constexpr operator&(E l, E r) { using U = std::underlying_type_t; return static_cast(static_cast(l) & static_cast(r)); } template std::enable_if_t::value, E&> constexpr operator&=(E& l, E r) { return l = l & r; } template std::enable_if_t::value, E> constexpr operator^(E l, E r) { using U = std::underlying_type_t; return static_cast(static_cast(l) ^ static_cast(r)); } template std::enable_if_t::value, E&> constexpr operator^=(E& l, E r) { return l = l ^ r; } template std::enable_if_t::value, E> constexpr operator~(E e) { return static_cast(~static_cast>(e)); } #endif // SkEnumOperators_DEFINED