5#ifndef TILESON_ENUMBITFLAGS_HPP
6#define TILESON_ENUMBITFLAGS_HPP
11#define TILESON_ENABLE_BITMASK_OPERATORS(x) \
13 ENABLE_BITMASK_OPERATORS(x) \
18 #define ENABLE_BITMASK_OPERATORS(x) \
20 struct EnableBitMaskOperators<x> \
22 static const bool enable = true; \
25 template<
typename Enum>
32 template<
typename Enum>
33 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
36 static_assert(std::is_enum<Enum>::value,
37 "template parameter is not an enum type");
39 using underlying =
typename std::underlying_type<Enum>::type;
41 return static_cast<Enum> (
42 static_cast<underlying
>(lhs) |
43 static_cast<underlying
>(rhs)
48 template<
typename Enum>
49 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
52 static_assert(std::is_enum<Enum>::value,
53 "template parameter is not an enum type");
55 using underlying =
typename std::underlying_type<Enum>::type;
57 return static_cast<Enum> (
58 static_cast<underlying
>(lhs) &
59 static_cast<underlying
>(rhs)
64 template<
typename Enum>
65 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
68 static_assert(std::is_enum<Enum>::value,
69 "template parameter is not an enum type");
71 using underlying =
typename std::underlying_type<Enum>::type;
73 return static_cast<Enum> (
74 static_cast<underlying
>(lhs) ^
75 static_cast<underlying
>(rhs)
80 template<
typename Enum>
81 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
84 static_assert(std::is_enum<Enum>::value,
85 "template parameter is not an enum type");
87 using underlying =
typename std::underlying_type<Enum>::type;
89 return static_cast<Enum> (
90 ~static_cast<underlying>(rhs)
95 template<
typename Enum>
96 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
99 static_assert(std::is_enum<Enum>::value,
100 "template parameter is not an enum type");
102 using underlying =
typename std::underlying_type<Enum>::type;
104 lhs =
static_cast<Enum> (
105 static_cast<underlying
>(lhs) |
106 static_cast<underlying
>(rhs)
113 template<
typename Enum>
114 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
117 static_assert(std::is_enum<Enum>::value,
118 "template parameter is not an enum type");
120 using underlying =
typename std::underlying_type<Enum>::type;
122 lhs =
static_cast<Enum> (
123 static_cast<underlying
>(lhs) &
124 static_cast<underlying
>(rhs)
131 template<
typename Enum>
132 typename std::enable_if<EnableBitMaskOperators<Enum>::enable,
Enum>::type
135 static_assert(std::is_enum<Enum>::value,
136 "template parameter is not an enum type");
138 using underlying =
typename std::underlying_type<Enum>::type;
140 lhs =
static_cast<Enum> (
141 static_cast<underlying
>(lhs) ^
142 static_cast<underlying
>(rhs)
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type operator~(Enum rhs)
Definition EnumBitflags.hpp:82
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type operator|(Enum lhs, Enum rhs)
Definition EnumBitflags.hpp:34
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type operator^(Enum lhs, Enum rhs)
Definition EnumBitflags.hpp:66
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type & operator&=(Enum &lhs, Enum rhs)
Definition EnumBitflags.hpp:115
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type & operator^=(Enum &lhs, Enum rhs)
Definition EnumBitflags.hpp:133
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type operator&(Enum lhs, Enum rhs)
Definition EnumBitflags.hpp:50
std::enable_if< EnableBitMaskOperators< Enum >::enable, Enum >::type & operator|=(Enum &lhs, Enum rhs)
Definition EnumBitflags.hpp:97
Definition EnumBitflags.hpp:27
static const bool enable
Definition EnumBitflags.hpp:28