My code:
#include <iostream>
#include <string>
int main()
{
std::string test = "45";
int myint = std::stoi(test);
std::cout << myint << '\n';
}
Gives me the compile error:
error: 'stoi' is not a member of 'std'
int myint = std::stoi(test);
^
However, according to here, this code should compile fine. I am using the line set(CMAKE_CXX_FLAGS "-std=c++11 -O3")
in my CMakeLists.txt
file.
Why is it not compiling?
Update: I am using gcc
, and running gcc --version
prints out:
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010