c++ - 我可以将 stoi 与 GCC 4.4.7 编译器一起使用吗?

标签 c++ gcc

我不想使用 -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/

相关文章:

c++ - 在 UWP 中找不到剪贴板

c++ - 在 C++ 字符串中替换的最佳方法是什么?

c++ - 未初始化的本地字符的行为?

c - 强制 mac 使用 GCC,而不是 clang

C++ 错误 : "' class' does not name a type"and "invalid use of incomplete type ‘struct ...' "

c++ - 成员函数指针c++

c - C中匿名数组的使用 "expected ' ;' before ' }' token"

c - 如何纠正 valgrind 错误?

c++ - 即使程序刚刚启动,是否也可以始终捕获信号?

c++ - 使用 const 键类型引用调用 std::set of pointers 的 count 方法