mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 00:38:56 +00:00
LibWeb: Ensure static cast is used when possible in as_if
This commit is contained in:
parent
5e6b8b2785
commit
4e57a2aedf
Notes:
github-actions[bot]
2025-08-22 18:27:25 +00:00
Author: https://github.com/tcl3
Commit: 4e57a2aedf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5953
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89
1 changed files with 2 additions and 3 deletions
|
@ -40,11 +40,10 @@ ALWAYS_INLINE CopyConst<InputType, OutputType>* as_if(InputType& input)
|
|||
{
|
||||
if (!is<OutputType>(input))
|
||||
return nullptr;
|
||||
if constexpr (IsBaseOf<InputType, OutputType>) {
|
||||
if constexpr (requires { static_cast<CopyConst<InputType, OutputType>*>(&input); }) {
|
||||
return static_cast<CopyConst<InputType, OutputType>*>(&input);
|
||||
} else {
|
||||
return dynamic_cast<CopyConst<InputType, OutputType>*>(&input);
|
||||
}
|
||||
return dynamic_cast<CopyConst<InputType, OutputType>*>(&input);
|
||||
}
|
||||
|
||||
template<typename OutputType, typename InputType>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue