1
0

Alias.h 601 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef NULLSOFT_UTILITY_ALIASH
  2. #define NULLSOFT_UTILITY_ALIASH
  3. template <class ptr_t>
  4. class Alias
  5. {
  6. public:
  7. Alias()
  8. :pointer(0)
  9. {
  10. }
  11. Alias(ptr_t *_pointer) : pointer(_pointer)
  12. {
  13. }
  14. Alias(const Alias<ptr_t> &copy)
  15. {
  16. pointer=copy.pointer;
  17. }
  18. ~Alias()
  19. {
  20. pointer=0;
  21. }
  22. ptr_t *operator = (ptr_t *copy)
  23. {
  24. pointer=copy;
  25. return copy;
  26. }
  27. ptr_t *operator ->()
  28. {
  29. return pointer;
  30. }
  31. operator bool()
  32. {
  33. return !!pointer;
  34. }
  35. bool operator == (ptr_t *compare)
  36. {
  37. return pointer == compare;
  38. }
  39. /*
  40. operator ptr_t *()
  41. {
  42. return pointer;
  43. }
  44. */
  45. private:
  46. ptr_t *pointer;
  47. };
  48. #endif