Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #ifndef Generator_h__
- #define Generator_h__
- // Генерация типа по переменной
- template<int v>
- struct Int2Type
- {
- enum { value = v };
- };
- static int counter = 0;
- template <typename T> class SingleTon
- {
- public:
- const static int get()
- {
- static bool init = false;
- const static int id = counter;
- if(!init)
- {
- ++counter;
- init = true;
- }
- return id;
- }
- protected:
- SingleTon() {}
- virtual ~SingleTon() {}
- };
- #define TYPE_ID(Type) SingleTon<Type>::get()
- #endif // Generator_h__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement