hexed 0.3.0
 
Loading...
Searching...
No Matches
hexed::Multiple_ptr< T, U > Class Template Reference

Like a Mutual_ptr, except it can accept multiple partners. More...

#include <Mutual_ptr.hpp>

Inheritance diagram for hexed::Multiple_ptr< T, U >:
hexed::Ptr_base< T, U >

Public Member Functions

 Multiple_ptr (T *data)
 Constructs a Multiple_ptr and permanently associates it with data.
 
 Multiple_ptr (const Multiple_ptr &)=delete
 Cannot copy a Multiple_ptr because it is unclear what that should do to partners.
 
Multiple_ptroperator= (const Multiple_ptr &)=delete
 
 Multiple_ptr (Multiple_ptr &&other)
 
Multiple_ptroperator= (Multiple_ptr &&other)
 Moving a Multiple_ptr steals the others partners.
 
void add (Ptr_base< U, T > &other)
 Adds other to the list of partners and reciprocally connects it with this.
 
void remove (Ptr_base< U, T > &other)
 Removes other from the list of partners and reciprocally disconnects it from this.
 
 operator bool () const
 Returns true iff this has at least 1 partner.
 
T & mine ()
 Obtain the object I am permanently associated with.
 
std::vector< Ptr_base< U, T > * > partners ()
 Obtains the sequence of partners, in no particular order.
 
const T & mine () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< const Ptr_base< U, T > * > partners () const
 Obtains the sequence of partners, in no particular order.
 

Additional Inherited Members

- Protected Member Functions inherited from hexed::Ptr_base< T, U >
void connect (Ptr_base< U, T > *other)
 Mutually connect us by calling both our connect_self.
 
void disconnect (Ptr_base< U, T > *other)
 Mutually disconnect us by calling both our disconnect_self.
 

Detailed Description

template<typename T, typename U>
class hexed::Multiple_ptr< T, U >

Like a Mutual_ptr, except it can accept multiple partners.

Has a sequence of partners(), each of which is a Ptr_base<U, T>. Thus it can be connected to Mutual_ptrs or other Multiple_ptrs. Disconnecting (using Multiple_ptr::remove, Mutual_ptr::unpair(), or destroying the partners) will simply remove partners from the sequence.

Constructor & Destructor Documentation

◆ Multiple_ptr() [1/2]

template<typename T , typename U >
hexed::Multiple_ptr< T, U >::Multiple_ptr ( T * data)
inline

Constructs a Multiple_ptr and permanently associates it with data.

data must not be null.

◆ Multiple_ptr() [2/2]

template<typename T , typename U >
hexed::Multiple_ptr< T, U >::Multiple_ptr ( Multiple_ptr< T, U > && other)
inline
See also
operator=(Multiple_ptr&&)

Member Function Documentation

◆ mine() [1/2]

template<typename T , typename U >
T & hexed::Multiple_ptr< T, U >::mine ( )
inlinevirtual

Obtain the object I am permanently associated with.

Implements hexed::Ptr_base< T, U >.

◆ mine() [2/2]

template<typename T , typename U >
const T & hexed::Multiple_ptr< T, U >::mine ( ) const
inlinevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implements hexed::Ptr_base< T, U >.

◆ operator=()

template<typename T , typename U >
Multiple_ptr & hexed::Multiple_ptr< T, U >::operator= ( Multiple_ptr< T, U > && other)
inline

Moving a Multiple_ptr steals the others partners.

mine() will point to other.mine(). Any partners this had before the move assignment will be removed. other will be left with its mine() intact and no partners.


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