azure-data-tables
Loading...
Searching...
No Matches
enum_operators.hpp
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
12#pragma once
13
14#include <type_traits>
15
16namespace Azure { namespace Data { namespace Tables {
20 template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
21 constexpr E operator|(E lhs, E rhs)
22 {
23 using type = std::underlying_type_t<E>;
24 return static_cast<E>(static_cast<type>(lhs) | static_cast<type>(rhs));
25 }
26
30 template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
31 constexpr E& operator|=(E& lhs, E rhs)
32 {
33 lhs = lhs | rhs;
34 return lhs;
35 }
36
40 template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
41 constexpr E operator&(E lhs, E rhs)
42 {
43 using type = std::underlying_type_t<E>;
44 return static_cast<E>(static_cast<type>(lhs) & static_cast<type>(rhs));
45 }
46
50 template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
51 constexpr E& operator&=(E& lhs, E rhs)
52 {
53 lhs = lhs & rhs;
54 return lhs;
55 }
56
60 template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
61 constexpr E operator^(E lhs, E rhs)
62 {
63 using type = std::underlying_type_t<E>;
64 return static_cast<E>(static_cast<type>(lhs) ^ static_cast<type>(rhs));
65 }
66
70 template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
71 constexpr E& operator^=(E& lhs, E rhs)
72 {
73 lhs = lhs ^ rhs;
74 return lhs;
75 }
76
80 template <class E, class = std::enable_if_t<std::is_enum<E>{}>> constexpr E operator~(E rhs)
81 {
82 using type = std::underlying_type_t<E>;
83 return static_cast<E>(~static_cast<type>(rhs));
84 }
85}}} // namespace Azure::Data::Tables
constexpr E operator&(E lhs, E rhs)
Bitwise AND operator for enum class.
Definition enum_operators.hpp:41
constexpr E & operator^=(E &lhs, E rhs)
Bitwise XOR EQUALS operator for enum class.
Definition enum_operators.hpp:71
constexpr E operator~(E rhs)
Bitwise COMPLEMENT operator for enum class.
Definition enum_operators.hpp:80
constexpr E operator|(E lhs, E rhs)
Bitwise OR operator for enum class.
Definition enum_operators.hpp:21
constexpr E & operator&=(E &lhs, E rhs)
Bitwise AND EQUALS operator for enum class.
Definition enum_operators.hpp:51
constexpr E & operator|=(E &lhs, E rhs)
Bitwise OR EQUALS operator for enum class.
Definition enum_operators.hpp:31
constexpr E operator^(E lhs, E rhs)
Bitwise XOR operator for enum class.
Definition enum_operators.hpp:61