T
tutmann
Hello All,
I'm confused about templating functions.
Say I have this, which is working fine:
#include <vector>
template <typename T>
struct X {
typedef std::vector< X < T > > Vector;
T x;
};
typedef X< int > XI;
XI x1, x2;
template<typename T>
int f(X<T> x1, X<T> x2) {
return 0;
}
int i = f(x1,x2);
Then, why isn't that working as well?
XI::Vector xv1, xv2;
template<typename T>
int f(typename X<T>::Vector &x1, typename X<T>::Vector &x2) {
return 0;
}
int k = f(xv1, xv2);
Instead I get:
error: no matching function for call to ‘f(std::vector<X<int>,
What is wrong here?
Thank you!
Henning
I'm confused about templating functions.
Say I have this, which is working fine:
#include <vector>
template <typename T>
struct X {
typedef std::vector< X < T > > Vector;
T x;
};
typedef X< int > XI;
XI x1, x2;
template<typename T>
int f(X<T> x1, X<T> x2) {
return 0;
}
int i = f(x1,x2);
Then, why isn't that working as well?
XI::Vector xv1, xv2;
template<typename T>
int f(typename X<T>::Vector &x1, typename X<T>::Vector &x2) {
return 0;
}
int k = f(xv1, xv2);
Instead I get:
error: no matching function for call to ‘f(std::vector<X<int>,
What is wrong here?
Thank you!
Henning