On Wed, 23 Feb 2005 09:39:15 GMT, Alf P. Steinbach wrote:
* Active8:
vector<double> signal;
vector<double>::iterator iter;
in_file.load_vector(signal);
in_file.load_vector(signal.begin());
those calls give the compiler error:
"could not deduce template argument for 'T'"
the infile object is a non-template class with a template function
in it
class Files
{
...
template <class T>
load_vector(vector<T>& sig);
...
};
template <class T>
int Files::load_vector(vector<T>& sig)
{
return 0;
}
What can I do about this?
To do: be more precise (most of the information you've provided is
irrelevant,
Other than the compiler (VC++) what info *would* you consider
"relevant"? The code I posted is all the code (except compiler
supplied headers) pertaining to the template function that won't
compile. I included the call that I used when I tried passing an
iterator.
and the word "those" is incorrect;
no it isn't.
with the irrelevant
information removed and that word corrected you have your solution).
calls give the compiler error:
"could not deduce template argument for 'T'"
Doesn't help. AFAICT, the syntax is right and it should work like
any other code written the same way like this code from an online
ref.
template <class T>
T GetMax (T a, T b) {
return (a>b?a:b);
}
int main () {
int i=5, j=6, k;
long l=10, m=5, n;
k=GetMax(i,j);
n=GetMax(l,m);
cout << k << endl;
cout << n << endl;
return 0;
}
That ref also shows this calling convention:
in_file.load_vector<double>(signal);
which generates this error:
"type 'double' unexpected"
--
Best Regards,
Mike