mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibCore: CObjects without is<T> specialization shouldn't LARP as others.
This commit is contained in:
parent
a4726b846c
commit
b8e705da0e
|
@ -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