mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
AK: Add const_cast escape hatch for converting const T& to RefPtr<T>
There are parts of the codebase where properly const-correctifying the the code would be a giant spaghetti mess, so add this loud workaround to defer the refactoring for later.
This commit is contained in:
parent
6ff0373556
commit
703abac9c8
Notes:
github-actions[bot]
2025-04-16 16:43:38 +00:00
Author: https://github.com/ADKaster
Commit: 703abac9c8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4362
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/Hendiadyoin1
1 changed files with 18 additions and 0 deletions
18
AK/RefPtr.h
18
AK/RefPtr.h
|
@ -312,6 +312,24 @@ inline RefPtr<T> static_ptr_cast(RefPtr<U> const& ptr)
|
||||||
return RefPtr<T>(static_cast<T const*>(ptr.ptr()));
|
return RefPtr<T>(static_cast<T const*>(ptr.ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline NonnullRefPtr<T> fixme_launder_const_through_pointer_cast(NonnullRefPtr<T const> const& ptr)
|
||||||
|
{
|
||||||
|
return NonnullRefPtr<T>(const_cast<T&>(*ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline RefPtr<T> fixme_launder_const_through_pointer_cast(RefPtr<T const> const& ptr)
|
||||||
|
{
|
||||||
|
return RefPtr<T>(const_cast<T*>(ptr.ptr()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline NonnullRefPtr<T> fixme_launder_const_through_pointer_cast(T const& ptr)
|
||||||
|
{
|
||||||
|
return NonnullRefPtr<T>(const_cast<T&>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
requires(IsConvertible<U*, T*>)
|
requires(IsConvertible<U*, T*>)
|
||||||
inline void swap(RefPtr<T>& a, RefPtr<U>& b)
|
inline void swap(RefPtr<T>& a, RefPtr<U>& b)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue