Commit 5d6d7f4b authored by Davis King's avatar Davis King

Added a factory function to easily create temporary member function pointers.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404131
parent 3ad1facf
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "member_function_pointer/member_function_pointer_kernel_1.h" #include "member_function_pointer/member_function_pointer_kernel_1.h"
#include "member_function_pointer/member_function_pointer_kernel_c.h" #include "member_function_pointer/member_function_pointer_kernel_c.h"
#include "member_function_pointer/make_mfp.h"
namespace dlib namespace dlib
{ {
......
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_MAKE_MFp_H_
#define DLIB_MAKE_MFp_H_
#include "member_function_pointer_kernel_1.h"
#include "make_mfp_abstract.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
template <
typename T
>
mfpk1<> make_mfp (
T& object,
void (T::*cb)()
)
{
mfpk1<> temp;
temp.set(object, cb);
return temp;
}
template <
typename T
>
mfpk1<> make_mfp (
const T& object,
void (T::*cb)()const
)
{
mfpk1<> temp;
temp.set(object, cb);
return temp;
}
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1
>
mfpk1<A1> make_mfp (
T& object,
void (T::*cb)(A1)
)
{
mfpk1<A1> temp;
temp.set(object, cb);
return temp;
}
template <
typename T,
typename A1
>
mfpk1<A1> make_mfp (
const T& object,
void (T::*cb)(A1)const
)
{
mfpk1<A1> temp;
temp.set(object, cb);
return temp;
}
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1,
typename A2
>
mfpk1<A1,A2> make_mfp (
T& object,
void (T::*cb)(A1,A2)
)
{
mfpk1<A1,A2> temp;
temp.set(object, cb);
return temp;
}
template <
typename T,
typename A1,
typename A2
>
mfpk1<A1,A2> make_mfp (
const T& object,
void (T::*cb)(A1,A2)const
)
{
mfpk1<A1,A2> temp;
temp.set(object, cb);
return temp;
}
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1,
typename A2,
typename A3
>
mfpk1<A1,A2,A3> make_mfp (
T& object,
void (T::*cb)(A1,A2,A3)
)
{
mfpk1<A1,A2,A3> temp;
temp.set(object, cb);
return temp;
}
template <
typename T,
typename A1,
typename A2,
typename A3
>
mfpk1<A1,A2,A3> make_mfp (
const T& object,
void (T::*cb)(A1,A2,A3)const
)
{
mfpk1<A1,A2,A3> temp;
temp.set(object, cb);
return temp;
}
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1,
typename A2,
typename A3,
typename A4
>
mfpk1<A1,A2,A3,A4> make_mfp (
T& object,
void (T::*cb)(A1,A2,A3,A4)
)
{
mfpk1<A1,A2,A3,A4> temp;
temp.set(object, cb);
return temp;
}
template <
typename T,
typename A1,
typename A2,
typename A3,
typename A4
>
mfpk1<A1,A2,A3,A4> make_mfp (
const T& object,
void (T::*cb)(A1,A2,A3,A4)const
)
{
mfpk1<A1,A2,A3,A4> temp;
temp.set(object, cb);
return temp;
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_MAKE_MFp_H_
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_MAKE_MFp_ABSTRACT_
#ifdef DLIB_MAKE_MFp_ABSTRACT_
#include "member_function_pointer_kernel_abstract.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
template <
typename T
>
member_function_pointer<>::kernel_1a make_mfp (
T& object,
void (T::*cb)()
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP() will call (object.*cb)()
!*/
template <
typename T
>
member_function_pointer<>::kernel_1a make_mfp (
const T& object,
void (T::*cb)()const
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP() will call (object.*cb)()
!*/
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1
>
typename member_function_pointer<A1>::kernel_1a make_mfp (
T& object,
void (T::*cb)(A1 a1)
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1) will call (object.*cb)(a1)
!*/
template <
typename T,
typename A1
>
typename member_function_pointer<A1>::kernel_1a make_mfp (
const T& object,
void (T::*cb)(A1 a1)const
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1) will call (object.*cb)(a1)
!*/
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1,
typename A2
>
typename member_function_pointer<A1,A2>::kernel_1a make_mfp (
T& object,
void (T::*cb)(A1 a1, A2 a2)
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1,a2) will call (object.*cb)(a1,a2)
!*/
template <
typename T,
typename A1,
typename A2
>
typename member_function_pointer<A1,A2>::kernel_1a make_mfp (
const T& object,
void (T::*cb)(A1 a1, A2 a2)const
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1,a2) will call (object.*cb)(a1,a2)
!*/
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1,
typename A2,
typename A3
>
typename member_function_pointer<A1,A2,A3>::kernel_1a make_mfp (
T& object,
void (T::*cb)(A1 a1, A2 a2, A3 a3)
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1,a2,a3) will call (object.*cb)(a1,a2,a3)
!*/
template <
typename T,
typename A1,
typename A2,
typename A3
>
typename member_function_pointer<A1,A2,A3>::kernel_1a make_mfp (
const T& object,
void (T::*cb)(A1 a1, A2 a2, A3 a3)const
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1,a2,a3) will call (object.*cb)(a1,a2,a3)
!*/
// ----------------------------------------------------------------------------------------
template <
typename T,
typename A1,
typename A2,
typename A3,
typename A4
>
typename member_function_pointer<A1,A2,A3,A4>::kernel_1a make_mfp (
T& object,
void (T::*cb)(A1 a1, A2 a2, A3 a3, A4 a4)
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1,a2,a3,a4) will call (object.*cb)(a1,a2,a3,a4)
!*/
template <
typename T,
typename A1,
typename A2,
typename A3,
typename A4
>
typename member_function_pointer<A1,A2,A3,A4>::kernel_1a make_mfp (
const T& object,
void (T::*cb)(A1 a1, A2 a2, A3 a3, A4 a4)const
);
/*!
requires
- cb == a valid member function pointer for class T
ensures
- returns a member function pointer object MFP such that:
- MFP.is_set() == true
- calls to MFP(a1,a2,a3,a4) will call (object.*cb)(a1,a2,a3,a4)
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_MAKE_MFp_ABSTRACT_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment