1#ifndef H5ENUM_OPERATORS_H
2#define H5ENUM_OPERATORS_H
10#define ENABLE_BITMASK_OPERATORS(x) \
12 struct EnableBitMaskOperators<x>{ \
13 static const bool enable = true;}; \
17template<
typename Enum>
19 static const bool enable =
false;
22template<
typename Enum>
23typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
24operator |(Enum lhs, Enum rhs)
26 using underlying =
typename std::underlying_type<Enum>::type;
27 return static_cast<Enum
> (
28 static_cast<underlying
>(lhs) |
29 static_cast<underlying
>(rhs)
33template<
typename Enum>
34typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
35operator &(Enum lhs, Enum rhs)
37 using underlying =
typename std::underlying_type<Enum>::type;
38 return static_cast<Enum
> (
39 static_cast<underlying
>(lhs) &
40 static_cast<underlying
>(rhs)
44template<
typename Enum>
45typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
46operator ^(Enum lhs, Enum rhs)
48 using underlying =
typename std::underlying_type<Enum>::type;
49 return static_cast<Enum
> (
50 static_cast<underlying
>(lhs) ^
51 static_cast<underlying
>(rhs)
55template<
typename Enum>
56typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
59 using underlying =
typename std::underlying_type<Enum>::type;
60 return static_cast<Enum
> (
61 ~static_cast<underlying>(rhs)
65template<
typename Enum>
66typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
67operator |=(Enum &lhs, Enum rhs)
69 using underlying =
typename std::underlying_type<Enum>::type;
70 lhs =
static_cast<Enum
> (
71 static_cast<underlying
>(lhs) |
72 static_cast<underlying
>(rhs)
77template<
typename Enum>
78typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
79operator &=(Enum &lhs, Enum rhs)
81 using underlying =
typename std::underlying_type<Enum>::type;
82 lhs =
static_cast<Enum
> (
83 static_cast<underlying
>(lhs) &
84 static_cast<underlying
>(rhs)
89template<
typename Enum>
90typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum>::type
91operator ^=(Enum &lhs, Enum rhs)
93 using underlying =
typename std::underlying_type<Enum>::type;
94 lhs =
static_cast<Enum
> (
95 static_cast<underlying
>(lhs) ^
96 static_cast<underlying
>(rhs)
Basic namespace.
Definition h5base.h:29
Definition h5enum_operators.h:18