c++ - 为什么 stoi 函数在 Visual Studio 2010 中可用

标签 c++ visual-studio gcc

我不明白为什么 中的 stoi 函数在 Visual Studio 2010 (Platform Toolset = v100) 中可用,因为文档中说这是一个 C++11 功能。

有人能帮我理解一下吗?

我也想将它与 GCC 4.4.7 一起使用....这是我的初衷。

最佳答案

C++11 是 2011 年之前的草案。由于 stoi() 将使其成为标准,许多编译器在 C++11 最终确定之前就已经添加了它。在 C++11 最终确定之前使用 C++11 功能是实验性的,因为一旦标准获得批准,情况可能会发生变化

运行

#include <iostream>
#include <string>
int main()
{
    int foo = std::stoi("5");
}

关于 godbolt.org使用 GCC 4.4.7 和 -std=c++0x 确实可以编译,所以看起来您已经准备好使用它了。

Live Example

关于c++ - 为什么 stoi 函数在 Visual Studio 2010 中可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33414052/

相关文章:

gcc - x86-64 汇编语言中的 ELF 共享对象

c++ - GCC 4.9 模棱两可的重载模板特化

Java 调用由 GCC 编译的 C 库有效,但在使用 G++ 编译时失败

c# - 服务器上不允许 C++ 可再发行组件

c++ - 双括号初始化

asp.net - 将 SVN 与 Visual Studio 2003 集成

vb.net - 在 VB.NET Intellisense 中禁用 Common Tab

C# Visual Studio 递增计时器

c++ - 将默认构造的对象传递给函数时为 "E2188 Expression syntax error"

c++ - boost::serialization Archive::register_type 如何工作?