diff --git a/src/util/BindMethod.hxx b/src/util/BindMethod.hxx index 08d02f98a..f96fa3e05 100644 --- a/src/util/BindMethod.hxx +++ b/src/util/BindMethod.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 Max Kellermann + * Copyright 2016-2021 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,8 +27,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BIND_METHOD_HXX -#define BIND_METHOD_HXX +#pragma once #include #include @@ -247,18 +246,20 @@ MakeBindFunctionWrapper() noexcept /** * Construct a #BoundMethod instance. * - * @param T the containing class - * @param S the plain function signature type * @param method the method pointer * @param instance the instance of #T to be bound */ -template::method_pointer method> -constexpr BoundMethod -BindMethod(T &_instance) noexcept +template +constexpr auto +BindMethod(typename BindMethodDetail::MethodSignatureHelper::class_type &instance) noexcept { - return BoundMethod(&_instance, - BindMethodDetail::MakeBindMethodWrapper()); + using H = BindMethodDetail::MethodSignatureHelper; + using class_type = typename H::class_type; + using plain_signature = typename H::plain_signature; + return BoundMethod{ + &instance, + BindMethodDetail::MakeBindMethodWrapper(), + }; } /** @@ -266,9 +267,7 @@ BindMethod(T &_instance) noexcept * constructs a #BoundMethod instance. */ #define BIND_METHOD(instance, method) \ - BindMethod::class_type, \ - typename BindMethodDetail::MethodSignatureHelper::plain_signature, \ - method>(instance) + BindMethod(instance) /** * Shortcut wrapper for BIND_METHOD() which assumes "*this" is the @@ -296,5 +295,3 @@ BindFunction() noexcept */ #define BIND_FUNCTION(function) \ BindFunction, &function>() - -#endif