- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
编译完hash_multimap后,我得到了这么大的一个段落错误
在成员函数“size_t __gnu_cxx::hashtable <
我从未见过如此大的错误,而且由于大小异常,我实际上不确定如何解决此错误。
任何建议为什么行:
p = map1.equal_range(searchKey);
/usr/include/c++/4.3/backward/hashtable.h: In member function ‘size_t
__gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
_Alloc>::_M_bkt_num_key(const _Key&, size_t) const [with _Val =
std::pair<const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, Map2*>, _Key = std::basic_string<char
std::char_traits<char>, std::allocator<char> > >, _Alloc =
std::allocator<Map2*>]’
hash_map2.cpp:55: instantiated from here
/usr/include/c++/4.3/backward/hashtable.h:595: error: no match for call to
‘(const __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >) (const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&)’
#ifndef MAP2_H
#define MAP2_H
#include <iostream>
#include <string>
using namespace std;
class Map2 {
public:
Map2(string data1, string data2, string data3, string data4, string data5);
string pop, keyword, user, desc, id;
string get_pop() {return pop;}
string get_key() {return keyword;}
string get_user() {return user;}
string get_desc() {return desc;}
string get_id() {return id;}
void call_Values(int i);
};
Map2:: Map2(string data1, string data2, string data3, string data4, string data5) {
pop = data1;
keyword = data2;
user = data3;
desc = data4;
id = data5;
}
void Map2:: call_Values(int i) {
get_pop();
get_key();
get_user();
get_desc();
get_id();
}
#endif
#include <fstream>
#include <iostream>
#include "Map2.h"
#include <ext/hash_map>
#include <string>
#include <sstream>
using namespace std;
using __gnu_cxx::hash_multimap;
int nav() {
cout <<"Select from the following options : " << endl <<endl;
cout <<"Search Tweets based on Keyword (Type 1) " <<endl;
cout <<"End Program (Type 2)"<<endl<<endl;
int key =0;
cin >> key;
return key;
}
int main() {
int option = nav();
if (option == 1) {
ifstream readFile("project4.csv");
string tempPop, tempID, tempKey, tempUser, tempDesc;
string tempRead;
hash_multimap<string, Map2 *>map1;
while (readFile != NULL){
// sends to a temp variable
readFile >> tempRead;
for (int i =0; i<400; i++){
//create new object each time
Map2 *mapNode = new Map2(tempPop,tempID,tempKey,tempUser,tempDesc);
//insert each time new object is made
map1.insert(pair<string, Map2 *> (tempKey, mapNode));
} //end for
} //end while
//Navigation through multimap
//first pointer is for first one and second to last hash table value
pair<hash_multimap<string, Map2 *> :: const_iterator,
hash_multimap<string, Map2 *> :: const_iterator> p;
string searchKey = "";
cout << "Please enter the keyword value exactly so we can search the"<<
"available tweets: " <<endl;
cin >> searchKey;
p = map1.equal_range(searchKey);
}
else
return 0;
}
最佳答案
问题是调用字符串进行搜索的事实。在调用equal_range函数内部的值之前,需要将字符串转换为int。
关于c++ - HashMap 错误: no match for call to ‘(const __gnu_cxx::,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29973386/
有没有关于“__gnu_cxx::hash_map”的文档?我想知道如何使用它。 斯里尼瓦斯 最佳答案 hash_map 的 GNU 实现与 STL documentation 中描述的基本相同。 .
我的 (GNU GCC) libstdc++ STL 代码: #include using __gnu_cxx::temporary_buffer; (LLVM) libc++ 中是否有等效项?在哪
我用谷歌搜索了上面的错误;没用。 此错误来自以下代码行: void Thread::join(void** status) { pthread_join(thread, status); } 有人
这会创建文件,但不会写入任何内容。 std::ofstream outstream; FILE * outfile; outfile = fopen("/usr7/cs/test_file.txt",
我一直在阅读有关现代 OpenGL 和 GLSL 的教程,但是当我运行该项目的示例时,它有时会中断。代码抛出: terminate called after throwing an instance
编译完hash_multimap后,我得到了这么大的一个段落错误 在成员函数“size_t __gnu_cxx::hashtable ::_M_bkt_num_key(const _Key&, siz
我刚刚在代码中看到了那个函数,直觉上它应该返回下一个大于参数的素数。然而,当我这样调用它时,我得到 53!然后当我输入 54 时,我得到 97。我没有在网上找到关于它的功能的描述,任何人都可以指点我或
我想在我的 JNI 代码中抛出一个 std::exception 的子类,该代码是使用 swig 包装的,但它并不真正相关,因为生成的代码相当简单: void function_that_throws
我正在尝试在 Linux (Redhat) 中运行旧的 C++ 代码。我正在使用 gcc 版本 4.1.2。这是我遇到错误的代码示例: template TP *GCVVect
这可能是一个愚蠢的错误,但我收到以下错误: error: request for member ‘speak’ in ‘it.__gnu_cxx::__normal_iterator::ope
自 std::pair没有为 __gnu_cxx 散列映射定义,如何使用类型为 std::pair 的键创建 __gnu_cxx 散列映射和 std::pair 类型的值? ( CBTNODE 是 t
我正在尝试使用 google-sparsehash library我想包括链接中描述的哈希库, using ext::hash; // or __gnu_cxx::hash, or maybe tr
C++(STL): Request for member ‘push_back’ in ‘pos.std::vector::operator[](((std::vector::size_type)i)
int webServerPort = -1; void configure(std::string responseFile, callback_function call_back, std
我是一名优秀的程序员,十分优秀!