From a28ae843ed9977559b3ed50f11fe701e17e5dcc6 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 6 Jan 2024 18:18:18 -0800 Subject: [PATCH] Added StaticCast overload for RefCntAutoPtr Also moved methods in the Cast.hpp header to Diligent namespace --- Common/interface/Cast.hpp | 7 ++++++- Common/interface/RefCntAutoPtr.hpp | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Common/interface/Cast.hpp b/Common/interface/Cast.hpp index 59478c5e1..6d0ab1371 100644 --- a/Common/interface/Cast.hpp +++ b/Common/interface/Cast.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,9 @@ #include "../../Platforms/Basic/interface/DebugUtilities.hpp" #include "CompilerDefinitions.h" +namespace Diligent +{ + template NODISCARD DstType* ClassPtrCast(SrcType* Ptr) { @@ -62,3 +65,5 @@ NODISCARD DstType StaticCast(const SrcType& Src) #endif return static_cast(Src); } + +} // namespace Diligent diff --git a/Common/interface/RefCntAutoPtr.hpp b/Common/interface/RefCntAutoPtr.hpp index 5884162ef..4144a66f0 100644 --- a/Common/interface/RefCntAutoPtr.hpp +++ b/Common/interface/RefCntAutoPtr.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 Diligent Graphics LLC + * Copyright 2019-2024 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -448,4 +448,10 @@ class RefCntWeakPtr T* m_pObject; }; +template +NODISCARD DstType StaticCast(const RefCntAutoPtr& Src) +{ + return static_cast(Src.RawPtr()); +} + } // namespace Diligent