[GCC-XML] Default parameter values in member functions of templated classes.

Brad King brad.king at kitware.com
Mon Feb 25 09:13:15 EST 2008


Bryan Ischo wrote:
> Yes, but since the class which contains the constructor which has the 
> argument which has the default is:
> 
> basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >
> 
> Then shouldn't npos be identified as:
> 
> std::basic_string<wchar_t, td::char_traits<wchar_t>, 
> std::allocator<wchar_t>
>> ::npos
> 
> instead of :
> 
> std::basic_string<_CharT, _Traits, _Alloc>::npos
> 
> ???
> 
> In other words, shouldn't the type of npos be identified by the actual 
> template parameter values used in declaring the template instance in 
> which npos is being referenced, instead of by the variable names used in 
> the template definition itself?

I think what happens is that GCC's expression-to-string conversion is 
designed to be used during error message construction.  GCC error 
messages look like this:

error:   initializing argument 1 of ‘std::basic_string<_CharT, _Traits, 
_Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, 
_Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’

(the code tried to construct std::string(1) which is an error).  Note 
that the prototype is given with the template formal parameters instead 
of the actual arguments.  Then the rest of the message maps the 
parameters to their values.  GCC-XML is using the same 
expression-to-string functionality from GCC.  This is not the only 
limitation of the expression-to-string conversion that people have 
encountered.  In general I think the "default" attribute is useful 
mostly for human reference.

-Brad



More information about the gccxml mailing list