From dcc4f2aeb3623ffb68f0e776b1c9b065ca22f422 Mon Sep 17 00:00:00 2001 From: Silvertakana <62156548+silvertakana@users.noreply.github.com> Date: Sat, 25 Jun 2022 21:02:34 +1200 Subject: [PATCH] Additional Scope and Ref Functions --- Hazel/src/Hazel/Core/Base.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Hazel/src/Hazel/Core/Base.h b/Hazel/src/Hazel/Core/Base.h index 426baa0d2..6614d7f9d 100644 --- a/Hazel/src/Hazel/Core/Base.h +++ b/Hazel/src/Hazel/Core/Base.h @@ -29,14 +29,29 @@ namespace Hazel { template using Scope = std::unique_ptr; + template + constexpr Scope GetScope(T& ptr) + { + return std::unique_ptr(&ptr); + } template constexpr Scope CreateScope(Args&& ... args) { return std::make_unique(std::forward(args)...); } - + template using Ref = std::shared_ptr; + template + constexpr Ref GetRef(T& ptr) + { + return std::shared_ptr(&ptr); + } + template + constexpr Ref CastRef(Ref& ptr) + { + return std::static_pointer_cast(ptr); + } template constexpr Ref CreateRef(Args&& ... args) {