[英]How to compile a c++ program with std::bind?
I want to compile this simple test.cpp program from Wrox's Professional C++ : 我想从Wrox的Professional C ++编译这个简单的test.cpp程序:
#include<iostream>
#include<functional>
using namespace std;
void func(int num, const string& str)
{
cout << num << ' ' << str << endl;
}
int main()
{
string str = "abc";
auto f = bind(func, placeholders::_1, str);
f(16);
}
I have g++ (Debian 4.4.5-8) 4.4.5 compilator and I use it like that: 我有g ++(Debian 4.4.5-8)4.4.5编译器,我使用它:
g++ -std = c++0x test.cpp -o test
I get error: 我收到错误:
error: no match for call to ‘(std::_Bind<void (*(std::_Placeholder<1>, int))
(int, int)>) (int)’
Why the program does not compile? 为什么程序不编译?
I cannot compile the example program from C++ Reference as well. 我也无法从C ++ Reference编译示例程序。
std::bind
是C ++ 11,g ++ 4.4不支持你需要通过系统升级或使用/ etc / apt / preferences软件包绑定至少升级到Debian Wheezy的g ++ 4.7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.