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
40 lines (32 loc) · 1.2 KB
/
Copy pathmem_bind.h
File metadata and controls
40 lines (32 loc) · 1.2 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
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <[email protected]>
//
// 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,typename ... P1>
struct binderX {
void (C::*member)(P1...);
P object;
void operator()(P1... args) const { ((*object).*member)(args...); }
};
}
/// \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()(P1 p) const and calls obj->mem(p)
///
template<typename C,typename P,typename ...P1>
details::binderX<C,P,P1...> mem_bind(void (C::*mem)(P1...),P obj)
{
details::binderX<C,P,P1...> tmp={mem,obj};
return tmp;
}
} } // cppcms::util
#endif