#include <iostream> #define ENUM_CLASS(NAME, TYPE, VALUES...) \ struct NAME { \ enum e { VALUES }; \ explicit NAME(TYPE v) : val(v) {} \ NAME(e v) : val(v) {} \ operator e() const { return e(val); } \ private:\ TYPE val; \ } struct Enum ; void f ( Enum e ) ; ENUM_CLASS ( Enum, int , VALUE, ANOTHER_VALUE ) ; void f ( Enum e ) { switch ( e ) { case Enum :: VALUE : std :: cout << "VALUE" << std :: endl ; return ; case Enum :: ANOTHER_VALUE : std :: cout << "ANOTHER_VALUE" << std :: endl ; return ; } Enum e2 = ( Enum ) ( e | Enum :: VALUE ) ; } int main ( ) { f ( Enum :: ANOTHER_VALUE ) ; return 0 ; }

I2luY2x1ZGUgPGlvc3RyZWFtPgoKI2RlZmluZSBFTlVNX0NMQVNTKE5BTUUsIFRZUEUsIFZBTFVFUy4uLikgXApzdHJ1Y3QgTkFNRSB7IFwKICAgIGVudW0gZSB7IFZBTFVFUyB9OyBcCiAgICBleHBsaWNpdCBOQU1FKFRZUEUgdikgOiB2YWwodikge30gXAogICAgTkFNRShlIHYpIDogdmFsKHYpIHt9IFwKICAgIG9wZXJhdG9yIGUoKSBjb25zdCB7IHJldHVybiBlKHZhbCk7IH0gXAogICAgcHJpdmF0ZTpcCiAgICAgICAgVFlQRSB2YWw7IFwKfQoKc3RydWN0IEVudW07Cgp2b2lkIGYoRW51bSBlKTsKCkVOVU1fQ0xBU1MoRW51bSwgaW50LCAKICAgIFZBTFVFLAogICAgQU5PVEhFUl9WQUxVRQopOwoKdm9pZCBmIChFbnVtIGUpCnsKICAgIHN3aXRjaChlKQogICAgewogICAgICAgIGNhc2UgRW51bTo6VkFMVUU6CiAgICAgICAgICAgIHN0ZDo6Y291dCA8PCAiVkFMVUUiIDw8IHN0ZDo6ZW5kbDsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgRW51bTo6QU5PVEhFUl9WQUxVRToKICAgICAgICAgICAgc3RkOjpjb3V0IDw8ICJBTk9USEVSX1ZBTFVFIiA8PCBzdGQ6OmVuZGw7CiAgICAgICAgICAgIHJldHVybjsKICAgIH0KCiAgICBFbnVtIGUyID0gKEVudW0pKGUgfCBFbnVtOjpWQUxVRSk7Cn0KCmludCBtYWluKCkKewogICAgZihFbnVtOjpBTk9USEVSX1ZBTFVFKTsKICAgIHJldHVybiAwOwp9