This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Enable input using variable-width encodings
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sat, 6 Sep 2003 00:06:05 -0700
- Subject: Re: [PATCH] Enable input using variable-width encodings
- References: <07D05A69A3D0C14FAEA60C3ACE8E5564028F55BD@mail.ru.is>
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