错误:对"set_union"的调用不匹配
Error: No matching for call to "set_union"
我今天正在研究一个算法问题([Uva 12096](,我用我的指导书写了一个代码。这就像书上的代码一样,但是当我编译它时发生了错误:[错误]没有匹配函数来调用"set_union(, std::set::iterator, , std::set::iterator, std::insert_iterator>("。
我使用 diff 来查找我的指南显示的代码是否有任何不同,但我找不到任何区别。我哪里做错了?我该如何解决这个问题?UVA 12096
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
#define ALL(x) x.begin, x.end()
#define INS(x) inserter(x,x.begin())
typedef set<int> Set;
map<Set, int> IDcache;
vector<Set> Setcache;
int ID(Set x){
if(IDcache.count(x)) return IDcache[x];
Setcache.push_back(x);
return IDcache[x] = Setcache.size() - 1;
}
int main(){
int T;
cin >> T;
while(T--){
stack<int> s;
int n;
cin >> n;
for(int i = 0; i < n; i++){
string op;
cin >> op;
if(op[0] == 'P') s.push(ID(Set()));
else if(op[0] == 'D') s.push(s.top());
else{
Set x1 = Setcache[s.top()]; s.pop();
Set x2 = Setcache[s.top()]; s.pop();
Set x;
if(op[0] == 'U') set_union (ALL(x1), ALL(x2), INS(x));//Error occured here.
if(op[0] == 'I') set_intersection (ALL(x1), ALL(x2), INS(x));//Error also occured here.
if(op[0] == 'A') {
x = x2;
x.insert(ID(x1));
}
s.push(ID(x));
}
cout << Setcache[s.top()].size() << endl;
}
cout<<"***"<<endl;
}
return 0;
}
您的ALL
宏包含错误,您缺少几个参数。
#define ALL(x) x.begin, x.end()
应该是#define ALL(x) x.begin(), x.end()
.
相关文章:
- Tbb 库:错误:编写自定义类函数而不是 lambda 表达式时,对函数的调用不匹配
- test1.cpp:9:77:错误:对"(const std::normal_distribution) <double>(std::mt19937&)"的调用不匹配
- 计算一个单词在映射中出现的次数 - 使用 transform() - 调用不匹配
- std::使用内部对象移动 - 与调用不匹配
- 对std::函数对象的调用不匹配,该对象是指向成员函数的指针
- 错误:对'boost::.......'的调用不匹配
- 错误:对"set_union"的调用不匹配
- 与构造函数中对(类)(类型)的调用不匹配
- 对"(std::vector<std::vector<int> >) (int, std::vector<int>)"的调用不匹配
- 声明后初始化对象时"调用不匹配"
- 功能参数与函数调用不匹配
- C++ 与函数调用不匹配
- C++ 错误:对 '(std::string {aka std::basic_string}) (<char>无符号整数、字符)的调用不匹配
- C++错误:对"(RgbImage) (int&, int&)"的调用不匹配
- C++ 错误:对"(std::string) (const char[4])"的调用不匹配
- 与结构sockaddr_in调用不匹配
- 错误:对'(Time) (int, int, int)'的调用不匹配
- 错误消息:与调用"(cv::Rect) (cv::Mat&, cv::P oint_, cv:<int>:P oint, cv::Scalar, int)"的调用不匹配
- 对c++函数的调用不匹配
- const_iterator、find_if和bind2nd:对错误的调用不匹配