mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
LibCore: CObjects without is<T> specialization shouldn't LARP as others.
This commit is contained in:
parent
a4726b846c
commit
b8e705da0e
Notes:
sideshowbarker
2024-07-19 13:48:38 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b8e705da0eb
2 changed files with 8 additions and 3 deletions
|
@ -293,3 +293,4 @@ using AK::max;
|
|||
using AK::min;
|
||||
using AK::move;
|
||||
using AK::swap;
|
||||
using AK::RemoveConst;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
||||
|
@ -63,19 +64,22 @@ private:
|
|||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool is(const CObject&) { return true; }
|
||||
inline bool is(const CObject&) { return false; }
|
||||
|
||||
template<>
|
||||
inline bool is<CObject>(const CObject&) { return true; }
|
||||
|
||||
template<typename T>
|
||||
inline T& to(CObject& object)
|
||||
{
|
||||
ASSERT(is<T>(object));
|
||||
ASSERT(is<typename RemoveConst<T>::Type>(object));
|
||||
return static_cast<T&>(object);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline const T& to(const CObject& object)
|
||||
{
|
||||
ASSERT(is<T>(object));
|
||||
ASSERT(is<typename RemoveConst<T>::Type>(object));
|
||||
return static_cast<const T&>(object);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue