Is stoi function supported?

I would like to use the stoi function as part of the namespace std which is included in the ‘string’ library. I seem to get an error that stoi is not a member of the std namespace hence my question, does ARM C++ compiler support the string library?

You can import string.

#include <string> 

I have done that, yes. The error comes in when std::stoi is called.
Error: Namespace “std” has no member “stoi”

It just works for me though.

How about specifying the namespace?

#include <string> 
using namespace std;

I tried that as well and the error remains so in that case I have no clue what could be the issue. I even tried to set a test in the main function with the included library and namespace set such as
string b = “5”;
int a = stoi(b);
And the same error comes up. Thanks for the help!

Are you using the online compiler? Maybe it uses c++98 and doesn’t have stoi(). I use CLI and c++11.

1 Like

That might be the reason, I am using in fact the online compiler. I’ll code this according to c++98 in that case. Thanks!!


maybe better question is… what version of MbedOS you use?

Online compiler with MbedOS(5.15.1) have no problem with this.

#include <string> 
using namespace std;
    string b = "5";
    int a = stoi(b);

But when you use older version of Mbed, for example, the Mbed OS2 or Mbed OS5 (lower than 5.11) then problem is occurred.
With some version of MbedOS was also changed its tools, the compiler, so that is probably the reason.

BR, Jan

1 Like