B
Buster Copley
Compiling the following code gives rise to the error indicated.
template <typename T, int N> void f (const T (& u) [N]) { }
void g (const int (& u) [2]) { }
int main ()
{
int x [2];
f (x); // ERROR
g (x);
}
(G++ 3.2.2): no matching function for call to `f(int[2])'
(Comeau online): no instance of function template "f" matches the
argument list ... The argument types that you used are: (int [2])
I didn't boot into Windows to try Borland C++ Builder 6, but IIRC
its compiler has very little success with references to arrays.
There is no error for the call of g ().
For my real problem I can use either a small set of overloaded
functions, or a partially ordered pair of function templates.
I'd rather use the latter, but only because it's cool. I don't
know whether I'm making a simple syntactic error, or merely
attempting the impossible. Any ideas?
Regards,
Buster
template <typename T, int N> void f (const T (& u) [N]) { }
void g (const int (& u) [2]) { }
int main ()
{
int x [2];
f (x); // ERROR
g (x);
}
(G++ 3.2.2): no matching function for call to `f(int[2])'
(Comeau online): no instance of function template "f" matches the
argument list ... The argument types that you used are: (int [2])
I didn't boot into Windows to try Borland C++ Builder 6, but IIRC
its compiler has very little success with references to arrays.
There is no error for the call of g ().
For my real problem I can use either a small set of overloaded
functions, or a partially ordered pair of function templates.
I'd rather use the latter, but only because it's cool. I don't
know whether I'm making a simple syntactic error, or merely
attempting the impossible. Any ideas?
Regards,
Buster