mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
AK: Assert that is<T>()
input and output types are not the same
This makes it a compile error to use is<T>() where the input and output types are known to be the same at compile time.
This commit is contained in:
parent
85863bb0ef
commit
82a63e350c
Notes:
github-actions[bot]
2024-08-08 15:51:53 +00:00
Author: https://github.com/tcl3
Commit: 82a63e350c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1010
Reviewed-by: https://github.com/awesomekling
1 changed files with 2 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
|
#include <AK/Concepts.h>
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/Platform.h>
|
#include <AK/Platform.h>
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ namespace AK {
|
||||||
template<typename OutputType, typename InputType>
|
template<typename OutputType, typename InputType>
|
||||||
ALWAYS_INLINE bool is(InputType& input)
|
ALWAYS_INLINE bool is(InputType& input)
|
||||||
{
|
{
|
||||||
|
static_assert(!SameAs<OutputType, InputType>);
|
||||||
if constexpr (requires { input.template fast_is<OutputType>(); }) {
|
if constexpr (requires { input.template fast_is<OutputType>(); }) {
|
||||||
return input.template fast_is<OutputType>();
|
return input.template fast_is<OutputType>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue