gpt4 book ai didi

c++ - 'stoi' 和 'to_string' 不是 'std' 的成员

转载 作者:行者123 更新时间:2023-11-27 23:01:09 25 4
gpt4 key购买 nike

<分区>

我有一些代码,它非常大,所以我将在这里创建它的快照:

int l = 3;
vector<int> weights;

void changeWeights(int out){
for (int i = 0; i < weights.size(); i++){
int w = std::stoi(std::to_string(weights[i])) -
out*std::stoi(std::to_string(weights[i]));
if (w < -l){
w = -l;
} else if(w > l){
w = l;
}
weights.assign(i, w);
}
}

我以

的形式在“stoi”和“to_string”函数调用中得到错误
Main.cpp:35:21: error: ‘stoi’ is not a member of ‘std’
int w = std::stoi(std::to_string(weights[i])) -
^
Main.cpp:35:31: error: ‘to_string’ is not a member of ‘std’
int w = std::stoi(std::to_string(weights[i])) -
^
Main.cpp:36:17: error: ‘stoi’ is not a member of ‘std’
out*std::stoi(std::to_string(weights[i]));
^
Main.cpp:36:27: error: ‘to_string’ is not a member of ‘std’
out*std::stoi(std::to_string(weights[i]));

我读过一些类似的查询,答案是在编译时添加 -std=c++11 或 -std=c++0x - 这两种解决方案均无效。另一个解决方案表明编译器版本中存在错误,但我不认为它不是我正在使用的编译器。我在 64x Apple Macbook Pro 上使用 g++ (GCC) 5.0.0 20141005(实验)版本。

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