![](/img/trans.png)
[英]Implementing a memoization table with a map templated on a pair of int, int and int
[英]Pair as a key in map for Memoization
我想让您对函数f(row, int)
使用unordered_map
进行记忆化。 不幸的是,我收到一个奇怪的编译错误(很长很神秘)。
#include <vector>
#include <unordered_map>
#include <utility>
using namespace std;
typedef vector<bool> row;
int main(void) {
unordered_map< pair<int, row>, int > x;
}
std::unordered_map
的密钥类型需要具有std::hash
的实现,我想您的错误是告诉您std::pair<int, row>
没有std::hash
实现。 我认为标准没有为std::pair
指定std::hash
的特殊化,因此您需要提供自己的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.