From Bugzilla Helper: User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i586) Description of problem: g++ can't find a function template with the signature template <typename T, size_t N> inline size_t arrsz(T const A[N]) Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Save the file under "additional information" to "example_error.cc". 2. Run g++ example_error.cc. Actual Results: example_error.cc: In function `int main (int, char **)': example_error.cc:14: no matching function for call to `arrsz (const int[6])' Expected Results: Successful compilation. Additional info: #include <cstdlib> using namespace std; template <typename T, size_t N> inline size_t arrsz(T const A[N]) { return N; } int main(int argc, char * * argv) { int const A[] = { 1, 5, 7, 4, 13, 10 }; int const * Aend = A + arrsz(A); return 0; }
That's correct, check ISO C++ 98. To make this work, you can e.g. use arrsz<int,6>(A) instead of arrsz(A).