I’m learning function templates in C++, so I wrote a simple function to remove duplicates. But the compiler throws following error.
removeDup is not a function or static data member
using namespace std;
template <typename T>
void removeDup(std::vector<T>& vec)
{
std::sort(vec.begin(), vec.end());
vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
}
What could be the problem?
This works fine for me: