Why on earth I can do this:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void myfunction (int i) {
cout << " " << i;
}
int main () {
vector<int> myvector;
myvector.push_back(10);
myvector.push_back(20);
myvector.push_back(30);
cout << "myvector contains:";
for_each (myvector.begin(), myvector.end(), myfunction);//<-------See below
return 0;
}
but can't do this:
template<class T>
void myfunction (T i) {
cout << " " << i;
}
I suspect that it has something to do with args deduction but it is so infuriating that "regular" fnc is accepted and template isn't.