Flutter Engine
The Flutter Engine
SkBitmaskEnum.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef SkEnumOperators_DEFINED
8#define SkEnumOperators_DEFINED
9
10#include <type_traits>
11
12namespace sknonstd {
13template <typename T> struct is_bitmask_enum : std::false_type {};
14
15template <typename E>
17 return static_cast<std::underlying_type_t<E>>(e) != 0;
18}
19} // namespace sknonstd
20
21template <typename E>
23 using U = std::underlying_type_t<E>;
24 return static_cast<E>(static_cast<U>(l) | static_cast<U>(r));
25}
26
27template <typename E>
29 return l = l | r;
30}
31
32template <typename E>
34 using U = std::underlying_type_t<E>;
35 return static_cast<E>(static_cast<U>(l) & static_cast<U>(r));
36}
37
38template <typename E>
40 return l = l & r;
41}
42
43template <typename E>
45 using U = std::underlying_type_t<E>;
46 return static_cast<E>(static_cast<U>(l) ^ static_cast<U>(r));
47}
48
49template <typename E>
51 return l = l ^ r;
52}
53
54template <typename E>
56 return static_cast<E>(~static_cast<std::underlying_type_t<E>>(e));
57}
58
59#endif // SkEnumOperators_DEFINED
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator&(E l, E r)
Definition: SkBitmaskEnum.h:33
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E & > constexpr operator&=(E &l, E r)
Definition: SkBitmaskEnum.h:39
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E & > constexpr operator^=(E &l, E r)
Definition: SkBitmaskEnum.h:50
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator~(E e)
Definition: SkBitmaskEnum.h:55
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator|(E l, E r)
Definition: SkBitmaskEnum.h:22
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E & > constexpr operator|=(E &l, E r)
Definition: SkBitmaskEnum.h:28
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator^(E l, E r)
Definition: SkBitmaskEnum.h:44
uint8_t value
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, bool > constexpr Any(E e)
Definition: SkBitmaskEnum.h:16