我正在尝试添加此对,其中entiticountdto是字符串标题,字符串体裁和int的结构,但我得到:C ++没有重载函数的实例与参数列表匹配。有什么想法吗?
struct EntityCountDTO {
std::string title;
std::string genre;
int count = 0;
};
for (const auto& m : v) {
if (mapa.find(m.getGenre()) == mapa.end()) {
mapa.insert(make_pair<string, EntityCountDTO>(m.getGenre(), EntityCountDTO{ m.getTitle(), m.getGenre(), 0 }));
}
else{
mapa.find(m.getGenre())->second.count++;
}
}
您可以使用std::map::emplace
在适当位置构造元素:
std::map::emplace