hash_map > push_back 错误!

herman011 2008-06-11 09:03:54
struct seed_region
{
seed_region(const unsigned int a,const unsigned int b):
start(a),end(b){}

unsigned int start;
unsigned int end;
};

hash_map<unsigned int,vector<seed_region> > reads_unmapped;

reads_unmapped[2].push_back(seed_region(0,1)); 这句编译不通过:

671 D:\SRMAP\NC_003070\srmap0609.cpp no match for call to `(__gnu_cxx::hash_map<unsigned int, std::vector<seed_region, std::allocator<seed_region> >, __gnu_cxx::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<std::vector<seed_region, std::allocator<seed_region> > > >) (int, int)'




之前我有个类似的都可以啊:
struct reads_seed
{
reads_seed(const unsigned int i,const unsigned char o,const bool s) :
id(i),offset(o),strand(s){}

unsigned int id;
unsigned offset :7;
unsigned strand :1;
};

hash_map<unsigned int,vector<reads_seed> > reads_hash;

reads_hash[5].push_back(reads_seed(1,3,true));
...全文
131 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
visame 2008-06-12
  • 打赏
  • 举报
回复

//未见明显错误
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};

int main()
{
hash_map<const char*, int, hash<const char*>, eqstr> months;

months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;

cout << "september -> " << months["september"] << endl;
cout << "april -> " << months["april"] << endl;
cout << "june -> " << months["june"] << endl;
cout << "november -> " << months["november"] << endl;
}
wsqshz 2008-06-12
  • 打赏
  • 举报
回复
一切正常

65,208

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧