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



## hhh (May 29, 2014)

Hi,

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


```
% 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?


```
#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.


----------



## freethread (May 29, 2014)

stoi is part of the c++11 standard, this standard is mostly implemented in gcc48 (not tested, though). *L*ook at this link specific for GCC 4.8.3: http://gcc.gnu.org/onlinedocs/gcc-4.8.3/libstdc++/manual/manual/status.html#status.iso.2011 and this one for GCC 4.7.3: http://gcc.gnu.org/onlinedocs/gcc-4.7.3/libstdc++/manual/manual/status.html#status.iso.2011.


----------



## ghii (May 30, 2014)

clang++ s.cc -stdlib=libc++ -std=c++11


----------

