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] Enable input using variable-width encodings


On Fri, Sep 05, 2003 at 12:57:00PM -0000, P?tur Run?lfsson wrote:
> Benjamin Kosnik wrote:
> > I'm wondering a bit about using a signed type for _M_ext_buf_size
> > when _M_buf_size is [un]signed,
> 
> That is to allow the comparisons:
> ! 	      if (_M_ext_buf_size < __blen)
> and
> ! 		      if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
> without extra casts. These are the only places that
> _M_ext_buf_size is used.
> 
> I agree that the current mix of size_t and streamsize in the 
> iostreams code is somewhat confusing. Maybe streamsize should
> be used everywhere? 

Streamsize is conceptually unsigned, but must be signed for conformance.

We should used unsigned values where we can, and accept that casts
are needed sometimes.  We should _not_ use streamsize to describe buffer 
sizes, but should use it only where the interface requires it, or where 
the use is clearly derived from that interface.

This will matter more, and be more noticeable, when streamsize is 
uniformly 64 bits on all targets, and (possibly) a class object.  
(Soon, I hope.)

Nathan Myers
ncm-nospam@cantrip.org


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