stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: test for lib.string.io
Date Thu, 22 Jun 2006 01:59:42 GMT
Anton Pevtsov wrote:
[...]
> Here is another one possible issue:
> 
> As I understand 21.3.7.9, paragraph 4 the os.setstate() should be called
> after os.width(0). In stdcxx width(0) is called after the setstate() and
> if the exceptions mask is not ios_base::goodbit then width(0) will not
> called. The Dinkumware STL and STLPort calls width (0) before
> setstate().

I agree, although I note that GNU libstdc++ behaves the same as
stdcxx. I believe both implementations are incorrect.

FWIW, the standard is slightly inconsistent when it comes to these
things. I've sent an email to the committee's reflector proposing
to clean them up (see the attachment). I also put together a test
program exercising all formatted output functions (including the
string overload which isn't listed as one but should be) according
to the current requirements as well as according to the requirements
I propose. See http://people.apache.org/~sebor/width_test.cpp

> 
> incubator\stdcxx\trunk\include\ostream
> 
> // 21.3.7.9, p3 - defined here, declared inline in <string>
> template<class _CharT, class _Traits, class _Allocator> inline
> basic_ostream<_CharT, _Traits>&
> operator<< (basic_ostream<_CharT, _Traits>                  & __strm,
>            const basic_string<_CharT, _Traits, _Allocator> &__str) {
>    _RW::__rw_insert (__strm, __str.data (), __str.length (),
>                      __strm.width ()).width (0);
>    return __strm;
> }
> 
> See the attached test, please.
> 
> What do you think about this?

Let's create an issue and fix it. The change shouldn't be too
difficult. I'll leave it up to you to propose a patch :)

Thanks
Martin

Mime
View raw message