6 #ifndef __FWCOM_UTIL_AUTOBIND_HXX__ 7 #define __FWCOM_UTIL_AUTOBIND_HXX__ 9 #ifndef __FWCOM_UTIL_AUTOBIND_HPP__ 10 #error fwCom/util/AutoBind.hpp not included 13 #include <boost/function_types/function_arity.hpp> 18 namespace stdplh = std::placeholders;
25 template<
typename F >
26 template<
typename W,
typename ... A >
27 std::function< typename AutoBind< F, 0 >::FunctionType > AutoBind< F, 0 >::wrap( W f, A ...
a )
29 return std::bind( f, a ... );
34 template<
typename F >
35 template<
typename W,
typename ... A >
36 std::function< typename AutoBind< F, 1 >::FunctionType > AutoBind< F, 1 >::wrap( W f, A ...
a )
38 return std::bind( f, a ..., stdplh::_1 );
43 template<
typename F >
44 template<
typename W,
typename ... A >
45 std::function< typename AutoBind< F, 2 >::FunctionType > AutoBind< F, 2 >::wrap( W f, A ...
a )
47 return std::bind( f, a ..., stdplh::_1, stdplh::_2 );
52 template<
typename F >
53 template<
typename W,
typename ... A >
54 std::function< typename AutoBind< F, 3 >::FunctionType > AutoBind< F, 3 >::wrap( W f, A ...
a )
56 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3 );
61 template<
typename F >
62 template<
typename W,
typename ... A >
63 std::function< typename AutoBind< F, 4 >::FunctionType > AutoBind< F, 4 >::wrap( W f, A ...
a )
65 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3, stdplh::_4 );
70 template<
typename F >
71 template<
typename W,
typename ... A >
72 std::function< typename AutoBind< F, 5 >::FunctionType > AutoBind< F, 5 >::wrap( W f, A ...
a )
74 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3, stdplh::_4, stdplh::_5 );
79 template<
typename F >
80 template<
typename W,
typename ... A >
81 std::function< typename AutoBind< F, 6 >::FunctionType > AutoBind< F, 6 >::wrap( W f, A ...
a )
83 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3, stdplh::_4, stdplh::_5, stdplh::_6 );
88 template<
typename F >
89 template<
typename W,
typename ... A >
90 std::function< typename AutoBind< F, 7 >::FunctionType > AutoBind< F, 7 >::wrap( W f, A ...
a )
92 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3, stdplh::_4, stdplh::_5, stdplh::_6,
98 template<
typename F >
99 template<
typename W,
typename ... A >
100 std::function< typename AutoBind< F, 8 >::FunctionType > AutoBind< F, 8 >::wrap( W f, A ...
a )
102 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3, stdplh::_4, stdplh::_5, stdplh::_6, stdplh::_7,
108 template<
typename F >
109 template<
typename W,
typename ... A >
110 std::function< typename AutoBind< F, 9 >::FunctionType > AutoBind< F, 9 >::wrap( W f, A ...
a )
112 return std::bind( f, a ..., stdplh::_1, stdplh::_2, stdplh::_3, stdplh::_4, stdplh::_5, stdplh::_6, stdplh::_7,
113 stdplh::_8, stdplh::_9 );
118 template <
typename F,
typename ... A >
119 std::function< typename convert_function_type< F >::type >
autobind(F f, A ...
a)
121 typedef typename convert_function_type< F >::type FunctionType;
122 const int arity = ::boost::function_types::function_arity< FunctionType >::value;
Namespace containing fw4spl communication tools.
Automatic binding class. This class allow to bind automatically a function/method with the right numb...
std::function< typename convert_function_type< F >::type > autobind(F f, A...a)
Automatic bind of given function.