通过引用传递向量是请求 std::分配器
Passing vector by reference is requesting std::allocator
我正在使用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++,感谢您的帮助:)
相关文章:
- 使用std::multimap迭代器创建std::list
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从持续时间构造std::chrono::system_clock::time_point
- std::具有相同基类的类的变体
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- std::向量与传递值的动态数组
- std::getline没有在while循环中重新请求用户输入
- 通过引用传递向量是请求 std::分配器
- 错误:请求从"Mstream"转换为非标量类型"std::string {aka std::basic_string<char>}"
- 错误:请求从 std::chrono::time_point 浮点数转换为非标量类型长整型
- 当请求的键丢失时,有没有办法从向量映射返回 std::vector ref?
- 请求C 17的编译器通过使用-STD 17标志在-STD = C 17时,将启用STD ::变体的支持
- 如何修复错误:请求从"void"转换为非标量类型"std::vector<int>"
- 是否有为std::set请求容量的函数
- 在std::unordered_set:上,请求一个具有默认散列的类型列表
- 错误:请求在"myVector"中请求成员'push_back',该成员的非类类型为"std::vector<Base>*"?
- std::ifstream::read()读取的数据少于请求的数据,并设置失败位,原因不明显