Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #define declare_singleton(class)    \
  2. private:                \
  3. class();                \
  4. class(const class&);            \
  5. class(class&);              \
  6. void operator=(const class&);       \   //usw  
  7. ~class();               \
  8. public:                 \
  9. friend class &singleton<class>();  
  10.  
  11. #define define_singleton(class)     \
  12. template <typename T>           \
  13. T &fSingleton(){            \
  14.     static T t;             \
  15.     return t;               \
  16. }                   \
  17. class &S_##class=fSingleton<class>();  
  18.  
  19. //x.h
  20. extern class x{
  21.     declare_singleton(x);
  22. } &S_x;
  23.  
  24. //x.cpp
  25. define_singleton(x);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement