5 #ifndef ICE_UTIL_FUNCTIONAL_H
6 #define ICE_UTIL_FUNCTIONAL_H
10 #if !defined(ICE_CPP11_MAPPING) && (ICE_CPLUSPLUS < 201703L)
15 namespace IceUtilInternal
23 template<
class R,
class T,
class H>
24 class MemFun :
public std::unary_function<H, R>
26 typedef R (T::*MemberFN)(void);
31 explicit MemFun(MemberFN p) : _mfn(p) { }
32 R operator()(H handle)
const
34 return (handle.get() ->* _mfn)();
38 template<
class R,
class T,
class H,
class A>
39 class MemFun1 :
public std::binary_function<H, A, R>
41 typedef R (T::*MemberFN)(A);
46 explicit MemFun1(MemberFN p) : _mfn(p) { }
47 R operator()(H handle, A arg)
const
49 return (handle.get() ->* _mfn)(arg);
53 template<
class T,
class H>
54 class VoidMemFun :
public std::unary_function<H, void>
56 typedef void (T::*MemberFN)(void);
61 explicit VoidMemFun(MemberFN p) : _mfn(p) { }
62 void operator()(H handle)
const
64 (handle.get() ->* _mfn)();
68 template<
class T,
class H,
class A>
69 class VoidMemFun1 :
public std::binary_function<H, A, void>
71 typedef void (T::*MemberFN)(A);
76 explicit VoidMemFun1(MemberFN p) : _mfn(p) { }
77 void operator()(H handle, A arg)
const
79 (handle.get() ->* _mfn)(arg);
83 template<
class R,
class K,
class T,
class H>
84 class SecondMemFun :
public std::unary_function<std::pair<K, H>, R>
86 typedef R (T::*MemberFN)(void);
91 explicit SecondMemFun(MemberFN p) : _mfn(p) { }
92 R operator()(std::pair<K, H> pair)
const
94 return (pair.second.get() ->* _mfn)();
98 template<
class R,
class K,
class T,
class H,
class A>
99 class SecondMemFun1 :
public std::binary_function<std::pair<K, H>, A, R>
101 typedef R (T::*MemberFN)(A);
106 explicit SecondMemFun1(MemberFN p) : _mfn(p) { }
107 R operator()(std::pair<K, H> pair, A arg)
const
109 return (pair.second.get() ->* _mfn)(arg);
113 template<
class K,
class T,
class H>
114 class SecondVoidMemFun :
public std::unary_function<std::pair<K, H>, void>
116 typedef void (T::*MemberFN)(void);
121 explicit SecondVoidMemFun(MemberFN p) : _mfn(p) { }
122 void operator()(std::pair<K, H> pair)
const
124 (pair.second.get() ->* _mfn)();
128 template<
class K,
class T,
class H,
class A>
129 class SecondVoidMemFun1 :
public std::binary_function<std::pair<K, H>, A, void>
131 typedef void (T::*MemberFN)(A);
136 explicit SecondVoidMemFun1(MemberFN p) : _mfn(p) { }
137 void operator()(std::pair<K, H> pair, A arg)
const
139 (pair.second.get() ->* _mfn)(arg);
143 template<
class R,
class T,
class H>
144 class ConstMemFun :
public std::unary_function<H, R>
146 typedef R (T::*MemberFN)(void)
const;
151 explicit ConstMemFun(MemberFN p) : _mfn(p) { }
152 R operator()(H handle)
const
154 return (handle.get() ->* _mfn)();
158 template<
class R,
class T,
class H,
class A>
159 class ConstMemFun1 :
public std::binary_function<H, A, R>
161 typedef R (T::*MemberFN)(A)
const;
166 explicit ConstMemFun1(MemberFN p) : _mfn(p) { }
167 R operator()(H handle, A arg)
const
169 return (handle.get() ->* _mfn)(arg);
173 template<
class T,
class H>
174 class ConstVoidMemFun :
public std::unary_function<H, void>
176 typedef void (T::*MemberFN)(void)
const;
181 explicit ConstVoidMemFun(MemberFN p) : _mfn(p) { }
182 void operator()(H handle)
const
184 (handle.get() ->* _mfn)();
188 template<
class T,
class H,
class A>
189 class ConstVoidMemFun1 :
public std::binary_function<H, A, void>
191 typedef void (T::*MemberFN)(A)
const;
196 explicit ConstVoidMemFun1(MemberFN p) : _mfn(p) { }
197 void operator()(H handle, A arg)
const
199 (handle.get() ->* _mfn)(arg);
203 template<
class R,
class K,
class T,
class H>
204 class SecondConstMemFun :
public std::unary_function<std::pair<K, H>, R>
206 typedef R (T::*MemberFN)(void)
const;
211 explicit SecondConstMemFun(MemberFN p) : _mfn(p) { }
212 R operator()(std::pair<K, H> pair)
const
214 return (pair.second.get() ->* _mfn)();
218 template<
class R,
class K,
class T,
class H,
class A>
219 class SecondConstMemFun1 :
public std::binary_function<std::pair<K, H>, A, R>
221 typedef R (T::*MemberFN)(A)
const;
226 explicit SecondConstMemFun1(MemberFN p) : _mfn(p) { }
227 R operator()(std::pair<K, H> pair, A arg)
const
229 return (pair.second.get() ->* _mfn)(arg);
233 template<
class K,
class T,
class H>
234 class SecondConstVoidMemFun :
public std::unary_function<std::pair<K, H>, void>
236 typedef void (T::*MemberFN)(void)
const;
241 explicit SecondConstVoidMemFun(MemberFN p) : _mfn(p) { }
242 void operator()(std::pair<K, H> pair)
const
244 (pair.second.get() ->* _mfn)();
248 template<
class K,
class T,
class H,
class A>
249 class SecondConstVoidMemFun1 :
public std::binary_function<std::pair<K, H>, A, void>
251 typedef void (T::*MemberFN)(A)
const;
256 explicit SecondConstVoidMemFun1(MemberFN p) : _mfn(p) { }
257 void operator()(std::pair<K, H> pair, A arg)
const
259 (pair.second.get() ->* _mfn)(arg);
273 template<
class R,
class T>
274 inline ::IceUtilInternal::MemFun<R, T, Handle<T> >
275 memFun(R (T::*p)(
void))
277 return ::IceUtilInternal::MemFun<R, T, Handle<T> >(p);
280 template<
class R,
class T,
class A>
281 inline ::IceUtilInternal::MemFun1<R, T, Handle<T>, A>
282 memFun1(R (T::*p)(A))
284 return ::IceUtilInternal::MemFun1<R, T, Handle<T>, A>(p);
288 inline ::IceUtilInternal::VoidMemFun<T, Handle<T> >
289 voidMemFun(
void (T::*p)(
void))
291 return ::IceUtilInternal::VoidMemFun<T, Handle<T> >(p);
294 template<
class T,
class A>
295 inline ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A>
296 voidMemFun1(
void (T::*p)(A))
298 return ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A>(p);
301 template<
class R,
class K,
class T>
302 inline ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> >
303 secondMemFun(R (T::*p)(
void))
305 return ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> >(p);
308 template<
class R,
class K,
class T,
class A>
309 inline ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A>
310 secondMemFun1(R (T::*p)(A))
312 return ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A>(p);
315 template<
class K,
class T>
316 inline ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> >
317 secondVoidMemFun(
void (T::*p)(
void))
319 return ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> >(p);
322 template<
class K,
class T,
class A>
323 inline ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A>
324 secondVoidMemFun1(
void (T::*p)(A))
326 return ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A>(p);
329 template<
class R,
class T>
330 inline ::IceUtilInternal::ConstMemFun<R, T, Handle<T> >
331 constMemFun(R (T::*p)(
void)
const)
333 return ::IceUtilInternal::ConstMemFun<R, T, Handle<T> >(p);
336 template<
class R,
class T,
class A>
337 inline ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A>
338 constMemFun1(R (T::*p)(A)
const)
340 return ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A>(p);
344 inline ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> >
345 constVoidMemFun(
void (T::*p)(
void)
const)
347 return ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> >(p);
350 template<
class T,
class A>
351 inline ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A>
352 constVoidMemFun1(
void (T::*p)(A)
const)
354 return ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A>(p);
357 template<
class R,
class K,
class T>
358 inline ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> >
359 secondConstMemFun(R (T::*p)(
void)
const)
361 return ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> >(p);
364 template<
class R,
class K,
class T,
class A>
365 inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>
366 secondConstMemFun1(R (T::*p)(A)
const)
368 return ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>(p);
371 template<
class K,
class T>
372 inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> >
373 secondConstVoidMemFun(
void (T::*p)(
void)
const)
375 return ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> >(p);
378 template<
class K,
class T,
class A>
379 inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>
380 secondConstVoidMemFun1(
void (T::*p)(A)
const)
382 return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>(p);