2010-11-19 3 views
1

[] 연산자가 오버로드 된 클래스가 있습니다. 또한 시작할 스레드가 있습니다 ... 스레드에 []을 (를) 바인딩하려면 어떻게해야합니까? Boost :: 바인딩 문제 바인딩 오버로드 된 연산자

나는이 시도 :

threadpool.schedule(bind(static_cast< MyClass (MyClass::*)(const MyClass &arg)>(&MyClass::operator[]), arg))

을하지만 VS2008는 말한다 :

오류 C2664 :

'boost::threadpool::thread_pool::schedule': cannot convert parameter 1 from 'boost::_bi::bind_t' to 'const boost::function0 &' 

가 어떻게이 문제를 해결할 수 있습니까? 미리 감사드립니다.

+0

'MyClass' 코드를 제공 할 수 있습니까? – icecrime

답변

1

잘못된 것처럼 보입니다. 멤버 함수는 여전히 하나의 인수를 허용합니다. 그래서 당신은 자리가 필요하거나 this

threadpool.schedule(bind( 
    static_cast< MyClass (MyClass::*)(const MyClass &arg)>(&MyClass::operator[]), 
    this, arg)) 

의 클래스 타입이 있지만 조금 이상한 보인다 받아들이는 operator[]을 결합하는 것을 잊었다. 다음은 "일반적인"첨자 연산자를 찾는 방법입니다.

threadpool.schedule(bind(
    static_cast< MyClass (MyClass::*)(std::size_t)>(&MyClass::operator[]), this, index) 
);