Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8dca6023
Commit
8dca6023
authored
Dec 02, 2021
by
Max Kellermann
Committed by
Max Kellermann
Dec 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/BindMethod: simplify BindMethod()
parent
0ed24f3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
BindMethod.hxx
src/util/BindMethod.hxx
+13
-16
No files found.
src/util/BindMethod.hxx
View file @
8dca6023
/*
* Copyright 2016-20
18
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2016-20
21
Max Kellermann <max.kellermann@gmail.com>
*
* 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 <type_traits>
#include <utility>
...
...
@@ -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
<
typename
T
,
typename
S
,
typename
BindMethodDetail
::
MethodWithSignature
<
T
,
S
>::
method_pointer
method
>
constexpr
BoundMethod
<
S
>
BindMethod
(
T
&
_instance
)
noexcept
template
<
auto
method
>
constexpr
auto
BindMethod
(
typename
BindMethodDetail
::
MethodSignatureHelper
<
decltype
(
method
)
>::
class_type
&
instance
)
noexcept
{
return
BoundMethod
<
S
>
(
&
_instance
,
BindMethodDetail
::
MakeBindMethodWrapper
<
T
,
S
,
method
>
());
using
H
=
BindMethodDetail
::
MethodSignatureHelper
<
decltype
(
method
)
>
;
using
class_type
=
typename
H
::
class_type
;
using
plain_signature
=
typename
H
::
plain_signature
;
return
BoundMethod
<
plain_signature
>
{
&
instance
,
BindMethodDetail
::
MakeBindMethodWrapper
<
class_type
,
plain_signature
,
method
>
(),
};
}
/**
...
...
@@ -266,9 +267,7 @@ BindMethod(T &_instance) noexcept
* constructs a #BoundMethod instance.
*/
#define BIND_METHOD(instance, method) \
BindMethod<typename BindMethodDetail::MethodSignatureHelper<decltype(method)>::class_type, \
typename BindMethodDetail::MethodSignatureHelper<decltype(method)>::plain_signature, \
method>(instance)
BindMethod<method>(instance)
/**
* Shortcut wrapper for BIND_METHOD() which assumes "*this" is the
...
...
@@ -296,5 +295,3 @@ BindFunction() noexcept
*/
#define BIND_FUNCTION(function) \
BindFunction<typename BindMethodDetail::FunctionTraits<decltype(function)>, &function>()
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment