Skip to content

Commit

Permalink
Added StaticCast overload for RefCntAutoPtr
Browse files Browse the repository at this point in the history
Also moved methods in the Cast.hpp header to Diligent namespace
  • Loading branch information
TheMostDiligent committed Jan 7, 2024
1 parent c6bb954 commit a28ae84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Common/interface/Cast.hpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -30,6 +30,9 @@
#include "../../Platforms/Basic/interface/DebugUtilities.hpp"
#include "CompilerDefinitions.h"

namespace Diligent
{

template <typename DstType, typename SrcType>
NODISCARD DstType* ClassPtrCast(SrcType* Ptr)
{
Expand Down Expand Up @@ -62,3 +65,5 @@ NODISCARD DstType StaticCast(const SrcType& Src)
#endif
return static_cast<DstType>(Src);
}

} // namespace Diligent
8 changes: 7 additions & 1 deletion Common/interface/RefCntAutoPtr.hpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -448,4 +448,10 @@ class RefCntWeakPtr
T* m_pObject;
};

template <typename DstType, typename SrcType>
NODISCARD DstType StaticCast(const RefCntAutoPtr<SrcType>& Src)
{
return static_cast<DstType>(Src.RawPtr());
}

} // namespace Diligent

0 comments on commit a28ae84

Please sign in to comment.