flags.hh File Reference
Include dependency graph for flags.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMPLEMENT_FLAG_OPERATIONS(E)
 

Macro Definition Documentation

◆ IMPLEMENT_FLAG_OPERATIONS

#define IMPLEMENT_FLAG_OPERATIONS (   E)
Value:
inline E operator | (E lhs, E rhs) \
{ \
return static_cast<E>( static_cast<int>(lhs) | static_cast<int>(rhs)); \
} \
\
inline E operator & (E lhs, E rhs) \
{ \
return static_cast<E>( static_cast<int>(lhs) & static_cast<int>(rhs)); \
} \
\
inline E operator -= (E& lhs, E rhs) \
{ \
lhs = static_cast<E>( static_cast<int>(lhs) & ~static_cast<int>(rhs)); \
return lhs; \
} \
\
inline bool has_flag(E flags, E test) \
{ \
return (flags & test) == test; \
}

This macro implements operations on a strongly typed enum that is used as a flag. We use a macro since we don't want to provide a template that would be valid for all types that don't have these operators implemented

Definition at line 36 of file flags.hh.