Hello,

$ g++ -c err.cc
err.cc:7: error: prototype for 'void C<int>::foo(const int&)' does not match 
any in class 'C<int>'
err.cc:3: error: candidate is: void C<T>::foo(const T&) [with T = int]
err.cc:7: error: template definition of non-template 'void C<int>::foo(const 
int&)'
$

Note that substituting 'int' for 'T' in the only candidate (reported in
error line 2) gives exactly the prototype in error line 1. Yes, the
third error line gives a clue, but the natural way to read error
messages is top-to-bottom, and the first two lines are really
puzzling. It'd be much better if the first two lines of the error
messages were not output at all, I think.

$ cat err.cc
template <typename T>
struct C {
  void foo(T const&) {}
};

template <typename T>
void C<int>::foo(int const&) {}

$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: [...]
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
$

-- Sergei.

Reply via email to