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
26dc37bd
Commit
26dc37bd
authored
Dec 03, 2021
by
Max Kellermann
Committed by
Max Kellermann
Dec 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/BindMethod: merge structs {Method,Function}WrapperGenerator into one
parent
c693e4aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
BindMethod.hxx
src/util/BindMethod.hxx
+12
-21
No files found.
src/util/BindMethod.hxx
View file @
26dc37bd
...
...
@@ -124,48 +124,39 @@ struct FunctionSignatureHelper<R (*)(Args...) noexcept(NoExcept)> {
/**
* Generate a wrapper function.
*
* @param method the method pointer
* @param method the method
/function
pointer
*/
template
<
typename
M
,
auto
method
>
struct
BindMethod
WrapperGenerator
;
struct
WrapperGenerator
;
template
<
typename
T
,
bool
NoExcept
,
auto
method
,
typename
R
,
typename
...
Args
>
struct
BindMethod
WrapperGenerator
<
R
(
T
::*
)(
Args
...)
noexcept
(
NoExcept
),
method
>
{
struct
WrapperGenerator
<
R
(
T
::*
)(
Args
...)
noexcept
(
NoExcept
),
method
>
{
static
R
Invoke
(
void
*
_instance
,
Args
...
args
)
noexcept
(
NoExcept
)
{
auto
&
t
=
*
(
T
*
)
_instance
;
return
(
t
.
*
method
)(
std
::
forward
<
Args
>
(
args
)...);
}
};
template
<
auto
method
>
typename
MethodSignatureHelper
<
decltype
(
method
)
>::
function_pointer
MakeBindMethodWrapper
()
noexcept
{
return
BindMethodWrapperGenerator
<
decltype
(
method
),
method
>::
Invoke
;
}
/**
* Generate a wrapper function.
*
* @param F the function pointer type
* @param function the function pointer
*/
template
<
typename
F
,
auto
function
>
struct
BindFunctionWrapperGenerator
;
template
<
auto
function
,
bool
NoExcept
,
typename
R
,
typename
...
Args
>
struct
BindFunction
WrapperGenerator
<
R
(
*
)(
Args
...)
noexcept
(
NoExcept
),
function
>
{
struct
WrapperGenerator
<
R
(
*
)(
Args
...)
noexcept
(
NoExcept
),
function
>
{
static
R
Invoke
(
void
*
,
Args
...
args
)
noexcept
(
NoExcept
)
{
return
function
(
std
::
forward
<
Args
>
(
args
)...);
}
};
template
<
auto
method
>
typename
MethodSignatureHelper
<
decltype
(
method
)
>::
function_pointer
MakeBindMethodWrapper
()
noexcept
{
return
WrapperGenerator
<
decltype
(
method
),
method
>::
Invoke
;
}
template
<
auto
function
>
typename
FunctionSignatureHelper
<
decltype
(
function
)
>::
function_pointer
MakeBindFunctionWrapper
()
noexcept
{
return
BindFunction
WrapperGenerator
<
decltype
(
function
),
function
>::
Invoke
;
return
WrapperGenerator
<
decltype
(
function
),
function
>::
Invoke
;
}
}
/* namespace BindMethodDetail */
...
...
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