1

我想从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);
}

我有 g++ (Debian 4.4.5-8) 4.4.5 编译器,我像这样使用它:

g++ -std = c++0x test.cpp -o test

我得到错误:

error: no match for call to ‘(std::_Bind<void (*(std::_Placeholder<1>, int))
(int, int)>) (int)’

为什么程序无法编译?

我也无法从C++ Reference编译示例程序。

4

1 回答 1

4

std::bind是C++11,g++ 4.4不支持你需要通过系统升级或者使用/etc/apt/preferences包绑定至少升级到Debian Wheezy的g++ 4.7

于 2013-08-16T06:14:08.837 回答