CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

mem_bind.h
1 //
3 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
4 //
5 // See accompanying file COPYING.TXT file for licensing details.
6 //
8 #ifndef CPPCMS_UTIL_MEM_BIND_H
9 #define CPPCMS_UTIL_MEM_BIND_H
10
11 namespace cppcms { namespace util {
12
14 namespace details {
15 template<typename C,typename P>
16 struct binder0 {
17 void (C::*member)();
18 P object;
19 void operator()() const { ((*object).*member)(); }
20 };
21 template<typename C,typename P,typename P1>
22 struct binder1 {
23 void (C::*member)(P1);
24 P object;
25 void operator()(P1 p1) const { ((*object).*member)(p1); }
26 };
27 template<typename C,typename P,typename P1,typename P2>
28 struct binder2 {
29 void (C::*member)(P1,P2);
30 P object;
31 void operator()(P1 p1,P2 p2) const { ((*object).*member)(p1,p2); }
32 };
33 template<typename C,typename P,typename P1,typename P2,typename P3>
34 struct binder3 {
35 void (C::*member)(P1,P2,P3);
36 P object;
37 void operator()(P1 p1,P2 p2,P3 p3) const { ((*object).*member)(p1,p2,p3); }
38 };
39 template<typename C,typename P,typename P1,typename P2,typename P3,typename P4>
40 struct binder4 {
41 void (C::*member)(P1,P2,P3,P4);
42 P object;
43 void operator()(P1 p1,P2 p2,P3 p3,P4 p4) const { ((*object).*member)(p1,p2,p3,p4); }
44 };
45 }
46
48
53 template<typename C,typename P>
54 details::binder0<C,P> mem_bind(void (C::*mem)(),P obj)
55 {
56 details::binder0<C,P> tmp={mem,obj};
57 return tmp;
58 }
63 template<typename C,typename P,typename P1>
64 details::binder1<C,P,P1> mem_bind(void (C::*mem)(P1),P obj)
65 {
66 details::binder1<C,P,P1> tmp={mem,obj};
67 return tmp;
68 }
73 template<typename C,typename P,typename P1,typename P2>
74 details::binder2<C,P,P1,P2> mem_bind(void (C::*mem)(P1,P2),P obj)
75 {
76 details::binder2<C,P,P1,P2> tmp={mem,obj};
77 return tmp;
78 }
83 template<typename C,typename P,typename P1,typename P2,typename P3>
84 details::binder3<C,P,P1,P2,P3> mem_bind(void (C::*mem)(P1,P2,P3),P obj)
85 {
86 details::binder3<C,P,P1,P2,P3> tmp={mem,obj};
87 return tmp;
88 }
93 template<typename C,typename P,typename P1,typename P2,typename P3,typename P4>
94 details::binder4<C,P,P1,P2,P3,P4> mem_bind(void (C::*mem)(P1,P2,P3,P4),P obj)
95 {
96 details::binder4<C,P,P1,P2,P3,P4> tmp={mem,obj};
97 return tmp;
98 }
99
100
101 } } // cppcms::util
102
103 #endif
cppcms
This is the namespace where all CppCMS functionality is placed.
Definition: application.h:19
cppcms::util::mem_bind
details::binder0< C, P > mem_bind(void(C::*mem)(), P obj)
Definition: mem_bind.h:54