mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 02:20:16 +01:00
memory: smart pointer factories should not be static (#72)
This commit is contained in:
parent
df6b8820c4
commit
69efb6291c
5 changed files with 11 additions and 19 deletions
|
|
@ -83,9 +83,7 @@ namespace Hyprutils::Memory {
|
|||
std::swap(m_ptr, ref.m_ptr);
|
||||
}
|
||||
|
||||
CAtomicSharedPointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CAtomicSharedPointer() noexcept = default;
|
||||
|
||||
CAtomicSharedPointer(std::nullptr_t) noexcept {
|
||||
; // empty
|
||||
|
|
@ -262,9 +260,7 @@ namespace Hyprutils::Memory {
|
|||
m_ptr = ref.m_ptr;
|
||||
}
|
||||
|
||||
CAtomicWeakPointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CAtomicWeakPointer() noexcept = default;
|
||||
|
||||
CAtomicWeakPointer(std::nullptr_t) noexcept {
|
||||
; // empty
|
||||
|
|
|
|||
|
|
@ -26,4 +26,6 @@ namespace Hyprutils::Memory {
|
|||
constexpr To bc(const From& from) noexcept {
|
||||
return std::bit_cast<To>(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
/* creates an empty shared pointer with no implementation */
|
||||
CSharedPointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CSharedPointer() noexcept = default;
|
||||
|
||||
/* creates an empty shared pointer with no implementation */
|
||||
CSharedPointer(std::nullptr_t) noexcept {
|
||||
|
|
@ -184,7 +182,7 @@ namespace Hyprutils {
|
|||
};
|
||||
|
||||
template <typename U, typename... Args>
|
||||
static CSharedPointer<U> makeShared(Args&&... args) {
|
||||
[[nodiscard]] inline CSharedPointer<U> makeShared(Args&&... args) {
|
||||
return CSharedPointer<U>(new U(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,9 +42,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
/* creates an empty unique pointer with no implementation */
|
||||
CUniquePointer() noexcept {
|
||||
; // empty
|
||||
}
|
||||
CUniquePointer() noexcept = default;
|
||||
|
||||
/* creates an empty unique pointer with no implementation */
|
||||
CUniquePointer(std::nullptr_t) noexcept {
|
||||
|
|
@ -136,7 +134,7 @@ namespace Hyprutils {
|
|||
};
|
||||
|
||||
template <typename U, typename... Args>
|
||||
static CUniquePointer<U> makeUnique(Args&&... args) {
|
||||
[[nodiscard]] inline CUniquePointer<U> makeUnique(Args&&... args) {
|
||||
return CUniquePointer<U>(new U(std::forward<Args>(args)...));
|
||||
}
|
||||
}
|
||||
|
|
@ -147,4 +145,4 @@ struct std::hash<Hyprutils::Memory::CUniquePointer<T>> {
|
|||
std::size_t operator()(const Hyprutils::Memory::CUniquePointer<T>& p) const noexcept {
|
||||
return std::hash<void*>{}(p.impl_);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -102,9 +102,7 @@ namespace Hyprutils {
|
|||
}
|
||||
|
||||
/* create an empty weak ptr */
|
||||
CWeakPointer() {
|
||||
;
|
||||
}
|
||||
CWeakPointer() noexcept = default;
|
||||
|
||||
~CWeakPointer() {
|
||||
decrementWeak();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue