通过引用传递向量是请求 std::分配器

Passing vector by reference is requesting std::allocator

本文关键字:请求 std 分配器 向量 引用      更新时间:2023-10-16

我正在使用c ++。

所以我的情况是,我试图通过引用函数来传递向量。在构建之前,编译器会在函数调用中抛出错误:

no instance of function matches the argument list
argument types are (std::vector<int, std::allocator<int>>)

如果我在Visual Studio中将项目创建为控制台应用程序,则工作正常,并且不会引发任何错误。如果我将项目创建为桌面应用程序,它会引发此错误。我宁愿坚持使用桌面应用程序。

任何帮助或意见都会很棒,谢谢!

下面是引发错误的代码示例


Definition
VOID SomeFunction(vector<int>& MyVector)
{
...Do something with the vector
}

Call
vector<int> vect;
vect.push_back(1);
//The error is thrown here
SomeFunction(vect);
//

重写我的代码表明这是项目中定义语句中的问题,而不是编译器或 c++,感谢您的帮助:)