forked from artyom-beilis/cppcms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem_bind.h
More file actions
103 lines (96 loc) · 3.54 KB
/
Copy pathmem_bind.h
File metadata and controls
103 lines (96 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCMS_UTIL_MEM_BIND_H
#define CPPCMS_UTIL_MEM_BIND_H
namespace cppcms { namespace util {
/// \cond INTERNAL
namespace details {
template<typename C,typename P>
struct binder0 {
void (C::*member)();
P object;
void operator()() const { ((*object).*member)(); }
};
template<typename C,typename P,typename P1>
struct binder1 {
void (C::*member)(P1);
P object;
void operator()(P1 p1) const { ((*object).*member)(p1); }
};
template<typename C,typename P,typename P1,typename P2>
struct binder2 {
void (C::*member)(P1,P2);
P object;
void operator()(P1 p1,P2 p2) const { ((*object).*member)(p1,p2); }
};
template<typename C,typename P,typename P1,typename P2,typename P3>
struct binder3 {
void (C::*member)(P1,P2,P3);
P object;
void operator()(P1 p1,P2 p2,P3 p3) const { ((*object).*member)(p1,p2,p3); }
};
template<typename C,typename P,typename P1,typename P2,typename P3,typename P4>
struct binder4 {
void (C::*member)(P1,P2,P3,P4);
P object;
void operator()(P1 p1,P2 p2,P3 p3,P4 p4) const { ((*object).*member)(p1,p2,p3,p4); }
};
}
/// \endcond
///
/// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
/// object that has an member function void operator()() const and calls obj->mem()
///
template<typename C,typename P>
details::binder0<C,P> mem_bind(void (C::*mem)(),P obj)
{
details::binder0<C,P> tmp={mem,obj};
return tmp;
}
///
/// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
/// object that has an member function void operator()(P1 p) const and calls obj->mem(p)
///
template<typename C,typename P,typename P1>
details::binder1<C,P,P1> mem_bind(void (C::*mem)(P1),P obj)
{
details::binder1<C,P,P1> tmp={mem,obj};
return tmp;
}
///
/// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
/// object that has an member function void operator()(P1 p1,P2 p2) const and calls obj->mem(p1,p2)
///
template<typename C,typename P,typename P1,typename P2>
details::binder2<C,P,P1,P2> mem_bind(void (C::*mem)(P1,P2),P obj)
{
details::binder2<C,P,P1,P2> tmp={mem,obj};
return tmp;
}
///
/// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
/// object that has an member function void operator()(P1 p1,P2 p2,P3 p3) const and calls obj->mem(p1,p2,p3)
///
template<typename C,typename P,typename P1,typename P2,typename P3>
details::binder3<C,P,P1,P2,P3> mem_bind(void (C::*mem)(P1,P2,P3),P obj)
{
details::binder3<C,P,P1,P2,P3> tmp={mem,obj};
return tmp;
}
///
/// Bind a member function \a mem of object referenced by a pointer \a obj creating a functional
/// object that has an member function void operator()(P1 p1,P2 p2,P3 p3,P4 ) const and calls obj->mem(p1,p2,p3,p4)
///
template<typename C,typename P,typename P1,typename P2,typename P3,typename P4>
details::binder4<C,P,P1,P2,P3,P4> mem_bind(void (C::*mem)(P1,P2,P3,P4),P obj)
{
details::binder4<C,P,P1,P2,P3,P4> tmp={mem,obj};
return tmp;
}
} } // cppcms::util
#endif