cygwin g ++ std :: stoi"错误:'stoi'不是'std.的成员

use*_*700 18 cygwin g++ c++11

我有:

Windows 7/32bit上的-cygwin 1.7.25

-g ++ --version - > g ++(GCC)4.8.2

-libstdc ++.a - > gcc-g ++ - 4.8.2-1

试图制作一个c ++ Hello World:

#include <string>

int main() 
{
   std::string s = "123";
   int i = std::stoi(s);
}
Run Code Online (Sandbox Code Playgroud)

编译给出:

$ g++ -std=c++11 main.cpp
main.cpp: In function ‘int main()’:
main.cpp:6:10: error: ‘stoi’ is not a member of ‘std’
  int i = std::stoi(s);
Run Code Online (Sandbox Code Playgroud)

我搜索了几个小时,但我仍然找不到解决方案.这是什么问题?

use*_*280 12

这是一个错误,可能是cygwin的一些库代码的不完整端口(这是cplusplus11功能) - 毕竟有些东西必须改变.一定要报告.

解决方案当然很简单: #include <cstdlib> strtol(s.c_str(),0,10);

www.cplusplus.com/.../strtol

这里也提到了一个类似的mingw bug

在MinGW上的g ++ 4.6.1中不存在std :: stoi