Lely core libraries
2.3.4
c_call.hpp
Go to the documentation of this file.
1
// NOLINT(legal/copyright)
54
#ifndef LELY_UTIL_C_CALL_HPP_
55
#define LELY_UTIL_C_CALL_HPP_
56
57
#include <
lely/util/util.h
>
58
59
namespace
lely {
60
61
template
<
class
,
class
>
62
struct
c_obj_call
;
63
64
template
<
class
,
class
>
65
struct
c_mem_fn
;
66
template <class F, class C, typename c_mem_fn<F, C>::type
>
67
struct
c_mem_call
;
68
69
namespace
impl {
70
71
template
<
class
...>
72
struct
c_pack
;
73
74
template
<
class
,
class
>
75
struct
c_pack_push_front
;
77
template
<
class
T,
class
...
S
>
78
struct
c_pack_push_front
<T,
c_pack
<
S
...>> {
79
using
type
=
c_pack
<T,
S
...>;
80
};
81
83
template
<
class
T,
class
...
S
>
84
struct
c_pack_pop_back
85
:
c_pack_push_front
<T, typename c_pack_pop_back<S...>::type> {};
87
template
<
class
T,
class
S>
88
struct
c_pack_pop_back
<T,
S
> {
89
using
type
=
c_pack<T>
;
90
};
91
92
}
// namespace impl
93
98
template
<
class
R
,
class
...
ArgTypes
,
class
F
>
99
struct
c_obj_call
<impl::c_pack<R, ArgTypes...>,
F
> {
100
static
R
101
function(
ArgTypes
...
args
,
void
* data)
noexcept
{
102
return
(*
static_cast<
F
*
>
(data))(
args
...);
103
}
104
};
105
110
template
<
class
R
,
class
...
ArgTypes
,
class
F
>
111
struct
c_obj_call
<
R
(*)(
ArgTypes
...),
F
>
112
:
c_obj_call
<
typename
impl::c_pack_pop_back
<
R
,
ArgTypes
...>::type,
F
> {};
113
118
template
<
class
R
,
class
...
ArgTypes
,
class
C
>
119
struct
c_mem_fn
<impl::c_pack<R, ArgTypes...>,
C
> {
120
using
type =
R
(
C
::*)(
ArgTypes
...);
121
};
122
127
template
<
class
R
,
class
...
ArgTypes
,
class
C
>
128
struct
c_mem_fn
<
R
(*)(
ArgTypes
...),
C
>
129
:
c_mem_fn
<
typename
impl::c_pack_pop_back
<
R
,
ArgTypes
...>::type,
C
> {};
130
135
template
<
class
R
,
class
...
ArgTypes
,
class
C
,
136
typename
c_mem_fn
<
impl::c_pack
<
R
,
ArgTypes
...>,
C
>::type
M
>
137
struct
c_mem_call
<
impl::c_pack
<
R
,
ArgTypes
...>,
C
,
M
> {
138
static
R
139
function(
ArgTypes
...
args
,
void
* data)
noexcept
{
140
return
((*
static_cast<
C
*
>
(data)).*
M
)(
args
...);
141
}
142
};
143
148
template
<
class
R
,
class
...
ArgTypes
,
class
C
,
149
typename
c_mem_fn
<
R
(*)(
ArgTypes
...),
C
>::type
M
>
150
struct
c_mem_call
<
R
(*)(
ArgTypes
...),
C
,
M
>
151
:
c_mem_call
<
typename
impl::c_pack_pop_back
<
R
,
ArgTypes
...>::type,
C
,
M
> {};
152
153
}
// namespace lely
154
155
#endif
// !LELY_UTIL_C_CALL_HPP_
lely::COVal
A CANopen value.
Definition
val.hpp:42
util.h
This is the public header file of the utilities library.
lely::c_mem_call
Definition
c_call.hpp:67
lely::c_mem_fn
Definition
c_call.hpp:65
lely::c_obj_call
Definition
c_call.hpp:62
lely::impl::c_pack_pop_back
Pops a type from the back of a parameter pack.
Definition
c_call.hpp:85
lely::impl::c_pack_push_front
Definition
c_call.hpp:75
lely::impl::c_pack
Definition
c_call.hpp:72
include
lely
util
c_call.hpp
Generated by
1.9.8