mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
AK: Introduce EquivalentFunctionType
This allows you to get the type from a function from some given callable 'T'. Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
This commit is contained in:
parent
0e61d039c9
commit
c6319d68c3
1 changed files with 37 additions and 0 deletions
|
@ -636,6 +636,42 @@ struct __InvokeResult<F, Args...> {
|
|||
template<typename F, typename... Args>
|
||||
using InvokeResult = typename __InvokeResult<F, Args...>::type;
|
||||
|
||||
template<typename Callable>
|
||||
struct EquivalentFunctionTypeImpl;
|
||||
|
||||
template<template<typename> class Function, typename T, typename... Args>
|
||||
struct EquivalentFunctionTypeImpl<Function<T(Args...)>> {
|
||||
using Type = T(Args...);
|
||||
};
|
||||
|
||||
template<typename T, typename... Args>
|
||||
struct EquivalentFunctionTypeImpl<T(Args...)> {
|
||||
using Type = T(Args...);
|
||||
};
|
||||
|
||||
template<typename T, typename... Args>
|
||||
struct EquivalentFunctionTypeImpl<T (*)(Args...)> {
|
||||
using Type = T(Args...);
|
||||
};
|
||||
|
||||
template<typename L>
|
||||
struct EquivalentFunctionTypeImpl {
|
||||
using Type = typename EquivalentFunctionTypeImpl<decltype(&L::operator())>::Type;
|
||||
};
|
||||
|
||||
template<typename T, typename C, typename... Args>
|
||||
struct EquivalentFunctionTypeImpl<T (C::*)(Args...)> {
|
||||
using Type = T(Args...);
|
||||
};
|
||||
|
||||
template<typename T, typename C, typename... Args>
|
||||
struct EquivalentFunctionTypeImpl<T (C::*)(Args...) const> {
|
||||
using Type = T(Args...);
|
||||
};
|
||||
|
||||
template<typename Callable>
|
||||
using EquivalentFunctionType = typename EquivalentFunctionTypeImpl<Callable>::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;
|
||||
|
|
Loading…
Reference in a new issue