글
C++11에서 STL의 bind와 Boost::bind를 같이 사용할 때 아래와 같이 사용하면 이름 충돌이 발생할 수 있습니다.
#include <functional>
using namespace std::placeholders;
#include <boost/bind.hpp>
int f(int, int);
auto g = std::bind(f, _1, 42); // _1 때문에 에러 발생
해결 방법은 이름 공간을 정확하게 지정하면 됩니다.
auto g = std::bind(f, std::placeholders::_1, 42);
namespace ph = std::placeholders;
auto g = std::bind(f, ph::_1, 42);
댓글