shared_ptr.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2008-12-19
  5. // Updated : 2005-06-13
  6. // Licence : This source is under MIT License
  7. // File : gli/fetch.hpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. #ifndef GLI_SHARED_PTR_INCLUDED
  10. #define GLI_SHARED_PTR_INCLUDED
  11. namespace gli
  12. {
  13. template <typename T>
  14. class shared_ptr
  15. {
  16. public:
  17. shared_ptr();
  18. shared_ptr(shared_ptr const & SmartPtr);
  19. shared_ptr(T* pPointer);
  20. ~shared_ptr();
  21. T& operator*();
  22. T* operator->();
  23. const T& operator*() const;
  24. const T* operator->() const;
  25. shared_ptr& operator=(shared_ptr const & SmartPtr);
  26. shared_ptr& operator=(T* pPointer);
  27. bool operator==(shared_ptr const & SmartPtr) const;
  28. bool operator!=(shared_ptr const & SmartPtr) const;
  29. private:
  30. int* m_pReference;
  31. T* m_pPointer;
  32. };
  33. }//namespace gli
  34. #include "shared_ptr.inl"
  35. #endif //GLI_SHARED_PTR_INCLUDED