부스트 라이브러리 테스트 프레임 워크를 사용하여 단위 테스트를 만들고이 라이브러리와 함께 std :: bind 자리 표시자를 사용하는 데 문제가 발생했습니다.boost 라이브러리와 함께 std :: bind 자리 표시 자 사용 문제
std::bind(&TestFixture::concatStrings, this, std::placeholders::_1, std::placeholders::_2)
을하지만이 std::placeholders::
직접이 _1
를 사용 생략하면, 그것은 컴파일 오류 발생 :
내가 명시 적으로 std::placeholders::
+ _1를 사용하는 경우, 그것을 잘 작동
Error 1 error C2664: 'std::string std::_Pmf_wrap<std::string (__thiscall TestFixture::*)(const std::string &,const std::string &),std::string,TestFixture,const std::string &,const std::string &>::operator()(_Farg0 &,const std::string &,const std::string &) const' : cannot convert argument 2 from 'boost::arg<1>' to 'const std::string &' C:\APPS\msvs2013\VC\include\functional 1149 1 test
람다를 사용하여 , 내가 생각할 수있는 최상의 솔루션입니다 :
[&](const std::string& x, const std::string& y){ return concatStrings(x, y); }
std :: bind와 같이 boost 라이브러리와 std 충돌로 정의 된 메소드를 사용하는 경우를 이해하고 싶습니다. 미리 감사드립니다.
안녕하세요! 답장을 보내 주셔서 감사합니다. '_1'을 사용하면 boost :: bind에서 잘 작동합니다. 비록 std :: bind를 명시 적으로 사용하려고한다면'std :: placeholders :: _ 1'을 사용해야합니다. 람다에서 캡처를 지적 해 주셔서 감사합니다, 나는 안전하게 캡처를 선택하는 습관을 만들 것입니다. :) – cawols