libstdc ++不实现std :: stoi? [英] Does libstdc++ not implement std::stoi?

查看:312
本文介绍了libstdc ++不实现std :: stoi?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 std :: stoi 。虽然我可以使用 :: atoi(str.c_str())它会使代码更清洁,如果这将工作。但Eclipse告诉我:

I want to use std::stoi. Although I could use ::atoi(str.c_str()) it would make the code cleaner if this would work. But Eclipse tells me:


函数'stoi'无法解析

Function 'stoi' could not be resolved

我检查过


  • 标题< string> ,我可以使用 std :: string
  • $ b来正确设置
  • $ b
  • 编译器标志 -std = c ++ 0x -std = c ++ 11 也被设置。

  • the header <string> is included,
  • include paths are set correctly, as I can use std::string,
  • the compiler flag -std=c++0x -std=c++11 is set too.

在gcc中缺少 stoi()

我使用gcc(Debian 4.7.2-4)4.7.2。

I am using gcc (Debian 4.7.2-4) 4.7.2.

推荐答案

您使用的是GCC 4.7.2,因此 std :: stoi 。您可以忽略Eclipse警告。它应该编译和运行良好。问题是与Eclipse编辑器,而不是与GCC。

You're using GCC 4.7.2, so std::stoi is supported. You can ignore the Eclipse warning. It should compile and run fine. The problem is with the Eclipse editor, not with GCC.

(你只需要 -std = c ++ 11 -std = gnu ++ 11 [也获得GCC扩展]标志,btw。 -std = c ++ 0x 只是一个已弃用的同义词。)

(You only need the -std=c++11 or -std=gnu++11 [to also get the GCC extensions] flag, btw. -std=c++0x is just a deprecated synonym.)

这篇关于libstdc ++不实现std :: stoi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆