From 8f62c3329948f3bd1aa5dc208ab5efac42543a57 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jul 2024 15:08:07 +0200 Subject: wa --- compat/borrowed-ptr.hpp | 36 ++++++++++++++++-------------------- compat/borrowed-ptr.inl | 5 ++++- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/compat/borrowed-ptr.hpp b/compat/borrowed-ptr.hpp index 7ab42ebb..c4cc7975 100644 --- a/compat/borrowed-ptr.hpp +++ b/compat/borrowed-ptr.hpp @@ -12,7 +12,17 @@ #define fm_bptr_assert(...) void() #endif -namespace floormat { struct bptr_base; } +namespace floormat { +struct bptr_base +{ + virtual ~bptr_base() noexcept; + bptr_base() noexcept; + bptr_base(const bptr_base&) noexcept; + bptr_base(bptr_base&&) noexcept; + bptr_base& operator=(const bptr_base&) noexcept; + bptr_base& operator=(bptr_base&&) noexcept; +}; +} // namespace floormat namespace floormat::detail_bptr { @@ -24,7 +34,6 @@ struct control_block final static void weak_decrement(control_block*& blk) noexcept; }; -#if 0 template concept StaticCastable = requires(From* from, To* to) { static_cast(from); @@ -34,29 +43,13 @@ concept StaticCastable = requires(From* from, To* to) { template concept DerivedFrom = requires(From* from, To* to) { - static_cast(from); - static_cast(to); - requires std::is_convertible_v; + requires std::is_convertible_v; }; -#else -template concept DerivedFrom = true; -template concept StaticCastable = true; -#endif } // namespace floormat::detail_bptr namespace floormat { -struct bptr_base -{ - virtual ~bptr_base() noexcept; - bptr_base() noexcept; - bptr_base(const bptr_base&) noexcept; - bptr_base(bptr_base&&) noexcept; - bptr_base& operator=(const bptr_base&) noexcept; - bptr_base& operator=(bptr_base&&) noexcept; -}; - template class bptr final // NOLINT(*-special-member-functions) { @@ -69,7 +62,7 @@ class bptr final // NOLINT(*-special-member-functions) public: template - //requires std::is_constructible_v, Ts&&...> + requires std::is_constructible_v, Ts&&...> explicit bptr(InPlaceInitT, Ts&&... args) noexcept; template Y> explicit bptr(Y* ptr) noexcept; @@ -79,6 +72,9 @@ public: bptr(std::nullptr_t) noexcept; // NOLINT(*-explicit-conversions) bptr& operator=(std::nullptr_t) noexcept; + bptr(const bptr>& ptr) noexcept requires std::is_const_v; + bptr(bptr>&& ptr) noexcept requires std::is_const_v; + bptr(const bptr&) noexcept; bptr& operator=(const bptr&) noexcept; template Y> bptr(const bptr&) noexcept; diff --git a/compat/borrowed-ptr.inl b/compat/borrowed-ptr.inl index 327bd7cd..dfc112c7 100644 --- a/compat/borrowed-ptr.inl +++ b/compat/borrowed-ptr.inl @@ -11,7 +11,7 @@ namespace floormat { template template -//requires std::is_constructible_v, Ts&&...> +requires std::is_constructible_v, Ts&&...> bptr::bptr(InPlaceInitT, Ts&&... args) noexcept: bptr{ new std::remove_const_t{ forward(args)... } } {} @@ -26,6 +26,9 @@ bptr::bptr(Y* ptr) noexcept: template bptr::~bptr() noexcept { if (blk) detail_bptr::control_block::decrement(blk); } +template bptr::bptr(const bptr>& ptr) noexcept requires std::is_const_v: bptr{ptr, nullptr} {} +template bptr::bptr(bptr>&& ptr) noexcept requires std::is_const_v: bptr{move(ptr), nullptr} {} + template bptr::bptr(const bptr& other) noexcept: bptr{other, nullptr} {} template bptr::bptr(bptr&& other) noexcept: bptr{move(other), nullptr} {} template bptr& bptr::operator=(const bptr& other) noexcept { return _copy_assign(other); } -- cgit v1.2.3