GLI  0.5.0
shared_ptr.hpp
Go to the documentation of this file.
1 
29 #ifndef GLI_SHARED_PTR_INCLUDED
30 #define GLI_SHARED_PTR_INCLUDED
31 
32 #include <cassert>
33 
34 namespace gli
35 {
36  template <typename T>
37  class shared_ptr
38  {
39 /* TODO: make_shared
40  template typename T
41  class refcounter
42  {
43  Long Counter;
44  T Data;
45  };
46 */
47 
48  public:
49  shared_ptr();
50  shared_ptr(shared_ptr const & SharedPtr);
51  explicit shared_ptr(T * Pointer);
52  ~shared_ptr();
53 
54  T * get() const;
55  T const & operator*() const;
56  T & operator*();
57  T const * const operator->() const;
58  T * operator->();
59  shared_ptr& operator=(shared_ptr const & SharedPtr);
60  shared_ptr& operator=(T * Pointer);
61  bool operator==(shared_ptr const & SharedPtr) const;
62  bool operator!=(shared_ptr const & SharedPtr) const;
63 
64  void reset();
65  void reset(T * Pointer);
66  long use_count() const;
67  bool unique() const;
68 
69  private:
70  long * Counter;
71  T * Pointer;
72  };
73 }//namespace gli
74 
75 #include "shared_ptr.inl"
76 
77 #endif //GLI_SHARED_PTR_INCLUDED
shared_ptr & operator=(shared_ptr const &SharedPtr)
T const & operator*() const
bool unique() const
bool operator!=(shared_ptr const &SharedPtr) const
long use_count() const
T const *const operator->() const
bool operator==(shared_ptr const &SharedPtr) const