最初我std::istringstream iss(std::move(string));
在while循环内写,所以在循环内给出错误crosses initialization
。现在它不在任何循环内,但即使它给出了 error crosses the initialization
。
void *SocketHandler(void *lp)
{
typedef std::unordered_map<std::string,int> occurrences;
occurrences s1;
std::string ss;
std::ostringstream bfr;
std::string result_string;
std::vector<std::string> most;
int max_count = 0;
int tmp=0;
while ((NULL != word) && (50 > i)) {
ch[i] = strdup(word);
excluded_string[j]=strdup(word);
word = strtok(NULL, " ");
skp = BoyerMoore_skip(ch[i], strlen(ch[i]) );
bfr << excluded_string[j] << " ";
result_string = bfr.str();
j++;
// std::cout << "string is :" << r1;
i++;
if(str==NULL && str==NULL and skp !=NULL)
{
pcount=0;
ncount=0;
}
}
std::cout << "string is :" << result_string << "\n";
std::istringstream iss(std::move(result_string)); // **Here it gives error**
while (iss >> result_string)
{
tmp = ++s1[result_string];
if (tmp == max_count)
{
most.push_back(result_string);
}
else if (tmp > max_count)
{
max_count = tmp;
most.clear();
most.push_back(result_string);
}
}
std::cout << std::endl << "Maximum Occurrences" << std::endl;
for (std::vector<std::string>::const_iterator it = most.cbegin(); it != most.cend(); ++it)
std::cout << *it << std::endl;
return 0;
}