나는 입력으로 boost::function<>
유형의 객체를 취하고 다른 물류를 처리하는 다른 함수로 함수를 래핑하는 도우미 메서드가 있습니다. 여기 boost :: bind의 결과 인 매개 변수를 취하는 템플릿 함수를 만들려면 어떻게해야합니까?
boost::bind
인라인을 호출 한 결과를 make_wrapper 통과하려고하면 내가 유형이 호환되지 않는 것에 대해 컴파일 에러가 발생
class Example {
public:
typedef ... Callback;
...
template<typename T>
static Callback make_wrapper(const boost::function<void(T)>&);
};
(애플 LLVM 버전 7.3.0)
class OtherClass {
public:
void method (uint32_t);
};
OtherClass* other;
Example::Callback c = Example::make_wrapper (boost::bind(&OtherClass::method, other, _1));
이 제공 :
error: no matching function for call to 'make_wrapper'
note: candidate template ignored: could not match 'function' against 'bind_t'
나는 F를 운드,이 약 2 가지 방법 :
온도 변수 : make_wrapper의
boost::function<void(uint32_t)> f = boost::bind(&OtherClass::method, other, _1); Example::Callback c = Example::make_wrapper (f);
전화 특정 전문화 : 나는를 건너 뛸 수 있다면
Example::Callback c = Example::make_wrapper<uint32_t> (boost::bind(&OtherClass::method, other, _1));
내가 많이 선호 여분의 힌팅과 바인딩 인라인 호출과 함께 make_wrapper를 호출하십시오.
컴파일러가 위의 해결 방법 중 하나를 사용하지 않고 유형을 파악하는 데 도움이되는 make_wrapper 템플릿의 서명을 선언 할 수있는 방법이 있습니까?
'자동'또는 'decltype'을 사용하십시오. – Zereges