Skip to content

Commit

Permalink
LibCore: CObjects without is<T> specialization shouldn't LARP as others.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 1, 2019
1 parent a4726b8 commit b8e705d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions AK/StdLibExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,4 @@ using AK::max;
using AK::min;
using AK::move;
using AK::swap;
using AK::RemoveConst;
10 changes: 7 additions & 3 deletions LibCore/CObject.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <AK/Function.h>
#include <AK/StdLibExtras.h>
#include <AK/Vector.h>
#include <AK/Weakable.h>

Expand Down Expand Up @@ -63,19 +64,22 @@ class CObject : public Weakable<CObject> {
};

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);
}

Expand Down

0 comments on commit b8e705d

Please sign in to comment.