I'm writing a function to manipulate a set with it's iterators, and it's giving me the error
candidate template ignored: couldn't infer template argument
The minimum reproducible code is as follows:
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void foo(typename set<T>::iterator it1)
{
// do something
}
int main()
{
set<int> aSet;
foo(aSet.begin()); // no matching function call to 'foo'
}
I tried including <set> directly, changing the order of function definitions, but nothing solved it. And the weirdest thing is that I used the set iterator as parameter in other functions, and it worked.
These other function declarations were something like this:
template <typename T>
void bar(set<T>& aSet, vector<T>& aVector, typename set<T>::iterator it);
(these exact parameters, in this exact order).