This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] PR 8761 and 7076, take 2


On Thu, 16 Jan 2003 11:03:37 -0800
Nathan Myers <ncm-nospam@cantrip.org> wrote:

>> +  // As far as I can tell, this more general form will never be invoked.
>> +  template<typename _CharT, typename _OutIter>
>> +    inline
>> +    _OutIter
>> +    __num_put_output(_OutIter __s, const _CharT* __ws, int __len)
>
>Best just leave it out.  You can add it back if it turns out to be used.

Wrong.

This is necessary. The num_put facet calls down into _M_insert and ends
up using this, and num_put should be able to be instantiated for any
output iterator, not just ostreambuf_iterator. Not being able to do this
is a regression. As noted, it's simple to fix, so please do.

Again, there are tests in the library testsuite for this exact thing.
Please run them!

>> +  // NB: Of the two parameters, _CharT can be deduced from the
>> +  // function arguments. The other (_Traits) has to be explicitly specified.
>> +
>> +  template<typename _CharT, typename _Traits>
>> +    struct __pad
>> +    {
>> +      static void
>> +      _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, 
>> +	     const _CharT* __olds, const streamsize __newlen, 
>> +	     const streamsize __oldlen, const bool __num);
>> +    };
>
>I don't see how arguments to a struct template can be deduced.  
>A better comment would explain why __pad is a struct at all.

This comment is misleading, and hasn't been updated since the switch to
a struct. I'll try to come up with something better tomorrow.

This cannot be a function template (with these parameters, at least)
because this function is shared by class templates of one and two
parameters (char and or traits). There is no way for the compiler to
deduce, from the arguments to the _S_pad function, what the traits-type
is, yet it is used in the function. Thus it has to be a struct, so that
invocations can be like:

_pad<char, _Traits>::_S_pad

best,
benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]