diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-07-14 16:03:57 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-07-14 16:03:57 +0200 |
commit | b47f6164b82c166afb6d560caa3ffb79db15c7b7 (patch) | |
tree | 69ce2522a25a4775e7749666abae1f456fd77e26 | |
parent | 68a0990512df4721d69b630aafccfb3f53ca7b0e (diff) |
w
-rw-r--r-- | compat/borrowed-ptr-fwd.hpp | 1 | ||||
-rw-r--r-- | compat/borrowed-ptr.inl | 1 | ||||
-rw-r--r-- | test/bptr.cpp | 14 |
3 files changed, 13 insertions, 3 deletions
diff --git a/compat/borrowed-ptr-fwd.hpp b/compat/borrowed-ptr-fwd.hpp index 8386decc..38927cc6 100644 --- a/compat/borrowed-ptr-fwd.hpp +++ b/compat/borrowed-ptr-fwd.hpp @@ -1,6 +1,7 @@ #pragma once namespace floormat { +struct bptr_base; template<typename T> class bptr; template<typename To, typename From> bptr<To> static_pointer_cast(const bptr<From>& p) noexcept; template<typename T> bptr(T* ptr) -> bptr<T>; diff --git a/compat/borrowed-ptr.inl b/compat/borrowed-ptr.inl index 68a545d6..e7b4bbbd 100644 --- a/compat/borrowed-ptr.inl +++ b/compat/borrowed-ptr.inl @@ -1,7 +1,6 @@ #pragma once #include "borrowed-ptr.hpp" #include "compat/assert.hpp" -#include <utility> #define FM_BPTR_DEBUG diff --git a/test/bptr.cpp b/test/bptr.cpp index 13c8119e..ffff5b19 100644 --- a/test/bptr.cpp +++ b/test/bptr.cpp @@ -365,8 +365,17 @@ void test10() fm_assert(!p6); fm_assert(p5 == p6); - (void)bptr<const bptr_base>{p6}; - //(void)bptr<bptr_base>{p6}; + fm_assert(!bptr<const bptr_base>{p6}); + //fm_assert(bptr<bptr_base>{p6}); +} + +void test11() +{ + auto p1 = bptr<bptr_base>{new Foo{1}}; + auto p2 = static_pointer_cast<Foo>(p1); + auto p3 = static_pointer_cast<bptr_base>(p1); + fm_assert(p2->x == 1); + fm_assert(p3); } } // namespace @@ -383,6 +392,7 @@ void Test::test_bptr() test8(); test9(); test10(); + test11(); } } // namespace floormat |