나는 표준을 구현하기 위해 노력하고있어 :: 바인드를 쉽게 예에서 사용하는 방법 :이 내가 무엇을 얻을 컴파일 할 때 그러나표준 : 바인드
#include <functional>
#include <iostream>
using namespace std;
using namespace std::placeholders;
int multiply(int a, int b)
{
return a * b;
}
int main()
{
auto f = bind(multiply, 5, _1);
for (int i = 0; i < 10; i++)
{
cout << "5 * " << i << " = " << f(i) << endl;
}
return 0;
}
을 :
test.cpp:5: error: ‘placeholders’ is not a namespace-name
test.cpp:5: error: expected namespace-name before ‘;’ token
test.cpp: In function ‘int main()’:
test.cpp:14: error: ISO C++ forbids declaration of ‘f’ with no type
test.cpp:14: error: ‘_1’ was not declared in this scope
test.cpp:14: error: ‘bind’ was not declared in this scope
test.cpp:17: error: ‘f’ cannot be used as a function
는 주어진 예는
이
어떤 컴파일러를 사용하고 있습니까? std :: bind는 C++ 11에서 도입되었습니다. 귀하의 컴파일러가 C++ 11을 지원하지 않을 수도 있고 올바른 옵션을 컴파일러에 전달하지 않을 수도 있습니다. – bashrc