Skip to content

Instantly share code, notes, and snippets.

@LuxoftAKutsan
Created November 11, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuxoftAKutsan/e756c2871a834a4a9858 to your computer and use it in GitHub Desktop.
Save LuxoftAKutsan/e756c2871a834a4a9858 to your computer and use it in GitHub Desktop.
Простудой навело
#include <iostream>
#include <string>
#include <vector>
template <class T>
struct Enum {
template <typename EType>
static const char* ToString(EType etype) {
return T::strType()[static_cast<int>(etype)];
}
template <typename EType>
static EType FromString(const char* etype) {
}
};
struct MyEnum : public Enum<MyEnum> {
enum eType {ZERO, ONE, TWO};
static const char** strType() {
static const char* args[3] = {"ZERO", "ONE", "TWO"};
std::cout << sizeof(args) << std::endl;
return args;
}
};
int main() {
MyEnum::eType one = MyEnum::ONE;
std::cout << one << " " << MyEnum::ToString(one) << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment