Open wc-duck opened 5 years ago
Add flag on enum to optionally decorate generated enums with something similar to this:
#define DECLARE_ENUM_OPERATORS( enum_name ) \ static_assert( sizeof(unsigned int) == sizeof(enum_name), "sizes should match" ); \ static enum_name operator | ( const enum_name& e1, const enum_name& e2 ) { return (enum_name)((unsigned int)e1 | (unsigned int)e2); } \ static enum_name operator & ( const enum_name& e1, const enum_name& e2 ) { return (enum_name)((unsigned int)e1 & (unsigned int)e2); } \ static enum_name operator ^ ( const enum_name& e1, const enum_name& e2 ) { return (enum_name)((unsigned int)e1 ^ (unsigned int)e2); } \ static enum_name& operator |= ( enum_name& e1, const enum_name e2 ) { e1 = ( e1 | e2 ); return e1; } \ static enum_name& operator &= ( enum_name& e1, const enum_name e2 ) { e1 = ( e1 & e2 ); return e1; } \ static enum_name& operator ^= ( enum_name& e1, const enum_name e2 ) { e1 = ( e1 ^ e2 ); return e1; } \ static enum_name operator ~ ( const enum_name e ) { return (enum_name)(~((unsigned int)e)); }
Add flag on enum to optionally decorate generated enums with something similar to this: