Public Member Functions | List of all members
rapidsmpf::BackRefMixin< BackRef > Class Template Reference

Mixin that lets copies of the this object keep an external object reference of type BackRef alive. More...

#include <back_ref_mixin.hpp>

Public Member Functions

 BackRefMixin () noexcept=default
 Construct a mixin with no installed back-reference.
 
 BackRefMixin (BackRefMixin const &other)
 Acquire shared ownership of other's back-referenced owner. More...
 
BackRefMixinoperator= (BackRefMixin const &other)
 Copy assignment with the same semantics as the copy constructor. More...
 
 BackRefMixin (BackRefMixin &&) noexcept=default
 Move constructor.
 
BackRefMixinoperator= (BackRefMixin &&) noexcept=default
 Move assignment operator. More...
 
bool operator== (BackRefMixin const &other) const noexcept
 Owner-based equality. More...
 
void set_backref (std::weak_ptr< BackRef > backref)
 Install a back-reference on this instance. More...
 

Detailed Description

template<typename BackRef>
class rapidsmpf::BackRefMixin< BackRef >

Mixin that lets copies of the this object keep an external object reference of type BackRef alive.

Note
Copying an instance without calling set_backref() throws std::bad_weak_ptr.
Template Parameters
BackRefType of the external object reference.

Definition at line 25 of file back_ref_mixin.hpp.

Constructor & Destructor Documentation

◆ BackRefMixin()

template<typename BackRef >
rapidsmpf::BackRefMixin< BackRef >::BackRefMixin ( BackRefMixin< BackRef > const &  other)
inline

Acquire shared ownership of other's back-referenced owner.

After construction, this references the same owner as other and keeps it alive for as long as this lives.

Parameters
otherMixin to copy from.
Exceptions
std::bad_weak_ptrif other is uninstalled, or is installed but its owner has been destroyed.

Definition at line 40 of file back_ref_mixin.hpp.

Member Function Documentation

◆ operator=() [1/2]

template<typename BackRef >
BackRefMixin& rapidsmpf::BackRefMixin< BackRef >::operator= ( BackRefMixin< BackRef > &&  )
defaultnoexcept

Move assignment operator.

Returns
Reference to this mixin.

◆ operator=() [2/2]

template<typename BackRef >
BackRefMixin& rapidsmpf::BackRefMixin< BackRef >::operator= ( BackRefMixin< BackRef > const &  other)
inline

Copy assignment with the same semantics as the copy constructor.

If the assignment throws, this is left unchanged.

Parameters
otherMixin to copy from.
Returns
Reference to this.
Exceptions
std::bad_weak_ptrif other is uninstalled, or is installed but its owner has been destroyed.

Definition at line 55 of file back_ref_mixin.hpp.

◆ operator==()

template<typename BackRef >
bool rapidsmpf::BackRefMixin< BackRef >::operator== ( BackRefMixin< BackRef > const &  other) const
inlinenoexcept

Owner-based equality.

Parameters
otherMixin to compare against.
Returns
true if both mixins reference the same back-referenced owner, or are both uninstalled.

Definition at line 84 of file back_ref_mixin.hpp.

◆ set_backref()

template<typename BackRef >
void rapidsmpf::BackRefMixin< BackRef >::set_backref ( std::weak_ptr< BackRef >  backref)
inline

Install a back-reference on this instance.

After this call, every subsequent copy of this will hold shared ownership of backref's referent for the lifetime of the copy.

Installation only affects this and copies made from it afterwards; copies that already exist are not retroactively back-referenced. To guarantee the back-reference is honored by every observable copy, install it before the host object becomes reachable to any code that may copy it.

Parameters
backrefNon-empty weak reference to the back-referenced owner.
Exceptions
std::invalid_argumentif backref is empty, or if a back-reference is already installed on this instance.

Definition at line 104 of file back_ref_mixin.hpp.


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