Created
November 11, 2015 15:59
-
-
Save LuxoftAKutsan/e756c2871a834a4a9858 to your computer and use it in GitHub Desktop.
Простудой навело
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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