summaryrefslogtreecommitdiff
path: root/AK/WeakPtr.h
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-04-10 18:29:06 +0430
committerAndreas Kling <kling@serenityos.org>2021-04-10 21:01:31 +0200
commita6e448208052c2d03fca53a4061a367b33167d37 (patch)
tree0d6f84d1257e2af57d28a3102d0622fcf716782b /AK/WeakPtr.h
parentd8d16dea957f15f07ebb08d1578e21d97fc163bc (diff)
downloadserenity-a6e448208052c2d03fca53a4061a367b33167d37.zip
AK+Everywhere: Make StdLibExtras templates less wrapper-y
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
Diffstat (limited to 'AK/WeakPtr.h')
-rw-r--r--AK/WeakPtr.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h
index 59bffa273a..f4e41281db 100644
--- a/AK/WeakPtr.h
+++ b/AK/WeakPtr.h
@@ -38,26 +38,26 @@ class WeakPtr {
public:
WeakPtr() = default;
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr(const WeakPtr<U>& other)
: m_link(other.m_link)
{
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr(WeakPtr<U>&& other)
: m_link(other.take_link())
{
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr& operator=(WeakPtr<U>&& other)
{
m_link = other.take_link();
return *this;
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr& operator=(const WeakPtr<U>& other)
{
if ((const void*)this != (const void*)&other)
@@ -71,20 +71,20 @@ public:
return *this;
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr(const U& object)
: m_link(object.template make_weak_ptr<U>().take_link())
{
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr(const U* object)
{
if (object)
m_link = object->template make_weak_ptr<U>().take_link();
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr(const RefPtr<U>& object)
{
object.do_while_locked([&](U* obj) {
@@ -93,7 +93,7 @@ public:
});
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr(const NonnullRefPtr<U>& object)
{
object.do_while_locked([&](U* obj) {
@@ -102,14 +102,14 @@ public:
});
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr& operator=(const U& object)
{
m_link = object.template make_weak_ptr<U>().take_link();
return *this;
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr& operator=(const U* object)
{
if (object)
@@ -119,7 +119,7 @@ public:
return *this;
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr& operator=(const RefPtr<U>& object)
{
object.do_while_locked([&](U* obj) {
@@ -131,7 +131,7 @@ public:
return *this;
}
- template<typename U, typename EnableIf<IsBaseOf<T, U>::value>::Type* = nullptr>
+ template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr>
WeakPtr& operator=(const NonnullRefPtr<U>& object)
{
object.do_while_locked([&](U* obj) {
@@ -199,7 +199,7 @@ template<typename T>
template<typename U>
inline WeakPtr<U> Weakable<T>::make_weak_ptr() const
{
- if constexpr (IsBaseOf<RefCountedBase, T>::value) {
+ if constexpr (IsBaseOf<RefCountedBase, T>) {
// Checking m_being_destroyed isn't sufficient when dealing with
// a RefCounted type.The reference count will drop to 0 before the
// destructor is invoked and revoke_weak_ptrs is called. So, try
@@ -223,7 +223,7 @@ inline WeakPtr<U> Weakable<T>::make_weak_ptr() const
WeakPtr<U> weak_ptr(m_link);
- if constexpr (IsBaseOf<RefCountedBase, T>::value) {
+ if constexpr (IsBaseOf<RefCountedBase, T>) {
// Now drop the reference we temporarily added
if (static_cast<const T*>(this)->unref()) {
// We just dropped the last reference, which should have called