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++ リファレンスのサンプル プログラムもコンパイルできません。

4

1 に答える 1

4

std::bindg++ 4.4 ではサポートされていない C++11 です。システム アップグレードまたは /etc/apt/preferences パッケージ バインディングを使用して、少なくとも Debian Wheezy の g++ 4.7 にアップグレードする必要があります。

于 2013-08-16T06:14:08.837 に答える