From 6fcd1c734b0361cee6b2eedad76236fd30606397 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 2 Dec 2021 22:45:04 +0100 Subject: [PATCH] util/BindMethod: eliminate struct BindMethodWrapperGenerator2 --- src/util/BindMethod.hxx | 47 ++++++++--------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/src/util/BindMethod.hxx b/src/util/BindMethod.hxx index 6667785d4..cafa0bddf 100644 --- a/src/util/BindMethod.hxx +++ b/src/util/BindMethod.hxx @@ -134,23 +134,6 @@ struct MethodWrapperWithSignature { Args...) noexcept(NoExcept); }; -/** - * Generate a wrapper function. Helper class for - * #BindMethodWrapperGenerator. - * - * @param T the containing class - * @param method the method pointer - * @param R the return type - * @param Args the method arguments - */ -template -struct BindMethodWrapperGenerator2 { - static R Invoke(void *_instance, Args... args) noexcept(NoExcept) { - auto &t = *(T *)_instance; - return (t.*method)(std::forward(args)...); - } -}; - /** * Generate a wrapper function. * @@ -163,8 +146,11 @@ struct BindMethodWrapperGenerator; template -struct BindMethodWrapperGenerator - : BindMethodWrapperGenerator2 { +struct BindMethodWrapperGenerator { + static R Invoke(void *_instance, Args... args) noexcept(NoExcept) { + auto &t = *(T *)_instance; + return (t.*method)(std::forward(args)...); + } }; template { typedef R (*pointer)(Args...) noexcept(NoExcept); }; -/** - * Generate a wrapper function for a plain function which ignores the - * instance pointer. Helper class for - * #BindFunctionWrapperGenerator. - * - * @param F the function pointer type - * @param function the function pointer - * @param R the return type - * @param Args the function arguments - */ -template -struct BindFunctionWrapperGenerator2 { - static R Invoke(void *, Args... args) noexcept(NoExcept) { - return function(std::forward(args)...); - } -}; - /** * Generate a wrapper function. * @@ -226,8 +195,10 @@ template struct BindFunctionWrapperGenerator; template -struct BindFunctionWrapperGenerator - : BindFunctionWrapperGenerator2 { +struct BindFunctionWrapperGenerator { + static R Invoke(void *, Args... args) noexcept(NoExcept) { + return function(std::forward(args)...); + } }; template