winss
Public Member Functions | List of all members
winss::NotOwningPtr< T > Class Template Reference

A container for pointers where the lifetime should be owned by the caller. More...

#include <not_owning_ptr.hpp>

Public Member Functions

 NotOwningPtr (T *p)
 Create a new NotOwningPtr with a pointer to the actual object. More...
 
template<class V >
 NotOwningPtr (const NotOwningPtr< V > &ptr)
 Copy constructor to allow copying the pointer. More...
 
T * Get ()
 Gets the not owned pointer. More...
 
T * Get () const
 Gets the not owned pointer as a constant. More...
 
T & operator* ()
 Gets the dereferenced object. More...
 
T & operator* () const
 Gets the dereferenced object as a constant. More...
 
T * operator-> ()
 Gets the not owned pointer. More...
 
T * operator-> () const
 Gets the not owned pointer as a constant. More...
 
bool operator== (const NotOwningPtr &ptr) const
 Checks equality of this not owned pointer and another. More...
 
bool operator!= (const NotOwningPtr &ptr) const
 Checks inequality of this not owned pointer and another. More...
 
NotOwningPtroperator= (const NotOwningPtr &ptr)
 Assigns the pointer to another pointer. More...
 

Detailed Description

template<class T>
class winss::NotOwningPtr< T >

A container for pointers where the lifetime should be owned by the caller.

Any function/class requiring a NotOwningPtr will be required to manage the lifetime of the object. If the object is deleted before the function/class has finished with it then unexpected errors will occur.

Template Parameters
TThe type of pointer which is not owned.

Constructor & Destructor Documentation

template<class T>
winss::NotOwningPtr< T >::NotOwningPtr ( T *  p)
inlineexplicit

Create a new NotOwningPtr with a pointer to the actual object.

template<class T>
template<class V >
winss::NotOwningPtr< T >::NotOwningPtr ( const NotOwningPtr< V > &  ptr)
inline

Copy constructor to allow copying the pointer.

Member Function Documentation

template<class T>
T* winss::NotOwningPtr< T >::Get ( )
inline

Gets the not owned pointer.

Returns
The raw pointer.
template<class T>
T* winss::NotOwningPtr< T >::Get ( ) const
inline

Gets the not owned pointer as a constant.

Returns
The raw pointer as a constant.
template<class T>
bool winss::NotOwningPtr< T >::operator!= ( const NotOwningPtr< T > &  ptr) const
inline

Checks inequality of this not owned pointer and another.

Parameters
[in]ptrThe other not owned pointer.
Returns
True if the pointers are not the same otherwise false.
template<class T>
T& winss::NotOwningPtr< T >::operator* ( )
inline

Gets the dereferenced object.

Returns
The dereferenced object.
template<class T>
T& winss::NotOwningPtr< T >::operator* ( ) const
inline

Gets the dereferenced object as a constant.

Returns
The dereferenced object as a constant.
template<class T>
T* winss::NotOwningPtr< T >::operator-> ( )
inline

Gets the not owned pointer.

Returns
The raw pointer.
template<class T>
T* winss::NotOwningPtr< T >::operator-> ( ) const
inline

Gets the not owned pointer as a constant.

Returns
The raw pointer as a constant.
template<class T>
NotOwningPtr& winss::NotOwningPtr< T >::operator= ( const NotOwningPtr< T > &  ptr)
inline

Assigns the pointer to another pointer.

Parameters
[in]ptrThe other not owned pointer.
Returns
This pointer.
template<class T>
bool winss::NotOwningPtr< T >::operator== ( const NotOwningPtr< T > &  ptr) const
inline

Checks equality of this not owned pointer and another.

Parameters
[in]ptrThe other not owned pointer.
Returns
True if the pointers are the same otherwise false.

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