GiNaC 1.8.7
Public Member Functions | Private Attributes | Friends | List of all members
GiNaC::ptr< T > Class Template Reference

Class of (intrusively) reference-counted pointers that support copy-on-write semantics. More...

#include <ptr.h>

Public Member Functions

 ptr (T *t) noexcept
 Bind ptr to newly created object, start reference counting. More...
 
 ptr (T &t) noexcept
 Bind ptr to existing reference-counted object. More...
 
 ptr (const ptr &other) noexcept
 
 ~ptr ()
 
ptroperator= (const ptr &other)
 
T & operator* () const noexcept
 
T * operator-> () const noexcept
 
void makewritable ()
 Announce your intention to modify the object bound to this ptr. More...
 
void swap (ptr &other) noexcept
 Swap the bound object of this ptr with another ptr. More...
 
template<class U >
bool operator== (const ptr< U > &rhs) const noexcept
 
template<class U >
bool operator!= (const ptr< U > &rhs) const noexcept
 

Private Attributes

T * p
 

Friends

struct std::less< ptr< T > >
 
T * get_pointer (const ptr &x) noexcept
 
template<class U >
bool operator== (const ptr &lhs, const U *rhs) noexcept
 
template<class U >
bool operator!= (const ptr &lhs, const U *rhs) noexcept
 
template<class U >
bool operator== (const U *lhs, const ptr &rhs) noexcept
 
template<class U >
bool operator!= (const U *lhs, const ptr &rhs) noexcept
 
std::ostream & operator<< (std::ostream &os, const ptr< T > &rhs)
 

Detailed Description

template<class T>
class GiNaC::ptr< T >

Class of (intrusively) reference-counted pointers that support copy-on-write semantics.

Requirements for T: must support the refcounted interface (usually by being derived from refcounted) T* T::duplicate() member function (only if makewriteable() is used)

Definition at line 56 of file ptr.h.

Constructor & Destructor Documentation

◆ ptr() [1/3]

template<class T >
GiNaC::ptr< T >::ptr ( T *  t)
inlinenoexcept

Bind ptr to newly created object, start reference counting.

Definition at line 67 of file ptr.h.

References GINAC_ASSERT, and GiNaC::ptr< T >::p.

◆ ptr() [2/3]

template<class T >
GiNaC::ptr< T >::ptr ( T &  t)
inlineexplicitnoexcept

Bind ptr to existing reference-counted object.

Definition at line 70 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ ptr() [3/3]

template<class T >
GiNaC::ptr< T >::ptr ( const ptr< T > &  other)
inlinenoexcept

Definition at line 72 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ ~ptr()

template<class T >
GiNaC::ptr< T >::~ptr ( )
inline

Definition at line 74 of file ptr.h.

References GiNaC::ptr< T >::p.

Member Function Documentation

◆ operator=()

template<class T >
ptr & GiNaC::ptr< T >::operator= ( const ptr< T > &  other)
inline

Definition at line 80 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ operator*()

template<class T >
T & GiNaC::ptr< T >::operator* ( ) const
inlinenoexcept

Definition at line 93 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ operator->()

template<class T >
T * GiNaC::ptr< T >::operator-> ( ) const
inlinenoexcept

Definition at line 94 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ makewritable()

template<class T >
void GiNaC::ptr< T >::makewritable ( )
inline

Announce your intention to modify the object bound to this ptr.

This ensures that the object is not shared by any other ptrs.

Definition at line 100 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ swap()

template<class T >
void GiNaC::ptr< T >::swap ( ptr< T > &  other)
inlinenoexcept

Swap the bound object of this ptr with another ptr.

Definition at line 111 of file ptr.h.

References GiNaC::ptr< T >::p.

◆ operator==()

template<class T >
template<class U >
bool GiNaC::ptr< T >::operator== ( const ptr< U > &  rhs) const
inlinenoexcept

Definition at line 124 of file ptr.h.

References GiNaC::ptr< T >::get_pointer, GiNaC::ptr< T >::p, and GiNaC::rhs().

◆ operator!=()

template<class T >
template<class U >
bool GiNaC::ptr< T >::operator!= ( const ptr< U > &  rhs) const
inlinenoexcept

Definition at line 127 of file ptr.h.

References GiNaC::ptr< T >::get_pointer, GiNaC::ptr< T >::p, and GiNaC::rhs().

Friends And Related Function Documentation

◆ std::less< ptr< T > >

template<class T >
friend struct std::less< ptr< T > >
friend

Definition at line 45 of file ptr.h.

◆ get_pointer

template<class T >
T * get_pointer ( const ptr< T > &  x)
friend

Definition at line 96 of file ptr.h.

Referenced by GiNaC::ptr< T >::operator!=(), and GiNaC::ptr< T >::operator==().

◆ operator== [1/2]

template<class T >
template<class U >
bool operator== ( const ptr< T > &  lhs,
const U *  rhs 
)
friend

Definition at line 130 of file ptr.h.

◆ operator!= [1/2]

template<class T >
template<class U >
bool operator!= ( const ptr< T > &  lhs,
const U *  rhs 
)
friend

Definition at line 133 of file ptr.h.

◆ operator== [2/2]

template<class T >
template<class U >
bool operator== ( const U *  lhs,
const ptr< T > &  rhs 
)
friend

Definition at line 136 of file ptr.h.

◆ operator!= [2/2]

template<class T >
template<class U >
bool operator!= ( const U *  lhs,
const ptr< T > &  rhs 
)
friend

Definition at line 139 of file ptr.h.

◆ operator<<

template<class T >
std::ostream & operator<< ( std::ostream &  os,
const ptr< T > &  rhs 
)
friend

Definition at line 141 of file ptr.h.

Member Data Documentation

◆ p

template<class T >
T* GiNaC::ptr< T >::p
private

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

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.