From c6319d68c3e88f2369c5b9b2cebb16457712b611 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Fri, 26 Jan 2024 22:41:45 +1300 Subject: [PATCH] AK: Introduce EquivalentFunctionType This allows you to get the type from a function from some given callable 'T'. Co-Authored-By: Ali Mohammad Pur --- AK/StdLibExtraDetails.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/AK/StdLibExtraDetails.h b/AK/StdLibExtraDetails.h index dc479082d2..e856e3e684 100644 --- a/AK/StdLibExtraDetails.h +++ b/AK/StdLibExtraDetails.h @@ -636,6 +636,42 @@ struct __InvokeResult { template using InvokeResult = typename __InvokeResult::type; +template +struct EquivalentFunctionTypeImpl; + +template class Function, typename T, typename... Args> +struct EquivalentFunctionTypeImpl> { + using Type = T(Args...); +}; + +template +struct EquivalentFunctionTypeImpl { + using Type = T(Args...); +}; + +template +struct EquivalentFunctionTypeImpl { + using Type = T(Args...); +}; + +template +struct EquivalentFunctionTypeImpl { + using Type = typename EquivalentFunctionTypeImpl::Type; +}; + +template +struct EquivalentFunctionTypeImpl { + using Type = T(Args...); +}; + +template +struct EquivalentFunctionTypeImpl { + using Type = T(Args...); +}; + +template +using EquivalentFunctionType = typename EquivalentFunctionTypeImpl::Type; + } #if !USING_AK_GLOBALLY @@ -651,6 +687,7 @@ using AK::Detail::Conditional; using AK::Detail::CopyConst; using AK::Detail::declval; using AK::Detail::DependentFalse; +using AK::Detail::EquivalentFunctionType; using AK::Detail::FalseType; using AK::Detail::IdentityType; using AK::Detail::IndexSequence;