GUID比较错误
GUID Comparer error!
我编写了以下简单函数—一个无序映射,它接受2个GUIDS作为键和值。但是,我认为它们没有定义GUID比较器,因此它会对我尝试过的所有GUID比较器抛出此错误。
#include <unordered_map>
#include<iostream>
#include<stdio.h>
#include<Objbase.h>
typedef unordered_map<GUID, GUID, less_guid> Mymap;
Mymap c1;
int __cdecl wmain(int /*argc*/, __in_ecount(argc) WCHAR * /*argv[ ]*/)
{
GUID TargetC;
GUID TargetA;
CoCreateGuid(&TargetC); CoCreateGuid(&TargetA);
c1.insert(Mymap::value_type(TargetC,TargetA)); /
getch();
return 0;
}
下面是显示的错误:">c:program files (x86)microsoft visual studio 10.0vcincludexhash(154):错误C2064:术语不计算为1个参数的函数
类没有定义'operator()'或用户定义的转换操作符到具有适当数量实参的指针到函数或引用到函数"我急需一个解决方案。谢谢你的建议。谢谢!
std::unordered_map
的第三个模板参数为哈希函数,第四个模板参数为比较函数:
template<class Key,
class T,
class Hash = hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<std::pair<const Key, T> > >
class unordered_map;
您正在传递less_guid
,它听起来像一个比较函数,作为第三个模板参数
相关文章:
- C++分数混合比较运算符错误
- 在C++中比较来自向量的字符串时出现分段错误
- 使用 getline(cin, var) 两次在进行字符串比较时会产生错误 (==)
- 比较迭代器会使程序崩溃,而不会在自定义气泡排序实现中出现错误
- 黑客兰克中的错误比较三元组代码
- Qt 错误 iso c++ 禁止指针和整数之间的比较 -permissive
- 为什么Visual Studio没有对逻辑比较错误进行热身?
- qsort 比较函子的分段错误
- std::映射服装比较函数和函数/lambda错误
- 错误:ISO C++禁止在指针和整数 [-fallowive] 之间进行比较
- 错误:运算符 [] 不匹配。在比较列表中的 int 和 int 时<int>,
- 将子字符串与字符串数组进行比较的 IF 条件会在C++中产生错误
- 在 constexpr-if 条件下比较 constexpr 函数参数会导致错误
- 为什么使用 and 运算符比较 if 语句中的 2 个对象会抛出错误,而使用 2 if 语句则不会
- 比较枚举的值会给出编译器错误
- 如何修复C++中的"指针和整数之间的比较"错误?
- Rcpp/C++/R:比较日期时间矢量与日期时间时出错(错误:"运算符>"的不明确重载)
- boost :: fibonacci_heap:带有比较器重新定义圆形定义错误的嵌套定义
- C++ priority_queue使用带有 lambda 比较器错误的映射
- 分词错误-比较不同的单词在c++输入中出现的次数