3 #if __cplusplus < 201103L
4 #error "strongenumflag is only supported with c++11 or newer"
9 #ifndef WIBBLE_STRONGENUMFLAG_H
10 #define WIBBLE_STRONGENUMFLAG_H
14 template<
typename E >
16 std::is_enum< E >::value && !std::is_convertible< E, int >::value >;
18 template<
typename Self >
22 using UnderlyingType =
typename std::underlying_type< Self >::type;
26 store( static_cast< UnderlyingType >( flag ) )
28 explicit constexpr
StrongEnumFlags( UnderlyingType st ) noexcept : store( st ) { }
30 constexpr
explicit operator UnderlyingType()
const noexcept {
44 friend constexpr This
operator|( This a, This b ) noexcept {
45 return This( a.store | b.store );
48 friend constexpr This
operator&( This a, This b ) noexcept {
49 return This( a.store & b.store );
52 friend constexpr
bool operator==( This a, This b ) noexcept {
53 return a.store == b.store;
56 friend constexpr
bool operator!=( This a, This b ) noexcept {
57 return a.store != b.store;
60 constexpr
bool has( Self x )
const noexcept {
64 constexpr
operator bool()
const noexcept {
73 template<
typename Self,
typename =
typename
74 std::enable_if< is_enum_class< Self >::value >::type >
77 return Ret( a ) | Ret( b );
80 template<
typename Self,
typename =
typename
81 std::enable_if< is_enum_class< Self >::value >::type >
84 return Ret( a ) & Ret( b );
89 #endif // WIBBLE_STRONGENUMFLAG_H
constexpr StrongEnumFlags< Self > operator&(Self a, Self b) noexcept
Definition: strongenumflags.h:82
std::integral_constant< bool, std::is_enum< E >::value &&!std::is_convertible< E, int >::value > is_enum_class
Definition: strongenumflags.h:16
Definition: strongenumflags.h:19
std::set< T > & operator|=(std::set< T > &a, const wibble::Empty< T > &)
Definition: operators.h:109
constexpr StrongEnumFlags< Self > operator|(Self a, Self b) noexcept
Definition: strongenumflags.h:75
std::set< T > & operator&=(std::set< T > &a, const SEQ &b)
Definition: operators.h:145