Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1.   template <typename _Enum>
  2.   struct define_bitwise_ops
  3.   {
  4.     using value_type = _Enum;
  5.     using basic_type = std::underlying_type_t<_Enum>;
  6.     friend constexpr value_type operator | (value_type a, value_type b)
  7.     {
  8.       return static_cast<value_type> (static_cast<basic_type>(a)|static_cast<basic_type>(b));
  9.     }
  10.     friend constexpr value_type operator & (value_type a, value_type b)
  11.     {
  12.       return static_cast<value_type> (static_cast<basic_type>(a)&static_cast<basic_type>(b));
  13.     }
  14.     friend constexpr value_type operator ^ (value_type a, value_type b)
  15.     {
  16.       return static_cast<value_type> (static_cast<basic_type>(a)^static_cast<basic_type>(b));
  17.     }
  18.     friend constexpr value_type operator ~ (value_type a)
  19.     {
  20.       return static_cast<value_type> (~static_cast<basic_type>(a));
  21.     }
  22.   };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement