Add EnumAddFlags for easy flags appending

This commit is contained in:
Wojtek Figat
2023-04-20 15:21:47 +02:00
parent 1ffe8a7b60
commit 8cfc14f4b1
2 changed files with 8 additions and 1 deletions

View File

@@ -171,5 +171,12 @@ constexpr bool EnumHasNoneFlags(T value, T flags)
return ((__underlying_type(T))value & (__underlying_type(T))flags) == 0;
}
// Returns enum value with additional enum flags set
template<typename T>
constexpr T EnumAddFlags(T value, T flags)
{
return (T)((__underlying_type(T))value | (__underlying_type(T))flags);
}
// Returns byte offset from the object pointer in vtable to the begin of the given inherited type implementation
#define VTABLE_OFFSET(type, baseType) (((intptr)static_cast<baseType*>((type*)1))-1)