Notcurses
3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
_flag_enum_operator_helpers.hh
Go to the documentation of this file.
1
#ifndef __NCPP_FLAG_ENUM_OPERATOR_HELPERS_H
2
#define __NCPP_FLAG_ENUM_OPERATOR_HELPERS_H
3
4
#include <type_traits>
5
6
#include "
_helpers.hh
"
7
8
namespace
ncpp
9
{
10
#define DECLARE_ENUM_FLAG_OPERATORS(__enum_name__) \
11
NCPP_API_EXPORT constexpr __enum_name__ operator& (__enum_name__ x, __enum_name__ y) \
12
{ \
13
typedef std::underlying_type<__enum_name__>::type etype; \
14
return __enum_name__ (static_cast<etype> (x) & static_cast<etype> (y)); \
15
} \
16
NCPP_API_EXPORT constexpr __enum_name__& operator&= (__enum_name__& x, __enum_name__ y) \
17
{ \
18
typedef std::underlying_type<__enum_name__>::type etype; \
19
return x = __enum_name__ (static_cast<etype> (x) & static_cast<etype> (y)); \
20
} \
21
NCPP_API_EXPORT constexpr __enum_name__ operator| (__enum_name__ x, __enum_name__ y) \
22
{ \
23
typedef std::underlying_type<__enum_name__>::type etype; \
24
return __enum_name__ (static_cast<etype> (x) | static_cast<etype> (y)); \
25
} \
26
NCPP_API_EXPORT constexpr __enum_name__& operator|= (__enum_name__& x, __enum_name__ y) \
27
{ \
28
typedef std::underlying_type<__enum_name__>::type etype; \
29
return x = __enum_name__ (static_cast<etype> (x) | static_cast<etype> (y)); \
30
} \
31
NCPP_API_EXPORT constexpr __enum_name__ operator^ (__enum_name__ x, __enum_name__ y) \
32
{ \
33
typedef std::underlying_type<__enum_name__>::type etype; \
34
return __enum_name__ (static_cast<etype> (x) ^ static_cast<etype> (y)); \
35
} \
36
NCPP_API_EXPORT constexpr __enum_name__& operator^= (__enum_name__& x, __enum_name__ y) \
37
{ \
38
typedef std::underlying_type<__enum_name__>::type etype; \
39
return x = __enum_name__ (static_cast<etype> (x) ^ static_cast<etype> (y)); \
40
} \
41
NCPP_API_EXPORT constexpr __enum_name__& operator~ (__enum_name__& x) \
42
{ \
43
typedef std::underlying_type<__enum_name__>::type etype; \
44
return x = __enum_name__ (~static_cast<etype> (x)); \
45
} \
46
NCPP_API_EXPORT constexpr __enum_name__ operator~ (__enum_name__ x) \
47
{ \
48
typedef std::underlying_type<__enum_name__>::type etype; \
49
return __enum_name__ (~static_cast<etype> (x)); \
50
}
51
}
52
#endif
_helpers.hh
ncpp
Definition
_exceptions.hh:9
include
ncpp
_flag_enum_operator_helpers.hh
Generated by
1.9.8