From 68a0990512df4721d69b630aafccfb3f53ca7b0e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 14 Jul 2024 14:24:43 +0200 Subject: w --- compat/borrowed-ptr.hpp | 18 +++++++++--------- compat/borrowed-ptr.inl | 4 +--- test/bptr.cpp | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/compat/borrowed-ptr.hpp b/compat/borrowed-ptr.hpp index 3982b547..146fc334 100644 --- a/compat/borrowed-ptr.hpp +++ b/compat/borrowed-ptr.hpp @@ -48,15 +48,15 @@ public: bptr(std::nullptr_t) noexcept; // NOLINT(*-explicit-conversions) bptr& operator=(std::nullptr_t) 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; + CORRADE_ALWAYS_INLINE bptr(const bptr&) noexcept; + CORRADE_ALWAYS_INLINE bptr& operator=(const bptr&) noexcept; + template Y> CORRADE_ALWAYS_INLINE bptr(const bptr&) noexcept; + template Y> CORRADE_ALWAYS_INLINE bptr& operator=(const bptr&) noexcept; + + CORRADE_ALWAYS_INLINE bptr(bptr&&) noexcept; + CORRADE_ALWAYS_INLINE bptr& operator=(bptr&&) noexcept; + template Y> CORRADE_ALWAYS_INLINE bptr(bptr&&) noexcept; + template Y> CORRADE_ALWAYS_INLINE bptr& operator=(bptr&&) noexcept; operator bptr() const noexcept requires (!std::is_const_v); diff --git a/compat/borrowed-ptr.inl b/compat/borrowed-ptr.inl index c2a8b730..68a545d6 100644 --- a/compat/borrowed-ptr.inl +++ b/compat/borrowed-ptr.inl @@ -134,7 +134,6 @@ bptr& bptr::_copy_assign(const bptr& other) noexcept { if (blk != other.blk) { - CORRADE_ASSUME(this != &other); // todo see if helps if (blk) blk->decrement(blk); blk = other.blk; @@ -187,8 +186,7 @@ template bool bptr::operator==(const bptr> template void bptr::swap(bptr& other) noexcept { - using floormat::swap; - swap(blk, other.blk); + floormat::swap(blk, other.blk); } template uint32_t bptr::use_count() const noexcept diff --git a/test/bptr.cpp b/test/bptr.cpp index 12bd9442..13c8119e 100644 --- a/test/bptr.cpp +++ b/test/bptr.cpp @@ -337,6 +337,8 @@ void test9() void test10() { + static_assert(std::is_same_v, std::decay_t()} )>>); + fm_assert(bptr{} == bptr{}); fm_assert(bptr{} == bptr{}); fm_assert(bptr{} == bptr{}); @@ -349,8 +351,22 @@ void test10() auto p4 = bptr{InPlace, 4}; (void)p4; auto p5 = bptr{p4}; (void)p5; + //p4 = p5; fm_assert(p4->x == 4); fm_assert(p5->x == 4); fm_assert(p4 == p5); + p5 = p4; + fm_assert(p5->x == 4); + fm_assert(p4 == p5); + auto p6 = bptr{p5}; (void)p6; + //p4.swap(p5); + p5.swap(p6); + fm_assert(p5 == p6); + p6.destroy(); + fm_assert(!p6); + fm_assert(p5 == p6); + + (void)bptr{p6}; + //(void)bptr{p6}; } } // namespace -- cgit v1.2.3