Quick actions

cmd+k|ctrl+k

Navigation

Languages

Type-Enum

Snippet info

Language

Cpp

Visibility

public

Author

ovidiugabriel

Created

2019-05-27T11:18:30Z

Updated

2019-06-07T20:29:31Z

#include <iostream>
#include <cstring>
using namespace std;



#define ENUM_VALUE(category, type) \
    struct type { \
        static inline const char* category() {\
            return #type; \
        } \
    }

#define ENUM_TYPE(category, type) static inline const char* category() { \
        return #type; \
    }

ENUM_VALUE( hello );

struct S {
    int a;
    // float c;
};

S s;
int a;

// static_assert(sizeof s == sizeof a, "");
// memcpy(&a, &s, sizeof a);

int main() {
    cout << hello::value();
    return 0;
}
INFO