- SmartPointer(const SmartPointer& other)
- : m_value(other.m_value)
- {
- Counter::increment(*m_value);
- }
- explicit SmartPointer(Type* value)
- : m_value(value)
- {
- Counter::increment(*m_value);
- }
- ~SmartPointer()
- {
- Counter::decrement(*m_value);
- }
- SmartPointer& operator=(const SmartPointer& other)
- {
- SmartPointer temp(other);
- temp.swap(*this);
- return *this;
- }
- SmartPointer& operator=(Type* value)
- {
- SmartPointer temp(value);
- temp.swap(*this);
- return *this;
- }
- void swap(SmartPointer& other)
- {
- std::swap(m_value, other.m_value);
- }
-
- operator Type*() const
- {
- return m_value;
- }
- Type& operator*() const
- {
- return *m_value;
- }
- Type* operator->() const
- {
- return m_value;
- }
- Type* get() const
- {
- return m_value;
- }
+SmartPointer( const SmartPointer& other )
+ : m_value( other.m_value ){
+ Counter::increment( *m_value );
+}
+explicit SmartPointer( Type* value )
+ : m_value( value ){
+ Counter::increment( *m_value );
+}
+~SmartPointer(){
+ Counter::decrement( *m_value );
+}
+SmartPointer& operator=( const SmartPointer& other ){
+ SmartPointer temp( other );
+ temp.swap( *this );
+ return *this;
+}
+SmartPointer& operator=( Type* value ){
+ SmartPointer temp( value );
+ temp.swap( *this );
+ return *this;
+}
+void swap( SmartPointer& other ){
+ std::swap( m_value, other.m_value );
+}
+
+operator Type*() const
+{
+ return m_value;
+}
+Type& operator*() const {
+ return *m_value;
+}
+Type* operator->() const {
+ return m_value;
+}
+Type* get() const {
+ return m_value;
+}