blob: e7300239a7db8badd48aa79dcda1b8d638afb5c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#pragma once
#include <type_traits>
#define OTR_FLAGS_OP2(type, op) \
inline type operator op (type a, type b) \
{ \
using t_ = std::underlying_type_t<type>; \
return type(t_((a)) op t_((b))); \
} // end
#define OTR_FLAGS_DELETE_SHIFT(type, op) \
template<typename u> \
type operator op (type, u) = delete // end
#define OTR_FLAGS_OP1(type, op) \
inline type operator op (type x) \
{ \
using t_ = std::underlying_type_t<type>; \
return type(op t_((x))); \
} // end
#define DEFINE_ENUM_OPERATORS(type) \
OTR_FLAGS_OP2(type, |) \
OTR_FLAGS_OP2(type, &) \
OTR_FLAGS_OP2(type, ^) \
OTR_FLAGS_OP1(type, ~) \
OTR_FLAGS_SHIFT(type, <<); \
OTR_FLAGS_SHIFT(type, >>) // end
|