Re: template error messages
"Imre" <imre42@pager.hu> a ?crit dans le message de news:
If I change sligthly your code so that "T" is a class :
int main()
{
S<std::string> s;
s.F();
return 0;
}
then I get another error message:
1>d:\users\adb\dev\temp\test_vc_2005\test_vc_2005.cpp(11) : error
C2039: 'F' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> d:\users\adb\dev\temp\test_vc_2005\test_vc_2005.cpp(11) :
while compiling class template member function 'void S<T>::F(void)'
1> with
1> [
1> T=std::string
1> ]
1> d:\users\adb\dev\temp\test_vc_2005\test_vc_2005.cpp(17) : see
reference to class template instantiation 'S<T>' being compiled
1> with
1> [
1> T=std::string
1> ]
Although those errors are quite (too) long, thay are quite clear (at
least for template related stuff....)
I don't think so. There's still no reference at all to the s.F(); line,
it only points out the S<std::string> s; line. If those two weren't
next to each other, I'd be in trouble finding where S<std::string>::F()
is referenced.
Reading template messages is quite tricky indeed ;-)
Generally speaking, the description of the error is at the beginning ot the
(lentghly)compiler message. In our case it is "'F' : is not a member of
'std::basic_string".
But in order to know where the error comes from, you need to go to the
bottom of the "instanciation stack", which is at the very end of the
compiler message. In our case, this last line is
"d:\users\adb\dev\temp\test_vc_2005\test_vc_2005.cpp(17)" which is indeed
the calling of s.F();
I know there are a few "compiler template messages decryptors" out there on
the web (http://www.bdsoft.com/tools/stlfilt.html for example) that make it
easier to read those messages.
For example, they replace "'std::basic_string<_Elem,_Traits,_Ax>" by
"std::string" which is already a great clarification.
Arnaud
MVP - VC