mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
AK: Allow as_if to perform dynamic cast when necessary
This means that if `is<OutputType>(x)` is true, that `as_if<OutputType>(x)` should always succeed.
This commit is contained in:
parent
6ebe19d13b
commit
1f87a09503
|
|
@ -56,7 +56,11 @@ ALWAYS_INLINE CopyConst<InputType, OutputType>* as_if(InputType& input)
|
|||
{
|
||||
if (!is<OutputType>(input))
|
||||
return nullptr;
|
||||
return static_cast<CopyConst<InputType, OutputType>*>(&input);
|
||||
if constexpr (IsBaseOf<InputType, OutputType>) {
|
||||
return static_cast<CopyConst<InputType, OutputType>*>(&input);
|
||||
} else {
|
||||
return dynamic_cast<CopyConst<InputType, OutputType>*>(&input);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename OutputType, typename InputType>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user