Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofCD1 status.

167. Improper use oftraits_type::length()

Section: 31.7.6.3.4[ostream.inserters.character]Status:CD1Submitter: Dietmar KühlOpened: 1999-07-20Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [ostream.inserters.character].

View all issues withCD1 status.

Discussion:

Paragraph 4 states that the length is determined usingtraits::length(s). Unfortunately, this function is notdefined for example if the character type iswchar_t and thetype ofs ischar const*. Similar problems exist ifthe character type ischar and the type ofs iseithersigned char const* orunsigned charconst*.

Proposed resolution:

Change 31.7.6.3.4[ostream.inserters.character] paragraph 4 from:

Effects: Behaves like an formatted inserter (as described in lib.ostream.formatted.reqmts) of out. After a sentry object is constructed it inserts characters. The number of characters starting at s to be inserted is traits::length(s). Padding is determined as described in lib.facet.num.put.virtuals. The traits::length(s) characters starting at s are widened using out.widen (lib.basic.ios.members). The widened characters and any required padding are inserted into out. Calls width(0).

to:

Effects: Behaves like a formatted inserter (as described in lib.ostream.formatted.reqmts) of out. After a sentry object is constructed it insertsn characters starting ats, wheren is the number that would be computed as if by:

Padding is determined as described in lib.facet.num.put.virtuals. Then characters starting ats are widened using out.widen (lib.basic.ios.members). The widened characters and any required padding are inserted into out. Calls width(0).

[Santa Cruz: Matt supplied new wording]

[Kona: changed "wheren is" to " wheren is the number that would be computed as if by"]

Rationale:

We have five separate cases. In two of them we can use theuser-supplied traits class without any fuss. In the other three wetry to use something as close to that user-supplied class as possible.In two cases we've got a traits class that's appropriate forchar and what we've got is a const signed char* or a constunsigned char*; that's close enough so we can just use a reinterpretcast, and continue to use the user-supplied traits class. Finally,there's one case where we just have to give up: where we've got atraits class for some arbitrary charT type, and we somehow have todeal with a const char*. There's nothing better to do but fall backto char_traits<char>


[8]ページ先頭

©2009-2026 Movatter.jp