gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 01:46:19 26 4
gpt4 key购买 nike

我不明白为什么 中的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com