Hey guys,
I have this code snippet:
template <typename ElementType, typename CompareClass>
struct Delegate {
virtual bool geef(const ElementType &element){
pair <set<ElementType, CompareClass>::iterator, bool> ret; //this is line 196
ret = elements.insert(element); //197
return (ret.second); //198
}
virtual void output() = 0;
set<ElementType, CompareClass> elements;
};
struct ArtiestenPrinter : public Delegate<Lied, LiedCompare> {
virtual bool geef(const Lied &lied){
bool nieuwElement = Delegate<Lied, LiedCompare>::geef(lied); // 210
if (nieuwElement) {
cout << lied.artiest;
}
return nieuwElement;
}
virtual void output(){
for(set<Lied, LiedCompare>::iterator it = elements.begin();
it != elements.end();
it++){
cout << it->artiest << endl;
}
}
};
Which gives me these errors:
196: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
196: error: expected a type, got 'std::set<ElementType,CompareClass,std::allocator<_CharT> >::iterator'
196: error: invalid type in declaration before ';' token
198: error: request for member 'second' in 'ret', which is of non-class type 'int'
210: instantiated from here
197: error: cannot convert 'std::pair<std::_Rb_tree_const_iterator<Lied>, bool>' to 'int' in assignment
I can't get my head around why the compiler is complaining, so any help is greatly appreciated.
Thanks in advance,