blob: 619eddd30bee93f2823eed7c929b981335bd8359 [file] [log] [blame]
Jeff Thompson3d613fd2013-10-15 15:39:04 -07001#ifndef NDNBOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
2#define NDNBOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07003
4//
5// make_adaptable.hpp
6//
7// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
8//
9// Distributed under the Boost Software License, Version 1.0. (See
10// accompanying file LICENSE_1_0.txt or copy at
11// http://www.boost.org/LICENSE_1_0.txt)
12//
13
14namespace ndnboost
15{
16
17namespace _bi
18{
19
20template<class R, class F> class af0
21{
22public:
23
24 typedef R result_type;
25
26 explicit af0(F f): f_(f)
27 {
28 }
29
30 result_type operator()()
31 {
32 return f_();
33 }
34
35 result_type operator()() const
36 {
37 return f_();
38 }
39
40private:
41
42 F f_;
43};
44
45template<class R, class A1, class F> class af1
46{
47public:
48
49 typedef R result_type;
50 typedef A1 argument_type;
51 typedef A1 arg1_type;
52
53 explicit af1(F f): f_(f)
54 {
55 }
56
57 result_type operator()(A1 a1)
58 {
59 return f_(a1);
60 }
61
62 result_type operator()(A1 a1) const
63 {
64 return f_(a1);
65 }
66
67private:
68
69 F f_;
70};
71
72template<class R, class A1, class A2, class F> class af2
73{
74public:
75
76 typedef R result_type;
77 typedef A1 first_argument_type;
78 typedef A2 second_argument_type;
79 typedef A1 arg1_type;
80 typedef A2 arg2_type;
81
82 explicit af2(F f): f_(f)
83 {
84 }
85
86 result_type operator()(A1 a1, A2 a2)
87 {
88 return f_(a1, a2);
89 }
90
91 result_type operator()(A1 a1, A2 a2) const
92 {
93 return f_(a1, a2);
94 }
95
96private:
97
98 F f_;
99};
100
101template<class R, class A1, class A2, class A3, class F> class af3
102{
103public:
104
105 typedef R result_type;
106 typedef A1 arg1_type;
107 typedef A2 arg2_type;
108 typedef A3 arg3_type;
109
110 explicit af3(F f): f_(f)
111 {
112 }
113
114 result_type operator()(A1 a1, A2 a2, A3 a3)
115 {
116 return f_(a1, a2, a3);
117 }
118
119 result_type operator()(A1 a1, A2 a2, A3 a3) const
120 {
121 return f_(a1, a2, a3);
122 }
123
124private:
125
126 F f_;
127};
128
129template<class R, class A1, class A2, class A3, class A4, class F> class af4
130{
131public:
132
133 typedef R result_type;
134 typedef A1 arg1_type;
135 typedef A2 arg2_type;
136 typedef A3 arg3_type;
137 typedef A4 arg4_type;
138
139 explicit af4(F f): f_(f)
140 {
141 }
142
143 result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4)
144 {
145 return f_(a1, a2, a3, a4);
146 }
147
148 result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4) const
149 {
150 return f_(a1, a2, a3, a4);
151 }
152
153private:
154
155 F f_;
156};
157
158} // namespace _bi
159
160template<class R, class F> _bi::af0<R, F> make_adaptable(F f)
161{
162 return _bi::af0<R, F>(f);
163}
164
165template<class R, class A1, class F> _bi::af1<R, A1, F> make_adaptable(F f)
166{
167 return _bi::af1<R, A1, F>(f);
168}
169
170template<class R, class A1, class A2, class F> _bi::af2<R, A1, A2, F> make_adaptable(F f)
171{
172 return _bi::af2<R, A1, A2, F>(f);
173}
174
175template<class R, class A1, class A2, class A3, class F> _bi::af3<R, A1, A2, A3, F> make_adaptable(F f)
176{
177 return _bi::af3<R, A1, A2, A3, F>(f);
178}
179
180template<class R, class A1, class A2, class A3, class A4, class F> _bi::af4<R, A1, A2, A3, A4, F> make_adaptable(F f)
181{
182 return _bi::af4<R, A1, A2, A3, A4, F>(f);
183}
184
185} // namespace ndnboost
186
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700187#endif // #ifndef NDNBOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED