Advertisement
bueddl

Untitled

Sep 23rd, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1.  
  2. template<class classT, typename ...method_arg_types>
  3. class func2;
  4.  
  5. template<class classT, typename ...method_arg_types>
  6. func2<classT, method_arg_types...>
  7. func(classT *instance, void(classT::*method)(method_arg_types...))
  8. {
  9.     return func2<classT, method_arg_types...>(instance, method);
  10. }
  11.  
  12. template<class classT, typename ...method_arg_types>
  13. class func2 {
  14.     friend func2<classT, method_arg_types...> func<classT, method_arg_types...>(classT *instance, void(classT::*method)(method_arg_types...));
  15. public:
  16.     using method_type = void(classT::*)(method_arg_types...);
  17.  
  18.     func2(classT *instance, method_type method)
  19.         : m_instance(instance), m_method(method)
  20.     {
  21.     }
  22.  
  23.     void operator()(method_arg_types&& ...method_args) {
  24.         (m_instance->*m_method)(std::forward(method_args...));
  25.     };
  26.  
  27. private:
  28.     method_type m_method;
  29.     classT *m_instance;
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement