mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-05-13 13:50:44 +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 Hyprutils {
|
||||||
namespace Memory {
|
namespace Memory {
|
||||||
|
|
||||||
struct SForceReinterpret {
|
|
||||||
explicit SForceReinterpret() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr SForceReinterpret FORCE_REINTERPRET = SForceReinterpret();
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class CSharedPointer {
|
class CSharedPointer {
|
||||||
public:
|
public:
|
||||||
|
@ -44,12 +38,6 @@ namespace Hyprutils {
|
||||||
increment();
|
increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
CSharedPointer(const CSharedPointer<U>& ref, SForceReinterpret) noexcept {
|
|
||||||
impl_ = ref.impl_;
|
|
||||||
increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
CSharedPointer(const CSharedPointer& ref) noexcept {
|
CSharedPointer(const CSharedPointer& ref) noexcept {
|
||||||
impl_ = ref.impl_;
|
impl_ = ref.impl_;
|
||||||
increment();
|
increment();
|
||||||
|
@ -197,6 +185,11 @@ namespace Hyprutils {
|
||||||
static CSharedPointer<U> makeShared(Args&&... args) {
|
static CSharedPointer<U> makeShared(Args&&... args) {
|
||||||
return CSharedPointer<U>(new U(std::forward<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