c++ - 如何制作自定义字符串的 std::unorder_set 类型?
问题描述
假设我有一个自定义字符串,如 type:
struct MyType {
std::string str_;
int somethingElse;
}
现在,我知道如何使它在 std::set 中可用 - 只需提供<
运算符。
我怎样才能使用它std::unordered_set
?什么时候应该基于std::string str_
成员?
std::unordered_set<MyType> um;
更新:我已经看到了这个答案:C++ unordered_map using a custom class type as the key
它看起来有些过时了(c++11 ?)并且还担心map
解决方案
推荐阅读
- node.js - 如何使用云功能在 Firestore 中输入数据?
- angularjs - 切换单选按钮时使用 angularjs 显示不同的内容
- ios - 架构 x86_64 的未定义符号:“_OBJC_METACLASS_$_GMVDetector”引用自:TextDetector
- jquery - 可重复使用的引导模式以确认删除
- spring - 引起:java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver - 微服务
- javascript - 带有服务器端数据表的空 ajax 返回
- android - Smack 4.2.4 版:资源限制 - 等待
- r - 使用 data.table 中的“:=”将值分配给子集上的多个列
- c# - 如何通过使用 linq 或反射比较 2 个列表来获取更新或修改的列表记录
- gnuradio - 关于我的 GNU Radio 源代码块的采样率