mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibCore: CObjects without is<T> specialization shouldn't LARP as others.
This commit is contained in:
parent
a4726b846c
commit
b8e705da0e
2 changed files with 8 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue