From 92d60403f3de094dc2d040a7fce869a5bb60695a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 May 2024 22:57:32 +0200 Subject: a --- compat/borrowed-ptr-fwd.hpp | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'compat/borrowed-ptr-fwd.hpp') diff --git a/compat/borrowed-ptr-fwd.hpp b/compat/borrowed-ptr-fwd.hpp index 465e9bf4..01dd20f7 100644 --- a/compat/borrowed-ptr-fwd.hpp +++ b/compat/borrowed-ptr-fwd.hpp @@ -1,6 +1,15 @@ #pragma once -namespace floormat::detail_borrowed_ptr { struct control_block_; } +namespace floormat::detail_borrowed_ptr { + +struct control_block; +template +concept DerivedFrom = requires(From* x) { + requires !std::is_same_v; + requires std::is_nothrow_convertible_v; +}; + +} // namespace floormat::detail_borrowed_ptr namespace floormat { @@ -11,26 +20,39 @@ template class bptr final // NOLINT(*-special-member-functions) { mutable T* casted_ptr; - detail_borrowed_ptr::control_block_* blk; + detail_borrowed_ptr::control_block* blk; - explicit bptr(DirectInitT, T* casted_ptr, detail_borrowed_ptr::control_block_* blk) noexcept; - //explicit bptr(NoInitT) noexcept; + explicit bptr(DirectInitT, T* casted_ptr, detail_borrowed_ptr::control_block* blk) noexcept; + + struct private_tag_t final {}; + static constexpr private_tag_t private_tag{}; + + template bptr(const bptr& other, private_tag_t) noexcept; + template bptr& _copy_assign(const bptr& other) noexcept; + template bptr(bptr&& other, private_tag_t) noexcept; + template bptr& _move_assign(bptr&& other) noexcept; public: template requires std::is_constructible_v explicit bptr(InPlaceInitT, Ts&&... args) noexcept; - bptr(std::nullptr_t) noexcept; // NOLINT(*-explicit-conversions) - bptr() noexcept; explicit bptr(T* ptr) noexcept; + bptr() noexcept; ~bptr() noexcept; + bptr(std::nullptr_t) noexcept; // NOLINT(*-explicit-conversions) bptr& operator=(std::nullptr_t) noexcept; - template requires std::is_convertible_v bptr(const bptr&) noexcept; - template requires std::is_convertible_v bptr& operator=(const bptr&) noexcept; - template requires std::is_convertible_v bptr(bptr&&) noexcept; - template requires std::is_convertible_v bptr& operator=(bptr&&) noexcept; + + bptr(const bptr&) noexcept; + bptr& operator=(const bptr&) noexcept; + template Y> bptr(const bptr&) noexcept; + template Y> bptr& operator=(const bptr&) noexcept; + + bptr(bptr&&) noexcept; + bptr& operator=(bptr&&) noexcept; + template Y> bptr(bptr&&) noexcept; + template Y> bptr& operator=(bptr&&) noexcept; friend bool operator==(const bptr& a, const bptr& b) noexcept; explicit operator bool() const noexcept; -- cgit v1.2.3