util/BindMethod: simplify more templates using "auto" template arguments

This commit is contained in:
Max Kellermann 2021-12-02 22:36:11 +01:00 committed by Max Kellermann
parent 51ffafa011
commit eca097dbfb

View File

@ -139,12 +139,11 @@ struct MethodWrapperWithSignature<R(Args...) noexcept(NoExcept)> {
* #BindMethodWrapperGenerator. * #BindMethodWrapperGenerator.
* *
* @param T the containing class * @param T the containing class
* @param M the method pointer type
* @param method the method pointer * @param method the method pointer
* @param R the return type * @param R the return type
* @param Args the method arguments * @param Args the method arguments
*/ */
template<typename T, bool NoExcept, typename M, M method, typename R, typename... Args> template<typename T, bool NoExcept, auto method, typename R, typename... Args>
struct BindMethodWrapperGenerator2 { struct BindMethodWrapperGenerator2 {
static R Invoke(void *_instance, Args... args) noexcept(NoExcept) { static R Invoke(void *_instance, Args... args) noexcept(NoExcept) {
auto &t = *(T *)_instance; auto &t = *(T *)_instance;
@ -156,17 +155,16 @@ struct BindMethodWrapperGenerator2 {
* Generate a wrapper function. * Generate a wrapper function.
* *
* @param T the containing class * @param T the containing class
* @param M the method pointer type
* @param method the method pointer * @param method the method pointer
* @param S the plain function signature type * @param S the plain function signature type
*/ */
template<typename T, typename M, M method, typename S> template<typename T, auto method, typename S>
struct BindMethodWrapperGenerator; struct BindMethodWrapperGenerator;
template<typename T, bool NoExcept, template<typename T, bool NoExcept,
typename M, M method, typename R, typename... Args> auto method, typename R, typename... Args>
struct BindMethodWrapperGenerator<T, M, method, R(Args...) noexcept(NoExcept)> struct BindMethodWrapperGenerator<T, method, R(Args...) noexcept(NoExcept)>
: BindMethodWrapperGenerator2<T, NoExcept, M, method, R, Args...> { : BindMethodWrapperGenerator2<T, NoExcept, method, R, Args...> {
}; };
template<typename T, typename S, template<typename T, typename S,
@ -174,7 +172,7 @@ template<typename T, typename S,
typename MethodWrapperWithSignature<S>::function_pointer typename MethodWrapperWithSignature<S>::function_pointer
MakeBindMethodWrapper() noexcept MakeBindMethodWrapper() noexcept
{ {
return BindMethodWrapperGenerator<T, typename MethodWithSignature<T, S>::method_pointer, method, S>::Invoke; return BindMethodWrapperGenerator<T, method, S>::Invoke;
} }
/** /**