我不想使用 -std=c++11。 还有别的办法吗?
我有这样的代码:
#include <iostream>
using namespace std;
#include <string>
#include <sstream>
int main()
{
std::string str1 = "45";
int myint1 = std::stoi(str1); <--error: Function 'stoi' could not be resolved
}
最佳答案
stoi
来自 C++11,所以如果你不想使用标志 -std=c++11
你就不能使用 stoi
(或者你可以等到 gcc 6.0 发布,其中 -std=gnu++14
将是默认标准)。
但你可以使用其他东西:boost::lexical_cast
,一些手动编写的函数等。
关于c++ - 我可以将 stoi 与 GCC 4.4.7 编译器一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33034320/