#include <iostream>
#include <algorithm>
#include <iterator>
#include <set>
#include <vector>
using namespace std;
template<typename T, typename InputIterator, typename OutputIterator>
void removeDup(InputIterator begin, InputIterator end, OutputIterator res) {
set<T> temp(begin, end);
copy(temp.begin(), temp.end(), res);
}
int main() {
vector<int> v1 = {1, 1, 2, 3, 3, 4, 4, 3, 3};
vector<int> res;
removeDup(v1.begin(), v1.end(), back_inserter(res));
copy(res.begin(), res.end(), ostream_iterator<int>(cout, "\n"));
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDx2ZWN0b3I+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKdGVtcGxhdGU8dHlwZW5hbWUgVCwgdHlwZW5hbWUgSW5wdXRJdGVyYXRvciwgdHlwZW5hbWUgT3V0cHV0SXRlcmF0b3I+CnZvaWQgcmVtb3ZlRHVwKElucHV0SXRlcmF0b3IgYmVnaW4sIElucHV0SXRlcmF0b3IgZW5kLCBPdXRwdXRJdGVyYXRvciByZXMpIHsKICAgIHNldDxUPiB0ZW1wKGJlZ2luLCBlbmQpOwogICAgY29weSh0ZW1wLmJlZ2luKCksIHRlbXAuZW5kKCksIHJlcyk7Cn0KIAppbnQgbWFpbigpIHsKICAgIHZlY3RvcjxpbnQ+IHYxID0gezEsIDEsIDIsIDMsIDMsIDQsIDQsIDMsIDN9OwogICAgdmVjdG9yPGludD4gcmVzOwogICAgcmVtb3ZlRHVwKHYxLmJlZ2luKCksIHYxLmVuZCgpLCBiYWNrX2luc2VydGVyKHJlcykpOwogICAgY29weShyZXMuYmVnaW4oKSwgcmVzLmVuZCgpLCBvc3RyZWFtX2l0ZXJhdG9yPGludD4oY291dCwgIlxuIikpOwogICAgcmV0dXJuIDA7Cn0=
prog.cpp: In function ‘int main()’:
prog.cpp:17:55: error: no matching function for call to ‘removeDup(std::vector<int>::iterator, std::vector<int>::iterator, std::back_insert_iterator<std::vector<int> >)’
removeDup(v1.begin(), v1.end(), back_inserter(res));
^
prog.cpp:17:55: note: candidate is:
prog.cpp:9:6: note: template<class T, class InputIterator, class OutputIterator> void removeDup(InputIterator, InputIterator, OutputIterator)
void removeDup(InputIterator begin, InputIterator end, OutputIterator res) {
^
prog.cpp:9:6: note: template argument deduction/substitution failed:
prog.cpp:17:55: note: couldn't deduce template parameter ‘T’
removeDup(v1.begin(), v1.end(), back_inserter(res));
^