mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-13 20:41:53 +00:00
LibCore+LibGUI: Add is<T>(CObject&) and to<T>(CObject&) helpers.
This commit is contained in:
parent
723ba91f74
commit
0c85d3dba9
Notes:
sideshowbarker
2024-07-19 13:55:24 +09:00
Author: https://github.com/awesomekling
Commit: 0c85d3dba9
5 changed files with 53 additions and 30 deletions
|
@ -58,3 +58,20 @@ private:
|
|||
bool m_widget { false };
|
||||
Vector<CObject*> m_children;
|
||||
};
|
||||
|
||||
template<typename T> 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));
|
||||
return static_cast<T&>(object);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline const T& to(const CObject& object)
|
||||
{
|
||||
ASSERT(is<T>(object));
|
||||
return static_cast<const T&>(object);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue