2011-08-31 6 views

답변

3
#include <boost/bind.hpp> 

template<typename T> 
void proxy_do_stuff(T return_here) 
{ 
    return_here(); // call stuff pased into boost::bind 
} 

struct myclass 
{ 
    void myfunction(int, int) 
    { 
    } 
    void foo() 
    { 
     int my_function_argument_value = 3; 
     int etc_fun_argument= 5; 
     proxy_do_stuff(boost::bind(&myclass::myfunction, this, my_function_argument_value, etc_fun_argument)); 
    } 
}; 

int main() 
{ 
    myclass c; 
    c.foo(); 
    return 0; 
} 
+0

그런 기능을 어떻게 사용합니까? 우리는 이것을'proxy_do_stuff (...)'처럼 부르지 않아야합니까? – Rella

+0

파트 사용법을 추가했습니다. bla-bla-bla가 필요 없습니다. –

4

boost :: bind의 반환 유형은 boost :: function 유형입니다. 아래 참조 :

void proxy_do_stuff(boost::function<void()> return_here) 
{ 
    return_here(); // call stuff pased into boost::bind 
} 
+3

+1 반환 유형은 실제로 boost :: _ bi :: bind_t , boost :: _ bi :: list3 , boost :: _ bi :: value , boost :: _ bi :: value >>하지만 boost :: function으로 변환하고 있습니다.