Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
43a028bb
Commit
43a028bb
authored
Nov 17, 2012
by
Davis King
Browse files
Turned the member_function_pointer into a single implementation component.
parent
fe93ddaf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
449 deletions
+98
-449
dlib/member_function_pointer.h
dlib/member_function_pointer.h
+0
-29
dlib/member_function_pointer/make_mfp.h
dlib/member_function_pointer/make_mfp.h
+20
-20
dlib/member_function_pointer/make_mfp_abstract.h
dlib/member_function_pointer/make_mfp_abstract.h
+10
-10
dlib/member_function_pointer/member_function_pointer_kernel_1.h
...ember_function_pointer/member_function_pointer_kernel_1.h
+61
-21
dlib/member_function_pointer/member_function_pointer_kernel_c.h
...ember_function_pointer/member_function_pointer_kernel_c.h
+0
-362
dlib/test/member_function_pointer.cpp
dlib/test/member_function_pointer.cpp
+7
-7
No files found.
dlib/member_function_pointer.h
View file @
43a028bb
...
...
@@ -4,36 +4,7 @@
#define DLIB_MEMBER_FUNCTION_POINTEr_
#include "member_function_pointer/member_function_pointer_kernel_1.h"
#include "member_function_pointer/member_function_pointer_kernel_c.h"
#include "member_function_pointer/make_mfp.h"
namespace
dlib
{
template
<
typename
PARAM1
=
void
,
typename
PARAM2
=
void
,
typename
PARAM3
=
void
,
typename
PARAM4
=
void
>
class
member_function_pointer
{
member_function_pointer
()
{}
public:
//----------- kernels ---------------
// kernel_1a
typedef
mfpk1
<
PARAM1
,
PARAM2
,
PARAM3
,
PARAM4
>
kernel_1a
;
typedef
mfpkc
<
kernel_1a
>
kernel_1a_c
;
};
}
#endif // DLIB_MEMBER_FUNCTION_POINTEr_
dlib/member_function_pointer/make_mfp.h
View file @
43a028bb
...
...
@@ -14,12 +14,12 @@ namespace dlib
template
<
typename
T
>
m
fpk1
<>
make_mfp
(
m
ember_function_pointer
<>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)()
)
{
m
fpk1
<>
temp
;
m
ember_function_pointer
<>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -27,12 +27,12 @@ namespace dlib
template
<
typename
T
>
m
fpk1
<>
make_mfp
(
m
ember_function_pointer
<>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)()
const
)
{
m
fpk1
<>
temp
;
m
ember_function_pointer
<>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -43,12 +43,12 @@ namespace dlib
typename
T
,
typename
A1
>
m
fpk1
<
A1
>
make_mfp
(
m
ember_function_pointer
<
A1
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
)
)
{
m
fpk1
<
A1
>
temp
;
m
ember_function_pointer
<
A1
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -57,12 +57,12 @@ namespace dlib
typename
T
,
typename
A1
>
m
fpk1
<
A1
>
make_mfp
(
m
ember_function_pointer
<
A1
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
)
const
)
{
m
fpk1
<
A1
>
temp
;
m
ember_function_pointer
<
A1
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -74,12 +74,12 @@ namespace dlib
typename
A1
,
typename
A2
>
m
fpk1
<
A1
,
A2
>
make_mfp
(
m
ember_function_pointer
<
A1
,
A2
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
,
A2
)
)
{
m
fpk1
<
A1
,
A2
>
temp
;
m
ember_function_pointer
<
A1
,
A2
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -89,12 +89,12 @@ namespace dlib
typename
A1
,
typename
A2
>
m
fpk1
<
A1
,
A2
>
make_mfp
(
m
ember_function_pointer
<
A1
,
A2
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
,
A2
)
const
)
{
m
fpk1
<
A1
,
A2
>
temp
;
m
ember_function_pointer
<
A1
,
A2
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -107,12 +107,12 @@ namespace dlib
typename
A2
,
typename
A3
>
m
fpk1
<
A1
,
A2
,
A3
>
make_mfp
(
m
ember_function_pointer
<
A1
,
A2
,
A3
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
,
A2
,
A3
)
)
{
m
fpk1
<
A1
,
A2
,
A3
>
temp
;
m
ember_function_pointer
<
A1
,
A2
,
A3
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -123,12 +123,12 @@ namespace dlib
typename
A2
,
typename
A3
>
m
fpk1
<
A1
,
A2
,
A3
>
make_mfp
(
m
ember_function_pointer
<
A1
,
A2
,
A3
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
,
A2
,
A3
)
const
)
{
m
fpk1
<
A1
,
A2
,
A3
>
temp
;
m
ember_function_pointer
<
A1
,
A2
,
A3
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -142,12 +142,12 @@ namespace dlib
typename
A3
,
typename
A4
>
m
fpk1
<
A1
,
A2
,
A3
,
A4
>
make_mfp
(
m
ember_function_pointer
<
A1
,
A2
,
A3
,
A4
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
,
A2
,
A3
,
A4
)
)
{
m
fpk1
<
A1
,
A2
,
A3
,
A4
>
temp
;
m
ember_function_pointer
<
A1
,
A2
,
A3
,
A4
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
@@ -159,12 +159,12 @@ namespace dlib
typename
A3
,
typename
A4
>
m
fpk1
<
A1
,
A2
,
A3
,
A4
>
make_mfp
(
m
ember_function_pointer
<
A1
,
A2
,
A3
,
A4
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
,
A2
,
A3
,
A4
)
const
)
{
m
fpk1
<
A1
,
A2
,
A3
,
A4
>
temp
;
m
ember_function_pointer
<
A1
,
A2
,
A3
,
A4
>
temp
;
temp
.
set
(
object
,
cb
);
return
temp
;
}
...
...
dlib/member_function_pointer/make_mfp_abstract.h
View file @
43a028bb
...
...
@@ -13,7 +13,7 @@ namespace dlib
template
<
typename
T
>
member_function_pointer
<>
::
kernel_1a
make_mfp
(
member_function_pointer
<>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)()
);
...
...
@@ -29,7 +29,7 @@ namespace dlib
template
<
typename
T
>
member_function_pointer
<>
::
kernel_1a
make_mfp
(
member_function_pointer
<>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)()
const
);
...
...
@@ -48,7 +48,7 @@ namespace dlib
typename
T
,
typename
A1
>
typename
member_function_pointer
<
A1
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
)
);
...
...
@@ -65,7 +65,7 @@ namespace dlib
typename
T
,
typename
A1
>
typename
member_function_pointer
<
A1
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
)
const
);
...
...
@@ -85,7 +85,7 @@ namespace dlib
typename
A1
,
typename
A2
>
typename
member_function_pointer
<
A1
,
A2
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
,
A2
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
,
A2
a2
)
);
...
...
@@ -103,7 +103,7 @@ namespace dlib
typename
A1
,
typename
A2
>
typename
member_function_pointer
<
A1
,
A2
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
,
A2
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
,
A2
a2
)
const
);
...
...
@@ -124,7 +124,7 @@ namespace dlib
typename
A2
,
typename
A3
>
typename
member_function_pointer
<
A1
,
A2
,
A3
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
,
A2
,
A3
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
,
A2
a2
,
A3
a3
)
);
...
...
@@ -143,7 +143,7 @@ namespace dlib
typename
A2
,
typename
A3
>
typename
member_function_pointer
<
A1
,
A2
,
A3
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
,
A2
,
A3
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
,
A2
a2
,
A3
a3
)
const
);
...
...
@@ -165,7 +165,7 @@ namespace dlib
typename
A3
,
typename
A4
>
typename
member_function_pointer
<
A1
,
A2
,
A3
,
A4
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
,
A2
,
A3
,
A4
>
make_mfp
(
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
)
);
...
...
@@ -185,7 +185,7 @@ namespace dlib
typename
A3
,
typename
A4
>
typename
member_function_pointer
<
A1
,
A2
,
A3
,
A4
>
::
kernel_1a
make_mfp
(
member_function_pointer
<
A1
,
A2
,
A3
,
A4
>
make_mfp
(
const
T
&
object
,
void
(
T
::*
cb
)(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
)
const
);
...
...
dlib/member_function_pointer/member_function_pointer_kernel_1.h
View file @
43a028bb
...
...
@@ -19,7 +19,20 @@ namespace dlib
typename
PARAM3
=
void
,
typename
PARAM4
=
void
>
class
mfpk1
;
class
member_function_pointer
;
// ----------------------------------------------------------------------------------------
#define DLIB_MFP_SC DLIB_ASSERT(cb != 0, \
"\tvoid member_function_pointer::set" \
<< "\n\tthe member function pointer can't be null" \
<< "\n\tthis: " << this );
#define DLIB_MFP_OC DLIB_ASSERT(this->is_set() == true , \
"\tvoid member_function_pointer::operator()" \
<< "\n\tYou must call set() before you can use this function" \
<< "\n\tthis: " << this);
// ----------------------------------------------------------------------------------------
...
...
@@ -188,7 +201,7 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template
<
>
class
m
fpk1
<
void
,
void
,
void
,
void
>
:
public
mfp_kernel_1_base_class
<
0
>
class
m
ember_function_pointer
<
void
,
void
,
void
,
void
>
:
public
mfp_kernel_1_base_class
<
0
>
{
class
mp_base
:
public
mp_base_base
{
public:
...
...
@@ -222,16 +235,22 @@ namespace dlib
typedef
void
param3_type
;
typedef
void
param4_type
;
void
operator
()
()
const
{
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
();
}
// These two typedefs are here for backwards compatibility with previous versions
// of dlib.
typedef
member_function_pointer
kernel_1a
;
typedef
member_function_pointer
kernel_1a_c
;
void
operator
()
()
const
{
DLIB_MFP_OC
;
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
();
}
// the reason for putting disable_if on this function is that it avoids an overload
// resolution bug in visual studio.
template
<
typename
T
>
typename
disable_if
<
is_const_type
<
T
>
,
void
>::
type
set
(
T
&
object
,
typename
mp_impl
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
typename
mp_impl_const
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
};
...
...
@@ -240,7 +259,7 @@ namespace dlib
template
<
typename
PARAM1
>
class
m
fpk1
<
PARAM1
,
void
,
void
,
void
>
:
public
mfp_kernel_1_base_class
<
1
>
class
m
ember_function_pointer
<
PARAM1
,
void
,
void
,
void
>
:
public
mfp_kernel_1_base_class
<
1
>
{
class
mp_base
:
public
mp_base_base
{
public:
...
...
@@ -274,16 +293,22 @@ namespace dlib
typedef
void
param3_type
;
typedef
void
param4_type
;
void
operator
()
(
PARAM1
p1
)
const
{
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
);
}
// These two typedefs are here for backwards compatibility with previous versions
// of dlib.
typedef
member_function_pointer
kernel_1a
;
typedef
member_function_pointer
kernel_1a_c
;
void
operator
()
(
PARAM1
p1
)
const
{
DLIB_MFP_OC
;
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
);
}
// the reason for putting disable_if on this function is that it avoids an overload
// resolution bug in visual studio.
template
<
typename
T
>
typename
disable_if
<
is_const_type
<
T
>
,
void
>::
type
set
(
T
&
object
,
typename
mp_impl
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
typename
mp_impl_const
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
};
...
...
@@ -293,7 +318,7 @@ namespace dlib
typename
PARAM1
,
typename
PARAM2
>
class
m
fpk1
<
PARAM1
,
PARAM2
,
void
,
void
>
:
public
mfp_kernel_1_base_class
<
2
>
class
m
ember_function_pointer
<
PARAM1
,
PARAM2
,
void
,
void
>
:
public
mfp_kernel_1_base_class
<
2
>
{
class
mp_base
:
public
mp_base_base
{
public:
...
...
@@ -327,16 +352,21 @@ namespace dlib
typedef
void
param3_type
;
typedef
void
param4_type
;
void
operator
()
(
PARAM1
p1
,
PARAM2
p2
)
const
{
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
,
p2
);
}
// These two typedefs are here for backwards compatibility with previous versions
// of dlib.
typedef
member_function_pointer
kernel_1a
;
typedef
member_function_pointer
kernel_1a_c
;
void
operator
()
(
PARAM1
p1
,
PARAM2
p2
)
const
{
DLIB_MFP_OC
;
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
,
p2
);
}
// the reason for putting disable_if on this function is that it avoids an overload
// resolution bug in visual studio.
template
<
typename
T
>
typename
disable_if
<
is_const_type
<
T
>
,
void
>::
type
set
(
T
&
object
,
typename
mp_impl
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
typename
mp_impl_const
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
};
...
...
@@ -347,7 +377,7 @@ namespace dlib
typename
PARAM2
,
typename
PARAM3
>
class
m
fpk1
<
PARAM1
,
PARAM2
,
PARAM3
,
void
>
:
public
mfp_kernel_1_base_class
<
3
>
class
m
ember_function_pointer
<
PARAM1
,
PARAM2
,
PARAM3
,
void
>
:
public
mfp_kernel_1_base_class
<
3
>
{
class
mp_base
:
public
mp_base_base
{
public:
...
...
@@ -381,16 +411,21 @@ namespace dlib
typedef
PARAM3
param3_type
;
typedef
void
param4_type
;
void
operator
()
(
PARAM1
p1
,
PARAM2
p2
,
PARAM3
p3
)
const
{
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
,
p2
,
p3
);
}
// These two typedefs are here for backwards compatibility with previous versions
// of dlib.
typedef
member_function_pointer
kernel_1a
;
typedef
member_function_pointer
kernel_1a_c
;
void
operator
()
(
PARAM1
p1
,
PARAM2
p2
,
PARAM3
p3
)
const
{
DLIB_MFP_OC
;
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
,
p2
,
p3
);
}
// the reason for putting disable_if on this function is that it avoids an overload
// resolution bug in visual studio.
template
<
typename
T
>
typename
disable_if
<
is_const_type
<
T
>
,
void
>::
type
set
(
T
&
object
,
typename
mp_impl
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
typename
mp_impl_const
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
};
...
...
@@ -402,7 +437,7 @@ namespace dlib
typename
PARAM3
,
typename
PARAM4
>
class
m
fpk1
:
public
mfp_kernel_1_base_class
<
4
>
class
m
ember_function_pointer
:
public
mfp_kernel_1_base_class
<
4
>
{
class
mp_base
:
public
mp_base_base
{
public:
...
...
@@ -436,17 +471,22 @@ namespace dlib
typedef
PARAM3
param3_type
;
typedef
PARAM4
param4_type
;
// These two typedefs are here for backwards compatibility with previous versions
// of dlib.
typedef
member_function_pointer
kernel_1a
;
typedef
member_function_pointer
kernel_1a_c
;
void
operator
()
(
PARAM1
p1
,
PARAM2
p2
,
PARAM3
p3
,
PARAM4
p4
)
const
{
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
,
p2
,
p3
,
p4
);
}
{
DLIB_MFP_OC
;
static_cast
<
const
mp_base
*>
(
mp_memory
.
get
())
->
call
(
p1
,
p2
,
p3
,
p4
);
}
// the reason for putting disable_if on this function is that it avoids an overload
// resolution bug in visual studio.
template
<
typename
T
>
typename
disable_if
<
is_const_type
<
T
>
,
void
>::
type
set
(
T
&
object
,
typename
mp_impl
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl
<
T
>
>
(
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
typename
mp_impl_const
<
T
>::
mfp_pointer_type
cb
)
{
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
{
DLIB_MFP_SC
;
destroy_mp_memory
();
mp_impl_T
<
mp_impl_const
<
T
>
>
((
void
*
)
&
object
,
cb
).
safe_clone
(
mp_memory
);
}
};
...
...
dlib/member_function_pointer/member_function_pointer_kernel_c.h
deleted
100644 → 0
View file @
fe93ddaf
// Copyright (C) 2005 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_MEMBER_FUNCTION_POINTER_KERNEl_C_
#define DLIB_MEMBER_FUNCTION_POINTER_KERNEl_C_
#include "member_function_pointer_kernel_abstract.h"
#include "../algs.h"
#include "../assert.h"
namespace
dlib
{
template
<
typename
mfpb
,
// is an implementation of member_function_pointer_kernel_abstract.h
typename
PARAM1
=
typename
mfpb
::
param1_type
,
typename
PARAM2
=
typename
mfpb
::
param2_type
,
typename
PARAM3
=
typename
mfpb
::
param3_type
,
typename
PARAM4
=
typename
mfpb
::
param4_type
>
class
mfpkc
;
// ----------------------------------------------------------------------------------------
template
<
typename
mfpb
>
class
mfpkc
<
mfpb
,
void
,
void
,
void
,
void
>
:
public
mfpb
{
public:
template
<
typename
T
>
void
set
(
T
&
object
,
void
(
T
::*
cb
)()
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
void
(
T
::*
cb
)()
const
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
void
operator
()
(
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_set
()
==
true
,
"
\t
void member_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
operator
()();
}
};
// ----------------------------------------------------------------------------------------
template
<
typename
mfpb
,
typename
PARAM1
>
class
mfpkc
<
mfpb
,
PARAM1
,
void
,
void
,
void
>
:
public
mfpb
{
public:
template
<
typename
T
>
void
set
(
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
)
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
)
const
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
void
operator
()
(
PARAM1
param1
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_set
()
==
true
,
"
\t
void member_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
operator
()(
param1
);
}
};
// ----------------------------------------------------------------------------------------
template
<
typename
mfpb
,
typename
PARAM1
,
typename
PARAM2
>
class
mfpkc
<
mfpb
,
PARAM1
,
PARAM2
,
void
,
void
>
:
public
mfpb
{
public:
template
<
typename
T
>
void
set
(
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
,
PARAM2
)
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
,
PARAM2
)
const
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
void
operator
()
(
PARAM1
param1
,
PARAM2
param2
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_set
()
==
true
,
"
\t
void member_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
operator
()(
param1
,
param2
);
}
};
// ----------------------------------------------------------------------------------------
template
<
typename
mfpb
,
typename
PARAM1
,
typename
PARAM2
,
typename
PARAM3
>
class
mfpkc
<
mfpb
,
PARAM1
,
PARAM2
,
PARAM3
,
void
>
:
public
mfpb
{
public:
template
<
typename
T
>
void
set
(
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
,
PARAM2
,
PARAM3
)
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
,
PARAM2
,
PARAM3
)
const
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
void
operator
()
(
PARAM1
param1
,
PARAM2
param2
,
PARAM3
param3
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_set
()
==
true
,
"
\t
void member_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
operator
()(
param1
,
param2
,
param3
);
}
};
// ----------------------------------------------------------------------------------------
template
<
typename
mfpb
,
typename
PARAM1
,
typename
PARAM2
,
typename
PARAM3
,
typename
PARAM4
>
class
mfpkc
:
public
mfpb
{
public:
template
<
typename
T
>
void
set
(
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
,
PARAM2
,
PARAM3
,
PARAM4
)
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
template
<
typename
T
>
void
set
(
const
T
&
object
,
void
(
T
::*
cb
)(
PARAM1
,
PARAM2
,
PARAM3
,
PARAM4
)
const
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
cb
!=
0
,
"
\t
void member_function_pointer::set"
<<
"
\n\t
the member function pointer can't be null"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
set
(
object
,
cb
);
}
void
operator
()
(
PARAM1
param1
,
PARAM2
param2
,
PARAM3
param3
,
PARAM4
param4
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_set
()
==
true
,
"
\t
void member_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
// call the real function
mfpb
::
operator
()(
param1
,
param2
,
param3
,
param4
);
}
};
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_MEMBER_FUNCTION_POINTER_KERNEl_C_
dlib/test/member_function_pointer.cpp
View file @
43a028bb
...
...
@@ -122,11 +122,11 @@ namespace
mfp
<
int
,
int
,
int
>
a3
,
b3
;
mfp
<
int
,
int
,
int
,
int
>
a4
,
b4
;
mfp
kc
<
mfp
<>
>
a0c
,
b0c
;
mfpkc
<
mfp
<
int
>
>
a1c
,
b1c
;
mfpkc
<
mfp
<
int
,
int
>
>
a2c
,
b2c
;
mfpkc
<
mfp
<
int
,
int
,
int
>
>
a3c
,
b3c
;
mfpkc
<
mfp
<
int
,
int
,
int
,
int
>
>
a4c
,
b4c
;
mfp
<
>
a0c
,
b0c
;
mfp
<
int
>
a1c
,
b1c
;
mfp
<
int
,
int
>
a2c
,
b2c
;
mfp
<
int
,
int
,
int
>
a3c
,
b3c
;
mfp
<
int
,
int
,
int
,
int
>
a4c
,
b4c
;
DLIB_TEST
(
a0c
==
b0c
);
DLIB_TEST
(
a1c
==
b1c
);
...
...
@@ -543,8 +543,8 @@ namespace
void
perform_test
(
)
{
member_function_pointer_kernel_test
<
m
fpk1
,
mfp_test_helper
>
();
member_function_pointer_kernel_test
<
m
fpk1
,
mfp_test_helper_const
>
();
member_function_pointer_kernel_test
<
m
ember_function_pointer
,
mfp_test_helper
>
();
member_function_pointer_kernel_test
<
m
ember_function_pointer
,
mfp_test_helper_const
>
();
}
}
a
;
...
...
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