smart_ptr.hpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#ifndef __CLAW_SMART_PTR_HPP__
#define __CLAW_SMART_PTR_HPP__
namespace claw
{
namespace memory
{
template<typename T>
class smart_ptr
{
public:
typedef T value_type;
typedef smart_ptr<value_type> self_type;
typedef T& reference;
typedef T* pointer;
typedef const T& const_reference;
typedef const T* const const_pointer;
public:
smart_ptr();
smart_ptr( pointer data );
smart_ptr( const self_type& that );
~smart_ptr();
self_type& operator=( const self_type& that );
bool operator==( const self_type& that ) const;
bool operator!=( const self_type& that ) const;
bool operator<( const self_type& that ) const;
bool operator<=( const self_type& that ) const;
bool operator>( const self_type& that ) const;
bool operator>=( const self_type& that ) const;
pointer operator->();
pointer operator->() const;
reference operator*();
reference operator*() const;
private:
void copy( const self_type& that );
void release();
private:
unsigned int* m_ref_count;
pointer m_ptr;
}; // class smart_ptr
} // namespace memory
} // namespace claw
#include <claw/impl/smart_ptr.tpp>
#endif // __CLAW_SMART_PTR_HPP__
claw::memory::smart_ptr< value_type >::const_pointer
const value_type *const const_pointer
Definition smart_ptr.hpp:70
claw::memory::smart_ptr::value_type
T value_type
The type of the pointed data.
Definition smart_ptr.hpp:55
claw::memory::smart_ptr< value_type >::const_reference
const value_type & const_reference
Definition smart_ptr.hpp:67
claw::memory::smart_ptr< value_type >::pointer
value_type * pointer
Definition smart_ptr.hpp:64
claw::memory::smart_ptr::self_type
smart_ptr< value_type > self_type
The type of the current class.
Definition smart_ptr.hpp:58
claw::memory::smart_ptr< value_type >::reference
value_type & reference
Definition smart_ptr.hpp:61
claw::memory
Memory management.
Definition claw.hpp:74
claw
This is the main namespace.
Definition algorithm.hpp:34