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