util/BindMethod: merge structs {Method,Function}SignatureHelper into one
This commit is contained in:
parent
26dc37bd76
commit
687327c9e8
@ -82,15 +82,15 @@ public:
|
|||||||
namespace BindMethodDetail {
|
namespace BindMethodDetail {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class which introspects a method pointer type.
|
* Helper class which introspects a method/function pointer type.
|
||||||
*
|
*
|
||||||
* @param M the method pointer type
|
* @param M the method/function pointer type
|
||||||
*/
|
*/
|
||||||
template<typename M>
|
template<typename M>
|
||||||
struct MethodSignatureHelper;
|
struct SignatureHelper;
|
||||||
|
|
||||||
template<typename R, bool NoExcept, typename T, typename... Args>
|
template<typename R, bool NoExcept, typename T, typename... Args>
|
||||||
struct MethodSignatureHelper<R (T::*)(Args...) noexcept(NoExcept)> {
|
struct SignatureHelper<R (T::*)(Args...) noexcept(NoExcept)> {
|
||||||
/**
|
/**
|
||||||
* The class which contains the given method (signature).
|
* The class which contains the given method (signature).
|
||||||
*/
|
*/
|
||||||
@ -106,15 +106,8 @@ struct MethodSignatureHelper<R (T::*)(Args...) noexcept(NoExcept)> {
|
|||||||
Args...) noexcept(NoExcept);
|
Args...) noexcept(NoExcept);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class which converts a function pointer to a wrapper
|
|
||||||
* function pointer type.
|
|
||||||
*/
|
|
||||||
template<typename S>
|
|
||||||
struct FunctionSignatureHelper;
|
|
||||||
|
|
||||||
template<typename R, bool NoExcept, typename... Args>
|
template<typename R, bool NoExcept, typename... Args>
|
||||||
struct FunctionSignatureHelper<R (*)(Args...) noexcept(NoExcept)> {
|
struct SignatureHelper<R (*)(Args...) noexcept(NoExcept)> {
|
||||||
typedef R plain_signature(Args...) noexcept(NoExcept);
|
typedef R plain_signature(Args...) noexcept(NoExcept);
|
||||||
|
|
||||||
typedef R (*function_pointer)(void *instance,
|
typedef R (*function_pointer)(void *instance,
|
||||||
@ -146,14 +139,14 @@ struct WrapperGenerator<R (*)(Args...) noexcept(NoExcept), function> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<auto method>
|
template<auto method>
|
||||||
typename MethodSignatureHelper<decltype(method)>::function_pointer
|
typename SignatureHelper<decltype(method)>::function_pointer
|
||||||
MakeBindMethodWrapper() noexcept
|
MakeBindMethodWrapper() noexcept
|
||||||
{
|
{
|
||||||
return WrapperGenerator<decltype(method), method>::Invoke;
|
return WrapperGenerator<decltype(method), method>::Invoke;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<auto function>
|
template<auto function>
|
||||||
typename FunctionSignatureHelper<decltype(function)>::function_pointer
|
typename SignatureHelper<decltype(function)>::function_pointer
|
||||||
MakeBindFunctionWrapper() noexcept
|
MakeBindFunctionWrapper() noexcept
|
||||||
{
|
{
|
||||||
return WrapperGenerator<decltype(function), function>::Invoke;
|
return WrapperGenerator<decltype(function), function>::Invoke;
|
||||||
@ -169,9 +162,9 @@ MakeBindFunctionWrapper() noexcept
|
|||||||
*/
|
*/
|
||||||
template<auto method>
|
template<auto method>
|
||||||
constexpr auto
|
constexpr auto
|
||||||
BindMethod(typename BindMethodDetail::MethodSignatureHelper<decltype(method)>::class_type &instance) noexcept
|
BindMethod(typename BindMethodDetail::SignatureHelper<decltype(method)>::class_type &instance) noexcept
|
||||||
{
|
{
|
||||||
using H = BindMethodDetail::MethodSignatureHelper<decltype(method)>;
|
using H = BindMethodDetail::SignatureHelper<decltype(method)>;
|
||||||
using plain_signature = typename H::plain_signature;
|
using plain_signature = typename H::plain_signature;
|
||||||
return BoundMethod<plain_signature>{
|
return BoundMethod<plain_signature>{
|
||||||
&instance,
|
&instance,
|
||||||
@ -201,7 +194,7 @@ template<auto function>
|
|||||||
constexpr auto
|
constexpr auto
|
||||||
BindFunction() noexcept
|
BindFunction() noexcept
|
||||||
{
|
{
|
||||||
using H = BindMethodDetail::FunctionSignatureHelper<decltype(function)>;
|
using H = BindMethodDetail::SignatureHelper<decltype(function)>;
|
||||||
using plain_signature = typename H::plain_signature;
|
using plain_signature = typename H::plain_signature;
|
||||||
return BoundMethod<plain_signature>{
|
return BoundMethod<plain_signature>{
|
||||||
nullptr,
|
nullptr,
|
||||||
|
Loading…
Reference in New Issue
Block a user