theCore C++ embedded framework
ecl::shared_ptr< T > Class Template Reference

Classical shared pointer. More...

#include </home/travis/build/forGGe/theCore/lib/cpp/export/ecl/memory.hpp>

Public Member Functions

 shared_ptr ()
 Constructs default shared pointer with no managed object. More...
 
virtual ~shared_ptr ()
 Destroys shared pointer and if counter. More...
 
 shared_ptr (std::nullptr_t nullp)
 Initializes shared pointer with nullpointer. More...
 
 shared_ptr (const shared_ptr &other)
 Constrcuts from existing pointer and inherit its ownership. More...
 
 shared_ptr (shared_ptr &&other)
 Moves other shared pointer and inherit ownership. More...
 
shared_ptroperator= (const shared_ptr &other)
 Shares ownership of the object with a pointer provided. More...
 
shared_ptroperator= (shared_ptr &&other)
 Moves ownership from the pointer provided. More...
 
 operator bool () const
 Returns true if this shared pointer manages the object. More...
 
template<typename U >
 shared_ptr (shared_ptr< U > &other)
 Constrcuts from existing pointer and inherit its ownership. More...
 
template<typename U >
shared_ptroperator= (shared_ptr< U > &other)
 Shares ownership with a shared pointer of the derived type. More...
 
bool unique () const
 Returns true if this pointer holds the last remaining node. More...
 
T * get () const
 Returs a value itself. More...
 
T & operator* ()
 Common smart pointer overload. More...
 
const T & operator* () const
 Common smart pointer overload. More...
 
T * operator-> ()
 Common smart pointer overload. More...
 
const T * operator-> () const
 Common smart pointer overload. More...
 
template<typename U >
shared_ptr< T > & operator= (shared_ptr< U > &other)
 

Friends

template<typename U >
class shared_ptr
 Related shared pointer type. More...
 
template<typename U >
class weak_ptr
 Weak reference. More...
 
template<typename U , class Alloc , class... Args>
shared_ptr< U > allocate_shared (const Alloc &alloc, Args... args)
 Allocates a shared pointer. More...
 

Detailed Description

template<typename T>
class ecl::shared_ptr< T >

Classical shared pointer.

Todo:
Mention about manadatory allocator for creating shared pointer

Constructor & Destructor Documentation

◆ shared_ptr() [1/5]

template<typename T >
ecl::shared_ptr< T >::shared_ptr ( )

Constructs default shared pointer with no managed object.

◆ ~shared_ptr()

template<typename T >
ecl::shared_ptr< T >::~shared_ptr ( )
virtual

Destroys shared pointer and if counter.

◆ shared_ptr() [2/5]

template<typename T >
ecl::shared_ptr< T >::shared_ptr ( std::nullptr_t  nullp)

Initializes shared pointer with nullpointer.

◆ shared_ptr() [3/5]

template<typename T >
ecl::shared_ptr< T >::shared_ptr ( const shared_ptr< T > &  other)

Constrcuts from existing pointer and inherit its ownership.

If other pointer manages no object, this manages no object too.

Parameters
[in]otherValid shared pointer.

◆ shared_ptr() [4/5]

template<typename T >
ecl::shared_ptr< T >::shared_ptr ( shared_ptr< T > &&  other)

Moves other shared pointer and inherit ownership.

This will not increase refernce counter, obviously.

Parameters
[in]otherValid shared pointer to move. After moving pointer will no longer hold any reference and will return to the default state.

◆ shared_ptr() [5/5]

template<typename T >
template<typename U >
ecl::shared_ptr< T >::shared_ptr ( shared_ptr< U > &  other)

Constrcuts from existing pointer and inherit its ownership.

If other pointer manages no object, this manages no object too.

Parameters
[in]otherValid shared pointer.
Template Parameters
UIs a subclass of T

Member Function Documentation

◆ operator=() [1/4]

template<typename T >
shared_ptr< T > & ecl::shared_ptr< T >::operator= ( const shared_ptr< T > &  other)

Shares ownership of the object with a pointer provided.

This shared pointer will release ownership of the previously managed object if any. In case other pointer owns an object then new ownership will be applied to this pointer and it will be shared with other pointer.

Parameters
[in]otherValid shared pointer.
Returns
This shared object.

◆ operator=() [2/4]

template<typename T >
shared_ptr< T > & ecl::shared_ptr< T >::operator= ( shared_ptr< T > &&  other)

Moves ownership from the pointer provided.

This shared pointer will release ownership of the previously managed object if any. Other pointer will no longer own any object.

Parameters
[in]otherValid shared pointer.
Returns
This shared object.

◆ operator bool()

template<typename T >
ecl::shared_ptr< T >::operator bool ( ) const
explicit

Returns true if this shared pointer manages the object.

◆ operator=() [3/4]

template<typename T>
template<typename U >
shared_ptr& ecl::shared_ptr< T >::operator= ( shared_ptr< U > &  other)

Shares ownership with a shared pointer of the derived type.

Template Parameters
UIs a subclass of T

◆ unique()

template<typename T >
bool ecl::shared_ptr< T >::unique ( ) const

Returns true if this pointer holds the last remaining node.

◆ get()

template<typename T >
T * ecl::shared_ptr< T >::get ( ) const

Returs a value itself.

◆ operator*() [1/2]

template<typename T >
T & ecl::shared_ptr< T >::operator* ( )

Common smart pointer overload.

◆ operator*() [2/2]

template<typename T >
const T & ecl::shared_ptr< T >::operator* ( ) const

Common smart pointer overload.

◆ operator->() [1/2]

template<typename T >
T * ecl::shared_ptr< T >::operator-> ( )

Common smart pointer overload.

◆ operator->() [2/2]

template<typename T >
const T * ecl::shared_ptr< T >::operator-> ( ) const

Common smart pointer overload.

◆ operator=() [4/4]

template<typename T>
template<typename U >
shared_ptr< T >& ecl::shared_ptr< T >::operator= ( shared_ptr< U > &  other)

Friends And Related Function Documentation

◆ shared_ptr

template<typename T>
template<typename U >
friend class shared_ptr
friend

Related shared pointer type.

Template Parameters
UIs a subclass of T.

◆ weak_ptr

template<typename T>
template<typename U >
friend class weak_ptr
friend

Weak reference.

Template Parameters
UIs a T or a subclass of T.

◆ allocate_shared

template<typename T>
template<typename U , class Alloc , class... Args>
shared_ptr< U > allocate_shared ( const Alloc &  alloc,
Args...  args 
)
friend

Allocates a shared pointer.

Template Parameters
UIs a T or is a subclass of T.

The documentation for this class was generated from the following file: