11 #include <rapidsmpf/error.hpp>
12 #include <rapidsmpf/utils/misc.hpp>
24 template <
typename BackRef>
42 strong_{other.strong_ ? other.strong_ : std::shared_ptr<BackRef>{other.weak_}} {
59 other.strong_ ? other.strong_ : std::shared_ptr<BackRef>{other.weak_};
61 strong_ = std::move(promoted);
84 [[nodiscard]]
bool operator==(
BackRefMixin const& other) const noexcept {
105 std::weak_ptr<BackRef>
const empty_weak{};
108 "set_backref: backref must not be empty",
109 std::invalid_argument
113 "set_backref: backref is already set",
114 std::invalid_argument
116 weak_ = std::move(backref);
121 std::weak_ptr<BackRef> weak_{};
122 std::shared_ptr<BackRef> strong_{};
Mixin that lets copies of the this object keep an external object reference of type BackRef alive.
void set_backref(std::weak_ptr< BackRef > backref)
Install a back-reference on this instance.
BackRefMixin & operator=(BackRefMixin const &other)
Copy assignment with the same semantics as the copy constructor.
BackRefMixin() noexcept=default
Construct a mixin with no installed back-reference.
BackRefMixin(BackRefMixin &&) noexcept=default
Move constructor.
RAPIDS Multi-Processor interfaces.
requires constexpr std::same_as< typename A::element_type, typename B::element_type > bool owner_equal(A const &a, B const &b) noexcept
Backport of std::weak_ptr::owner_equal / std::owner_equal from C++26.