mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-05-13 05:40:40 +01:00
memory: Change constructor to reinterpretPointerCast function
This commit is contained in:
parent
c3ddf46b2a
commit
642f94e9df
1 changed files with 5 additions and 12 deletions
|
@ -16,12 +16,6 @@
|
|||
namespace Hyprutils {
|
||||
namespace Memory {
|
||||
|
||||
struct SForceReinterpret {
|
||||
explicit SForceReinterpret() = default;
|
||||
};
|
||||
|
||||
constexpr SForceReinterpret FORCE_REINTERPRET = SForceReinterpret();
|
||||
|
||||
template <typename T>
|
||||
class CSharedPointer {
|
||||
public:
|
||||
|
@ -44,12 +38,6 @@ namespace Hyprutils {
|
|||
increment();
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
CSharedPointer(const CSharedPointer<U>& ref, SForceReinterpret) noexcept {
|
||||
impl_ = ref.impl_;
|
||||
increment();
|
||||
}
|
||||
|
||||
CSharedPointer(const CSharedPointer& ref) noexcept {
|
||||
impl_ = ref.impl_;
|
||||
increment();
|
||||
|
@ -197,6 +185,11 @@ namespace Hyprutils {
|
|||
static CSharedPointer<U> makeShared(Args&&... args) {
|
||||
return CSharedPointer<U>(new U(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
CSharedPointer<T> reinterpretPointerCast(const CSharedPointer<U>& ref) {
|
||||
return CSharedPointer<T>(ref.impl_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue