g++: 'stoi' is not a member of 'std'

Hi,

I get the following error, when trying to compile example C++ code with g++47. There is no problem when using clang++ instead.

Code:
% g++47 -std=c++11 s.cc
s.cc: In function 'int main()':
s.cc:8:13: error: 'stoi' is not a member of 'std'

How could could I compile this example?

Code:
#include <iostream>
#include <string>

using namespace std;

int main(){
  string theAnswer = "42";
  int ans = std::stoi(theAnswer, 0, 10);

  cout << "The answer to everything is " << ans << endl;
}

Thank you in advance for help.

Henryk

Note: I'm using FreeBSD 10.
 
Back
Top