From eba565a6359957a7ba5c3af645af36eefd58fbf3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jul 2024 10:52:09 +0200 Subject: w --- compat/weak-borrowed-ptr.hpp | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 compat/weak-borrowed-ptr.hpp (limited to 'compat/weak-borrowed-ptr.hpp') diff --git a/compat/weak-borrowed-ptr.hpp b/compat/weak-borrowed-ptr.hpp new file mode 100644 index 00000000..ac512c5c --- /dev/null +++ b/compat/weak-borrowed-ptr.hpp @@ -0,0 +1,45 @@ +#pragma once +#include "borrowed-ptr.hpp" + +namespace floormat { + +template +class weak_bptr final +{ + detail_bptr::control_block* blk; + + static detail_bptr::control_block* _copy(detail_bptr::control_block* ptr); + weak_bptr& _copy_assign(detail_bptr::control_block* other) noexcept; + weak_bptr& _move_assign(detail_bptr::control_block*& other) noexcept; + +public: + weak_bptr(std::nullptr_t) noexcept; + weak_bptr& operator=(std::nullptr_t) noexcept; + weak_bptr() noexcept; + ~weak_bptr() noexcept; + + template Y> weak_bptr(const bptr& ptr) noexcept; + template Y> weak_bptr(const weak_bptr& ptr) noexcept; + weak_bptr(const weak_bptr& ptr) noexcept; + + template Y> weak_bptr& operator=(const bptr& ptr) noexcept; + template Y> weak_bptr& operator=(const weak_bptr& ptr) noexcept; + weak_bptr& operator=(const weak_bptr& ptr) noexcept; + + template Y> weak_bptr(weak_bptr&& ptr) noexcept; + weak_bptr(weak_bptr&& ptr) noexcept; + + template Y> weak_bptr& operator=(weak_bptr&& ptr) noexcept; + weak_bptr& operator=(weak_bptr&& ptr) noexcept; + + void reset() noexcept; + void swap(weak_bptr& other) noexcept; + + uint32_t use_count() const noexcept; + bool expired() const noexcept; + bptr lock() const noexcept; + + bool operator==(const weak_bptr& other) const noexcept; +}; + +} // namespace floormat -- cgit v1.2.3