1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2 <html><head><title>C++ Standard Library Defect Report List</title>
4 <style>ins {background-color:#FFFFA0}
5 del {background-color:#FFFFA0}</style></head>
7 <body bgcolor="#ffffff" text="#000000">
10 <td align="left">Doc. no.</td>
11 <td align="left">N2131=06-0201</td>
14 <td align="left">Date:</td>
15 <td align="left">2006-11-03</td>
18 <td align="left">Project:</td>
19 <td align="left">Programming Language C++</td>
22 <td align="left">Reply to:</td>
23 <td align="left">Howard Hinnant <howard.hinnant@gmail.com></td>
26 <h1>C++ Standard Library Defect Report List (Revision R45)</h1>
27 <p>Reference ISO/IEC IS 14882:1998(E)</p>
31 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-toc.html">Table of Contents</a> for all library issues.</li>
33 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-index.html">Index by Section</a> for all library issues.</li>
35 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-status.html">Index by Status</a> for all library issues.</li>
36 <li><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html">Library Active Issues List</a></li>
37 <li><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html">Library Closed Issues List</a></li>
39 <p>This document contains only library issues which have been closed
40 by the Library Working Group (LWG) after being found to be defects
41 in the standard. That is, issues which have a status of <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a>, or <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#RR">RR</a>. See the
42 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html">Library Closed Issues List</a> for issues closed as non-defects. See the
43 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html">Library Active Issues List</a> for active issues and more information. The
44 introductory material in that document also applies to this
46 <h2>Revision History</h2>
49 2006-11-03 post-Portland mailing.
50 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#520">520</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#521">521</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#530">530</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#535">535</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#537">537</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#538">538</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#540">540</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#541">541</a> to WP.
51 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#504">504</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#512">512</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#516">516</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#544">544</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#549">549</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#554">554</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#555">555</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#558">558</a> to NAD.
52 Moved issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#569">569</a> to Dup.
53 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#518">518</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#523">523</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#524">524</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#542">542</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#556">556</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#557">557</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#559">559</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#597">597</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#606">606</a> to Open.
54 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#543">543</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#545">545</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#549">549</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#549">549</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#598">598</a> - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#603">603</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#605">605</a> to Ready.
55 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#531">531</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#551">551</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#604">604</a> to Review.
56 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#593">593</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#609">609</a>.
59 2006-09-08 pre-Portland mailing.
60 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#583">583</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#592">592</a>.
63 2006-06-23 mid-term mailing.
64 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#575">575</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#582">582</a>.
65 Reopened <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#255">255</a>.
66 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#520">520</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#541">541</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#544">544</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#569">569</a> to Tentatively Ready.
69 2006-04-21 post-Berlin mailing.
70 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#567">567</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#572">572</a>.
71 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#499">499</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#501">501</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#506">506</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#509">509</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#511">511</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#513">513</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#514">514</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#517">517</a> to NAD.
72 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#502">502</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#503">503</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#515">515</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#516">516</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#522">522</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#525">525</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#529">529</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#532">532</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#536">536</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#539">539</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#548">548</a> to Open.
73 Moved issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#504">504</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#512">512</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#521">521</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#530">530</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#531">531</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#535">535</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#537">537</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#538">538</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#540">540</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#549">549</a> to Ready.
74 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#247">247</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#294">294</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#362">362</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#369">369</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#371">371</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#376">376</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#384">384</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#475">475</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#478">478</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#495">495</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#497">497</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#505">505</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#507">507</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#508">508</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#519">519</a> to WP.
75 Moved issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#534">534</a> to Review.
78 2006-02-24 pre-Berlin mailing.
79 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#536">536</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#566">566</a>.
80 Moved <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#342">342</a> from Ready to Open.
81 Reopened <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#309">309</a>.
84 2005-12-16 mid-term mailing.
85 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#529">529</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#535">535</a>.
88 2005-10-14 post-Mont Tremblant mailing.
89 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#526">526</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#528">528</a>.
90 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#280">280</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#461">461</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464">464</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#465">465</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#467">467</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#468">468</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#474">474</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#496">496</a> from Ready to WP as per the vote from Mont Tremblant.
91 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#247">247</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#294">294</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#342">342</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#362">362</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#369">369</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#371">371</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#376">376</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#384">384</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#475">475</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#478">478</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#495">495</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#497">497</a> from Review to Ready.
92 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#498">498</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#504">504</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#506">506</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#509">509</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#510">510</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#511">511</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#512">512</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#513">513</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#514">514</a> from New to Open.
93 Moved issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#505">505</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#507">507</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#508">508</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#519">519</a> from New to Ready.
94 Moved issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#500">500</a> from New to NAD.
95 Moved issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#518">518</a> from New to Review.
98 2005-07-03 pre-Mont Tremblant mailing.
99 Merged open TR1 issues in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#504">504</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#522">522</a>.
100 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#523">523</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#523">523</a>
103 2005-06 mid-term mailing.
104 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#498">498</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#503">503</a>.
107 2005-04 post-Lillehammer mailing. All issues in "ready" status except
108 for <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#454">454</a> were moved to "DR" status, and all issues
109 previously in "DR" status were moved to "WP".
112 2005-03 pre-Lillehammer mailing.
115 2005-01 mid-term mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#488">488</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#494">494</a>.
118 2004-11 post-Redmond mailing. Reflects actions taken in Redmond.
121 2004-09 pre-Redmond mailing: reflects new proposed resolutions and
122 new issues received after the 2004-07 mailing. Added
123 new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#479">479</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#481">481</a>.
126 2004-07 mid-term mailing: reflects new proposed resolutions and
127 new issues received after the post-Sydney mailing. Added
128 new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#463">463</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#478">478</a>.
131 Post-Sydney mailing: reflects decisions made at the Sydney meeting.
132 Voted all "Ready" issues from R29 into the working paper.
133 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#460">460</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#462">462</a>.
136 Pre-Sydney mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#441">441</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#457">457</a>.
139 Post-Kona mailing: reflects decisions made at the Kona meeting.
140 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#432">432</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#440">440</a>.
143 Pre-Kona mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#404">404</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#431">431</a>.
146 Post-Oxford mailing: reflects decisions made at the Oxford meeting.
147 All issues in Ready status were voted into DR status. All issues in
148 DR status were voted into WP status.
151 Pre-Oxford mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#390">390</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#402">402</a>.
154 Post-Santa Cruz mailing: reflects decisions made at the Santa Cruz
155 meeting. All Ready issues from R23 with the exception of <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#253">253</a>, which has been given a new proposed resolution, were
156 moved to DR status. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#383">383</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#389">389</a>. (Issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#387">387</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#389">389</a> were discussed
157 at the meeting.) Made progress on issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">225</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#226">226</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#229">229</a>: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">225</a> and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#229">229</a> have been moved to Ready status, and the only remaining
158 concerns with <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#226">226</a> involve wording.
161 Pre-Santa Cruz mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#367">367</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#382">382</a>.
162 Moved issues in the TC to TC status.
165 Post-Curaçao mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#362">362</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#366">366</a>.
168 Pre-Curaçao mailing. Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#351">351</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#361">361</a>.
171 Post-Redmond mailing; reflects actions taken in Redmond. Added
172 new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#336">336</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#350">350</a>, of which issues
173 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#347">347</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#350">350</a> were added since Redmond, hence
174 not discussed at the meeting.
176 All Ready issues were moved to DR status, with the exception of issues
177 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#284">284</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#241">241</a>, and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#267">267</a>.
179 Noteworthy issues discussed at Redmond include
180 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#120">120</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#202">202</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#226">226</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#233">233</a>,
181 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#270">270</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#253">253</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#254">254</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#323">323</a>.
184 Pre-Redmond mailing. Added new issues
185 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#323">323</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#335">335</a>.
188 Post-Copenhagen mailing; reflects actions taken in Copenhagen.
189 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#312">312</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#317">317</a>, and discussed
190 new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#271">271</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#314">314</a>.
192 Changed status of issues
193 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#103">103</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#118">118</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#136">136</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#153">153</a>
194 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#165">165</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#171">171</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#183">183</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#184">184</a>
195 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#185">185</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#186">186</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#214">214</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#221">221</a>
196 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#234">234</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#237">237</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#243">243</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#248">248</a>
197 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#251">251</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#252">252</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#256">256</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#260">260</a>
198 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#261">261</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#262">262</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#263">263</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#265">265</a>
199 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#268">268</a>
202 Changed status of issues
203 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#49">49</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#109">109</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#117">117</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#182">182</a>
204 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#228">228</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#230">230</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#232">232</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#235">235</a>
205 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#238">238</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#241">241</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#242">242</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#250">250</a>
206 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#259">259</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#264">264</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#266">266</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#267">267</a>
207 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#271">271</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#272">272</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#273">273</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#275">275</a>
208 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#281">281</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#284">284</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#285">285</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#286">286</a>
209 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#288">288</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#292">292</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#295">295</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#297">297</a>
210 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#298">298</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#301">301</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#303">303</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#306">306</a>
211 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#307">307</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#308">308</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#312">312</a>
215 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#111">111</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#277">277</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#279">279</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#287">287</a>
216 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#289">289</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#293">293</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#302">302</a> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#313">313</a>
217 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#314">314</a>
222 Pre-Copenhagen mailing. Converted issues list to XML. Added proposed
223 resolutions for issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#49">49</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#76">76</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#91">91</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#235">235</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#250">250</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#267">267</a>.
224 Added new issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#278">278</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#311">311</a>.
227 post-Toronto mailing; reflects actions taken in Toronto. Added new
228 issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#265">265</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#277">277</a>. Changed status of issues
229 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#3">3</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#8">8</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#9">9</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#19">19</a>,
230 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#26">26</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#31">31</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#61">61</a>,
231 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#63">63</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#86">86</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#108">108</a>,
232 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#112">112</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#114">114</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#115">115</a>,
233 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#122">122</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#127">127</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#129">129</a>,
234 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#134">134</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#137">137</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#142">142</a>,
235 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#144">144</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#146">146</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#147">147</a>,
236 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#159">159</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#164">164</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#170">170</a>,
237 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#181">181</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#199">199</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#208">208</a>,
238 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#209">209</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#210">210</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#211">211</a>,
239 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#212">212</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#217">217</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#220">220</a>,
240 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#222">222</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#223">223</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#224">224</a>,
241 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#227">227</a> to "DR". Reopened issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#23">23</a>. Reopened
242 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#187">187</a>. Changed issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#2">2</a> and
243 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#4">4</a> to NAD. Fixed a typo in issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#17">17</a>. Fixed
244 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#70">70</a>: signature should be changed both places it
245 appears. Fixed issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#160">160</a>: previous version didn't fix
246 the bug in enough places.
249 pre-Toronto mailing. Added issues
250 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#233">233</a>-<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#264">264</a>. Some small HTML formatting
251 changes so that we pass Weblint tests.
254 post-Tokyo II mailing; reflects committee actions taken in
255 Tokyo. Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#228">228</a> to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#232">232</a>. (00-0019R1/N1242)
258 pre-Tokyo II updated: Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#212">212</a> to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#227">227</a>.
261 pre-Tokyo II mailing: Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#199">199</a> to
262 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#211">211</a>. Added "and paragraph 5" to the proposed resolution
263 of issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#29">29</a>. Add further rationale to issue
264 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#178">178</a>.
267 post-Kona mailing: Updated to reflect LWG and full committee actions
268 in Kona (99-0048/N1224). Note changed resolution of issues
269 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#4">4</a> and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#38">38</a>. Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#196">196</a>
270 to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198">198</a>. Closed issues list split into "defects" and
271 "closed" documents. Changed the proposed resolution of issue
272 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#4">4</a> to NAD, and changed the wording of proposed resolution
273 of issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#38">38</a>.
276 pre-Kona updated. Added proposed resolutions <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#83">83</a>,
277 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#86">86</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#91">91</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#92">92</a>,
278 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#109">109</a>. Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#190">190</a> to
279 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#195">195</a>. (99-0033/D1209, 14 Oct 99)
282 pre-Kona mailing. Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#140">140</a> to
283 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#189">189</a>. Issues list split into separate "active" and
284 "closed" documents. (99-0030/N1206, 25 Aug 99)
287 post-Dublin mailing. Updated to reflect LWG and full committee actions
288 in Dublin. (99-0016/N1193, 21 Apr 99)
291 pre-Dublin updated: Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#130">130</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#131">131</a>,
292 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#132">132</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#133">133</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#134">134</a>,
293 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#135">135</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#136">136</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#137">137</a>,
294 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#138">138</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#139">139</a> (31 Mar 99)
297 pre-Dublin mailing. Added issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#127">127</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#128">128</a>,
298 and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#129">129</a>. (99-0007/N1194, 22 Feb 99)
301 update issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#103">103</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#112">112</a>; added issues
302 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#114">114</a> to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#126">126</a>. Format revisions to prepare
303 for making list public. (30 Dec 98)
306 post-Santa Cruz II updated: Issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#110">110</a>,
307 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#111">111</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#112">112</a>, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#113">113</a> added, several
308 issues corrected. (22 Oct 98)
311 post-Santa Cruz II: Issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#94">94</a> to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#109">109</a>
312 added, many issues updated to reflect LWG consensus (12 Oct 98)
315 pre-Santa Cruz II: Issues <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#73">73</a> to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#93">93</a> added,
316 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#17">17</a> updated. (29 Sep 98)
319 Correction to issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#55">55</a> resolution, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#60">60</a> code
320 format, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#64">64</a> title. (17 Sep 98)
323 <h2>Defect Reports</h2>
325 <a name="1"><h3>1. C library linkage editing oversight</h3></a><p><b>Section:</b> 17.4.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.using.linkage"> [lib.using.linkage]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 16 Nov 1997</p>
326 <p>The change specified in the proposed resolution below did not make
327 it into the Standard. This change was accepted in principle at the
328 London meeting, and the exact wording below was accepted at the
329 Morristown meeting.</p>
330 <p><b>Proposed resolution:</b></p>
331 <p>Change 17.4.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.using.linkage"> [lib.using.linkage]</a> paragraph 2
335 <p>It is unspecified whether a name from the Standard C library
336 declared with external linkage has either extern "C" or
337 extern "C++" linkage.</p>
343 <p>Whether a name from the Standard C library declared with external
344 linkage has extern "C" or extern "C++" linkage
345 is implementation defined. It is recommended that an implementation
346 use extern "C++" linkage for this purpose.</p>
349 <a name="3"><h3>3. Atexit registration during atexit() call is not described</h3></a><p><b>Section:</b> 18.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.cstdint"> [lib.cstdint]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 12 Dec 1997</p>
350 <p>We appear not to have covered all the possibilities of
351 exit processing with respect to
352 atexit registration. <br>
354 Example 1: (C and C++)</p>
356 <pre> #include <stdlib.h>
358 void f2() { atexit(f1); }
362 atexit(f2); // the only use of f2
363 return 0; // for C compatibility
366 <p>At program exit, f2 gets called due to its registration in
367 main. Running f2 causes f1 to be newly registered during the exit
368 processing. Is this a valid program? If so, what are its
372 Interestingly, neither the C standard, nor the C++ draft standard nor
373 the forthcoming C9X Committee Draft says directly whether you can
374 register a function with atexit during exit processing.</p>
377 All 3 standards say that functions are run in reverse order of their
378 registration. Since f1 is registered last, it ought to be run first,
379 but by the time it is registered, it is too late to be first.</p>
381 <p>If the program is valid, the standards are self-contradictory about
384 <p>Example 2: (C++ only)</p>
387 void F() { static T t; } // type T has a destructor
391 atexit(F); // the only use of F
395 <p>Function F registered with atexit has a local static variable t,
396 and F is called for the first time during exit processing. A local
397 static object is initialized the first time control flow passes
398 through its definition, and all static objects are destroyed during
399 exit processing. Is the code valid? If so, what are its semantics?</p>
402 Section 18.3 "Start and termination" says that if a function
403 F is registered with atexit before a static object t is initialized, F
404 will not be called until after t's destructor completes.</p>
407 In example 2, function F is registered with atexit before its local
408 static object O could possibly be initialized. On that basis, it must
409 not be called by exit processing until after O's destructor
410 completes. But the destructor cannot be run until after F is called,
411 since otherwise the object could not be constructed in the first
414 <p>If the program is valid, the standard is self-contradictory about
417 <p>I plan to submit Example 1 as a public comment on the C9X CD, with
418 a recommendation that the results be undefined. (Alternative: make it
419 unspecified. I don't think it is worthwhile to specify the case where
420 f1 itself registers additional functions, each of which registers
421 still more functions.)</p>
423 <p>I think we should resolve the situation in the whatever way the C
424 committee decides. </p>
426 <p>For Example 2, I recommend we declare the results undefined.</p>
428 <p><i>[See reflector message lib-6500 for further discussion.]</i></p>
430 <p><b>Proposed resolution:</b></p>
431 <p>Change section 18.3/8 from:</p>
433 First, objects with static storage duration are destroyed and
434 functions registered by calling atexit are called. Objects with
435 static storage duration are destroyed in the reverse order of the
436 completion of their constructor. (Automatic objects are not
437 destroyed as a result of calling exit().) Functions registered with
438 atexit are called in the reverse order of their registration. A
439 function registered with atexit before an object obj1 of static
440 storage duration is initialized will not be called until obj1's
441 destruction has completed. A function registered with atexit after
442 an object obj2 of static storage duration is initialized will be
443 called before obj2's destruction starts.
447 First, objects with static storage duration are destroyed and
448 functions registered by calling atexit are called. Non-local objects
449 with static storage duration are destroyed in the reverse order of
450 the completion of their constructor. (Automatic objects are not
451 destroyed as a result of calling exit().) Functions registered with
452 atexit are called in the reverse order of their registration, except
453 that a function is called after any previously registered functions
454 that had already been called at the time it was registered. A
455 function registered with atexit before a non-local object obj1 of
456 static storage duration is initialized will not be called until
457 obj1's destruction has completed. A function registered with atexit
458 after a non-local object obj2 of static storage duration is
459 initialized will be called before obj2's destruction starts. A local
460 static object obj3 is destroyed at the same time it would be if a
461 function calling the obj3 destructor were registered with atexit at
462 the completion of the obj3 constructor.
464 <p><b>Rationale:</b></p>
465 <p>See 99-0039/N1215, October 22, 1999, by Stephen D. Clamage for the analysis
466 supporting to the proposed resolution.</p>
468 <a name="5"><h3>5. String::compare specification questionable</h3></a><p><b>Section:</b> 21.3.6.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::compare"> [lib.string::compare]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Jack Reeves <b>Date:</b> 11 Dec 1997</p>
469 <p>At the very end of the basic_string class definition is the signature: int
470 compare(size_type pos1, size_type n1, const charT* s, size_type n2 = npos) const; In the
471 following text this is defined as: returns
472 basic_string<charT,traits,Allocator>(*this,pos1,n1).compare(
473 basic_string<charT,traits,Allocator>(s,n2); </p>
475 <p>Since the constructor basic_string(const charT* s, size_type n, const Allocator& a
476 = Allocator()) clearly requires that s != NULL and n < npos and further states that it
477 throws length_error if n == npos, it appears the compare() signature above should always
478 throw length error if invoked like so: str.compare(1, str.size()-1, s); where 's' is some
479 null terminated character array. </p>
481 <p>This appears to be a typo since the obvious intent is to allow either the call above or
482 something like: str.compare(1, str.size()-1, s, strlen(s)-1); </p>
484 <p>This would imply that what was really intended was two signatures int compare(size_type
485 pos1, size_type n1, const charT* s) const int compare(size_type pos1, size_type n1, const
486 charT* s, size_type n2) const; each defined in terms of the corresponding constructor. </p>
487 <p><b>Proposed resolution:</b></p>
488 <p>Replace the compare signature in 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a>
489 (at the very end of the basic_string synopsis) which reads:</p>
492 <p><tt>int compare(size_type pos1, size_type n1,<br>
493 const charT* s,
494 size_type n2 = npos) const;</tt></p>
500 <p><tt>int compare(size_type pos1, size_type n1,<br>
501 const charT* s) const;<br>
502 int compare(size_type pos1, size_type n1,<br>
503 const charT* s,
504 size_type n2) const;</tt></p>
507 <p>Replace the portion of 21.3.6.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::compare"> [lib.string::compare]</a>
508 paragraphs 5 and 6 which read:</p>
511 <p><tt>int compare(size_type pos, size_type n1,<br>
512 charT * s, size_type n2
514 </tt>Returns:<tt><br>
515 basic_string<charT,traits,Allocator>(*this, pos, n1).compare(<br>
516
517 basic_string<charT,traits,Allocator>( s, n2))</tt></p>
523 <p><tt>int compare(size_type pos, size_type n1,<br>
524 const charT * s) const;<br>
525 </tt>Returns:<tt><br>
526 basic_string<charT,traits,Allocator>(*this, pos, n1).compare(<br>
527
528 basic_string<charT,traits,Allocator>( s ))<br>
530 int compare(size_type pos, size_type n1,<br>
531 const charT * s,
532 size_type n2) const;<br>
533 </tt>Returns:<tt><br>
534 basic_string<charT,traits,Allocator>(*this, pos, n1).compare(<br>
535
536 basic_string<charT,traits,Allocator>( s, n2))</tt></p>
539 <p>Editors please note that in addition to splitting the signature, the third argument
540 becomes const, matching the existing synopsis.</p>
541 <p><b>Rationale:</b></p>
542 <p>While the LWG dislikes adding signatures, this is a clear defect in
543 the Standard which must be fixed. The same problem was also
544 identified in issues 7 (item 5) and 87.</p>
546 <a name="7"><h3>7. String clause minor problems</h3></a><p><b>Section:</b> 21 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.strings"> [lib.strings]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 15 Dec 1997</p>
547 <p>(1) In 21.3.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::insert"> [lib.string::insert]</a>, the description of template
548 <class InputIterator> insert(iterator, InputIterator,
549 InputIterator) makes no sense. It refers to a member function that
550 doesn't exist. It also talks about the return value of a void
553 <p>(2) Several versions of basic_string::replace don't appear in the
556 <p>(3) basic_string::push_back appears in the synopsis, but is never
557 described elsewhere. In the synopsis its argument is const charT,
558 which doesn't makes much sense; it should probably be charT, or
559 possible const charT&. </p>
561 <p>(4) basic_string::pop_back is missing. </p>
563 <p>(5) int compare(size_type pos, size_type n1, charT* s, size_type n2
564 = npos) make no sense. First, it's const charT* in the synopsis and
565 charT* in the description. Second, given what it says in RETURNS,
566 leaving out the final argument will always result in an exception
567 getting thrown. This is paragraphs 5 and 6 of
568 21.3.6.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::compare"> [lib.string::compare]</a></p>
570 <p>(6) In table 37, in section 21.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.require"> [lib.char.traits.require]</a>,
571 there's a note for X::move(s, p, n). It says "Copies correctly
572 even where p is in [s, s+n)". This is correct as far as it goes,
573 but it doesn't go far enough; it should also guarantee that the copy
574 is correct even where s in in [p, p+n). These are two orthogonal
575 guarantees, and neither one follows from the other. Both guarantees
576 are necessary if X::move is supposed to have the same sort of
577 semantics as memmove (which was clearly the intent), and both
578 guarantees are necessary if X::move is actually supposed to be
580 <p><b>Proposed resolution:</b></p>
581 <p>ITEM 1: In 21.3.5.4 [lib.string::insert], change paragraph 16 to <br>
583 EFFECTS: Equivalent to insert(p - begin(), basic_string(first, last)).<br>
585 ITEM 2: Not a defect; the Standard is clear.. There are ten versions of replace() in
586 the synopsis, and ten versions in 21.3.5.6 [lib.string::replace].<br>
588 ITEM 3: Change the declaration of push_back in the string synopsis (21.3,
589 [lib.basic.string]) from:</p>
591 <p> void push_back(const charT)<br>
595 void push_back(charT)<br>
597 Add the following text immediately after 21.3.5.2 [lib.string::append], paragraph 10.<br>
599 void basic_string::push_back(charT c);<br>
600 EFFECTS: Equivalent to append(static_cast<size_type>(1), c);<br>
602 ITEM 4: Not a defect. The omission appears to have been deliberate.<br>
604 ITEM 5: Duplicate; see issue 5 (and 87).<br>
606 ITEM 6: In table 37, Replace:<br>
608 "Copies correctly even where p is in [s, s+n)."<br>
612 "Copies correctly even where the ranges [p, p+n) and [s,
615 <a name="8"><h3>8. Locale::global lacks guarantee</h3></a><p><b>Section:</b> 22.1.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.statics"> [lib.locale.statics]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 24 Dec 1997</p>
616 <p>It appears there's an important guarantee missing from clause
617 22. We're told that invoking locale::global(L) sets the C locale if L
618 has a name. However, we're not told whether or not invoking
619 setlocale(s) sets the global C++ locale. </p>
621 <p>The intent, I think, is that it should not, but I can't find any
622 such words anywhere. </p>
623 <p><b>Proposed resolution:</b></p>
624 <p>Add a sentence at the end of 22.1.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.statics"> [lib.locale.statics]</a>,
625 paragraph 2: </p>
628 <p>No library function other than <tt>locale::global()</tt> shall affect
629 the value returned by <tt>locale()</tt>. </p>
633 <a name="9"><h3>9. Operator new(0) calls should not yield the same pointer</h3></a><p><b>Section:</b> 18.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete"> [lib.new.delete]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 4 Jan 1998</p>
634 <p>Scott Meyers, in a comp.std.c++ posting: I just noticed that
635 section 3.7.3.1 of CD2 seems to allow for the possibility that all
636 calls to operator new(0) yield the same pointer, an implementation
637 technique specifically prohibited by ARM 5.3.3.Was this prohibition
638 really lifted? Does the FDIS agree with CD2 in the regard? [Issues
639 list maintainer's note: the IS is the same.]</p>
640 <p><b>Proposed resolution:</b></p>
641 <p>Change the last paragraph of 3.7.3 from:</p>
643 <p>Any allocation and/or deallocation functions defined in a C++ program shall
644 conform to the semantics specified in 3.7.3.1 and 3.7.3.2.</p>
648 <p>Any allocation and/or deallocation functions defined in a C++ program,
649 including the default versions in the library, shall conform to the semantics
650 specified in 3.7.3.1 and 3.7.3.2.</p>
652 <p>Change 3.7.3.1/2, next-to-last sentence, from :</p>
654 <p>If the size of the space requested is zero, the value returned shall not be
655 a null pointer value (4.10).</p>
659 <p>Even if the size of the space requested is zero, the request can fail. If
660 the request succeeds, the value returned shall be a non-null pointer value
661 (4.10) p0 different from any previously returned value p1, unless that value
662 p1 was since passed to an operator delete.</p>
664 <p>5.3.4/7 currently reads:</p>
666 <p>When the value of the expression in a direct-new-declarator is zero, the
667 allocation function is called to allocate an array with no elements. The
668 pointer returned by the new-expression is non-null. [Note: If the library
669 allocation function is called, the pointer returned is distinct from the
670 pointer to any other object.]</p>
672 <p>Retain the first sentence, and delete the remainder.</p>
673 <p>18.5.1 currently has no text. Add the following:</p>
675 <p>Except where otherwise specified, the provisions of 3.7.3 apply to the
676 library versions of operator new and operator delete.</p>
678 <p>To 18.5.1.3, add the following text:</p>
680 <p>The provisions of 3.7.3 do not apply to these reserved placement forms of
681 operator new and operator delete.</p>
683 <p><b>Rationale:</b></p>
684 <p>See 99-0040/N1216, October 22, 1999, by Stephen D. Clamage for the analysis
685 supporting to the proposed resolution.</p>
687 <a name="11"><h3>11. Bitset minor problems</h3></a><p><b>Section:</b> 23.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.template.bitset"> [lib.template.bitset]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 22 Jan 1998</p>
688 <p>(1) bitset<>::operator[] is mentioned in the class synopsis (23.3.5), but it is
689 not documented in 23.3.5.2. </p>
691 <p>(2) The class synopsis only gives a single signature for bitset<>::operator[],
692 reference operator[](size_t pos). This doesn't make much sense. It ought to be overloaded
693 on const. reference operator[](size_t pos); bool operator[](size_t pos) const. </p>
695 <p>(3) Bitset's stream input function (23.3.5.3) ought to skip all whitespace before
696 trying to extract 0s and 1s. The standard doesn't explicitly say that, though. This should
697 go in the Effects clause.</p>
698 <p><b>Proposed resolution:</b></p>
699 <p>ITEMS 1 AND 2:<br>
701 In the bitset synopsis (23.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.template.bitset"> [lib.template.bitset]</a>),
702 replace the member function <br>
704 <tt> reference operator[](size_t pos);<br>
706 with the two member functions<br>
708 <tt> bool operator[](size_t pos) const; <br>
709 reference operator[](size_t pos); <br>
711 Add the following text at the end of 23.3.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.members"> [lib.bitset.members]</a>,
712 immediately after paragraph 45:</p>
715 <p><tt>bool operator[](size_t pos) const;</tt><br>
716 Requires: pos is valid<br>
718 Returns: <tt>test(pos)</tt><br>
720 <tt>bitset<N>::reference operator[](size_t pos);</tt> <br>
721 Requires: pos is valid<br>
723 Returns: An object of type <tt>bitset<N>::reference</tt> such that <tt>(*this)[pos]
724 == this->test(pos)</tt>, and such that <tt>(*this)[pos] = val</tt> is equivalent to <tt>this->set(pos,
727 <p><b>Rationale:</b></p>
728 <p>The LWG believes Item 3 is not a defect. "Formatted
729 input" implies the desired semantics. See 27.6.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted"> [lib.istream.formatted]</a>.
732 <a name="13"><h3>13. Eos refuses to die</h3></a><p><b>Section:</b> 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> William M. Miller <b>Date:</b> 3 Mar 1998</p>
733 <p>In 27.6.1.2.3, there is a reference to "eos", which is
734 the only one in the whole draft (at least using Acrobat search), so
736 <p><b>Proposed resolution:</b></p>
737 <p>In 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a>, replace "eos" with
740 <a name="14"><h3>14. Locale::combine should be const</h3></a><p><b>Section:</b> 22.1.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.members"> [lib.locale.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
741 <p>locale::combine is the only member function of locale (other than constructors and
742 destructor) that is not const. There is no reason for it not to be const, and good reasons
743 why it should have been const. Furthermore, leaving it non-const conflicts with 22.1.1
744 paragraph 6: "An instance of a locale is immutable." </p>
746 <p>History: this member function originally was a constructor. it happened that the
747 interface it specified had no corresponding language syntax, so it was changed to a member
748 function. As constructors are never const, there was no "const" in the interface
749 which was transformed into member "combine". It should have been added at that
750 time, but the omission was not noticed. </p>
751 <p><b>Proposed resolution:</b></p>
752 <p>In 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> and also in 22.1.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.members"> [lib.locale.members]</a>, add
753 "const" to the declaration of member combine: </p>
755 <pre>template <class Facet> locale combine(const locale& other) const; </pre>
758 <a name="15"><h3>15. Locale::name requirement inconsistent</h3></a><p><b>Section:</b> 22.1.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.members"> [lib.locale.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
759 <p>locale::name() is described as returning a string that can be passed to a locale
760 constructor, but there is no matching constructor. </p>
761 <p><b>Proposed resolution:</b></p>
762 <p>In 22.1.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.members"> [lib.locale.members]</a>, paragraph 5, replace
763 "<tt>locale(name())</tt>" with
764 "<tt>locale(name().c_str())</tt>".
767 <a name="16"><h3>16. Bad ctype_byname<char> decl</h3></a><p><b>Section:</b> 22.2.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt"> [lib.locale.codecvt]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
768 <p>The new virtual members ctype_byname<char>::do_widen and do_narrow did not get
769 edited in properly. Instead, the member do_widen appears four times, with wrong argument
771 <p><b>Proposed resolution:</b></p>
772 <p>The correct declarations for the overloaded members
773 <tt>do_narrow</tt> and <tt>do_widen</tt> should be copied
774 from 22.2.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.ctype.special"> [lib.facet.ctype.special]</a>.</p>
776 <a name="17"><h3>17. Bad bool parsing</h3></a><p><b>Section:</b> 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
777 <p>This section describes the process of parsing a text boolean value from the input
778 stream. It does not say it recognizes either of the sequences "true" or
779 "false" and returns the corresponding bool value; instead, it says it recognizes
780 only one of those sequences, and chooses which according to the received value of a
781 reference argument intended for returning the result, and reports an error if the other
782 sequence is found. (!) Furthermore, it claims to get the names from the ctype<>
783 facet rather than the numpunct<> facet, and it examines the "boolalpha"
784 flag wrongly; it doesn't define the value "loc"; and finally, it computes
785 wrongly whether to use numeric or "alpha" parsing.<br>
787 I believe the correct algorithm is "as if": </p>
789 <pre> // in, err, val, and str are arguments.
791 const numpunct<charT>& np = use_facet<numpunct<charT> >(str.getloc());
792 const string_type t = np.truename(), f = np.falsename();
793 bool tm = true, fm = true;
795 while (tm && pos < t.size() || fm && pos < f.size()) {
796 if (in == end) { err = str.eofbit; }
797 bool matched = false;
798 if (tm && pos < t.size()) {
799 if (!err && t[pos] == *in) matched = true;
802 if (fm && pos < f.size()) {
803 if (!err && f[pos] == *in) matched = true;
806 if (matched) { ++in; ++pos; }
807 if (pos > t.size()) tm = false;
808 if (pos > f.size()) fm = false;
810 if (tm == fm || pos == 0) { err |= str.failbit; }
814 <p>Notice this works reasonably when the candidate strings are both empty, or equal, or
815 when one is a substring of the other. The proposed text below captures the logic of the
817 <p><b>Proposed resolution:</b></p>
818 <p>In 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a>, in the first line of paragraph 14,
819 change "&&" to "&".</p>
821 <p>Then, replace paragraphs 15 and 16 as follows:</p>
825 <p>Otherwise target sequences are determined "as if" by
826 calling the members <tt>falsename()</tt> and
827 <tt>truename()</tt> of the facet obtained by
828 <tt>use_facet<numpunct<charT> >(str.getloc())</tt>.
829 Successive characters in the range <tt>[in,end)</tt> (see
830 [lib.sequence.reqmts]) are obtained and matched against
831 corresponding positions in the target sequences only as necessary to
832 identify a unique match. The input iterator <tt>in</tt> is
833 compared to <tt>end</tt> only when necessary to obtain a
834 character. If and only if a target sequence is uniquely matched,
835 <tt>val</tt> is set to the corresponding value.</p>
840 <p>The <tt>in</tt> iterator is always left pointing one position beyond the last character
841 successfully matched. If <tt>val</tt> is set, then err is set to <tt>str.goodbit</tt>; or to
842 <tt>str.eofbit</tt> if, when seeking another character to match, it is found that
843 <tt>(in==end)</tt>. If <tt>val</tt> is not set, then <i>err</i> is set to <tt>str.failbit</tt>; or to
844 <tt>(str.failbit|str.eofbit)</tt>if
845 the reason for the failure was that <tt>(in==end)</tt>. [Example: for targets
846 <tt>true</tt>:"a" and <tt>false</tt>:"abb", the input sequence "a" yields
847 <tt>val==true</tt> and <tt>err==str.eofbit</tt>; the input sequence "abc" yields
848 <tt>err=str.failbit</tt>, with <tt>in</tt> ending at the 'c' element. For targets
850 and <tt>false</tt>:"0", the input sequence "1" yields <tt>val==true</tt>
851 and <tt>err=str.goodbit</tt>. For empty targets (""), any input sequence yields
852 <tt>err==str.failbit</tt>. --end example]</p>
855 <a name="18"><h3>18. Get(...bool&) omitted</h3></a><p><b>Section:</b> 22.2.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.members"> [lib.facet.num.get.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
856 <p>In the list of num_get<> non-virtual members on page 22-23, the member
857 that parses bool values was omitted from the list of definitions of non-virtual
858 members, though it is listed in the class definition and the corresponding
859 virtual is listed everywhere appropriate. </p>
860 <p><b>Proposed resolution:</b></p>
861 <p>Add at the beginning of 22.2.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.members"> [lib.facet.num.get.members]</a>
862 another get member for bool&, copied from the entry in
863 22.2.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.num.get"> [lib.locale.num.get]</a>.</p>
865 <a name="19"><h3>19. "Noconv" definition too vague</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
867 In the definitions of codecvt<>::do_out and do_in, they are
868 specified to return noconv if "no conversion is
869 needed". This definition is too vague, and does not say
870 normatively what is done with the buffers.
872 <p><b>Proposed resolution:</b></p>
874 Change the entry for noconv in the table under paragraph 4 in section
875 <font color="red">22.2.1.5.2</font> to read:
878 <p><tt>noconv</tt>: <tt>internT</tt> and <tt>externT</tt> are the same type,
879 and input sequence is identical to converted sequence.</p>
881 <p>Change the Note in paragraph 2 to normative text as follows:</p>
883 <p>If returns <tt>noconv</tt>, <tt>internT</tt> and <tt>externT</tt> are the
884 same type and the converted sequence is identical to the input sequence <tt>[from,from_next)</tt>.
885 <tt>to_next</tt> is set equal to <tt>to</tt>, the value of <tt>state</tt> is
886 unchanged, and there are no changes to the values in <tt>[to, to_limit)</tt>.</p>
889 <a name="20"></a><h3><a name="20">20. Thousands_sep returns wrong type</a></h3><p><b>Section:</b> 22.2.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.numpunct.virtuals"> [lib.facet.numpunct.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
890 <p>The synopsis for numpunct<>::do_thousands_sep, and the
891 definition of numpunct<>::thousands_sep which calls it, specify
892 that it returns a value of type char_type. Here it is erroneously
893 described as returning a "string_type". </p>
894 <p><b>Proposed resolution:</b></p>
895 <p>In 22.2.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.numpunct.virtuals"> [lib.facet.numpunct.virtuals]</a>, above paragraph 2, change
896 "string_type" to "char_type". </p>
898 <a name="21"><h3>21. Codecvt_byname<> instantiations</h3></a><p><b>Section:</b> 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
899 <p>In the second table in the section, captioned "Required
900 instantiations", the instantiations for codecvt_byname<>
901 have been omitted. These are necessary to allow users to construct a
902 locale by name from facets. </p>
903 <p><b>Proposed resolution:</b></p>
904 <p>Add in 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> to the table captioned
905 "Required instantiations", in the category "ctype"
909 <pre>codecvt_byname<char,char,mbstate_t>,
910 codecvt_byname<wchar_t,char,mbstate_t> </pre>
913 <a name="22"><h3>22. Member open vs. flags</h3></a><p><b>Section:</b> 27.8.1.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.members"> [lib.ifstream.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
914 <p>The description of basic_istream<>::open leaves unanswered questions about how it
915 responds to or changes flags in the error status for the stream. A strict reading
916 indicates that it ignores the bits and does not change them, which confuses users who do
917 not expect eofbit and failbit to remain set after a successful open. There are three
918 reasonable resolutions: 1) status quo 2) fail if fail(), ignore eofbit 3) clear failbit
919 and eofbit on call to open(). </p>
920 <p><b>Proposed resolution:</b></p>
921 <p>In 27.8.1.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.members"> [lib.ifstream.members]</a> paragraph 3, <i>and</i> in 27.8.1.10 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ofstream.members"> [lib.ofstream.members]</a> paragraph 3, under open() effects, add a footnote:
925 <p>A successful open does not change the error state.</p>
927 <p><b>Rationale:</b></p>
928 <p>This may seem surprising to some users, but it's just an instance
929 of a general rule: error flags are never cleared by the
930 implementation. The only way error flags are are ever cleared is if
931 the user explicitly clears them by hand.</p>
933 <p>The LWG believed that preserving this general rule was
934 important enough so that an exception shouldn't be made just for this
935 one case. The resolution of this issue clarifies what the LWG
936 believes to have been the original intent.</p>
939 <a name="24"><h3>24. "do_convert" doesn't exist</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
940 <p>The description of codecvt<>::do_out and do_in mentions a
941 symbol "do_convert" which is not defined in the
942 standard. This is a leftover from an edit, and should be "do_in
944 <p><b>Proposed resolution:</b></p>
945 <p>In 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a>, paragraph 3, change
946 "do_convert" to "do_in or do_out". Also, in <font color="red">22.2.1.5.2</font>, change "do_convert()" to "do_in
949 <a name="25"><h3>25. String operator<< uses width() value wrong</h3></a><p><b>Section:</b> 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
950 <p>In the description of operator<< applied to strings, the standard says that uses
951 the smaller of os.width() and str.size(), to pad "as described in stage 3"
952 elsewhere; but this is inconsistent, as this allows no possibility of space for padding. </p>
953 <p><b>Proposed resolution:</b></p>
954 <p>Change 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> paragraph 4 from:<br>
956 "... where <tt>n</tt> is the smaller of <tt>os.width()</tt> and <tt>str.size()</tt>;
961 "... where <tt>n</tt> is the larger of <tt>os.width()</tt> and <tt>str.size()</tt>;
964 <a name="26"><h3>26. Bad sentry example</h3></a><p><b>Section:</b> 27.6.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::sentry"> [lib.istream::sentry]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
965 <p>In paragraph 6, the code in the example: </p>
967 <pre> template <class charT, class traits = char_traits<charT> >
968 basic_istream<charT,traits>::sentry(
969 basic_istream<charT,traits>& is, bool noskipws = false) {
972 typedef ctype<charT> ctype_type;
973 const ctype_type& ctype = use_facet<ctype_type>(is.getloc());
974 while ((c = is.rdbuf()->snextc()) != traits::eof()) {
975 if (ctype.is(ctype.space,c)==0) {
976 is.rdbuf()->sputbackc (c);
983 <p>fails to demonstrate correct use of the facilities described. In
984 particular, it fails to use traits operators, and specifies incorrect
985 semantics. (E.g. it specifies skipping over the first character in the
986 sequence without examining it.) </p>
987 <p><b>Proposed resolution:</b></p>
988 <p>Remove the example above from 27.6.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::sentry"> [lib.istream::sentry]</a>
990 <p><b>Rationale:</b></p>
991 <p>The originally proposed replacement code for the example was not
992 correct. The LWG tried in Kona and again in Tokyo to correct it
993 without success. In Tokyo, an implementor reported that actual working
994 code ran over one page in length and was quite complicated. The LWG
995 decided that it would be counter-productive to include such a lengthy
996 example, which might well still contain errors.</p>
998 <a name="27"><h3>27. String::erase(range) yields wrong iterator</h3></a><p><b>Section:</b> 21.3.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::erase"> [lib.string::erase]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
999 <p>The string::erase(iterator first, iterator last) is specified to return an element one
1000 place beyond the next element after the last one erased. E.g. for the string
1001 "abcde", erasing the range ['b'..'d') would yield an iterator for element 'e',
1002 while 'd' has not been erased. </p>
1003 <p><b>Proposed resolution:</b></p>
1004 <p>In 21.3.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::erase"> [lib.string::erase]</a>, paragraph 10, change: </p>
1007 <p>Returns: an iterator which points to the element immediately following _last_ prior to
1008 the element being erased. </p>
1014 <p>Returns: an iterator which points to the element pointed to by _last_ prior to the
1015 other elements being erased. </p>
1018 <a name="28"><h3>28. Ctype<char>is ambiguous</h3></a><p><b>Section:</b> 22.2.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.ctype.char.members"> [lib.facet.ctype.char.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1019 <p>The description of the vector form of ctype<char>::is can be interpreted to mean
1020 something very different from what was intended. Paragraph 4 says </p>
1023 <p>Effects: The second form, for all *p in the range [low, high), assigns vec[p-low] to
1024 table()[(unsigned char)*p]. </p>
1027 <p>This is intended to copy the value indexed from table()[] into the place identified in
1029 <p><b>Proposed resolution:</b></p>
1030 <p>Change 22.2.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.ctype.char.members"> [lib.facet.ctype.char.members]</a>, paragraph 4, to read </p>
1033 <p>Effects: The second form, for all *p in the range [low, high), assigns into vec[p-low]
1034 the value table()[(unsigned char)*p]. </p>
1037 <a name="29"><h3>29. Ios_base::init doesn't exist</h3></a><p><b>Section:</b> 27.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.narrow.stream.objects"> [lib.narrow.stream.objects]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1038 <p>Sections 27.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.narrow.stream.objects"> [lib.narrow.stream.objects]</a> and 27.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.wide.stream.objects"> [lib.wide.stream.objects]</a> mention
1039 a function ios_base::init, which is not defined. Probably they mean
1040 basic_ios<>::init, defined in 27.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.cons"> [lib.basic.ios.cons]</a>,
1042 <p><b>Proposed resolution:</b></p>
1043 <p>[R12: modified to include paragraph 5.]</p>
1045 <p>In 27.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.narrow.stream.objects"> [lib.narrow.stream.objects]</a> paragraph 2 and 5, change </p>
1048 <p>ios_base::init </p>
1054 <p>basic_ios<char>::init </p>
1057 <p>Also, make a similar change in 27.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.wide.stream.objects"> [lib.wide.stream.objects]</a> except it
1061 <p>basic_ios<wchar_t>::init </p>
1064 <a name="30"><h3>30. Wrong header for LC_*</h3></a><p><b>Section:</b> 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1065 <p>Paragraph 2 implies that the C macros LC_CTYPE etc. are defined in <cctype>,
1066 where they are in fact defined elsewhere to appear in <clocale>. </p>
1067 <p><b>Proposed resolution:</b></p>
1068 <p>In 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a>, paragraph 2, change
1069 "<cctype>" to read "<clocale>". </p>
1071 <a name="31"><h3>31. Immutable locale values</h3></a><p><b>Section:</b> 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1072 <p>Paragraph 6, says "An instance of <tt>locale</tt> is
1073 <i>immutable</i>; once a facet reference is obtained from it,
1074 ...". This has caused some confusion, because locale variables
1075 are manifestly assignable. </p>
1076 <p><b>Proposed resolution:</b></p>
1077 <p>In 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> replace paragraph 6</p>
1080 <p>An instance of <tt>locale</tt> is immutable; once a facet
1081 reference is obtained from it, that reference remains usable as long
1082 as the locale value itself exists.</p>
1088 <p>Once a facet reference is obtained from a locale object by
1089 calling use_facet<>, that reference remains usable, and the
1090 results from member functions of it may be cached and re-used, as
1091 long as some locale object refers to that facet.</p>
1094 <a name="32"><h3>32. Pbackfail description inconsistent</h3></a><p><b>Section:</b> 27.5.2.4.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.pback"> [lib.streambuf.virt.pback]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1095 <p>The description of the required state before calling virtual member
1096 basic_streambuf<>::pbackfail requirements is inconsistent with the conditions
1097 described in 27.5.2.2.4 [lib.streambuf.pub.pback] where member sputbackc calls it.
1098 Specifically, the latter says it calls pbackfail if: </p>
1100 <p> traits::eq(c,gptr()[-1]) is false </p>
1102 <p>where pbackfail claims to require: </p>
1104 <p> traits::eq(*gptr(),traits::to_char_type(c)) returns false </p>
1106 <p>It appears that the pbackfail description is wrong. </p>
1107 <p><b>Proposed resolution:</b></p>
1108 <p>In 27.5.2.4.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.pback"> [lib.streambuf.virt.pback]</a>, paragraph 1, change:</p>
1111 <p>"<tt>traits::eq(*gptr(),traits::to_char_type( c))</tt>"</p>
1117 <p>"<tt>traits::eq(traits::to_char_type(c),gptr()[-1])</tt>"
1120 <p><b>Rationale:</b></p>
1121 <p>Note deliberate reordering of arguments for clarity in addition to the correction of
1122 the argument value.</p>
1124 <a name="33"><h3>33. Codecvt<> mentions from_type</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1125 <p>In the table defining the results from do_out and do_in, the specification for the
1126 result <i>error</i> says </p>
1129 <p>encountered a from_type character it could not convert </p>
1132 <p>but from_type is not defined. This clearly is intended to be an externT for do_in, or
1133 an internT for do_out. </p>
1134 <p><b>Proposed resolution:</b></p>
1135 <p>In <font color="red">22.2.1.5.2</font> paragraph 4, replace the definition
1136 in the table for the case of _error_ with </p>
1139 <p>encountered a character in <tt>[from,from_end)</tt> that it could not convert. </p>
1142 <a name="34"><h3>34. True/falsename() not in ctype<></h3></a><p><b>Section:</b> 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1143 <p>In paragraph 19, Effects:, members truename() and falsename are used from facet
1144 ctype<charT>, but it has no such members. Note that this is also a problem in
1145 22.2.2.1.2, addressed in (4). </p>
1146 <p><b>Proposed resolution:</b></p>
1147 <p>In 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a>, paragraph 19, in the Effects:
1148 clause for member put(...., bool), replace the initialization of the
1149 string_type value s as follows: </p>
1152 <pre>const numpunct& np = use_facet<numpunct<charT> >(loc);
1153 string_type s = val ? np.truename() : np.falsename(); </pre>
1156 <a name="35"><h3>35. No manipulator unitbuf in synopsis</h3></a><p><b>Section:</b> 27.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostreams.base"> [lib.iostreams.base]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1157 <p>In 27.4.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fmtflags.manip"> [lib.fmtflags.manip]</a>, we have a definition for a manipulator
1158 named "unitbuf". Unlike other manipulators, it's not listed
1159 in synopsis. Similarly for "nounitbuf". </p>
1160 <p><b>Proposed resolution:</b></p>
1161 <p>Add to the synopsis for <ios> in 27.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostreams.base"> [lib.iostreams.base]</a>, after
1162 the entry for "nouppercase", the prototypes: </p>
1165 <pre>ios_base& unitbuf(ios_base& str);
1166 ios_base& nounitbuf(ios_base& str); </pre>
1169 <a name="36"><h3>36. Iword & pword storage lifetime omitted</h3></a><p><b>Section:</b> 27.4.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.storage"> [lib.ios.base.storage]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1170 <p>In the definitions for ios_base::iword and pword, the lifetime of the storage is
1171 specified badly, so that an implementation which only keeps the last value stored appears
1172 to conform. In particular, it says: </p>
1174 <p>The reference returned may become invalid after another call to the object's iword
1175 member with a different index ... </p>
1177 <p>This is not idle speculation; at least one implementation was done this way. </p>
1178 <p><b>Proposed resolution:</b></p>
1179 <p>Add in 27.4.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.storage"> [lib.ios.base.storage]</a>, in both paragraph 2 and also in
1180 paragraph 4, replace the sentence: </p>
1183 <p>The reference returned may become invalid after another call to the object's iword
1184 [pword] member with a different index, after a call to its copyfmt member, or when the
1185 object is destroyed. </p>
1191 <p>The reference returned is invalid after any other operations on the object. However,
1192 the value of the storage referred to is retained, so that until the next call to copyfmt,
1193 calling iword [pword] with the same index yields another reference to the same value. </p>
1196 <p>substituting "iword" or "pword" as appropriate. </p>
1198 <a name="37"><h3>37. Leftover "global" reference</h3></a><p><b>Section:</b> 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1199 <p>In the overview of locale semantics, paragraph 4, is the sentence </p>
1202 <p>If Facet is not present in a locale (or, failing that, in the global locale), it throws
1203 the standard exception bad_cast. </p>
1206 <p>This is not supported by the definition of use_facet<>, and represents semantics
1207 from an old draft. </p>
1208 <p><b>Proposed resolution:</b></p>
1209 <p>In 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a>, paragraph 4, delete the parenthesized
1213 <p>(or, failing that, in the global locale) </p>
1216 <a name="38"><h3>38. Facet definition incomplete</h3></a><p><b>Section:</b> 22.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.global.templates"> [lib.locale.global.templates]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1217 <p>It has been noticed by Esa Pulkkinen that the definition of
1218 "facet" is incomplete. In particular, a class derived from
1219 another facet, but which does not define a member <i>id</i>, cannot
1220 safely serve as the argument <i>F</i> to use_facet<F>(loc),
1221 because there is no guarantee that a reference to the facet instance
1222 stored in <i>loc</i> is safely convertible to <i>F</i>. </p>
1223 <p><b>Proposed resolution:</b></p>
1224 <p>In the definition of std::use_facet<>(), replace the text in paragraph 1 which
1228 <p>Get a reference to a facet of a locale. </p>
1234 <p>Requires: <tt>Facet</tt> is a facet class whose definition
1235 contains the public static member <tt>id</tt> as defined in 22.1.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.facet"> [lib.locale.facet]</a>. </p>
1239 Kona: strike as overspecification the text "(not inherits)"
1240 from the original resolution, which read "... whose definition
1241 contains (not inherits) the public static member
1246 <a name="39"><h3>39. istreambuf_iterator<>::operator++(int) definition garbled</h3></a><p><b>Section:</b> 24.5.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator::op++"> [lib.istreambuf.iterator::op++]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1247 <p>Following the definition of istreambuf_iterator<>::operator++(int) in paragraph
1248 3, the standard contains three lines of garbage text left over from a previous edit. </p>
1251 <pre>istreambuf_iterator<charT,traits> tmp = *this;
1255 <p><b>Proposed resolution:</b></p>
1256 <p>In 24.5.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator::op++"> [lib.istreambuf.iterator::op++]</a>, delete the three lines of code at the
1257 end of paragraph 3. </p>
1259 <a name="40"><h3>40. Meaningless normative paragraph in examples</h3></a><p><b>Section:</b> 22.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facets.examples"> [lib.facets.examples]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1260 <p>Paragraph 3 of the locale examples is a description of part of an
1261 implementation technique that has lost its referent, and doesn't mean
1263 <p><b>Proposed resolution:</b></p>
1264 <p>Delete 22.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facets.examples"> [lib.facets.examples]</a> paragraph 3 which begins "This
1265 initialization/identification system depends...", or (at the
1266 editor's option) replace it with a place-holder to keep the paragraph
1267 numbering the same. </p>
1269 <a name="41"><h3>41. Ios_base needs clear(), exceptions()</h3></a><p><b>Section:</b> 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1270 <p>The description of ios_base::iword() and pword() in 27.4.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.members.static"> [lib.ios.members.static]</a>, say that if they fail, they "set badbit,
1271 which may throw an exception". However, ios_base offers no
1272 interface to set or to test badbit; those interfaces are defined in
1273 basic_ios<>. </p>
1274 <p><b>Proposed resolution:</b></p>
1275 <p>Change the description in 27.4.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.storage"> [lib.ios.base.storage]</a> in
1276 paragraph 2, and also in paragraph 4, as follows. Replace</p>
1279 <p>If the function fails it sets badbit, which may throw an exception.</p>
1285 <p>If the function fails, and <tt>*this</tt> is a base sub-object of
1286 a <tt>basic_ios<></tt> object or sub-object, the effect is
1287 equivalent to calling <tt>basic_ios<>::setstate(badbit)</tt>
1288 on the derived object (which may throw <tt>failure</tt>).</p>
1291 <p><i>[Kona: LWG reviewed wording; setstate(failbit) changed to
1292 setstate(badbit).]</i></p>
1295 <a name="42"><h3>42. String ctors specify wrong default allocator</h3></a><p><b>Section:</b> 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1296 <p>The basic_string<> copy constructor: </p>
1298 <pre>basic_string(const basic_string& str, size_type pos = 0,
1299 size_type n = npos, const Allocator& a = Allocator()); </pre>
1301 <p>specifies an Allocator argument default value that is
1302 counter-intuitive. The natural choice for a the allocator to copy from
1303 is str.get_allocator(). Though this cannot be expressed in
1304 default-argument notation, overloading suffices. </p>
1306 <p>Alternatively, the other containers in Clause 23 (deque, list,
1307 vector) do not have this form of constructor, so it is inconsistent,
1308 and an evident source of confusion, for basic_string<> to have
1309 it, so it might better be removed. </p>
1310 <p><b>Proposed resolution:</b></p>
1311 <p> In 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a>, replace the declaration of the copy
1312 constructor as follows: </p>
1315 <pre>basic_string(const basic_string& str);
1316 basic_string(const basic_string& str, size_type pos, size_type n = npos,
1317 const Allocator& a = Allocator());</pre>
1320 <p>In 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a>, replace the copy constructor declaration
1321 as above. Add to paragraph 5, Effects:</p>
1324 <p>In the first form, the Allocator value used is copied from
1325 <tt>str.get_allocator()</tt>.</p>
1327 <p><b>Rationale:</b></p>
1328 <p>The LWG believes the constructor is actually broken, rather than
1329 just an unfortunate design choice.</p>
1331 <p>The LWG considered two other possible resolutions:</p>
1333 <p>A. In 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a>, replace the declaration of the copy
1334 constructor as follows:</p>
1337 <pre>basic_string(const basic_string& str, size_type pos = 0,
1338 size_type n = npos);
1339 basic_string(const basic_string& str, size_type pos,
1340 size_type n, const Allocator& a); </pre>
1343 <p>In 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a>, replace the copy constructor declaration
1344 as above. Add to paragraph 5, Effects: </p>
1347 <p>When no <tt>Allocator</tt> argument is provided, the string is constructed using the
1348 value <tt>str.get_allocator()</tt>. </p>
1351 <p>B. In 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a>, and also in 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a>, replace
1352 the declaration of the copy constructor as follows: </p>
1355 <pre>basic_string(const basic_string& str, size_type pos = 0,
1356 size_type n = npos); </pre>
1359 <p>The proposed resolution reflects the original intent of the LWG. It
1360 was also noted by Pete Becker that this fix "will cause
1361 a small amount of existing code to now work correctly."</p>
1364 Kona: issue editing snafu fixed - the proposed resolution now correctly
1365 reflects the LWG consensus.
1368 <a name="44"><h3>44. Iostreams use operator== on int_type values</h3></a><p><b>Section:</b> 27 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.input.output"> [lib.input.output]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 6 Aug 1998</p>
1369 <p>Many of the specifications for iostreams specify that character
1370 values or their int_type equivalents are compared using operators ==
1371 or !=, though in other places traits::eq() or traits::eq_int_type is
1372 specified to be used throughout. This is an inconsistency; we should
1373 change uses of == and != to use the traits members instead. </p>
1374 <p><b>Proposed resolution:</b></p>
1376 <p><i>[Pre-Kona: Dietmar supplied wording]</i></p>
1378 <p>List of changes to clause 27:</p>
1381 In lib.basic.ios.members paragraph 13 (postcondition clause for
1391 traits::eq(fillch, fill())
1397 In lib.istream.unformatted paragraph 7 (effects clause for
1398 'get(cT,streamsize,cT)'), third bullet, change
1401 c == delim for the next available input character c
1407 traits::eq(c, delim) for the next available input character c
1412 In lib.istream.unformatted paragraph 12 (effects clause for
1413 'get(basic_streambuf<cT,Tr>&,cT)'), third bullet, change
1416 c == delim for the next available input character c
1422 traits::eq(c, delim) for the next available input character c
1427 In lib.istream.unformatted paragraph 17 (effects clause for
1428 'getline(cT,streamsize,cT)'), second bullet, change
1431 c == delim for the next available input character c
1437 traits::eq(c, delim) for the next available input character c
1442 In lib.istream.unformatted paragraph 24 (effects clause for
1443 'ignore(int,int_type)'), second bullet, change
1446 c == delim for the next available input character c
1452 traits::eq_int_type(c, delim) for the next available input
1458 In lib.istream.unformatted paragraph 25 (notes clause for
1459 'ignore(int,int_type)'), second bullet, change
1462 The last condition will never occur if delim == traits::eof()
1468 The last condition will never occur if
1469 traits::eq_int_type(delim, traits::eof()).
1474 In lib.istream.sentry paragraph 6 (example implementation for the
1475 sentry constructor) change
1478 while ((c = is.rdbuf()->snextc()) != traits::eof()) {
1484 while (!traits::eq_int_type(c = is.rdbuf()->snextc(), traits::eof())) {
1490 <p>List of changes to Chapter 21:</p>
1494 In lib.string::find paragraph 1 (effects clause for find()),
1495 second bullet, change
1498 at(xpos+I) == str.at(I) for all elements ...
1504 traits::eq(at(xpos+I), str.at(I)) for all elements ...
1509 In lib.string::rfind paragraph 1 (effects clause for rfind()),
1510 second bullet, change
1513 at(xpos+I) == str.at(I) for all elements ...
1519 traits::eq(at(xpos+I), str.at(I)) for all elements ...
1524 In lib.string::find.first.of paragraph 1 (effects clause for
1525 find_first_of()), second bullet, change
1528 at(xpos+I) == str.at(I) for all elements ...
1534 traits::eq(at(xpos+I), str.at(I)) for all elements ...
1539 In lib.string::find.last.of paragraph 1 (effects clause for
1540 find_last_of()), second bullet, change
1543 at(xpos+I) == str.at(I) for all elements ...
1549 traits::eq(at(xpos+I), str.at(I)) for all elements ...
1554 In lib.string::find.first.not.of paragraph 1 (effects clause for
1555 find_first_not_of()), second bullet, change
1558 at(xpos+I) == str.at(I) for all elements ...
1564 traits::eq(at(xpos+I), str.at(I)) for all elements ...
1569 In lib.string::find.last.not.of paragraph 1 (effects clause for
1570 find_last_not_of()), second bullet, change
1573 at(xpos+I) == str.at(I) for all elements ...
1579 traits::eq(at(xpos+I), str.at(I)) for all elements ...
1584 In lib.string.ios paragraph 5 (effects clause for getline()),
1585 second bullet, change
1588 c == delim for the next available input character c
1594 traits::eq(c, delim) for the next available input character c
1603 Fixing this issue highlights another sloppyness in
1604 lib.istream.unformatted paragraph 24: this clause mentions a "character"
1605 which is then compared to an 'int_type' (see item 5. in the list
1606 below). It is not clear whether this requires explicit words and
1607 if so what these words are supposed to be. A similar issue exists,
1608 BTW, for operator*() of istreambuf_iterator which returns the result
1609 of sgetc() as a character type (see lib.istreambuf.iterator::op*
1610 paragraph 1), and for operator++() of istreambuf_iterator which
1611 passes the result of sbumpc() to a constructor taking a char_type
1612 (see lib.istreambuf.iterator::operator++ paragraph 3). Similarily, the
1613 assignment operator ostreambuf_iterator passes a char_type to a function
1614 taking an int_type (see lib.ostreambuf.iter.ops paragraph 1).
1617 It is inconsistent to use comparisons using the traits functions in
1618 Chapter 27 while not using them in Chapter 21, especially as some
1619 of the inconsistent uses actually involve streams (eg. getline() on
1620 streams). To avoid leaving this issue open still longer due to this
1621 inconsistency (it is open since 1998), a list of changes to Chapter
1625 In Chapter 24 there are several places with statements like "the end
1626 of stream is reached (streambuf_type::sgetc() returns traits::eof())"
1627 (lib.istreambuf.iterator paragraph 1, lib.ostreambuf.iter.ops
1628 paragraph 5). It is unclear whether these should be clarified to use
1629 traits::eq_int_type() for detecting traits::eof().
1634 <a name="46"><h3>46. Minor Annex D errors</h3></a><p><b>Section:</b> D.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.str.strstreams"> [depr.str.strstreams]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Brendan Kehoe <b>Date:</b> 1 Jun 1998</p>
1635 <p>See lib-6522 and edit-814.</p>
1636 <p><b>Proposed resolution:</b></p>
1637 <p>Change D.7.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstreambuf"> [depr.strstreambuf]</a> (since streambuf is a typedef of
1638 basic_streambuf<char>) from:</p>
1640 <pre> virtual streambuf<char>* setbuf(char* s, streamsize n);</pre>
1644 <pre> virtual streambuf* setbuf(char* s, streamsize n);</pre>
1646 <p>In D.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstream"> [depr.strstream]</a> insert the semicolon now missing after
1649 <pre> namespace std {
1651 : public basic_iostream<char> {
1654 typedef char char_type;
1655 typedef typename char_traits<char>::int_type int_type
1656 typedef typename char_traits<char>::pos_type pos_type;</pre>
1658 <a name="47"><h3>47. Imbue() and getloc() Returns clauses swapped</h3></a><p><b>Section:</b> 27.4.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.locales"> [lib.ios.base.locales]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 21 Jun 1998</p>
1659 <p>Section 27.4.2.3 specifies how imbue() and getloc() work. That
1660 section has two RETURNS clauses, and they make no sense as
1661 stated. They make perfect sense, though, if you swap them. Am I
1662 correct in thinking that paragraphs 2 and 4 just got mixed up by
1664 <p><b>Proposed resolution:</b></p>
1665 <p>In 27.4.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.locales"> [lib.ios.base.locales]</a> swap paragraphs 2 and 4.</p>
1667 <a name="48"><h3>48. Use of non-existent exception constructor</h3></a><p><b>Section:</b> 27.4.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios::failure"> [lib.ios::failure]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 21 Jun 1998</p>
1668 <p>27.4.2.1.1, paragraph 2, says that class failure initializes the
1669 base class, exception, with exception(msg). Class exception (see
1670 18.6.1) has no such constructor.</p>
1671 <p><b>Proposed resolution:</b></p>
1672 <p>Replace 27.4.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios::failure"> [lib.ios::failure]</a>, paragraph 2, with</p>
1675 <p>EFFECTS: Constructs an object of class <tt>failure</tt>.</p>
1678 <a name="49"><h3>49. Underspecification of ios_base::sync_with_stdio</h3></a><p><b>Section:</b> 27.4.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.members.static"> [lib.ios.members.static]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 21 Jun 1998</p>
1681 <p>(1) 27.4.2.4 doesn't say what ios_base::sync_with_stdio(f)
1682 returns. Does it return f, or does it return the previous
1683 synchronization state? My guess is the latter, but the standard
1686 <p>(2) 27.4.2.4 doesn't say what it means for streams to be
1687 synchronized with stdio. Again, of course, I can make some
1688 guesses. (And I'm unhappy about the performance implications of those
1689 guesses, but that's another matter.)</p>
1690 <p><b>Proposed resolution:</b></p>
1691 <p>Change the following sentence in 27.4.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.members.static"> [lib.ios.members.static]</a>
1692 returns clause from:</p>
1695 <p><tt>true</tt> if the standard iostream objects (27.3) are
1696 synchronized and otherwise returns <tt>false</tt>.</p>
1702 <p><tt>true</tt> if the previous state of the standard iostream
1703 objects (27.3) was synchronized and otherwise returns
1707 <p>Add the following immediately after 27.4.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.members.static"> [lib.ios.members.static]</a>,
1711 <p>When a standard iostream object str is <i>synchronized</i> with a
1712 standard stdio stream f, the effect of inserting a character c by</p>
1716 <p>is the same as the effect of</p>
1717 <pre> str.rdbuf()->sputc(c);
1720 <p>for any sequence of characters; the effect of extracting a
1725 <p>is the same as the effect of:</p>
1726 <pre> c = str.rdbuf()->sbumpc(c);
1729 <p>for any sequences of characters; and the effect of pushing
1730 back a character c by</p>
1734 <p>is the same as the effect of</p>
1735 <pre> str.rdbuf()->sputbackc(c);
1738 <p>for any sequence of characters. [<i>Footnote</i>: This implies
1739 that operations on a standard iostream object can be mixed arbitrarily
1740 with operations on the corresponding stdio stream. In practical
1741 terms, synchronization usually means that a standard iostream object
1742 and a standard stdio object share a buffer. <i>--End Footnote</i>]</p>
1745 <p><i>[pre-Copenhagen: PJP and Matt contributed the definition
1746 of "synchronization"]</i></p>
1748 <p><i>[post-Copenhagen: proposed resolution was revised slightly:
1749 text was added in the non-normative footnote to say that operations
1750 on the two streams can be mixed arbitrarily.]</i></p>
1752 <a name="50"><h3>50. Copy constructor and assignment operator of ios_base</h3></a><p><b>Section:</b> 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 21 Jun 1998</p>
1753 <p>As written, ios_base has a copy constructor and an assignment
1754 operator. (Nothing in the standard says it doesn't have one, and all
1755 classes have copy constructors and assignment operators unless you
1756 take specific steps to avoid them.) However, nothing in 27.4.2 says
1757 what the copy constructor and assignment operator do. </p>
1759 <p>My guess is that this was an oversight, that ios_base is, like
1760 basic_ios, not supposed to have a copy constructor or an assignment
1764 Jerry Schwarz comments: Yes, its an oversight, but in the opposite
1765 sense to what you're suggesting. At one point there was a definite
1766 intention that you could copy ios_base. It's an easy way to save the
1767 entire state of a stream for future use. As you note, to carry out
1768 that intention would have required a explicit description of the
1769 semantics (e.g. what happens to the iarray and parray stuff).
1771 <p><b>Proposed resolution:</b></p>
1772 <p>In 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a>, class ios_base, specify the copy
1773 constructor and operator= members as being private.</p>
1774 <p><b>Rationale:</b></p>
1775 <p>The LWG believes the difficulty of specifying correct semantics
1776 outweighs any benefit of allowing ios_base objects to be copyable.</p>
1778 <a name="51"><h3>51. Requirement to not invalidate iterators missing</h3></a><p><b>Section:</b> 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> David Vandevoorde <b>Date:</b> 23 Jun 1998</p>
1779 <p>The std::sort algorithm can in general only sort a given sequence
1780 by moving around values. The list<>::sort() member on the other
1781 hand could move around values or just update internal pointers. Either
1782 method can leave iterators into the list<> dereferencable, but
1783 they would point to different things. </p>
1785 <p>Does the FDIS mandate anywhere which method should be used for
1786 list<>::sort()?</p>
1788 <p>Matt Austern comments:</p>
1790 <p>I think you've found an omission in the standard. </p>
1792 <p>The library working group discussed this point, and there was
1793 supposed to be a general requirement saying that list, set, map,
1794 multiset, and multimap may not invalidate iterators, or change the
1795 values that iterators point to, except when an operation does it
1796 explicitly. So, for example, insert() doesn't invalidate any iterators
1797 and erase() and remove() only invalidate iterators pointing to the
1798 elements that are being erased. </p>
1800 <p>I looked for that general requirement in the FDIS, and, while I
1801 found a limited form of it for the sorted associative containers, I
1802 didn't find it for list. It looks like it just got omitted. </p>
1804 <p>The intention, though, is that list<>::sort does not
1805 invalidate any iterators and does not change the values that any
1806 iterator points to. There would be no reason to have the member
1807 function otherwise.</p>
1808 <p><b>Proposed resolution:</b></p>
1809 <p>Add a new paragraph at the end of 23.1:</p>
1812 <p>Unless otherwise specified (either explicitly or by defining a function in terms of
1813 other functions), invoking a container member function or passing a container as an
1814 argument to a library function shall not invalidate iterators to, or change the values of,
1815 objects within that container. </p>
1817 <p><b>Rationale:</b></p>
1818 <p>This was US issue CD2-23-011; it was accepted in London but the
1819 change was not made due to an editing oversight. The wording in the
1820 proposed resolution below is somewhat updated from CD2-23-011,
1821 particularly the addition of the phrase "or change the values
1824 <a name="52"><h3>52. Small I/O problems</h3></a><p><b>Section:</b> 27.4.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fpos.operations"> [lib.fpos.operations]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 23 Jun 1998</p>
1825 <p>First, 27.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.cons"> [lib.basic.ios.cons]</a>, table 89. This is pretty obvious:
1826 it should be titled "basic_ios<>() effects", not
1827 "ios_base() effects". </p>
1829 <p>[The second item is a duplicate; see issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#6">6</a> for
1832 <p>Second, 27.4.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fpos.operations"> [lib.fpos.operations]</a> table 88 . There are a couple
1833 different things wrong with it, some of which I've already discussed
1834 with Jerry, but the most obvious mechanical sort of error is that it
1835 uses expressions like P(i) and p(i), without ever defining what sort
1839 <p>(The other problem is that it requires support for streampos
1840 arithmetic. This is impossible on some systems, i.e. ones where file
1841 position is a complicated structure rather than just a number. Jerry
1842 tells me that the intention was to require syntactic support for
1843 streampos arithmetic, but that it wasn't actually supposed to do
1844 anything meaningful except on platforms, like Unix, where genuine
1845 arithmetic is possible.) </p>
1846 <p><b>Proposed resolution:</b></p>
1847 <p>Change 27.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.cons"> [lib.basic.ios.cons]</a> table 89 title from
1848 "ios_base() effects" to "basic_ios<>()
1851 <a name="53"><h3>53. Basic_ios destructor unspecified</h3></a><p><b>Section:</b> 27.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.cons"> [lib.basic.ios.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 23 Jun 1998</p>
1852 <p>There's nothing in 27.4.4 saying what basic_ios's destructor does.
1853 The important question is whether basic_ios::~basic_ios() destroys
1855 <p><b>Proposed resolution:</b></p>
1856 <p>Add after 27.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.cons"> [lib.basic.ios.cons]</a> paragraph 2:</p>
1859 <p><tt>virtual ~basic_ios();</tt></p>
1860 <p><b>Notes</b>: The destructor does not destroy <tt>rdbuf()</tt>.</p>
1862 <p><b>Rationale:</b></p>
1863 <p>The LWG reviewed the additional question of whether or not
1864 <tt>rdbuf(0)</tt> may set <tt>badbit</tt>. The answer is
1865 clearly yes; it may be set via <tt>clear()</tt>. See 27.4.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.members"> [lib.basic.ios.members]</a>, paragraph 6. This issue was reviewed at length
1866 by the LWG, which removed from the original proposed resolution a
1867 footnote which incorrectly said "<tt>rdbuf(0)</tt> does not set
1868 <tt>badbit</tt>".</p>
1870 <a name="54"><h3>54. Basic_streambuf's destructor</h3></a><p><b>Section:</b> 27.5.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.cons"> [lib.streambuf.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 25 Jun 1998</p>
1871 <p>The class synopsis for basic_streambuf shows a (virtual)
1872 destructor, but the standard doesn't say what that destructor does. My
1873 assumption is that it does nothing, but the standard should say so
1875 <p><b>Proposed resolution:</b></p>
1876 <p>Add after 27.5.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.cons"> [lib.streambuf.cons]</a> paragraph 2:</p>
1879 <p><tt>virtual ~basic_streambuf();</tt></p>
1880 <p><b>Effects</b>: None.</p>
1883 <a name="55"><h3>55. Invalid stream position is undefined</h3></a><p><b>Section:</b> 27 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.input.output"> [lib.input.output]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 26 Jun 1998</p>
1884 <p>Several member functions in clause 27 are defined in certain
1885 circumstances to return an "invalid stream position", a term
1886 that is defined nowhere in the standard. Two places (27.5.2.4.2,
1887 paragraph 4, and 27.8.1.4, paragraph 15) contain a cross-reference to
1888 a definition in _lib.iostreams.definitions_, a nonexistent
1891 <p>I suspect that the invalid stream position is just supposed to be
1892 pos_type(-1). Probably best to say explicitly in (for example)
1893 27.5.2.4.2 that the return value is pos_type(-1), rather than to use
1894 the term "invalid stream position", define that term
1895 somewhere, and then put in a cross-reference. </p>
1897 <p>The phrase "invalid stream position" appears ten times in
1898 the C++ Standard. In seven places it refers to a return value, and it
1899 should be changed. In three places it refers to an argument, and it
1900 should not be changed. Here are the three places where "invalid
1901 stream position" should not be changed:</p>
1904 <p>27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a>, paragraph 14<br>
1905 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a>, paragraph 14<br>
1906 D.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstreambuf.virtuals"> [depr.strstreambuf.virtuals]</a>, paragraph 17
1909 <p><b>Proposed resolution:</b></p>
1910 <p>In 27.5.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.buffer"> [lib.streambuf.virt.buffer]</a>, paragraph 4, change "Returns an
1911 object of class pos_type that stores an invalid stream position
1912 (_lib.iostreams.definitions_)" to "Returns
1913 <tt>pos_type(off_type(-1))</tt>".
1916 <p>In 27.5.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.buffer"> [lib.streambuf.virt.buffer]</a>, paragraph 6, change "Returns
1917 an object of class pos_type that stores an invalid stream
1918 position" to "Returns <tt>pos_type(off_type(-1))</tt>".</p>
1920 <p>In 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a>, paragraph 13, change "the object
1921 stores an invalid stream position" to "the return value is
1922 <tt>pos_type(off_type(-1))</tt>". </p>
1924 <p>In 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a>, paragraph 13, change "returns an
1925 invalid stream position (27.4.3)" to "returns
1926 <tt>pos_type(off_type(-1))</tt>" </p>
1928 <p>In 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a>, paragraph 15, change "Otherwise
1929 returns an invalid stream position (_lib.iostreams.definitions_)"
1930 to "Otherwise returns <tt>pos_type(off_type(-1))</tt>"
1933 <p>In D.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstreambuf.virtuals"> [depr.strstreambuf.virtuals]</a>, paragraph 15, change "the object
1934 stores an invalid stream position" to "the return value is
1935 <tt>pos_type(off_type(-1))</tt>" </p>
1937 <p>In D.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstreambuf.virtuals"> [depr.strstreambuf.virtuals]</a>, paragraph 18, change "the object
1938 stores an invalid stream position" to "the return value is
1939 <tt>pos_type(off_type(-1))</tt>"</p>
1941 <a name="56"><h3>56. Showmanyc's return type</h3></a><p><b>Section:</b> 27.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf"> [lib.streambuf]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 29 Jun 1998</p>
1942 <p>The class summary for basic_streambuf<>, in 27.5.2, says that
1943 showmanyc has return type int. However, 27.5.2.4.3 says that its
1944 return type is streamsize. </p>
1945 <p><b>Proposed resolution:</b></p>
1946 <p>Change <tt>showmanyc</tt>'s return type in the
1947 27.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf"> [lib.streambuf]</a> class summary to <tt>streamsize</tt>.</p>
1949 <a name="57"><h3>57. Mistake in char_traits</h3></a><p><b>Section:</b> 21.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.specializations.wchar.t"> [lib.char.traits.specializations.wchar.t]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 1 Jul 1998</p>
1950 <p>21.1.3.2, paragraph 3, says "The types streampos and
1951 wstreampos may be different if the implementation supports no shift
1952 encoding in narrow-oriented iostreams but supports one or more shift
1953 encodings in wide-oriented streams". </p>
1955 <p>That's wrong: the two are the same type. The <iosfwd> summary
1956 in 27.2 says that streampos and wstreampos are, respectively, synonyms
1957 for fpos<char_traits<char>::state_type> and
1958 fpos<char_traits<wchar_t>::state_type>, and, flipping back
1959 to clause 21, we see in 21.1.3.1 and 21.1.3.2 that
1960 char_traits<char>::state_type and
1961 char_traits<wchar_t>::state_type must both be mbstate_t. </p>
1962 <p><b>Proposed resolution:</b></p>
1963 <p>Remove the sentence in 21.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.specializations.wchar.t"> [lib.char.traits.specializations.wchar.t]</a> paragraph 3 which
1964 begins "The types streampos and wstreampos may be
1965 different..." . </p>
1967 <a name="59"><h3>59. Ambiguity in specification of gbump</h3></a><p><b>Section:</b> 27.5.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.get.area"> [lib.streambuf.get.area]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 28 Jul 1998</p>
1968 <p>27.5.2.3.1 says that basic_streambuf::gbump() "Advances the
1969 next pointer for the input sequence by n." </p>
1971 <p>The straightforward interpretation is that it is just gptr() +=
1972 n. An alternative interpretation, though, is that it behaves as if it
1973 calls sbumpc n times. (The issue, of course, is whether it might ever
1974 call underflow.) There is a similar ambiguity in the case of
1977 <p>(The "classic" AT&T implementation used the
1978 former interpretation.)</p>
1979 <p><b>Proposed resolution:</b></p>
1980 <p>Change 27.5.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.get.area"> [lib.streambuf.get.area]</a> paragraph 4 gbump effects from:</p>
1983 <p>Effects: Advances the next pointer for the input sequence by n.</p>
1989 <p>Effects: Adds <tt>n</tt> to the next pointer for the input sequence.</p>
1992 <p>Make the same change to 27.5.2.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.put.area"> [lib.streambuf.put.area]</a> paragraph 4 pbump
1995 <a name="60"><h3>60. What is a formatted input function?</h3></a><p><b>Section:</b> 27.6.1.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.reqmts"> [lib.istream.formatted.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 3 Aug 1998</p>
1996 <p>Paragraph 1 of 27.6.1.2.1 contains general requirements for all
1997 formatted input functions. Some of the functions defined in section
1998 27.6.1.2 explicitly say that those requirements apply ("Behaves
1999 like a formatted input member (as described in 27.6.1.2.1)"), but
2000 others don't. The question: is 27.6.1.2.1 supposed to apply to
2001 everything in 27.6.1.2, or only to those member functions that
2002 explicitly say "behaves like a formatted input member"? Or
2003 to put it differently: are we to assume that everything that appears
2004 in a section called "Formatted input functions" really is a
2005 formatted input function? I assume that 27.6.1.2.1 is intended to
2006 apply to the arithmetic extractors (27.6.1.2.2), but I assume that it
2007 is not intended to apply to extractors like </p>
2009 <pre> basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));</pre>
2013 <pre> basic_istream& operator>>(basic_streammbuf*);</pre>
2015 <p>There is a similar ambiguity for unformatted input, formatted output, and unformatted
2018 <p>Comments from Judy Ward: It seems like the problem is that the
2019 basic_istream and basic_ostream operator <<()'s that are used
2020 for the manipulators and streambuf* are in the wrong section and
2021 should have their own separate section or be modified to make it clear
2022 that the "Common requirements" listed in section 27.6.1.2.1
2023 (for basic_istream) and section 27.6.2.5.1 (for basic_ostream) do not
2026 <p>Additional comments from Dietmar Kühl: It appears to be somewhat
2027 nonsensical to consider the functions defined in 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a> paragraphs 1 to 5 to be "Formatted input
2028 function" but since these functions are defined in a section
2029 labeled "Formatted input functions" it is unclear to me
2030 whether these operators are considered formatted input functions which
2031 have to conform to the "common requirements" from 27.6.1.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.reqmts"> [lib.istream.formatted.reqmts]</a>: If this is the case, all manipulators, not
2032 just <tt>ws</tt>, would skip whitespace unless <tt>noskipws</tt> is
2033 set (... but setting <tt>noskipws</tt> using the manipulator syntax
2034 would also skip whitespace :-)</p> <p>It is not clear which functions
2035 are to be considered unformatted input functions. As written, it seems
2036 that all functions in 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> are unformatted input
2037 functions. However, it does not really make much sense to construct a
2038 sentry object for <tt>gcount()</tt>, <tt>sync()</tt>, ... Also it is
2039 unclear what happens to the <tt>gcount()</tt> if
2040 eg. <tt>gcount()</tt>, <tt>putback()</tt>, <tt>unget()</tt>, or
2041 <tt>sync()</tt> is called: These functions don't extract characters,
2042 some of them even "unextract" a character. Should this still
2043 be reflected in <tt>gcount()</tt>? Of course, it could be read as if
2044 after a call to <tt>gcount()</tt> <tt>gcount()</tt> return <tt>0</tt>
2045 (the last unformatted input function, <tt>gcount()</tt>, didn't
2046 extract any character) and after a call to <tt>putback()</tt>
2047 <tt>gcount()</tt> returns <tt>-1</tt> (the last unformatted input
2048 function <tt>putback()</tt> did "extract" back into the
2049 stream). Correspondingly for <tt>unget()</tt>. Is this what is
2050 intended? If so, this should be clarified. Otherwise, a corresponding
2051 clarification should be used.</p>
2052 <p><b>Proposed resolution:</b></p>
2054 In 27.6.1.2.2 [lib.istream.formatted.arithmetic], paragraph 1.
2055 Change the beginning of the second sentence from "The conversion
2056 occurs" to "These extractors behave as formatted input functions (as
2057 described in 27.6.1.2.1). After a sentry object is constructed,
2058 the conversion occurs"
2062 In 27.6.1.2.3, [lib.istream::extractors], before paragraph 1.
2063 Add an effects clause. "Effects: None. This extractor does
2064 not behave as a formatted input function (as described in
2069 In 27.6.1.2.3, [lib.istream::extractors], paragraph 2. Change the
2070 effects clause to "Effects: Calls pf(*this). This extractor does not
2071 behave as a formatted input function (as described in 27.6.1.2.1).
2075 In 27.6.1.2.3, [lib.istream::extractors], paragraph 4. Change the
2076 effects clause to "Effects: Calls pf(*this). This extractor does not
2077 behave as a formatted input function (as described in 27.6.1.2.1).
2081 In 27.6.1.2.3, [lib.istream::extractors], paragraph 12. Change the
2082 first two sentences from "If sb is null, calls setstate(failbit),
2083 which may throw ios_base::failure (27.4.4.3). Extracts characters
2084 from *this..." to "Behaves as a formatted input function (as described
2085 in 27.6.1.2.1). If sb is null, calls setstate(failbit), which may
2086 throw ios_base::failure (27.4.4.3). After a sentry object is
2087 constructed, extracts characters from *this...".
2091 In 27.6.1.3, [lib.istream.unformatted], before paragraph 2. Add an
2092 effects clause. "Effects: none. This member function does not behave
2093 as an unformatted input function (as described in 27.6.1.3, paragraph 1)."
2097 In 27.6.1.3, [lib.istream.unformatted], paragraph 3. Change the
2098 beginning of the first sentence of the effects clause from "Extracts a
2099 character" to "Behaves as an unformatted input function (as described
2100 in 27.6.1.3, paragraph 1). After constructing a sentry object, extracts a
2105 In 27.6.1.3, [lib.istream.unformatted], paragraph 5. Change the
2106 beginning of the first sentence of the effects clause from "Extracts a
2107 character" to "Behaves as an unformatted input function (as described
2108 in 27.6.1.3, paragraph 1). After constructing a sentry object, extracts a
2113 In 27.6.1.3, [lib.istream.unformatted], paragraph 7. Change the
2114 beginning of the first sentence of the effects clause from "Extracts
2115 characters" to "Behaves as an unformatted input function (as described
2116 in 27.6.1.3, paragraph 1). After constructing a sentry object, extracts
2121 [No change needed in paragraph 10, because it refers to paragraph 7.]
2125 In 27.6.1.3, [lib.istream.unformatted], paragraph 12. Change the
2126 beginning of the first sentence of the effects clause from "Extracts
2127 characters" to "Behaves as an unformatted input function (as described
2128 in 27.6.1.3, paragraph 1). After constructing a sentry object, extracts
2133 [No change needed in paragraph 15.]
2137 In 27.6.1.3, [lib.istream.unformatted], paragraph 17. Change the
2138 beginning of the first sentence of the effects clause from "Extracts
2139 characters" to "Behaves as an unformatted input function (as described
2140 in 27.6.1.3, paragraph 1). After constructing a sentry object, extracts
2145 [No change needed in paragraph 23.]
2149 In 27.6.1.3, [lib.istream.unformatted], paragraph 24. Change the
2150 beginning of the first sentence of the effects clause from "Extracts
2151 characters" to "Behaves as an unformatted input function (as described
2152 in 27.6.1.3, paragraph 1). After constructing a sentry object, extracts
2157 In 27.6.1.3, [lib.istream.unformatted], before paragraph 27. Add an
2158 Effects clause: "Effects: Behaves as an unformatted input function (as
2159 described in 27.6.1.3, paragraph 1). After constructing a sentry
2160 object, reads but does not extract the current input character."
2164 In 27.6.1.3, [lib.istream.unformatted], paragraph 28. Change the
2165 first sentence of the Effects clause from "If !good() calls" to
2166 Behaves as an unformatted input function (as described in 27.6.1.3,
2167 paragraph 1). After constructing a sentry object, if !good() calls"
2171 In 27.6.1.3, [lib.istream.unformatted], paragraph 30. Change the
2172 first sentence of the Effects clause from "If !good() calls" to
2173 "Behaves as an unformatted input function (as described in 27.6.1.3,
2174 paragraph 1). After constructing a sentry object, if !good() calls"
2178 In 27.6.1.3, [lib.istream.unformatted], paragraph 32. Change the
2179 first sentence of the Effects clause from "If !good() calls..." to
2180 "Behaves as an unformatted input function (as described in 27.6.1.3,
2181 paragraph 1). After constructing a sentry object, if !good()
2182 calls..." Add a new sentence to the end of the Effects clause:
2183 "[Note: this function extracts no characters, so the value returned
2184 by the next call to gcount() is 0.]"
2188 In 27.6.1.3, [lib.istream.unformatted], paragraph 34. Change the
2189 first sentence of the Effects clause from "If !good() calls" to
2190 "Behaves as an unformatted input function (as described in 27.6.1.3,
2191 paragraph 1). After constructing a sentry object, if !good() calls".
2192 Add a new sentence to the end of the Effects clause: "[Note: this
2193 function extracts no characters, so the value returned by the next
2194 call to gcount() is 0.]"
2198 In 27.6.1.3, [lib.istream.unformatted], paragraph 36. Change the
2199 first sentence of the Effects clause from "If !rdbuf() is" to "Behaves
2200 as an unformatted input function (as described in 27.6.1.3, paragraph
2201 1), except that it does not count the number of characters extracted
2202 and does not affect the value returned by subsequent calls to
2203 gcount(). After constructing a sentry object, if rdbuf() is"
2207 In 27.6.1.3, [lib.istream.unformatted], before paragraph 37. Add an
2208 Effects clause: "Effects: Behaves as an unformatted input function (as
2209 described in 27.6.1.3, paragraph 1), except that it does not count the
2210 number of characters extracted and does not affect the value returned
2211 by subsequent calls to gcount()." Change the first sentence of
2212 paragraph 37 from "if fail()" to "after constructing a sentry object,
2217 In 27.6.1.3, [lib.istream.unformatted], paragraph 38. Change the
2218 first sentence of the Effects clause from "If fail()" to "Behaves
2219 as an unformatted input function (as described in 27.6.1.3, paragraph
2220 1), except that it does not count the number of characters extracted
2221 and does not affect the value returned by subsequent calls to
2222 gcount(). After constructing a sentry object, if fail()
2226 In 27.6.1.3, [lib.istream.unformatted], paragraph 40. Change the
2227 first sentence of the Effects clause from "If fail()" to "Behaves
2228 as an unformatted input function (as described in 27.6.1.3, paragraph
2229 1), except that it does not count the number of characters extracted
2230 and does not affect the value returned by subsequent calls to
2231 gcount(). After constructing a sentry object, if fail()
2235 In 27.6.2.5.2 [lib.ostream.inserters.arithmetic], paragraph 1. Change
2236 the beginning of the third sentence from "The formatting conversion"
2237 to "These extractors behave as formatted output functions (as
2238 described in 27.6.2.5.1). After the sentry object is constructed, the
2243 In 27.6.2.5.3 [lib.ostream.inserters], before paragraph 1. Add an
2244 effects clause: "Effects: None. Does not behave as a formatted output
2245 function (as described in 27.6.2.5.1).".
2249 In 27.6.2.5.3 [lib.ostream.inserters], paragraph 2. Change the
2250 effects clause to "Effects: calls pf(*this). This extractor does not
2251 behave as a formatted output function (as described in 27.6.2.5.1).".
2255 In 27.6.2.5.3 [lib.ostream.inserters], paragraph 4. Change the
2256 effects clause to "Effects: calls pf(*this). This extractor does not
2257 behave as a formatted output function (as described in 27.6.2.5.1).".
2261 In 27.6.2.5.3 [lib.ostream.inserters], paragraph 6. Change the first
2262 sentence from "If sb" to "Behaves as a formatted output function (as
2263 described in 27.6.2.5.1). After the sentry object is constructed, if
2268 In 27.6.2.6 [lib.ostream.unformatted], paragraph 2. Change the first
2269 sentence from "Inserts the character" to "Behaves as an unformatted
2270 output function (as described in 27.6.2.6, paragraph 1). After
2271 constructing a sentry object, inserts the character".
2275 In 27.6.2.6 [lib.ostream.unformatted], paragraph 5. Change the first
2276 sentence from "Obtains characters" to "Behaves as an unformatted
2277 output function (as described in 27.6.2.6, paragraph 1). After
2278 constructing a sentry object, obtains characters".
2282 In 27.6.2.6 [lib.ostream.unformatted], paragraph 7. Add a new
2283 sentence at the end of the paragraph: "Does not behave as an
2284 unformatted output function (as described in 27.6.2.6, paragraph 1)."
2286 <p><b>Rationale:</b></p>
2287 <p>See J16/99-0043==WG21/N1219, Proposed Resolution to Library Issue 60,
2288 by Judy Ward and Matt Austern. This proposed resolution is section
2289 VI of that paper.</p>
2291 <a name="61"><h3>61. Ambiguity in iostreams exception policy</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 6 Aug 1998</p>
2292 <p>The introduction to the section on unformatted input (27.6.1.3)
2293 says that every unformatted input function catches all exceptions that
2294 were thrown during input, sets badbit, and then conditionally rethrows
2295 the exception. That seems clear enough. Several of the specific
2296 functions, however, such as get() and read(), are documented in some
2297 circumstances as setting eofbit and/or failbit. (The standard notes,
2298 correctly, that setting eofbit or failbit can sometimes result in an
2299 exception being thrown.) The question: if one of these functions
2300 throws an exception triggered by setting failbit, is this an exception
2301 "thrown during input" and hence covered by 27.6.1.3, or does
2302 27.6.1.3 only refer to a limited class of exceptions? Just to make
2303 this concrete, suppose you have the following snippet. </p>
2309 is.exceptions(istream::failbit); // Throw on failbit but not on badbit.
2310 is.read(buffer, N);</pre>
2312 <p>Now suppose we reach EOF before we've read N characters. What
2313 iostate bits can we expect to be set, and what exception (if any) will
2315 <p><b>Proposed resolution:</b></p>
2317 In 27.6.1.3, paragraph 1, after the sentence that begins
2318 "If an exception is thrown...", add the following
2319 parenthetical comment: "(Exceptions thrown from
2320 <tt>basic_ios<>::clear()</tt> are not caught or rethrown.)"
2322 <p><b>Rationale:</b></p>
2323 <p>The LWG looked to two alternative wordings, and choose the proposed
2324 resolution as better standardese.</p>
2326 <a name="62"><h3>62. <tt>Sync</tt>'s return value</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 6 Aug 1998</p>
2327 <p>The Effects clause for sync() (27.6.1.3, paragraph 36) says that it
2328 "calls rdbuf()->pubsync() and, if that function returns -1
2329 ... returns traits::eof()." </p>
2331 <p>That looks suspicious, because traits::eof() is of type
2332 traits::int_type while the return type of sync() is int. </p>
2333 <p><b>Proposed resolution:</b></p>
2334 <p>In 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>, paragraph 36, change "returns
2335 <tt>traits::eof()</tt>" to "returns <tt>-1</tt>".
2338 <a name="63"><h3>63. Exception-handling policy for unformatted output</h3></a><p><b>Section:</b> 27.6.2.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.unformatted"> [lib.ostream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 11 Aug 1998</p>
2339 <p>Clause 27 details an exception-handling policy for formatted input,
2340 unformatted input, and formatted output. It says nothing for
2341 unformatted output (27.6.2.6). 27.6.2.6 should either include the same
2342 kind of exception-handling policy as in the other three places, or
2343 else it should have a footnote saying that the omission is
2345 <p><b>Proposed resolution:</b></p>
2347 In 27.6.2.6, paragraph 1, replace the last sentence ("In any
2348 case, the unformatted output function ends by destroying the sentry
2349 object, then returning the value specified for the formatted output
2350 function.") with the following text:
2353 If an exception is thrown during output, then <tt>ios::badbit</tt> is
2354 turned on [Footnote: without causing an <tt>ios::failure</tt> to be
2355 thrown.] in <tt>*this</tt>'s error state. If <tt>(exceptions() &
2356 badbit) != 0</tt> then the exception is rethrown. In any case, the
2357 unformatted output function ends by destroying the sentry object,
2358 then, if no exception was thrown, returning the value specified for
2359 the formatted output function.
2361 <p><b>Rationale:</b></p>
2363 This exception-handling policy is consistent with that of formatted
2364 input, unformatted input, and formatted output.
2367 <a name="64"><h3>64. Exception handling in <tt>basic_istream::operator>>(basic_streambuf*)</tt>
2368 </h3></a><p><b>Section:</b> 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 11 Aug 1998 </p>
2369 <p>27.6.1.2.3, paragraph 13, is ambiguous. It can be interpreted two
2370 different ways, depending on whether the second sentence is read as an
2371 elaboration of the first. </p>
2372 <p><b>Proposed resolution:</b></p>
2373 <p>Replace 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a>, paragraph 13, which begins
2374 "If the function inserts no characters ..." with:</p>
2377 <p>If the function inserts no characters, it calls
2378 <tt>setstate(failbit)</tt>, which may throw
2379 <tt>ios_base::failure</tt> (27.4.4.3). If it inserted no characters
2380 because it caught an exception thrown while extracting characters
2381 from <tt>sb</tt> and <tt>failbit</tt> is on in <tt>exceptions()</tt>
2382 (27.4.4.3), then the caught exception is rethrown. </p>
2385 <a name="66"><h3>66. Strstreambuf::setbuf</h3></a><p><b>Section:</b> D.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstreambuf.virtuals"> [depr.strstreambuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 18 Aug 1998</p>
2386 <p>D.7.1.3, paragraph 19, says that strstreambuf::setbuf
2387 "Performs an operation that is defined separately for each class
2388 derived from strstreambuf". This is obviously an incorrect
2389 cut-and-paste from basic_streambuf. There are no classes derived from
2391 <p><b>Proposed resolution:</b></p>
2392 <p>D.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstreambuf.virtuals"> [depr.strstreambuf.virtuals]</a>, paragraph 19, replace the setbuf effects
2393 clause which currently says "Performs an operation that is
2394 defined separately for each class derived from strstreambuf"
2398 <p><b>Effects</b>: implementation defined, except that
2399 <tt>setbuf(0,0)</tt> has no effect.</p>
2402 <a name="68"><h3>68. Extractors for char* should store null at end</h3></a><p><b>Section:</b> 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> 14 Jul 1998</p>
2403 <p>Extractors for char* (27.6.1.2.3) do not store a null character
2404 after the extracted character sequence whereas the unformatted
2405 functions like get() do. Why is this?</p>
2407 <p>Comment from Jerry Schwarz: There is apparently an editing
2408 glitch. You'll notice that the last item of the list of what stops
2409 extraction doesn't make any sense. It was supposed to be the line that
2410 said a null is stored.</p>
2411 <p><b>Proposed resolution:</b></p>
2412 <p>27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a>, paragraph 7, change the last list
2416 A null byte (<tt>charT()</tt>) in the next position, which may be
2417 the first position if no characters were extracted.
2420 <p>to become a new paragraph which reads:</p>
2423 Operator>> then stores a null byte (<tt>charT()</tt>) in the
2424 next position, which may be the first position if no characters were
2428 <a name="69"><h3>69. Must elements of a vector be contiguous?</h3></a><p><b>Section:</b> 23.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.adaptors"> [lib.container.adaptors]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 29 Jul 1998</p>
2429 <p>The issue is this: Must the elements of a vector be in contiguous memory?</p>
2431 <p>(Please note that this is entirely separate from the question of
2432 whether a vector iterator is required to be a pointer; the answer to
2433 that question is clearly "no," as it would rule out
2434 debugging implementations)</p>
2435 <p><b>Proposed resolution:</b></p>
2436 <p>Add the following text to the end of 23.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.adaptors"> [lib.container.adaptors]</a>,
2440 <p>The elements of a vector are stored contiguously, meaning that if
2441 v is a <tt>vector<T, Allocator></tt> where T is some type
2442 other than <tt>bool</tt>, then it obeys the identity <tt>&v[n]
2443 == &v[0] + n</tt> for all <tt>0 <= n < v.size()</tt>.</p>
2445 <p><b>Rationale:</b></p>
2446 <p>The LWG feels that as a practical matter the answer is clearly
2447 "yes". There was considerable discussion as to the best way
2448 to express the concept of "contiguous", which is not
2449 directly defined in the standard. Discussion included:</p>
2452 <li>An operational definition similar to the above proposed resolution is
2453 already used for valarray (<font color="red">26.3.2.3</font>).</li>
2454 <li>There is no need to explicitly consider a user-defined operator&
2455 because elements must be copyconstructible (23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> para 3)
2456 and copyconstructible (20.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.copyconstructible"> [lib.copyconstructible]</a>) specifies
2457 requirements for operator&.</li>
2458 <li>There is no issue of one-past-the-end because of language rules.</li>
2461 <a name="70"><h3>70. Uncaught_exception() missing throw() specification</h3></a><p><b>Section:</b> 18.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.support.exception"> [lib.support.exception]</a>, 18.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.uncaught"> [lib.uncaught]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> Unknown</p>
2462 <p>In article 3E04@pratique.fr, Valentin Bonnard writes: </p>
2464 <p>uncaught_exception() doesn't have a throw specification.</p>
2466 <p>It is intentional ? Does it means that one should be prepared to
2467 handle exceptions thrown from uncaught_exception() ?</p>
2469 <p>uncaught_exception() is called in exception handling contexts where
2470 exception safety is very important.</p>
2471 <p><b>Proposed resolution:</b></p>
2472 <p>In 15.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/except.html#except.uncaught"> [except.uncaught]</a>, paragraph 1, 18.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.support.exception"> [lib.support.exception]</a>, and 18.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.uncaught"> [lib.uncaught]</a>, add "throw()" to uncaught_exception().</p>
2474 <a name="71"><h3>71. Do_get_monthname synopsis missing argument</h3></a><p><b>Section:</b> 22.2.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.get"> [lib.locale.time.get]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 13 Aug 1998</p>
2475 <p>The locale facet member <tt>time_get<>::do_get_monthname</tt>
2476 is described in 22.2.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.get.virtuals"> [lib.locale.time.get.virtuals]</a> with five arguments,
2477 consistent with do_get_weekday and with its specified use by member
2478 get_monthname. However, in the synopsis, it is specified instead with
2479 four arguments. The missing argument is the "end" iterator
2481 <p><b>Proposed resolution:</b></p>
2482 <p>In 22.2.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.get"> [lib.locale.time.get]</a>, add an "end" argument to
2483 the declaration of member do_monthname as follows:</p>
2485 <pre> virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&,
2486 ios_base::iostate& err, tm* t) const;</pre>
2488 <a name="74"><h3>74. Garbled text for <tt>codecvt::do_max_length</tt>
2489 </h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 8 Sep 1998</p>
2490 <p>The text of <tt>codecvt::do_max_length</tt>'s "Returns"
2491 clause (22.2.1.5.2, paragraph 11) is garbled. It has unbalanced
2492 parentheses and a spurious <b>n</b>.</p>
2493 <p><b>Proposed resolution:</b></p>
2494 <p>Replace <font color="red">22.2.1.5.2</font> paragraph 11 with the
2498 <b>Returns</b>: The maximum value that
2499 <tt>do_length(state, from, from_end, 1)</tt> can return for any
2500 valid range <tt>[from, from_end)</tt> and <tt>stateT</tt> value
2501 <tt>state</tt>. The specialization <tt>codecvt<char, char,
2502 mbstate_t>::do_max_length()</tt> returns 1.
2505 <a name="75"><h3>75. Contradiction in <tt>codecvt::length</tt>'s argument types</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt
2506 Austern <b>Date:</b> 18 Sep 1998</p>
2507 <p>The class synopses for classes <tt>codecvt<></tt> (22.2.1.5)
2508 and <tt>codecvt_byname<></tt> (22.2.1.6) say that the first
2509 parameter of the member functions <tt>length</tt> and
2510 <tt>do_length</tt> is of type <tt>const stateT&</tt>. The member
2511 function descriptions, however (22.2.1.5.1, paragraph 6; 22.2.1.5.2,
2512 paragraph 9) say that the type is <tt>stateT&</tt>. Either the
2513 synopsis or the summary must be changed. </p>
2515 <p>If (as I believe) the member function descriptions are correct,
2516 then we must also add text saying how <tt>do_length</tt> changes its
2517 <tt>stateT</tt> argument. </p>
2518 <p><b>Proposed resolution:</b></p>
2519 <p>In 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a>, and also in <font color="red">22.2.1.6</font>,
2520 change the <tt>stateT</tt> argument type on both member
2521 <tt>length()</tt> and member <tt>do_length()</tt> from </p>
2524 <p><tt>const stateT&</tt></p>
2530 <p><tt>stateT&</tt></p>
2533 <p>In <font color="red">22.2.1.5.2</font>, add to the definition for member
2534 <tt>do_length</tt> a paragraph:</p>
2537 <p>Effects: The effect on the <tt>state</tt> argument is ``as if''
2538 it called <tt>do_in(state, from, from_end, from, to, to+max,
2539 to)</tt> for <tt>to</tt> pointing to a buffer of at least
2540 <tt>max</tt> elements.</p>
2543 <a name="76"><h3>76. Can a <tt>codecvt</tt> facet always convert one internal character at a time?</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 25 Sep 1998</p>
2544 <p>This issue concerns the requirements on classes derived from
2545 <tt>codecvt</tt>, including user-defined classes. What are the
2546 restrictions on the conversion from external characters
2547 (e.g. <tt>char</tt>) to internal characters (e.g. <tt>wchar_t</tt>)?
2548 Or, alternatively, what assumptions about <tt>codecvt</tt> facets can
2549 the I/O library make? </p>
2551 <p>The question is whether it's possible to convert from internal
2552 characters to external characters one internal character at a time,
2553 and whether, given a valid sequence of external characters, it's
2554 possible to pick off internal characters one at a time. Or, to put it
2555 differently: given a sequence of external characters and the
2556 corresponding sequence of internal characters, does a position in the
2557 internal sequence correspond to some position in the external
2560 <p>To make this concrete, suppose that <tt>[first, last)</tt> is a
2561 sequence of <i>M</i> external characters and that <tt>[ifirst,
2562 ilast)</tt> is the corresponding sequence of <i>N</i> internal
2563 characters, where <i>N > 1</i>. That is, <tt>my_encoding.in()</tt>,
2564 applied to <tt>[first, last)</tt>, yields <tt>[ifirst,
2565 ilast)</tt>. Now the question: does there necessarily exist a
2566 subsequence of external characters, <tt>[first, last_1)</tt>, such
2567 that the corresponding sequence of internal characters is the single
2568 character <tt>*ifirst</tt>?
2571 <p>(What a "no" answer would mean is that
2572 <tt>my_encoding</tt> translates sequences only as blocks. There's a
2573 sequence of <i>M</i> external characters that maps to a sequence of
2574 <i>N</i> internal characters, but that external sequence has no
2575 subsequence that maps to <i>N-1</i> internal characters.) </p>
2577 <p>Some of the wording in the standard, such as the description of
2578 <tt>codecvt::do_max_length</tt> (<font color="red">22.2.1.5.2</font>,
2579 paragraph 11) and <tt>basic_filebuf::underflow</tt> (27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a>, paragraph 3) suggests that it must always be
2580 possible to pick off internal characters one at a time from a sequence
2581 of external characters. However, this is never explicitly stated one
2582 way or the other. </p>
2584 <p>This issue seems (and is) quite technical, but it is important if
2585 we expect users to provide their own encoding facets. This is an area
2586 where the standard library calls user-supplied code, so a well-defined
2587 set of requirements for the user-supplied code is crucial. Users must
2588 be aware of the assumptions that the library makes. This issue affects
2589 positioning operations on <tt>basic_filebuf</tt>, unbuffered input,
2590 and several of <tt>codecvt</tt>'s member functions. </p>
2591 <p><b>Proposed resolution:</b></p>
2592 <p>Add the following text as a new paragraph, following <font color="red">22.2.1.5.2</font> paragraph 2:</p>
2595 <p>A <tt>codecvt</tt> facet that is used by <tt>basic_filebuf</tt>
2596 (27.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.file.streams"> [lib.file.streams]</a>) must have the property that if</p>
2597 <pre> do_out(state, from, from_end, from_next, to, to_lim, to_next)
2599 would return <tt>ok</tt>, where <tt>from != from_end</tt>, then
2600 <pre> do_out(state, from, from + 1, from_next, to, to_end, to_next)
2602 must also return <tt>ok</tt>, and that if
2603 <pre> do_in(state, from, from_end, from_next, to, to_lim, to_next)
2605 would return <tt>ok</tt>, where <tt>to != to_lim</tt>, then
2606 <pre> do_in(state, from, from_end, from_next, to, to + 1, to_next)
2608 <p>must also return <tt>ok</tt>. [<i>Footnote:</i> Informally, this
2609 means that <tt>basic_filebuf</tt> assumes that the mapping from
2610 internal to external characters is 1 to N: a <tt>codecvt</tt> that is
2611 used by <tt>basic_filebuf</tt> must be able to translate characters
2612 one internal character at a time. <i>--End Footnote</i>]</p>
2615 <p><i>[Redmond: Minor change in proposed resolution. Original
2616 proposed resolution talked about "success", with a parenthetical
2617 comment that success meant returning <tt>ok</tt>. New wording
2618 removes all talk about "success", and just talks about the
2619 return value.]</i></p>
2621 <p><b>Rationale:</b></p>
2623 <p>The proposed resoluion says that conversions can be performed one
2624 internal character at a time. This rules out some encodings that
2625 would otherwise be legal. The alternative answer would mean there
2626 would be some internal positions that do not correspond to any
2627 external file position.</p>
2629 An example of an encoding that this rules out is one where the
2630 <tt>internT</tt> and <tt>externT</tt> are of the same type, and
2631 where the internal sequence <tt>c1 c2</tt> corresponds to the
2632 external sequence <tt>c2 c1</tt>.
2634 <p>It was generally agreed that <tt>basic_filebuf</tt> relies
2635 on this property: it was designed under the assumption that
2636 the external-to-internal mapping is N-to-1, and it is not clear
2637 that <tt>basic_filebuf</tt> is implementable without that
2641 The proposed resolution is expressed as a restriction on
2642 <tt>codecvt</tt> when used by <tt>basic_filebuf</tt>, rather
2643 than a blanket restriction on all <tt>codecvt</tt> facets,
2644 because <tt>basic_filebuf</tt> is the only other part of the
2645 library that uses <tt>codecvt</tt>. If a user wants to define
2646 a <tt>codecvt</tt> facet that implements a more general N-to-M
2647 mapping, there is no reason to prohibit it, so long as the user
2648 does not expect <tt>basic_filebuf</tt> to be able to use it.
2651 <a name="78"><h3>78. Typo: event_call_back</h3></a><p><b>Section:</b> 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2652 <p>typo: event_call_back should be event_callback </p>
2653 <p><b>Proposed resolution:</b></p>
2654 <p>In the 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a> synopsis change
2655 "event_call_back" to "event_callback". </p>
2657 <a name="79"><h3>79. Inconsistent declaration of polar()</h3></a><p><b>Section:</b> 26.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.synopsis"> [lib.complex.synopsis]</a>, 26.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.value.ops"> [lib.complex.value.ops]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2658 <p>In 26.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.synopsis"> [lib.complex.synopsis]</a> polar is declared as follows:</p>
2659 <pre> template<class T> complex<T> polar(const T&, const T&); </pre>
2661 <p>In 26.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.value.ops"> [lib.complex.value.ops]</a> it is declared as follows:</p>
2662 <pre> template<class T> complex<T> polar(const T& rho, const T& theta = 0); </pre>
2664 <p>Thus whether the second parameter is optional is not clear. </p>
2665 <p><b>Proposed resolution:</b></p>
2666 <p>In 26.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.synopsis"> [lib.complex.synopsis]</a> change:</p>
2667 <pre> template<class T> complex<T> polar(const T&, const T&);</pre>
2670 <pre> template<class T> complex<T> polar(const T& rho, const T& theta = 0); </pre>
2672 <a name="80"><h3>80. Global Operators of complex declared twice</h3></a><p><b>Section:</b> 26.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.cfenv.syn"> [lib.cfenv.syn]</a>, 26.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.fenv"> [lib.fenv]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2673 <p>Both 26.2.1 and 26.2.2 contain declarations of global operators for
2674 class complex. This redundancy should be removed.</p>
2675 <p><b>Proposed resolution:</b></p>
2676 <p>Reduce redundancy according to the general style of the standard. </p>
2678 <a name="83"><h3>83. String::npos vs. string::max_size()</h3></a><p><b>Section:</b> 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2679 <p>Many string member functions throw if size is getting or exceeding
2680 npos. However, I wonder why they don't throw if size is getting or
2681 exceeding max_size() instead of npos. May be npos is known at compile
2682 time, while max_size() is known at runtime. However, what happens if
2683 size exceeds max_size() but not npos, then? It seems the standard
2684 lacks some clarifications here.</p>
2685 <p><b>Proposed resolution:</b></p>
2686 <p>After 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> paragraph 4 ("The functions
2687 described in this clause...") add a new paragraph:</p>
2690 <p>For any string operation, if as a result of the operation, <tt> size()</tt> would exceed
2691 <tt> max_size()</tt> then
2692 the operation throws <tt>length_error</tt>.</p>
2694 <p><b>Rationale:</b></p>
2695 <p>The LWG believes length_error is the correct exception to throw.</p>
2697 <a name="86"><h3>86. String constructors don't describe exceptions</h3></a><p><b>Section:</b> 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2698 <p>The constructor from a range:</p>
2700 <pre>template<class InputIterator>
2701 basic_string(InputIterator begin, InputIterator end,
2702 const Allocator& a = Allocator());</pre>
2704 <p>lacks a throws clause. However, I would expect that it throws
2705 according to the other constructors if the numbers of characters in
2706 the range equals npos (or exceeds max_size(), see above). </p>
2707 <p><b>Proposed resolution:</b></p>
2708 <p>In 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a>, Strike throws paragraphs for
2709 constructors which say "Throws: length_error if n ==
2711 <p><b>Rationale:</b></p>
2712 <p>Throws clauses for length_error if n == npos are no longer needed
2713 because they are subsumed by the general wording added by the
2714 resolution for issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#83">83</a>.</p>
2716 <a name="90"><h3>90. Incorrect description of operator >> for strings</h3></a><p><b>Section:</b> 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2717 <p>The effect of operator >> for strings contain the following item:</p>
2719 <p> <tt>isspace(c,getloc())</tt> is true for the next available input
2722 <p>Here <tt>getloc()</tt> has to be replaced by <tt>is.getloc()</tt>. </p>
2723 <p><b>Proposed resolution:</b></p>
2724 <p>In 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> paragraph 1 Effects clause replace:</p>
2727 <p><tt>isspace(c,getloc())</tt> is true for the next available input character c.</p>
2733 <p><tt>isspace(c,is.getloc())</tt> is true for the next available input character c.</p>
2736 <a name="91"><h3>91. Description of operator>> and getline() for string<> might cause endless loop</h3></a><p><b>Section:</b> 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2737 <p>Operator >> and getline() for strings read until eof()
2738 in the input stream is true. However, this might never happen, if the
2739 stream can't read anymore without reaching EOF. So shouldn't it be
2740 changed into that it reads until !good() ? </p>
2741 <p><b>Proposed resolution:</b></p>
2742 <p>In 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a>, paragraph 1, replace:</p>
2744 Effects: Begins by constructing a sentry object k as if k were
2745 constructed by typename basic_istream<charT,traits>::sentry k( is). If
2746 bool( k) is true, it calls str.erase() and then extracts characters
2747 from is and appends them to str as if by calling str.append(1, c). If
2748 is.width() is greater than zero, the maximum number n of characters
2749 appended is is.width(); otherwise n is str.max_size(). Characters are
2750 extracted and appended until any of the following occurs:
2754 Effects: Behaves as a formatted input function (27.6.1.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.reqmts"> [lib.istream.formatted.reqmts]</a>). After constructing a sentry object, if the
2755 sentry converts to true, calls str.erase() and then extracts
2756 characters from is and appends them to str as if by calling
2757 str.append(1,c). If is.width() is greater than zero, the maximum
2758 number n of characters appended is is.width(); otherwise n is
2759 str.max_size(). Characters are extracted and appended until any of the
2763 <p>In 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a>, paragraph 6, replace</p>
2765 Effects: Begins by constructing a sentry object k as if by typename
2766 basic_istream<charT,traits>::sentry k( is, true). If bool( k) is true,
2767 it calls str.erase() and then extracts characters from is and appends
2768 them to str as if by calling str.append(1, c) until any of the
2773 Effects: Behaves as an unformatted input function (27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>), except that it does not affect the value returned
2774 by subsequent calls to basic_istream<>::gcount(). After
2775 constructing a sentry object, if the sentry converts to true, calls
2776 str.erase() and then extracts characters from is and appends them to
2777 str as if by calling str.append(1,c) until any of the following
2781 <p><i>[Redmond: Made changes in proposed resolution. <tt>operator>></tt>
2782 should be a formatted input function, not an unformatted input function.
2783 <tt>getline</tt> should not be required to set <tt>gcount</tt>, since
2784 there is no mechanism for <tt>gcount</tt> to be set except by one of
2785 <tt>basic_istream</tt>'s member functions.]</i></p>
2787 <p><i>[Curaçao: Nico agrees with proposed resolution.]</i></p>
2789 <p><b>Rationale:</b></p>
2790 <p>The real issue here is whether or not these string input functions
2791 get their characters from a streambuf, rather than by calling an
2792 istream's member functions, a streambuf signals failure either by
2793 returning eof or by throwing an exception; there are no other
2794 possibilities. The proposed resolution makes it clear that these two
2795 functions do get characters from a streambuf.</p>
2797 <a name="92"><h3>92. Incomplete Algorithm Requirements</h3></a><p><b>Section:</b> 25 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.algorithms"> [lib.algorithms]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 29 Sep 1998</p>
2798 <p>The standard does not state, how often a function object is copied,
2799 called, or the order of calls inside an algorithm. This may lead to
2800 surprising/buggy behavior. Consider the following example: </p>
2802 <pre>class Nth { // function object that returns true for the nth element
2804 int nth; // element to return true for
2805 int count; // element counter
2807 Nth (int n) : nth(n), count(0) {
2809 bool operator() (int) {
2810 return ++count == nth;
2814 // remove third element
2815 list<int>::iterator pos;
2816 pos = remove_if(coll.begin(),coll.end(), // range
2817 Nth(3)), // remove criterion
2818 coll.erase(pos,coll.end()); </pre>
2820 <p>This call, in fact removes the 3rd <b>AND the 6th</b> element. This
2821 happens because the usual implementation of the algorithm copies the
2822 function object internally: </p>
2824 <pre>template <class ForwIter, class Predicate>
2825 ForwIter std::remove_if(ForwIter beg, ForwIter end, Predicate op)
2827 beg = find_if(beg, end, op);
2832 ForwIter next = beg;
2833 return remove_copy_if(++next, end, beg, op);
2837 <p>The algorithm uses find_if() to find the first element that should
2838 be removed. However, it then uses a copy of the passed function object
2839 to process the resulting elements (if any). Here, Nth is used again
2840 and removes also the sixth element. This behavior compromises the
2841 advantage of function objects being able to have a state. Without any
2842 cost it could be avoided (just implement it directly instead of
2843 calling find_if()). </p>
2844 <p><b>Proposed resolution:</b></p>
2846 <p>Add a new paragraph following 25 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.algorithms"> [lib.algorithms]</a> paragraph 8:</p>
2848 [Note: Unless otherwise specified, algorithms that take function
2849 objects as arguments are permitted to copy those function objects
2850 freely. Programmers for whom object identity is important should
2851 consider using a wrapper class that points to a noncopied
2852 implementation object, or some equivalent solution.]
2855 <p><i>[Dublin: Pete Becker felt that this may not be a defect,
2856 but rather something that programmers need to be educated about.
2857 There was discussion of adding wording to the effect that the number
2858 and order of calls to function objects, including predicates, not
2859 affect the behavior of the function object.]</i></p>
2861 <p><i>[Pre-Kona: Nico comments: It seems the problem is that we don't
2862 have a clear statement of "predicate" in the
2863 standard. People including me seemed to think "a function
2864 returning a Boolean value and being able to be called by an STL
2865 algorithm or be used as sorting criterion or ... is a
2866 predicate". But a predicate has more requirements: It should
2867 never change its behavior due to a call or being copied. IMHO we have
2868 to state this in the standard. If you like, see section 8.1.4 of my
2869 library book for a detailed discussion.]</i></p>
2871 <p><i>[Kona: Nico will provide wording to the effect that "unless
2872 otherwise specified, the number of copies of and calls to function
2873 objects by algorithms is unspecified". Consider placing in
2874 25 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.algorithms"> [lib.algorithms]</a> after paragraph 9.]</i></p>
2876 <p><i>[Santa Cruz: The standard doesn't currently guarantee that
2877 functions object won't be copied, and what isn't forbidden is
2878 allowed. It is believed (especially since implementations that were
2879 written in concert with the standard do make copies of function
2880 objects) that this was intentional. Thus, no normative change is
2881 needed. What we should put in is a non-normative note suggesting to
2882 programmers that if they want to guarantee the lack of copying they
2883 should use something like the <tt>ref</tt> wrapper.]</i></p>
2885 <p><i>[Oxford: Matt provided wording.]</i></p>
2889 <a name="98"><h3>98. Input iterator requirements are badly written</h3></a><p><b>Section:</b> 24.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.input.iterators"> [lib.input.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> AFNOR <b>Date:</b> 7 Oct 1998</p>
2890 <p>Table 72 in 24.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.input.iterators"> [lib.input.iterators]</a> specifies semantics for
2891 <tt>*r++</tt> of:</p>
2893 <p> <tt>{ T tmp = *r; ++r; return tmp; }</tt></p>
2895 <p>There are two problems with this. First, the return type is
2896 specified to be "T", as opposed to something like "convertible to T".
2897 This is too specific: we want to allow *r++ to return an lvalue.</p>
2899 <p>Second, writing the semantics in terms of code misleadingly
2900 suggests that the effects *r++ should precisely replicate the behavior
2901 of this code, including side effects. (Does this mean that *r++
2902 should invoke the copy constructor exactly as many times as the sample
2903 code above would?) See issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#334">334</a> for a similar
2906 <p><b>Proposed resolution:</b></p>
2907 In Table 72 in 24.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.input.iterators"> [lib.input.iterators]</a>, change the return type
2908 for <tt>*r++</tt> from <tt>T</tt> to "convertible to T".
2909 <p><b>Rationale:</b></p>
2910 <p>This issue has two parts: the return type, and the number of times
2911 the copy constructor is invoked.</p>
2913 <p>The LWG believes the the first part is a real issue. It's
2914 inappropriate for the return type to be specified so much more
2915 precisely for *r++ than it is for *r. In particular, if r is of
2916 (say) type <tt>int*</tt>, then *r++ isn't <tt>int</tt>,
2917 but <tt>int&</tt>.</p>
2919 <p>The LWG does not believe that the number of times the copy
2920 constructor is invoked is a real issue. This can vary in any case,
2921 because of language rules on copy constructor elision. That's too
2922 much to read into these semantics clauses.</p>
2924 <p>Additionally, as Dave Abrahams pointed out (c++std-lib-13703): since
2925 we're told (24.1/3) that forward iterators satisfy all the requirements
2926 of input iterators, we can't impose any requirements in the Input
2927 Iterator requirements table that forward iterators don't satisfy.</p>
2929 <a name="103"><h3>103. set::iterator is required to be modifiable, but this allows modification of keys</h3></a><p><b>Section:</b> 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> AFNOR <b>Date:</b> 7 Oct 1998</p>
2930 <p>Set::iterator is described as implementation-defined with a
2931 reference to the container requirement; the container requirement says
2932 that const_iterator is an iterator pointing to const T and iterator an
2933 iterator pointing to T.</p>
2935 <p>23.1.2 paragraph 2 implies that the keys should not be modified to
2936 break the ordering of elements. But that is not clearly
2937 specified. Especially considering that the current standard requires
2938 that iterator for associative containers be different from
2939 const_iterator. Set, for example, has the following: </p>
2941 <p><tt>typedef implementation defined iterator;<br>
2942 // See _lib.container.requirements_</tt></p>
2944 <p>23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> actually requires that iterator type pointing
2945 to T (table 65). Disallowing user modification of keys by changing the
2946 standard to require an iterator for associative container to be the
2947 same as const_iterator would be overkill since that will unnecessarily
2948 significantly restrict the usage of associative container. A class to
2949 be used as elements of set, for example, can no longer be modified
2950 easily without either redesigning the class (using mutable on fields
2951 that have nothing to do with ordering), or using const_cast, which
2952 defeats requiring iterator to be const_iterator. The proposed solution
2953 goes in line with trusting user knows what he is doing. </p>
2955 <p><b>Other Options Evaluated:</b> </p>
2957 <p>Option A. In 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a>, paragraph 2, after
2958 first sentence, and before "In addition,...", add one line:
2962 <p>Modification of keys shall not change their strict weak ordering. </p>
2965 <p>Option B. Add three new sentences to 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a>:</p>
2968 <p>At the end of paragraph 5: "Keys in an associative container
2969 are immutable." At the end of paragraph 6: "For
2970 associative containers where the value type is the same as the key
2971 type, both <tt>iterator</tt> and <tt>const_iterator</tt> are
2972 constant iterators. It is unspecified whether or not
2973 <tt>iterator</tt> and <tt>const_iterator</tt> are the same
2977 <p>Option C. To 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a>, paragraph 3, which
2978 currently reads:</p>
2981 <p>The phrase ``equivalence of keys'' means the equivalence relation imposed by the
2982 comparison and not the operator== on keys. That is, two keys k1 and k2 in the same
2983 container are considered to be equivalent if for the comparison object comp, comp(k1, k2)
2984 == false && comp(k2, k1) == false.</p>
2987 <p> add the following:</p>
2990 <p>For any two keys k1 and k2 in the same container, comp(k1, k2) shall return the same
2991 value whenever it is evaluated. [Note: If k2 is removed from the container and later
2992 reinserted, comp(k1, k2) must still return a consistent value but this value may be
2993 different than it was the first time k1 and k2 were in the same container. This is
2994 intended to allow usage like a string key that contains a filename, where comp compares
2995 file contents; if k2 is removed, the file is changed, and the same k2 (filename) is
2996 reinserted, comp(k1, k2) must again return a consistent value but this value may be
2997 different than it was the previous time k2 was in the container.]</p>
2999 <p><b>Proposed resolution:</b></p>
3000 <p>Add the following to 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> at
3001 the indicated location:</p>
3004 <p>At the end of paragraph 3: "For any two keys k1 and k2 in the same container,
3005 calling comp(k1, k2) shall always return the same
3007 <p>At the end of paragraph 5: "Keys in an associative container are immutable."</p>
3008 <p>At the end of paragraph 6: "For associative containers where the value type is the
3009 same as the key type, both <tt>iterator</tt> and <tt>const_iterator</tt> are constant
3010 iterators. It is unspecified whether or not <tt>iterator</tt> and <tt>const_iterator</tt>
3011 are the same type."</p>
3013 <p><b>Rationale:</b></p>
3014 <p>Several arguments were advanced for and against allowing set elements to be
3015 mutable as long as the ordering was not effected. The argument which swayed the
3016 LWG was one of safety; if elements were mutable, there would be no compile-time
3017 way to detect of a simple user oversight which caused ordering to be
3018 modified. There was a report that this had actually happened in practice,
3019 and had been painful to diagnose. If users need to modify elements,
3020 it is possible to use mutable members or const_cast.</p>
3022 <p>Simply requiring that keys be immutable is not sufficient, because the comparison
3023 object may indirectly (via pointers) operate on values outside of the keys.</p>
3026 The types <tt>iterator</tt> and <tt>const_iterator</tt> are permitted
3027 to be different types to allow for potential future work in which some
3028 member functions might be overloaded between the two types. No such
3029 member functions exist now, and the LWG believes that user functionality
3030 will not be impaired by permitting the two types to be the same. A
3031 function that operates on both iterator types can be defined for
3032 <tt>const_iterator</tt> alone, and can rely on the automatic
3033 conversion from <tt>iterator</tt> to <tt>const_iterator</tt>.
3036 <p><i>[Tokyo: The LWG crafted the proposed resolution and rationale.]</i></p>
3038 <a name="106"><h3>106. Numeric library private members are implementation defined</h3></a><p><b>Section:</b> 26.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.member.ops"> [lib.complex.member.ops]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> AFNOR <b>Date:</b> 7 Oct 1998</p>
3039 <p>This is the only place in the whole standard where the implementation has to document
3040 something private.</p>
3041 <p><b>Proposed resolution:</b></p>
3043 Remove the comment which says "// remainder implementation defined" from:
3047 <li>26.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.member.ops"> [lib.complex.member.ops]</a>
3049 <li>26.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.value.ops"> [lib.complex.value.ops]</a>
3051 <li>26.3.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.transcendentals"> [lib.complex.transcendentals]</a>
3053 <li>26.3.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.cmplx.over"> [lib.cmplx.over]</a>
3057 <a name="108"><h3>108. Lifetime of exception::what() return unspecified</h3></a><p><b>Section:</b> 18.6.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.type.info"> [lib.type.info]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> AFNOR <b>Date:</b> 7 Oct 1998</p>
3058 <p>In 18.6.1, paragraphs 8-9, the lifetime of the return value of
3059 exception::what() is left unspecified. This issue has implications
3060 with exception safety of exception handling: some exceptions should
3061 not throw bad_alloc.</p>
3062 <p><b>Proposed resolution:</b></p>
3063 <p>Add to 18.6.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.type.info"> [lib.type.info]</a> paragraph 9 (exception::what notes
3064 clause) the sentence:</p>
3067 <p>The return value remains valid until the exception object from which it is obtained is
3068 destroyed or a non-const member function of the exception object is called.</p>
3070 <p><b>Rationale:</b></p>
3071 <p>If an exception object has non-const members, they may be used
3072 to set internal state that should affect the contents of the string
3073 returned by <tt>what()</tt>.
3076 <a name="109"><h3>109. Missing binders for non-const sequence elements</h3></a><p><b>Section:</b> 20.5.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.arithmetic.operations"> [lib.arithmetic.operations]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Bjarne Stroustrup <b>Date:</b> 7 Oct 1998</p>
3078 <p>There are no versions of binders that apply to non-const elements
3079 of a sequence. This makes examples like for_each() using bind2nd() on
3080 page 521 of "The C++ Programming Language (3rd)"
3081 non-conforming. Suitable versions of the binders need to be added.</p>
3083 <p>Further discussion from Nico:</p>
3085 <p>What is probably meant here is shown in the following example:</p>
3089 void print (int i) const { }
3090 void modify (int i) { }
3094 vector<Elem> coll(2);
3095 for_each (coll.begin(), coll.end(), bind2nd(mem_fun_ref(&Elem::print),42)); // OK
3096 for_each (coll.begin(), coll.end(), bind2nd(mem_fun_ref(&Elem::modify),42)); // ERROR
3099 <p>The error results from the fact that bind2nd() passes its first
3100 argument (the argument of the sequence) as constant reference. See the
3101 following typical implementation:</p>
3104 <pre>template <class Operation>
3106 : public unary_function<typename Operation::first_argument_type,
3107 typename Operation::result_type> {
3110 typename Operation::second_argument_type value;
3112 binder2nd(const Operation& o,
3113 const typename Operation::second_argument_type& v)
3114 : op(o), value(v) {} </pre>
3115 <pre> typename Operation::result_type
3116 operator()(const typename Operation::first_argument_type& x) const {
3117 return op(x, value);
3122 <p>The solution is to overload operator () of bind2nd for non-constant arguments:</p>
3125 <pre>template <class Operation>
3127 : public unary_function<typename Operation::first_argument_type,
3128 typename Operation::result_type> {
3131 typename Operation::second_argument_type value;
3133 binder2nd(const Operation& o,
3134 const typename Operation::second_argument_type& v)
3135 : op(o), value(v) {} </pre>
3136 <pre> typename Operation::result_type
3137 operator()(const typename Operation::first_argument_type& x) const {
3138 return op(x, value);
3140 typename Operation::result_type
3141 operator()(typename Operation::first_argument_type& x) const {
3142 return op(x, value);
3146 <p><b>Proposed resolution:</b></p>
3148 <p><b>Howard believes there is a flaw</b> in this resolution.
3149 See c++std-lib-9127. We may need to reopen this issue.</p>
3151 <p>In <font color="red">20.5.6.1</font> in the declaration of binder1st after:</p>
3153 <p><tt>typename Operation::result_type<br>
3154 operator()(const typename Operation::second_argument_type& x) const;</tt></p>
3158 <p><tt>typename Operation::result_type<br>
3159 operator()(typename Operation::second_argument_type& x) const;</tt></p>
3161 <p>In <font color="red">20.5.6.3</font> in the declaration of binder2nd after:</p>
3163 <p><tt>typename Operation::result_type<br>
3164 operator()(const typename Operation::first_argument_type& x) const;</tt></p>
3168 <p><tt>typename Operation::result_type<br>
3169 operator()(typename Operation::first_argument_type& x) const;</tt></p>
3172 <p><i>[Kona: The LWG discussed this at some length.It was agreed that
3173 this is a mistake in the design, but there was no consensus on whether
3174 it was a defect in the Standard. Straw vote: NAD - 5. Accept
3175 proposed resolution - 3. Leave open - 6.]</i></p>
3177 <p><i>[Copenhagen: It was generally agreed that this was a defect.
3178 Strap poll: NAD - 0. Accept proposed resolution - 10.
3179 Leave open - 1.]</i></p>
3182 <a name="110"><h3>110. istreambuf_iterator::equal not const</h3></a><p><b>Section:</b> 24.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator"> [lib.istreambuf.iterator]</a>, 24.5.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator::equal"> [lib.istreambuf.iterator::equal]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 15 Oct 1998</p>
3183 <p>Member istreambuf_iterator<>::equal is not declared
3184 "const", yet 24.5.3.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator::op=="> [lib.istreambuf.iterator::op==]</a> says that operator==,
3185 which is const, calls it. This is contradictory. </p>
3186 <p><b>Proposed resolution:</b></p>
3187 <p>In 24.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator"> [lib.istreambuf.iterator]</a> and also in 24.5.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator::equal"> [lib.istreambuf.iterator::equal]</a>,
3191 <pre>bool equal(istreambuf_iterator& b);</pre>
3197 <pre>bool equal(const istreambuf_iterator& b) const;</pre>
3200 <a name="112"><h3>112. Minor typo in <tt>ostreambuf_iterator</tt> constructor</h3></a><p><b>Section:</b> 24.5.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.ostreambuf.iter.cons"> [lib.ostreambuf.iter.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 20 Oct 1998</p>
3201 <p>The <b>requires</b> clause for <tt>ostreambuf_iterator</tt>'s
3202 constructor from an <tt>ostream_type</tt> (24.5.4.1, paragraph 1)
3203 reads "<i>s</i> is not null". However, <i>s</i> is a
3204 reference, and references can't be null. </p>
3205 <p><b>Proposed resolution:</b></p>
3206 <p>In 24.5.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.ostreambuf.iter.cons"> [lib.ostreambuf.iter.cons]</a>:</p>
3208 <p>Move the current paragraph 1, which reads "Requires: s is not
3209 null.", from the first constructor to the second constructor.</p>
3211 <p>Insert a new paragraph 1 Requires clause for the first constructor
3215 <p><b>Requires</b>: <tt>s.rdbuf()</tt> is not null.</p>
3218 <a name="114"><h3>114. Placement forms example in error twice</h3></a><p><b>Section:</b> 18.5.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.placement"> [lib.new.delete.placement]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 28 Oct 1998</p>
3219 <p>Section 18.5.1.3 contains the following example: </p>
3221 <pre>[Example: This can be useful for constructing an object at a known address:
3222 char place[sizeof(Something)];
3223 Something* p = new (place) Something();
3226 <p>First code line: "place" need not have any special alignment, and the
3227 following constructor could fail due to misaligned data.</p>
3229 <p>Second code line: Aren't the parens on Something() incorrect? [Dublin: the LWG
3230 believes the () are correct.]</p>
3232 <p>Examples are not normative, but nevertheless should not show code that is invalid or
3234 <p><b>Proposed resolution:</b></p>
3235 <p>Replace the <u> first line of code</u> in the example in
3236 18.5.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.placement"> [lib.new.delete.placement]</a> with:
3240 <pre>void* place = operator new(sizeof(Something));</pre>
3243 <a name="115"><h3>115. Typo in strstream constructors</h3></a><p><b>Section:</b> D.7.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstream.cons"> [depr.strstream.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 2 Nov 1998</p>
3244 <p>D.7.4.1 strstream constructors paragraph 2 says: </p>
3247 <p>Effects: Constructs an object of class strstream, initializing the base class with
3248 iostream(& sb) and initializing sb with one of the two constructors: </p>
3249 <p>- If mode&app==0, then s shall designate the first element of an array of n
3250 elements. The constructor is strstreambuf(s, n, s). </p>
3251 <p>- If mode&app==0, then s shall designate the first element of an array of n
3252 elements that contains an NTBS whose first element is designated by s. The constructor is
3253 strstreambuf(s, n, s+std::strlen(s)).</p>
3256 <p>Notice the second condition is the same as the first. I think the second condition
3257 should be "If mode&app==app", or "mode&app!=0", meaning that
3258 the append bit is set.</p>
3259 <p><b>Proposed resolution:</b></p>
3260 <p>In D.7.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ostrstream.cons"> [depr.ostrstream.cons]</a> paragraph 2 and D.7.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.strstream.cons"> [depr.strstream.cons]</a>
3261 paragraph 2, change the first condition to <tt>(mode&app)==0</tt>
3262 and the second condition to <tt>(mode&app)!=0</tt>.</p>
3264 <a name="117"><h3>117. <tt>basic_ostream</tt> uses nonexistent <tt>num_put</tt> member functions</h3></a><p><b>Section:</b> 27.6.2.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.inserters.arithmetic"> [lib.ostream.inserters.arithmetic]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 20 Nov 1998</p>
3265 <p>The <b>effects</b> clause for numeric inserters says that
3266 insertion of a value <tt>x</tt>, whose type is either <tt>bool</tt>,
3267 <tt>short</tt>, <tt>unsigned short</tt>, <tt>int</tt>, <tt>unsigned
3268 int</tt>, <tt>long</tt>, <tt>unsigned long</tt>, <tt>float</tt>,
3269 <tt>double</tt>, <tt>long double</tt>, or <tt>const void*</tt>, is
3270 delegated to <tt>num_put</tt>, and that insertion is performed as if
3271 through the following code fragment: </p>
3273 <pre>bool failed = use_facet<
3274 num_put<charT,ostreambuf_iterator<charT,traits> >
3275 >(getloc()).put(*this, *this, fill(), val). failed();</pre>
3277 <p>This doesn't work, because <tt>num_put<></tt>::put is only
3278 overloaded for the types <tt>bool</tt>, <tt>long</tt>, <tt>unsigned
3279 long</tt>, <tt>double</tt>, <tt>long double</tt>, and <tt>const
3280 void*</tt>. That is, the code fragment in the standard is incorrect
3281 (it is diagnosed as ambiguous at compile time) for the types
3282 <tt>short</tt>, <tt>unsigned short</tt>, <tt>int</tt>, <tt>unsigned
3283 int</tt>, and <tt>float</tt>. </p>
3285 <p>We must either add new member functions to <tt>num_put</tt>, or
3286 else change the description in <tt>ostream</tt> so that it only calls
3287 functions that are actually there. I prefer the latter. </p>
3288 <p><b>Proposed resolution:</b></p>
3289 <p>Replace 27.6.2.5.2, paragraph 1 with the following: </p>
3293 The classes num_get<> and num_put<> handle localeÂdependent numeric
3294 formatting and parsing. These inserter functions use the imbued
3295 locale value to perform numeric formatting. When val is of type bool,
3296 long, unsigned long, double, long double, or const void*, the
3297 formatting conversion occurs as if it performed the following code
3301 <pre>bool failed = use_facet<
3302 num_put<charT,ostreambuf_iterator<charT,traits> >
3303 >(getloc()).put(*this, *this, fill(), val). failed();
3307 When val is of type short the formatting conversion occurs as if it
3308 performed the following code fragment:
3311 <pre>ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
3312 bool failed = use_facet<
3313 num_put<charT,ostreambuf_iterator<charT,traits> >
3314 >(getloc()).put(*this, *this, fill(),
3315 baseflags == ios_base::oct || baseflags == ios_base::hex
3316 ? static_cast<long>(static_cast<unsigned short>(val))
3317 : static_cast<long>(val)). failed();
3321 When val is of type int the formatting conversion occurs as if it performed
3322 the following code fragment:
3325 <pre>ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;
3326 bool failed = use_facet<
3327 num_put<charT,ostreambuf_iterator<charT,traits> >
3328 >(getloc()).put(*this, *this, fill(),
3329 baseflags == ios_base::oct || baseflags == ios_base::hex
3330 ? static_cast<long>(static_cast<unsigned int>(val))
3331 : static_cast<long>(val)). failed();
3335 When val is of type unsigned short or unsigned int the formatting conversion
3336 occurs as if it performed the following code fragment:
3339 <pre>bool failed = use_facet<
3340 num_put<charT,ostreambuf_iterator<charT,traits> >
3341 >(getloc()).put(*this, *this, fill(), static_cast<unsigned long>(val)).
3346 When val is of type float the formatting conversion occurs as if it
3347 performed the following code fragment:
3350 <pre>bool failed = use_facet<
3351 num_put<charT,ostreambuf_iterator<charT,traits> >
3352 >(getloc()).put(*this, *this, fill(), static_cast<double>(val)).
3358 <p><i>[post-Toronto: This differs from the previous proposed
3359 resolution; PJP provided the new wording. The differences are in
3360 signed short and int output.]</i></p>
3361 <p><b>Rationale:</b></p>
3362 <p>The original proposed resolution was to cast int and short to long,
3363 unsigned int and unsigned short to unsigned long, and float to double,
3364 thus ensuring that we don't try to use nonexistent num_put<>
3365 member functions. The current proposed resolution is more
3366 complicated, but gives more expected results for hex and octal output
3367 of signed short and signed int. (On a system with 16-bit short, for
3368 example, printing short(-1) in hex format should yield 0xffff.)</p>
3370 <a name="118"><h3>118. <tt>basic_istream</tt> uses nonexistent <tt>num_get</tt> member functions</h3></a><p><b>Section:</b> 27.6.1.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.arithmetic"> [lib.istream.formatted.arithmetic]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 20 Nov 1998</p>
3371 <p>Formatted input is defined for the types <tt>short</tt>, <tt>unsigned short</tt>, <tt>int</tt>,
3372 <tt>unsigned int</tt>, <tt>long</tt>, <tt>unsigned long</tt>, <tt>float</tt>, <tt>double</tt>,
3373 <tt>long double</tt>, <tt>bool</tt>, and <tt>void*</tt>. According to section 27.6.1.2.2,
3374 formatted input of a value <tt>x</tt> is done as if by the following code fragment: </p>
3376 <pre>typedef num_get< charT,istreambuf_iterator<charT,traits> > numget;
3378 use_facet< numget >(loc).get(*this, 0, *this, err, val);
3379 setstate(err);</pre>
3381 <p>According to section 22.2.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.members"> [lib.facet.num.get.members]</a>, however,
3382 <tt>num_get<>::get()</tt> is only overloaded for the types
3383 <tt>bool</tt>, <tt>long</tt>, <tt>unsigned short</tt>, <tt>unsigned
3384 int</tt>, <tt>unsigned long</tt>, <tt>unsigned long</tt>,
3385 <tt>float</tt>, <tt>double</tt>, <tt>long double</tt>, and
3386 <tt>void*</tt>. Comparing the lists from the two sections, we find
3387 that 27.6.1.2.2 is using a nonexistent function for types
3388 <tt>short</tt> and <tt>int</tt>. </p>
3389 <p><b>Proposed resolution:</b></p>
3390 <p>In 27.6.1.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.arithmetic"> [lib.istream.formatted.arithmetic]</a> Arithmetic Extractors, remove the
3391 two lines (1st and 3rd) which read:</p>
3393 <pre>operator>>(short& val);
3395 operator>>(int& val);</pre>
3398 <p>And add the following at the end of that section (27.6.1.2.2) :</p>
3401 <pre>operator>>(short& val);</pre>
3402 <p>The conversion occurs as if performed by the following code fragment (using
3403 the same notation as for the preceding code fragment):</p>
3404 <pre> typedef num_get< charT,istreambuf_iterator<charT,traits> > numget;
3407 use_facet< numget >(loc).get(*this, 0, *this, err, lval);
3409 && (lval < numeric_limits<short>::min() || numeric_limits<short>::max() < lval))
3410 err = ios_base::failbit;
3411 setstate(err);</pre>
3412 <pre>operator>>(int& val);</pre>
3413 <p>The conversion occurs as if performed by the following code fragment (using
3414 the same notation as for the preceding code fragment):</p>
3415 <pre> typedef num_get< charT,istreambuf_iterator<charT,traits> > numget;
3418 use_facet< numget >(loc).get(*this, 0, *this, err, lval);
3420 && (lval < numeric_limits<int>::min() || numeric_limits<int>::max() < lval))
3421 err = ios_base::failbit;
3422 setstate(err);</pre>
3425 <p><i>[Post-Tokyo: PJP provided the above wording.]</i></p>
3427 <a name="119"><h3>119. Should virtual functions be allowed to strengthen the exception specification?</h3></a><p><b>Section:</b> 17.4.4.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.res.on.exception.handling"> [lib.res.on.exception.handling]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998</p>
3428 <p>Section 17.4.4.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.res.on.exception.handling"> [lib.res.on.exception.handling]</a> states: </p>
3430 <p>"An implementation may strengthen the exception-specification
3431 for a function by removing listed exceptions." </p>
3433 <p>The problem is that if an implementation is allowed to do this for
3434 virtual functions, then a library user cannot write a class that
3435 portably derives from that class. </p>
3437 <p>For example, this would not compile if ios_base::failure::~failure
3438 had an empty exception specification: </p>
3440 <pre>#include <ios>
3441 #include <string>
3443 class D : public std::ios_base::failure {
3445 D(const std::string&);
3446 ~D(); // error - exception specification must be compatible with
3447 // overridden virtual function ios_base::failure::~failure()
3449 <p><b>Proposed resolution:</b></p>
3450 <p>Change Section 17.4.4.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.res.on.exception.handling"> [lib.res.on.exception.handling]</a> from:</p>
3452 <p> "may strengthen the
3453 exception-specification for a function"</p>
3457 <p> "may strengthen the
3458 exception-specification for a non-virtual function". </p>
3460 <a name="120"><h3>120. Can an implementor add specializations?</h3></a><p><b>Section:</b> 17.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.reserved.names"> [lib.reserved.names]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998</p>
3462 <p>The original issue asked whether a library implementor could
3463 specialize standard library templates for built-in types. (This was
3464 an issue because users are permitted to explicitly instantiate
3465 standard library templates.)</p>
3467 <p>Specializations are no longer a problem, because of the resolution
3468 to core issue 259. Under the proposed resolution, it will be legal
3469 for a translation unit to contain both a specialization and an
3470 explicit instantiation of the same template, provided that the
3471 specialization comes first. In such a case, the explicit
3472 instantiation will be ignored. Further discussion of library issue
3473 120 assumes that the core 259 resolution will be adopted.</p>
3475 <p>However, as noted in lib-7047, one piece of this issue still
3476 remains: what happens if a standard library implementor explicitly
3477 instantiates a standard library templates? It's illegal for a program
3478 to contain two different explicit instantiations of the same template
3479 for the same type in two different translation units (ODR violation),
3480 and the core working group doesn't believe it is practical to relax
3481 that restriction.</p>
3483 <p>The issue, then, is: are users allowed to explicitly instantiate
3484 standard library templates for non-user defined types? The status quo
3485 answer is 'yes'. Changing it to 'no' would give library implementors
3488 <p>This is an issue because, for performance reasons, library
3489 implementors often need to explicitly instantiate standard library
3490 templates. (for example, std::basic_string<char>) Does giving
3491 users freedom to explicitly instantiate standard library templates for
3492 non-user defined types make it impossible or painfully difficult for
3493 library implementors to do this?</p>
3495 <p>John Spicer suggests, in lib-8957, that library implementors have a
3496 mechanism they can use for explicit instantiations that doesn't
3497 prevent users from performing their own explicit instantiations: put
3498 each explicit instantiation in its own object file. (Different
3499 solutions might be necessary for Unix DSOs or MS-Windows DLLs.) On
3500 some platforms, library implementors might not need to do anything
3501 special: the "undefined behavior" that results from having two
3502 different explicit instantiations might be harmless.</p>
3504 <p><b>Proposed resolution:</b></p>
3505 <p>Append to 17.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.reserved.names"> [lib.reserved.names]</a> paragraph 1: </p>
3507 A program may explicitly instantiate any templates in the standard
3508 library only if the declaration depends on the name of a user-defined
3509 type of external linkage and the instantiation meets the standard library
3510 requirements for the original template.
3513 <p><i>[Kona: changed the wording from "a user-defined name" to "the name of
3514 a user-defined type"]</i></p>
3516 <p><b>Rationale:</b></p>
3517 <p>The LWG considered another possible resolution:</p>
3519 <p>In light of the resolution to core issue 259, no normative changes
3520 in the library clauses are necessary. Add the following non-normative
3521 note to the end of 17.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.reserved.names"> [lib.reserved.names]</a> paragraph 1:</p>
3523 [<i>Note:</i> A program may explicitly instantiate standard library
3524 templates, even when an explicit instantiation does not depend on
3525 a user-defined name. <i>--end note</i>]
3529 <p>The LWG rejected this because it was believed that it would make
3530 it unnecessarily difficult for library implementors to write
3531 high-quality implementations. A program may not include an
3532 explicit instantiation of the same template, for the same template
3533 arguments, in two different translation units. If users are
3534 allowed to provide explicit instantiations of Standard Library
3535 templates for built-in types, then library implementors aren't,
3536 at least not without nonportable tricks.</p>
3538 <p>The most serious problem is a class template that has writeable
3539 static member variables. Unfortunately, such class templates are
3540 important and, in existing Standard Library implementations, are
3541 often explicitly specialized by library implementors: locale facets,
3542 which have a writeable static member variable <tt>id</tt>. If a
3543 user's explicit instantiation collided with the implementations
3544 explicit instantiation, iostream initialization could cause locales
3545 to be constructed in an inconsistent state.</p>
3547 <p>One proposed implementation technique was for Standard Library
3548 implementors to provide explicit instantiations in separate object
3549 files, so that they would not be picked up by the linker when the
3550 user also provides an explicit instantiation. However, this
3551 technique only applies for Standard Library implementations that
3552 are packaged as static archives. Most Standard Library
3553 implementations nowadays are packaged as dynamic libraries, so this
3554 technique would not apply.</p>
3556 <p>The Committee is now considering standardization of dynamic
3557 linking. If there are such changes in the future, it may be
3558 appropriate to revisit this issue later.</p>
3560 <a name="122"><h3>122. streambuf/wstreambuf description should not say they are specializations</h3></a><p><b>Section:</b> 27.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf"> [lib.streambuf]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998</p>
3561 <p>Section 27.5.2 describes the streambuf classes this way: </p>
3565 <p>The class streambuf is a specialization of the template class basic_streambuf
3566 specialized for the type char. </p>
3568 <p>The class wstreambuf is a specialization of the template class basic_streambuf
3569 specialized for the type wchar_t. </p>
3573 <p>This implies that these classes must be template specializations, not typedefs. </p>
3575 <p>It doesn't seem this was intended, since Section 27.5 has them declared as typedefs. </p>
3576 <p><b>Proposed resolution:</b></p>
3577 <p>Remove 27.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf"> [lib.streambuf]</a> paragraphs 2 and 3 (the above two
3579 <p><b>Rationale:</b></p>
3580 <p>The <tt>streambuf</tt> synopsis already has a declaration for the
3581 typedefs and that is sufficient. </p>
3583 <a name="123"><h3>123. Should valarray helper arrays fill functions be const?</h3></a><p><b>Section:</b> 26.5.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.slice.arr.fill"> [lib.slice.arr.fill]</a>, 26.5.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.gslice.array.fill"> [lib.gslice.array.fill]</a>, 26.5.8.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.mask.array.fill"> [lib.mask.array.fill]</a>, 26.5.9.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.indirect.array.fill"> [lib.indirect.array.fill]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998 </p>
3584 <p>One of the operator= in the valarray helper arrays is const and one
3585 is not. For example, look at slice_array. This operator= in Section
3586 26.5.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.slice.arr.assign"> [lib.slice.arr.assign]</a> is const: </p>
3588 <p> <tt>void operator=(const valarray<T>&) const;</tt> </p>
3590 <p>but this one in Section 26.5.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.slice.arr.fill"> [lib.slice.arr.fill]</a> is not: </p>
3592 <p> <tt>void operator=(const T&); </tt></p>
3594 <p>The description of the semantics for these two functions is similar. </p>
3595 <p><b>Proposed resolution:</b></p>
3597 <p>26.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.slice.array"> [lib.template.slice.array]</a> Template class slice_array</p>
3600 <p>In the class template definition for slice_array, replace the member
3601 function declaration</p>
3602 <pre> void operator=(const T&);
3605 <pre> void operator=(const T&) const;
3609 <p>26.5.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.slice.arr.fill"> [lib.slice.arr.fill]</a> slice_array fill function</p>
3612 <p>Change the function declaration</p>
3613 <pre> void operator=(const T&);
3616 <pre> void operator=(const T&) const;
3620 <p>26.5.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.gslice.array"> [lib.template.gslice.array]</a> Template class gslice_array</p>
3623 <p>In the class template definition for gslice_array, replace the member
3624 function declaration</p>
3625 <pre> void operator=(const T&);
3628 <pre> void operator=(const T&) const;
3632 <p>26.5.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.gslice.array.fill"> [lib.gslice.array.fill]</a> gslice_array fill function</p>
3635 <p>Change the function declaration</p>
3636 <pre> void operator=(const T&);
3639 <pre> void operator=(const T&) const;
3643 <p>26.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.mask.array"> [lib.template.mask.array]</a> Template class mask_array</p>
3646 <p>In the class template definition for mask_array, replace the member
3647 function declaration</p>
3648 <pre> void operator=(const T&);
3651 <pre> void operator=(const T&) const;
3655 <p>26.5.8.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.mask.array.fill"> [lib.mask.array.fill]</a> mask_array fill function</p>
3658 <p>Change the function declaration</p>
3659 <pre> void operator=(const T&);
3662 <pre> void operator=(const T&) const;
3666 <p>26.5.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.indirect.array"> [lib.template.indirect.array]</a> Template class indirect_array</p>
3669 <p>In the class template definition for indirect_array, replace the member
3670 function declaration</p>
3671 <pre> void operator=(const T&);
3674 <pre> void operator=(const T&) const;
3678 <p>26.5.9.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.indirect.array.fill"> [lib.indirect.array.fill]</a> indirect_array fill function</p>
3681 <p>Change the function declaration</p>
3682 <pre> void operator=(const T&);
3685 <pre> void operator=(const T&) const;
3690 <p><i>[Redmond: Robert provided wording.]</i></p>
3692 <p><b>Rationale:</b></p>
3693 <p>There's no good reason for one version of operator= being const and
3694 another one not. Because of issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#253">253</a>, this now
3695 matters: these functions are now callable in more circumstances. In
3696 many existing implementations, both versions are already const.</p>
3698 <a name="124"><h3>124. ctype_byname<charT>::do_scan_is & do_scan_not return type should be const charT*</h3></a><p><b>Section:</b> 22.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.byname"> [lib.locale.ctype.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998</p>
3699 <p>In Section 22.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.byname"> [lib.locale.ctype.byname]</a>
3700 ctype_byname<charT>::do_scan_is() and do_scan_not() are declared
3701 to return a const char* not a const charT*. </p>
3702 <p><b>Proposed resolution:</b></p>
3703 <p>Change Section 22.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.byname"> [lib.locale.ctype.byname]</a> <tt>do_scan_is()</tt> and
3704 <tt>do_scan_not()</tt> to return a <tt> const
3707 <a name="125"><h3>125. valarray<T>::operator!() return type is inconsistent</h3></a><p><b>Section:</b> 26.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex"> [lib.complex]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998</p>
3708 <p>In Section 26.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex"> [lib.complex]</a> valarray<T>::operator!() is
3709 declared to return a valarray<T>, but in Section <font color="red">26.3.2.5</font> it is declared to return a valarray<bool>. The
3710 latter appears to be correct. </p>
3711 <p><b>Proposed resolution:</b></p>
3712 <p>Change in Section 26.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex"> [lib.complex]</a> the declaration of
3713 <tt>operator!()</tt> so that the return type is
3714 <tt>valarray<bool></tt>. </p>
3716 <a name="126"><h3>126. typos in Effects clause of ctype::do_narrow()</h3></a><p><b>Section:</b> 22.2.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.virtuals"> [lib.locale.ctype.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 15 Dec 1998</p>
3717 <p>Typos in 22.2.1.1.2 need to be fixed.</p>
3718 <p><b>Proposed resolution:</b></p>
3719 <p>In Section 22.2.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.virtuals"> [lib.locale.ctype.virtuals]</a> change: </p>
3721 <pre> do_widen(do_narrow(c),0) == c</pre>
3725 <pre> do_widen(do_narrow(c,0)) == c</pre>
3729 <pre> (is(M,c) || !ctc.is(M, do_narrow(c),dfault) )</pre>
3733 <pre> (is(M,c) || !ctc.is(M, do_narrow(c,dfault)) )</pre>
3735 <a name="127"><h3>127. auto_ptr<> conversion issues</h3></a><p><b>Section:</b> 20.4.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.unary"> [lib.meta.unary]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Greg Colvin <b>Date:</b> 17 Feb 1999</p>
3736 <p>There are two problems with the current <tt>auto_ptr</tt> wording
3737 in the standard: </p>
3739 <p>First, the <tt>auto_ptr_ref</tt> definition cannot be nested
3740 because <tt>auto_ptr<Derived>::auto_ptr_ref</tt> is unrelated to
3741 <tt>auto_ptr<Base>::auto_ptr_ref</tt>. <i>Also submitted by
3742 Nathan Myers, with the same proposed resolution.</i></p>
3744 <p>Second, there is no <tt>auto_ptr</tt> assignment operator taking an
3745 <tt>auto_ptr_ref</tt> argument. </p>
3747 <p>I have discussed these problems with my proposal coauthor, Bill
3748 Gibbons, and with some compiler and library implementors, and we
3749 believe that these problems are not desired or desirable implications
3750 of the standard. </p>
3752 <p>25 Aug 1999: The proposed resolution now reflects changes suggested
3753 by Dave Abrahams, with Greg Colvin's concurrence; 1) changed
3754 "assignment operator" to "public assignment
3755 operator", 2) changed effects to specify use of release(), 3)
3756 made the conversion to auto_ptr_ref const. </p>
3758 <p>2 Feb 2000: Lisa Lippincott comments: [The resolution of] this issue
3759 states that the conversion from auto_ptr to auto_ptr_ref should
3760 be const. This is not acceptable, because it would allow
3761 initialization and assignment from _any_ const auto_ptr! It also
3762 introduces an implementation difficulty in writing this conversion
3763 function -- namely, somewhere along the line, a const_cast will be
3764 necessary to remove that const so that release() may be called. This
3765 may result in undefined behavior [7.1.5.1/4]. The conversion
3766 operator does not have to be const, because a non-const implicit
3767 object parameter may be bound to an rvalue [13.3.3.1.4/3]
3770 <p>Tokyo: The LWG removed the following from the proposed resolution:</p>
3772 <p>In 20.4.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.unary"> [lib.meta.unary]</a>, paragraph 2, and 20.4.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.unary.prop"> [lib.meta.unary.prop]</a>,
3773 paragraph 2, make the conversion to auto_ptr_ref const:</p>
3775 <pre>template<class Y> operator auto_ptr_ref<Y>() const throw();</pre>
3777 <p><b>Proposed resolution:</b></p>
3778 <p>In 20.4.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.unary"> [lib.meta.unary]</a>, paragraph 2, move
3779 the <tt>auto_ptr_ref</tt> definition to namespace scope.</p>
3781 <p>In 20.4.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.unary"> [lib.meta.unary]</a>, paragraph 2, add
3782 a public assignment operator to the <tt>auto_ptr</tt> definition: </p>
3785 <pre>auto_ptr& operator=(auto_ptr_ref<X> r) throw();</pre>
3788 <p>Also add the assignment operator to 20.4.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.unary.prop"> [lib.meta.unary.prop]</a>: </p>
3791 <pre>auto_ptr& operator=(auto_ptr_ref<X> r) throw()</pre>
3793 <b>Effects:</b> Calls <tt>reset(p.release())</tt> for the <tt>auto_ptr
3794 p</tt> that <tt>r</tt> holds a reference to.<br>
3795 <b>Returns: </b><tt>*this</tt>.
3799 <a name="129"><h3>129. Need error indication from seekp() and seekg()</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>, 27.6.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.seeks"> [lib.ostream.seeks]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> 22 Feb 1999</p>
3800 <p>Currently, the standard does not specify how seekg() and seekp()
3801 indicate failure. They are not required to set failbit, and they can't
3802 return an error indication because they must return *this, i.e. the
3803 stream. Hence, it is undefined what happens if they fail. And they
3804 <i>can</i> fail, for instance, when a file stream is disconnected from the
3805 underlying file (is_open()==false) or when a wide character file
3806 stream must perform a state-dependent code conversion, etc. </p>
3808 <p>The stream functions seekg() and seekp() should set failbit in the
3809 stream state in case of failure.</p>
3810 <p><b>Proposed resolution:</b></p>
3811 <p>Add to the Effects: clause of seekg() in
3812 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> and to the Effects: clause of seekp() in
3813 27.6.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.seeks"> [lib.ostream.seeks]</a>: </p>
3816 <p>In case of failure, the function calls <tt>setstate(failbit)</tt> (which may throw <tt>ios_base::failure</tt>).
3819 <p><b>Rationale:</b></p>
3820 <p>Setting failbit is the usual error reporting mechanism for streams</p>
3822 <a name="130"><h3>130. Return type of container::erase(iterator) differs for associative containers</h3></a><p><b>Section:</b> 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a>, 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 2 Mar 1999</p>
3823 <p>Table 67 (23.1.1) says that container::erase(iterator) returns an
3824 iterator. Table 69 (23.1.2) says that in addition to this requirement,
3825 associative containers also say that container::erase(iterator)
3826 returns void. That's not an addition; it's a change to the
3827 requirements, which has the effect of making associative containers
3828 fail to meet the requirements for containers.</p>
3829 <p><b>Proposed resolution:</b></p>
3832 In 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a>, in Table 69 Associative container
3833 requirements, change the return type of <tt>a.erase(q)</tt> from
3834 <tt>void</tt> to <tt>iterator</tt>. Change the
3835 assertion/not/pre/post-condition from "erases the element pointed to
3836 by <tt>q</tt>" to "erases the element pointed to by <tt>q</tt>.
3837 Returns an iterator pointing to the element immediately following q
3838 prior to the element being erased. If no such element exists, a.end()
3843 In 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a>, in Table 69 Associative container
3844 requirements, change the return type of <tt>a.erase(q1, q2)</tt>
3845 from <tt>void</tt> to <tt>iterator</tt>. Change the
3846 assertion/not/pre/post-condition from "erases the elements in the
3847 range <tt>[q1, q2)</tt>" to "erases the elements in the range <tt>[q1,
3848 q2)</tt>. Returns q2."
3852 In 23.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map"> [lib.map]</a>, in the <tt>map</tt> class synopsis; and
3853 in 23.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.multimap"> [lib.multimap]</a>, in the <tt>multimap</tt> class synopsis; and
3854 in 23.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.set"> [lib.set]</a>, in the <tt>set</tt> class synopsis; and
3855 in 23.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.multiset"> [lib.multiset]</a>, in the <tt>multiset</tt> class synopsis:
3856 change the signature of the first <tt>erase</tt> overload to
3858 <pre> iterator erase(iterator position);
3860 <p>and change the signature of the third <tt>erase</tt> overload to</p>
3861 <pre> iterator erase(iterator first, iterator last);
3865 <p><i>[Pre-Kona: reopened at the request of Howard Hinnant]</i></p>
3867 <p><i>[Post-Kona: the LWG agrees the return type should be
3868 <tt>iterator</tt>, not <tt>void</tt>. (Alex Stepanov agrees too.)
3869 Matt provided wording.]</i></p>
3872 Sydney: the proposed wording went in the right direction, but it
3873 wasn't good enough. We want to return an iterator from the range form
3874 of erase as well as the single-iterator form. Also, the wording is
3875 slightly different from the wording we have for sequences; there's no
3876 good reason for having a difference. Matt provided new wording,
3877 which we will review at the next meeting.
3881 <a name="132"><h3>132. list::resize description uses random access iterators</h3></a><p><b>Section:</b> 23.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.capacity"> [lib.deque.capacity]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 6 Mar 1999</p>
3882 <p>The description reads:</p>
3886 <pre> if (sz > size())
3887 insert(end(), sz-size(), c);
3888 else if (sz < size())
3889 erase(begin()+sz, end());
3891 ; // do nothing</pre>
3893 <p>Obviously list::resize should not be specified in terms of random access iterators.</p>
3894 <p><b>Proposed resolution:</b></p>
3895 <p>Change 23.2.2.2 paragraph 1 to:</p>
3899 <pre> if (sz > size())
3900 insert(end(), sz-size(), c);
3901 else if (sz < size())
3903 iterator i = begin();
3908 <p><i>[Dublin: The LWG asked Howard to discuss exception safety offline
3909 with David Abrahams. They had a discussion and believe there is
3910 no issue of exception safety with the proposed resolution.]</i></p>
3912 <a name="133"><h3>133. map missing get_allocator()</h3></a><p><b>Section:</b> 23.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map"> [lib.map]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 6 Mar 1999</p>
3913 <p>The title says it all.</p>
3914 <p><b>Proposed resolution:</b></p>
3915 <p>Insert in 23.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map"> [lib.map]</a>, paragraph 2,
3916 after operator= in the map declaration:</p>
3918 <pre> allocator_type get_allocator() const;</pre>
3920 <a name="134"><h3>134. vector constructors over specified</h3></a><p><b>Section:</b> 23.2.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.queue"> [lib.queue]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 6 Mar 1999</p>
3921 <p>The complexity description says: "It does at most 2N calls to the copy constructor
3922 of T and logN reallocations if they are just input iterators ...".</p>
3924 <p>This appears to be overly restrictive, dictating the precise memory/performance
3925 tradeoff for the implementor.</p>
3926 <p><b>Proposed resolution:</b></p>
3927 <p>Change 23.2.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.queue"> [lib.queue]</a>, paragraph 1 to:</p>
3929 <p>-1- Complexity: The constructor template <class
3930 InputIterator> vector(InputIterator first, InputIterator last)
3931 makes only N calls to the copy constructor of T (where N is the
3932 distance between first and last) and no reallocations if iterators
3933 first and last are of forward, bidirectional, or random access
3934 categories. It makes order N calls to the copy constructor of T and
3935 order logN reallocations if they are just input iterators.
3937 <p><b>Rationale:</b></p>
3938 <p>"at most 2N calls" is correct only if the growth factor
3939 is greater than or equal to 2.
3942 <a name="136"><h3>136. seekp, seekg setting wrong streams?</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 6 Mar 1999</p>
3943 <p>I may be misunderstanding the intent, but should not seekg set only
3944 the input stream and seekp set only the output stream? The description
3945 seems to say that each should set both input and output streams. If
3946 that's really the intent, I withdraw this proposal.</p>
3947 <p><b>Proposed resolution:</b></p>
3948 <p>In section 27.6.1.3 change:</p>
3950 <pre>basic_istream<charT,traits>& seekg(pos_type pos);
3951 Effects: If fail() != true, executes rdbuf()->pubseekpos(pos). </pre>
3955 <pre>basic_istream<charT,traits>& seekg(pos_type pos);
3956 Effects: If fail() != true, executes rdbuf()->pubseekpos(pos, ios_base::in). </pre>
3958 <p>In section 27.6.1.3 change:</p>
3960 <pre>basic_istream<charT,traits>& seekg(off_type& off, ios_base::seekdir dir);
3961 Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir). </pre>
3965 <pre>basic_istream<charT,traits>& seekg(off_type& off, ios_base::seekdir dir);
3966 Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir, ios_base::in). </pre>
3968 <p>In section 27.6.2.4, paragraph 2 change:</p>
3970 <pre>-2- Effects: If fail() != true, executes rdbuf()->pubseekpos(pos). </pre>
3974 <pre>-2- Effects: If fail() != true, executes rdbuf()->pubseekpos(pos, ios_base::out). </pre>
3976 <p>In section 27.6.2.4, paragraph 4 change:</p>
3978 <pre>-4- Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir). </pre>
3982 <pre>-4- Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir, ios_base::out). </pre>
3984 <p><i>[Dublin: Dietmar Kühl thinks this is probably correct, but would
3985 like the opinion of more iostream experts before taking action.]</i></p>
3987 <p><i>[Tokyo: Reviewed by the LWG. PJP noted that although his docs are
3988 incorrect, his implementation already implements the Proposed
3989 Resolution.]</i></p>
3991 <p><i>[Post-Tokyo: Matt Austern comments:<br>
3992 Is it a problem with basic_istream and basic_ostream, or is it a problem
3993 with basic_stringbuf?
3994 We could resolve the issue either by changing basic_istream and
3995 basic_ostream, or by changing basic_stringbuf. I prefer the latter
3996 change (or maybe both changes): I don't see any reason for the standard to
3997 require that std::stringbuf s(std::string("foo"), std::ios_base::in);
3998 s.pubseekoff(0, std::ios_base::beg); must fail.<br>
3999 This requirement is a bit weird. There's no similar requirement
4000 for basic_streambuf<>::seekpos, or for basic_filebuf<>::seekoff or
4001 basic_filebuf<>::seekpos.]</i></p>
4003 <a name="137"><h3>137. Do use_facet and has_facet look in the global locale?</h3></a><p><b>Section:</b> 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> 17 Mar 1999</p>
4004 <p>Section 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> says:</p>
4006 <p>-4- In the call to use_facet<Facet>(loc), the type argument
4007 chooses a facet, making available all members of the named type. If
4008 Facet is not present in a locale (or, failing that, in the global
4009 locale), it throws the standard exception bad_cast. A C++ program can
4010 check if a locale implements a particular facet with the template
4011 function has_facet<Facet>(). </p>
4013 <p>This contradicts the specification given in section
4014 22.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.global.templates"> [lib.locale.global.templates]</a>:
4016 template <class Facet> const Facet& use_facet(const
4017 locale& loc); <br>
4019 -1- Get a reference to a facet of a locale. <br>
4020 -2- Returns: a reference to the corresponding facet of loc, if present. <br>
4021 -3- Throws: bad_cast if has_facet<Facet>(loc) is false. <br>
4022 -4- Notes: The reference returned remains valid at least as long as any copy of loc exists
4024 <p><b>Proposed resolution:</b></p>
4025 <p>Remove the phrase "(or, failing that, in the global locale)"
4026 from section 22.1.1. </p>
4027 <p><b>Rationale:</b></p>
4028 <p>Needed for consistency with the way locales are handled elsewhere
4029 in the standard.</p>
4031 <a name="139"><h3>139. Optional sequence operation table description unclear</h3></a><p><b>Section:</b> 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 30 Mar 1999</p>
4032 <p>The sentence introducing the Optional sequence operation table
4033 (23.1.1 paragraph 12) has two problems:</p>
4035 <p>A. It says ``The operations in table 68 are provided only for the containers for which
4036 they take constant time.''<br>
4038 That could be interpreted in two ways, one of them being ``Even though table 68 shows
4039 particular operations as being provided, implementations are free to omit them if they
4040 cannot implement them in constant time.''<br>
4042 B. That paragraph says nothing about amortized constant time, and it should. </p>
4043 <p><b>Proposed resolution:</b></p>
4044 <p>Replace the wording in 23.1.1 paragraph 12 which begins ``The operations in table 68 are provided only..."
4048 <p>Table 68 lists sequence operations that are provided for some types of sequential
4049 containers but not others. An implementation shall provide these operations for all
4050 container types shown in the ``container'' column, and shall implement them so as to take
4051 amortized constant time.</p>
4054 <a name="141"><h3>141. basic_string::find_last_of, find_last_not_of say pos instead of xpos</h3></a><p><b>Section:</b> 21.3.6.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::find.last.of"> [lib.string::find.last.of]</a>, 21.3.6.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::find.last.not.of"> [lib.string::find.last.not.of]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Arch Robison <b>Date:</b> 28 Apr 1999</p>
4055 <p>Sections 21.3.6.4 paragraph 1 and 21.3.6.6 paragraph 1 surely have misprints where they
4058 — <tt>xpos <= pos</tt> and <tt>pos < size();</tt></p>
4060 <p>Surely the document meant to say ``<tt>xpos < size()</tt>'' in both places.</p>
4062 <p><i>[Judy Ward also sent in this issue for 21.3.6.4 with the same
4063 proposed resolution.]</i></p>
4064 <p><b>Proposed resolution:</b></p>
4065 <p>Change Sections 21.3.6.4 paragraph 1 and 21.3.6.6 paragraph 1, the line which says:<br>
4067 — <tt>xpos <= pos</tt> and <tt>pos < size();<br>
4071 </tt>— <tt>xpos <= pos</tt> and <tt>xpos < size();</tt></p>
4073 <a name="142"><h3>142. lexicographical_compare complexity wrong</h3></a><p><b>Section:</b> 25.3.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.lex.comparison"> [lib.alg.lex.comparison]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 20 Jun 1999</p>
4074 <p>The lexicographical_compare complexity is specified as:<br>
4076 "At most min((last1 - first1), (last2 - first2))
4077 applications of the corresponding comparison."<br>
4079 The best I can do is twice that expensive.</p>
4081 <p>Nicolai Josuttis comments in lib-6862: You mean, to check for
4082 equality you have to check both < and >? Yes, IMO you are
4083 right! (and Matt states this complexity in his book)</p>
4085 <p><b>Proposed resolution:</b></p>
4086 <p>Change 25.3.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.lex.comparison"> [lib.alg.lex.comparison]</a> complexity to:</p>
4088 At most <tt>2*min((last1 - first1), (last2 - first2))</tt>
4089 applications of the corresponding comparison.
4092 <p>Change the example at the end of paragraph 3 to read:</p>
4096 for ( ; first1 != last1 && first2 != last2 ;
4097 ++first1, ++first2) {<br>
4098 if (*first1 < *first2) return true;<br>
4099 if (*first2 < *first1) return false;<br>
4100 }<br>
4101 return first1 == last1 && first2 != last2;<br>
4102 <br>
4106 <a name="144"><h3>144. Deque constructor complexity wrong </h3></a><p><b>Section:</b> 23.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.array.cons"> [lib.array.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Herb Sutter <b>Date:</b> 9 May 1999</p>
4107 <p>In 23.2.1.1 paragraph 6, the deque ctor that takes an iterator range appears
4108 to have complexity requirements which are incorrect, and which contradict the
4109 complexity requirements for insert(). I suspect that the text in question,
4110 below, was taken from vector:</p>
4112 <p>Complexity: If the iterators first and last are forward iterators,
4113 bidirectional iterators, or random access iterators the constructor makes only
4114 N calls to the copy constructor, and performs no reallocations, where N is
4117 <p>The word "reallocations" does not really apply to deque. Further,
4118 all of the following appears to be spurious:</p>
4120 <p>It makes at most 2N calls to the copy constructor of T and log N
4121 reallocations if they are input iterators.1)</p>
4122 <p>1) The complexity is greater in the case of input iterators because each
4123 element must be added individually: it is impossible to determine the distance
4124 between first abd last before doing the copying.</p>
4126 <p>This makes perfect sense for vector, but not for deque. Why should deque gain
4127 an efficiency advantage from knowing in advance the number of elements to
4129 <p><b>Proposed resolution:</b></p>
4130 <p>In 23.2.1.1 paragraph 6, replace the Complexity description, including the
4131 footnote, with the following text (which also corrects the "abd"
4134 <p>Complexity: Makes last - first calls to the copy constructor of T.</p>
4137 <a name="146"><h3>146. complex<T> Inserter and Extractor need sentries</h3></a><p><b>Section:</b> 26.3.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.ops"> [lib.complex.ops]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> 12 May 1999</p>
4138 <p>The <u> extractor</u> for complex numbers is specified as: </p>
4142 <p> template<class T, class charT, class traits> <br>
4143 basic_istream<charT, traits>& <br>
4144 operator>>(basic_istream<charT, traits>& is, complex<T>& x);<br>
4146 Effects: Extracts a complex number x of the form: u, (u), or (u,v),
4147 where u is the real part and v is the imaginary part
4148 (lib.istream.formatted). <br>
4149 Requires: The input values be convertible to T. If bad input is
4150 encountered, calls is.setstate(ios::failbit) (which may throw
4151 ios::failure (lib.iostate.flags). <br>
4155 <p>Is it intended that the extractor for complex numbers does not skip
4156 whitespace, unlike all other extractors in the standard library do?
4157 Shouldn't a sentry be used? <br>
4159 The <u>inserter</u> for complex numbers is specified as:</p>
4163 <p> template<class T, class charT, class traits> <br>
4164 basic_ostream<charT, traits>& <br>
4165 operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);<br>
4167 Effects: inserts the complex number x onto the stream o as if it were implemented as follows:<br>
4169 template<class T, class charT, class traits> <br>
4170 basic_ostream<charT, traits>& <br>
4171 operator<<(basic_ostream<charT, traits>& o, const complex<T>& x) <br>
4173 basic_ostringstream<charT, traits> s; <br>
4174 s.flags(o.flags()); <br>
4175 s.imbue(o.getloc()); <br>
4176 s.precision(o.precision()); <br>
4177 s << '(' << x.real() << "," << x.imag() << ')'; <br>
4178 return o << s.str(); <br>
4183 <p>Is it intended that the inserter for complex numbers ignores the
4184 field width and does not do any padding? If, with the suggested
4185 implementation above, the field width were set in the stream then the
4186 opening parentheses would be adjusted, but the rest not, because the
4187 field width is reset to zero after each insertion.</p>
4189 <p>I think that both operations should use sentries, for sake of
4190 consistency with the other inserters and extractors in the
4191 library. Regarding the issue of padding in the inserter, I don't know
4192 what the intent was. </p>
4193 <p><b>Proposed resolution:</b></p>
4194 <p>After 26.3.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex.ops"> [lib.complex.ops]</a> paragraph 14 (operator>>), add a
4199 <p>Notes: This extraction is performed as a series of simpler
4200 extractions. Therefore, the skipping of whitespace is specified to be the
4201 same for each of the simpler extractions.</p>
4204 <p><b>Rationale:</b></p>
4205 <p>For extractors, the note is added to make it clear that skipping whitespace
4206 follows an "all-or-none" rule.</p>
4208 <p>For inserters, the LWG believes there is no defect; the standard is correct
4211 <a name="147"><h3>147. Library Intro refers to global functions that aren't global</h3></a><p><b>Section:</b> 17.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.global.functions"> [lib.global.functions]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Lois Goldthwaite <b>Date:</b> 4 Jun 1999</p>
4212 <p>The library had many global functions until 17.4.1.1 [lib.contents]
4213 paragraph 2 was added: </p>
4217 <p>All library entities except macros, operator new and operator
4218 delete are defined within the namespace std or namespaces nested
4219 within namespace std. </p>
4223 <p>It appears "global function" was never updated in the following: </p>
4227 <p>17.4.4.3 - Global functions [lib.global.functions]<br>
4229 -1- It is unspecified whether any global functions in the C++ Standard
4230 Library are defined as inline (dcl.fct.spec).<br>
4232 -2- A call to a global function signature described in Clauses
4233 lib.language.support through lib.input.output behaves the same as if
4234 the implementation declares no additional global function
4237 [Footnote: A valid C++ program always calls the expected library
4238 global function. An implementation may also define additional
4239 global functions that would otherwise not be called by a valid C++
4240 program. --- end footnote]<br>
4242 -3- A global function cannot be declared by the implementation as
4243 taking additional default arguments. <br>
4245 17.4.4.4 - Member functions [lib.member.functions]<br>
4247 -2- An implementation can declare additional non-virtual member
4248 function signatures within a class: </p>
4252 <p>-- by adding arguments with default values to a member function
4253 signature; The same latitude does not extend to the implementation of
4254 virtual or global functions, however. </p>
4258 <p><b>Proposed resolution:</b></p>
4259 <p> Change "global" to "global or non-member" in:</p>
4261 <p>17.4.4.3 [lib.global.functions] section title,<br>
4262 17.4.4.3 [lib.global.functions] para 1,<br>
4263 17.4.4.3 [lib.global.functions] para 2 in 2 places plus 2
4264 places in the footnote,<br>
4265 17.4.4.3 [lib.global.functions] para 3,<br>
4266 17.4.4.4 [lib.member.functions] para 2</p>
4268 <p><b>Rationale:</b></p>
4270 Because operator new and delete are global, the proposed resolution
4271 was changed from "non-member" to "global or non-member.
4274 <a name="148"><h3>148. Functions in the example facet BoolNames should be const</h3></a><p><b>Section:</b> 22.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facets.examples"> [lib.facets.examples]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Jeremy Siek <b>Date:</b> 3 Jun 1999</p>
4275 <p>In 22.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facets.examples"> [lib.facets.examples]</a> paragraph 13, the do_truename() and
4276 do_falsename() functions in the example facet BoolNames should be
4277 const. The functions they are overriding in
4278 numpunct_byname<char> are const. </p>
4279 <p><b>Proposed resolution:</b></p>
4280 <p>In 22.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facets.examples"> [lib.facets.examples]</a> paragraph 13, insert "const" in
4283 <p><tt>string do_truename() const { return "Oui Oui!"; }<br>
4284 string do_falsename() const { return "Mais Non!"; }</tt></p>
4287 <a name="150"><h3>150. Find_first_of says integer instead of iterator </h3></a><p><b>Section:</b> 25.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.find.first.of"> [lib.alg.find.first.of]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt McClure <b>Date:</b> 30 Jun 1999</p>
4288 <p><b>Proposed resolution:</b></p>
4289 <p>Change 25.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.find.first.of"> [lib.alg.find.first.of]</a> paragraph 2 from:</p>
4292 <p>Returns: The first iterator i in the range [first1, last1) such
4293 that for some <u>integer</u> j in the range [first2, last2) ...</p>
4299 <p>Returns: The first iterator i in the range [first1, last1) such
4300 that for some iterator j in the range [first2, last2) ...</p>
4303 <a name="151"><h3>151. Can't currently clear() empty container</h3></a><p><b>Section:</b> 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Ed Brey <b>Date:</b> 21 Jun 1999</p>
4304 <p>For both sequences and associative containers, a.clear() has the
4305 semantics of erase(a.begin(),a.end()), which is undefined for an empty
4306 container since erase(q1,q2) requires that q1 be dereferenceable
4307 (23.1.1,3 and 23.1.2,7). When the container is empty, a.begin() is
4308 not dereferenceable.<br>
4310 The requirement that q1 be unconditionally dereferenceable causes many
4311 operations to be intuitively undefined, of which clearing an empty
4312 container is probably the most dire.<br>
4314 Since q1 and q2 are only referenced in the range [q1, q2), and [q1,
4315 q2) is required to be a valid range, stating that q1 and q2 must be
4316 iterators or certain kinds of iterators is unnecessary.
4318 <p><b>Proposed resolution:</b></p>
4319 <p>In 23.1.1, paragraph 3, change:</p>
4321 <p>p and q2 denote valid iterators to a, q <u> and q1</u> denote valid dereferenceable iterators to a, [q1, q2) denotes a valid range</p>
4325 <p>p denotes a valid iterator to a, q denotes a valid dereferenceable iterator to a, [q1, q2) denotes a valid range<u>
4328 <p>In 23.1.2, paragraph 7, change:</p>
4330 <p>p and q2 are valid iterators to a, q <u> and q1</u> are valid dereferenceable
4331 iterators to a, [q1, q2) is a valid range</p>
4335 <p>p is a valid iterator to a, q is a valid dereferenceable iterator to a, [q1, q2) is a valid range
4339 <a name="152"><h3>152. Typo in <tt>scan_is()</tt> semantics</h3></a><p><b>Section:</b> 22.2.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.virtuals"> [lib.locale.ctype.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4340 <p>The semantics of <tt>scan_is()</tt> (paragraphs 4 and 6) is not exactly described
4341 because there is no function <tt>is()</tt> which only takes a character as
4342 argument. Also, in the effects clause (paragraph 3), the semantic is also kept
4344 <p><b>Proposed resolution:</b></p>
4345 <p>In 22.2.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.virtuals"> [lib.locale.ctype.virtuals]</a> paragraphs 4 and 6, change the returns
4348 <p>"... such that <tt>is(*p)</tt>
4351 <p>to: "... such that <tt>is(m, *p)</tt>
4354 <a name="153"><h3>153. Typo in <tt>narrow()</tt> semantics</h3></a><p><b>Section:</b> 22.2.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.ctype.char.members"> [lib.facet.ctype.char.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4355 <p>The description of the array version of <tt>narrow()</tt> (in
4356 paragraph 11) is flawed: There is no member <tt>do_narrow()</tt> which
4357 takes only three arguments because in addition to the range a default
4358 character is needed.</p>
4360 <p>Additionally, for both <tt>widen</tt> and <tt>narrow</tt> we have
4361 two signatures followed by a <b>Returns</b> clause that only addresses
4364 <p><b>Proposed resolution:</b></p>
4365 <p>Change the returns clause in 22.2.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.ctype.char.members"> [lib.facet.ctype.char.members]</a>
4366 paragraph 10 from:</p>
4367 <p> Returns: do_widen(low, high, to).</p>
4370 <p> Returns: do_widen(c) or do_widen(low, high, to),
4373 <p>Change 22.2.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.ctype.char.members"> [lib.facet.ctype.char.members]</a> paragraph 10 and 11 from:</p>
4374 <pre> char narrow(char c, char /*dfault*/) const;
4375 const char* narrow(const char* low, const char* high,
4376 char /*dfault*/, char* to) const;</pre>
4377 <pre> Returns: do_narrow(low, high, to).</pre>
4379 <pre> char narrow(char c, char dfault) const;
4380 const char* narrow(const char* low, const char* high,
4381 char dfault, char* to) const;</pre>
4382 <pre> Returns: do_narrow(c, dfault) or
4383 do_narrow(low, high, dfault, to), respectively.</pre>
4385 <p><i>[Kona: 1) the problem occurs in additional places, 2) a user
4386 defined version could be different.]</i></p>
4388 <p><i>[Post-Tokyo: Dietmar provided the above wording at the request of
4389 the LWG. He could find no other places the problem occurred. He
4390 asks for clarification of the Kona "a user defined
4391 version..." comment above. Perhaps it was a circuitous way of
4392 saying "dfault" needed to be uncommented?]</i></p>
4394 <p><i>[Post-Toronto: the issues list maintainer has merged in the
4395 proposed resolution from issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#207">207</a>, which addresses the
4396 same paragraphs.]</i></p>
4398 <a name="154"><h3>154. Missing <tt>double</tt> specifier for <tt>do_get()</tt>
4399 </h3></a><p><b>Section:</b> 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4400 <p>The table in paragraph 7 for the length modifier does not list the length
4401 modifier <tt>l</tt> to be applied if the type is <tt>double</tt>. Thus, the
4402 standard asks the implementation to do undefined things when using <tt>scanf()</tt>
4403 (the missing length modifier for <tt>scanf()</tt> when scanning <tt>double</tt>s
4404 is actually a problem I found quite often in production code, too).</p>
4405 <p><b>Proposed resolution:</b></p>
4406 <p>In 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a>, paragraph 7, add a row in the Length
4407 Modifier table to say that for <tt>double</tt> a length modifier
4408 <tt>l</tt> is to be used.</p>
4409 <p><b>Rationale:</b></p>
4410 <p>The standard makes an embarrassing beginner's mistake.</p>
4412 <a name="155"><h3>155. Typo in naming the class defining the class <tt>Init</tt>
4413 </h3></a><p><b>Section:</b> 27.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostream.objects"> [lib.iostream.objects]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4414 <p>There are conflicting statements about where the class
4415 <tt>Init</tt> is defined. According to 27.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostream.objects"> [lib.iostream.objects]</a> paragraph 2
4416 it is defined as <tt>basic_ios::Init</tt>, according to 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a> it is defined as <tt>ios_base::Init</tt>.</p>
4417 <p><b>Proposed resolution:</b></p>
4418 <p>Change 27.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostream.objects"> [lib.iostream.objects]</a> paragraph 2 from
4419 "<tt>basic_ios::Init"</tt> to
4420 "<tt>ios_base::Init"</tt>.</p>
4421 <p><b>Rationale:</b></p>
4422 <p>Although not strictly wrong, the standard was misleading enough to warrant
4425 <a name="156"><h3>156. Typo in <tt>imbue()</tt> description</h3></a><p><b>Section:</b> 27.4.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.locales"> [lib.ios.base.locales]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4426 <p>There is a small discrepancy between the declarations of
4427 <tt>imbue()</tt>: in 27.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base"> [lib.ios.base]</a> the argument is passed as
4428 <tt>locale const&</tt> (correct), in 27.4.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.locales"> [lib.ios.base.locales]</a> it
4429 is passed as <tt>locale const</tt> (wrong).</p>
4430 <p><b>Proposed resolution:</b></p>
4431 <p>In 27.4.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.locales"> [lib.ios.base.locales]</a> change the <tt>imbue</tt> argument
4432 from "<tt>locale const" to "locale
4433 const&".</tt></p>
4435 <a name="158"><h3>158. Underspecified semantics for <tt>setbuf()</tt>
4436 </h3></a><p><b>Section:</b> 27.5.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.buffer"> [lib.streambuf.virt.buffer]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4437 <p>The default behavior of <tt>setbuf()</tt> is described only for the
4438 situation that <tt>gptr() != 0 && gptr() != egptr()</tt>:
4439 namely to do nothing. What has to be done in other situations
4440 is not described although there is actually only one reasonable
4441 approach, namely to do nothing, too.</p>
4443 <p>Since changing the buffer would almost certainly mess up most
4444 buffer management of derived classes unless these classes do it
4445 themselves, the default behavior of <tt>setbuf()</tt> should always be
4447 <p><b>Proposed resolution:</b></p>
4448 <p>Change 27.5.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.buffer"> [lib.streambuf.virt.buffer]</a>, paragraph 3, Default behavior,
4449 to: "Default behavior: Does nothing. Returns this."</p>
4451 <a name="159"><h3>159. Strange use of <tt>underflow()</tt>
4452 </h3></a><p><b>Section:</b> 27.5.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.get"> [lib.streambuf.virt.get]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4453 <p>The description of the meaning of the result of
4454 <tt>showmanyc()</tt> seems to be rather strange: It uses calls to
4455 <tt>underflow()</tt>. Using <tt>underflow()</tt> is strange because
4456 this function only reads the current character but does not extract
4457 it, <tt>uflow()</tt> would extract the current character. This should
4458 be fixed to use <tt>sbumpc()</tt> instead.</p>
4459 <p><b>Proposed resolution:</b></p>
4460 <p>Change 27.5.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.get"> [lib.streambuf.virt.get]</a> paragraph 1,
4461 <tt>showmanyc()</tt>returns clause, by replacing the word
4462 "supplied" with the words "extracted from the
4465 <a name="160"><h3>160. Typo: Use of non-existing function <tt>exception()</tt>
4466 </h3></a><p><b>Section:</b> 27.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream"> [lib.istream]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4467 <p>The paragraph 4 refers to the function <tt>exception()</tt> which
4468 is not defined. Probably, the referred function is
4469 <tt>basic_ios<>::exceptions()</tt>.</p>
4470 <p><b>Proposed resolution:</b></p>
4471 <p>In 27.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream"> [lib.istream]</a>, 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>, paragraph 1,
4472 27.6.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream"> [lib.ostream]</a>, paragraph 3, and 27.6.2.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.formatted.reqmts"> [lib.ostream.formatted.reqmts]</a>,
4473 paragraph 1, change "<tt>exception()" to
4474 "exceptions()"</tt>.</p>
4476 <p><i>[Note to Editor: "exceptions" with an "s"
4477 is the correct spelling.]</i></p>
4479 <a name="161"><h3>161. Typo: <tt>istream_iterator</tt> vs. <tt>istreambuf_iterator</tt>
4480 </h3></a><p><b>Section:</b> 27.6.1.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.arithmetic"> [lib.istream.formatted.arithmetic]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4481 <p>The note in the second paragraph pretends that the first argument
4482 is an object of type <tt>istream_iterator</tt>. This is wrong: It is
4483 an object of type <tt>istreambuf_iterator</tt>.</p>
4484 <p><b>Proposed resolution:</b></p>
4485 <p>Change 27.6.1.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.arithmetic"> [lib.istream.formatted.arithmetic]</a> from:</p>
4487 <p>The first argument provides an object of the istream_iterator class...</p>
4491 <p>The first argument provides an object of the istreambuf_iterator class...</p>
4494 <a name="164"><h3>164. do_put() has apparently unused fill argument</h3></a><p><b>Section:</b> 22.2.5.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.put.virtuals"> [lib.locale.time.put.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> 23 Jul 1999</p>
4495 <p>In 22.2.5.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.put.virtuals"> [lib.locale.time.put.virtuals]</a> the do_put() function is specified
4496 as taking a fill character as an argument, but the description of the
4497 function does not say whether the character is used at all and, if so,
4498 in which way. The same holds for any format control parameters that
4499 are accessible through the ios_base& argument, such as the
4500 adjustment or the field width. Is strftime() supposed to use the fill
4501 character in any way? In any case, the specification of
4502 time_put.do_put() looks inconsistent to me.<br> <br> Is the
4503 signature of do_put() wrong, or is the effects clause incomplete?</p>
4504 <p><b>Proposed resolution:</b></p>
4505 <p>Add the following note after 22.2.5.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.put.virtuals"> [lib.locale.time.put.virtuals]</a>
4508 <p> [Note: the <tt>fill</tt> argument may be used in the implementation-defined formats, or by derivations. A space character is a reasonable default
4509 for this argument. --end Note]</p>
4511 <p><b>Rationale:</b></p>
4512 <p>The LWG felt that while the normative text was correct,
4513 users need some guidance on what to pass for the <tt>fill</tt>
4514 argument since the standard doesn't say how it's used.</p>
4516 <a name="165"><h3>165. <tt>xsputn()</tt>, <tt>pubsync()</tt> never called by <tt>basic_ostream</tt> members?</h3></a><p><b>Section:</b> 27.6.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream"> [lib.ostream]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4517 <p>Paragraph 2 explicitly states that none of the <tt>basic_ostream</tt>
4518 functions falling into one of the groups "formatted output functions"
4519 and "unformatted output functions" calls any stream buffer function
4520 which might call a virtual function other than <tt>overflow()</tt>. Basically
4521 this is fine but this implies that <tt>sputn()</tt> (this function would call
4522 the virtual function <tt>xsputn()</tt>) is never called by any of the standard
4523 output functions. Is this really intended? At minimum it would be convenient to
4524 call <tt>xsputn()</tt> for strings... Also, the statement that <tt>overflow()</tt>
4525 is the only virtual member of <tt>basic_streambuf</tt> called is in conflict
4526 with the definition of <tt>flush()</tt> which calls <tt>rdbuf()->pubsync()</tt>
4527 and thereby the virtual function <tt>sync()</tt> (<tt>flush()</tt> is listed
4528 under "unformatted output functions").</p>
4529 <p>In addition, I guess that the sentence starting with "They may use other
4530 public members of <tt>basic_ostream</tt> ..." probably was intended to
4531 start with "They may use other public members of <tt>basic_streamuf</tt>..."
4532 although the problem with the virtual members exists in both cases.</p>
4533 <p>I see two obvious resolutions:</p>
4535 <li>state in a footnote that this means that <tt>xsputn()</tt> will never be
4536 called by any ostream member and that this is intended.</li>
4537 <li>relax the restriction and allow calling <tt>overflow()</tt> and <tt>xsputn()</tt>.
4538 Of course, the problem with <tt>flush()</tt> has to be resolved in some way.</li>
4540 <p><b>Proposed resolution:</b></p>
4541 <p>Change the last sentence of 27.6.2.1 (lib.ostream) paragraph 2 from:</p>
4543 <p>They may use other public members of basic_ostream except that they do not
4544 invoke any virtual members of rdbuf() except overflow().</p>
4548 <p>They may use other public members of basic_ostream except that they shall
4549 not invoke any virtual members of rdbuf() except overflow(), xsputn(), and
4553 <p><i>[Kona: the LWG believes this is a problem. Wish to ask Jerry or
4554 PJP why the standard is written this way.]</i></p>
4556 <p><i>[Post-Tokyo: Dietmar supplied wording at the request of the
4557 LWG. He comments: The rules can be made a little bit more specific if
4558 necessary be explicitly spelling out what virtuals are allowed to be
4559 called from what functions and eg to state specifically that flush()
4560 is allowed to call sync() while other functions are not.]</i></p>
4562 <a name="167"><h3>167. Improper use of <tt>traits_type::length()</tt>
4563 </h3></a><p><b>Section:</b> 27.6.2.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.inserters.character"> [lib.ostream.inserters.character]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4564 <p>Paragraph 4 states that the length is determined using
4565 <tt>traits::length(s)</tt>. Unfortunately, this function is not
4566 defined for example if the character type is <tt>wchar_t</tt> and the
4567 type of <tt>s</tt> is <tt>char const*</tt>. Similar problems exist if
4568 the character type is <tt>char</tt> and the type of <tt>s</tt> is
4569 either <tt>signed char const*</tt> or <tt>unsigned char
4571 <p><b>Proposed resolution:</b></p>
4572 <p>Change 27.6.2.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.inserters.character"> [lib.ostream.inserters.character]</a> paragraph 4 from:</p>
4574 <p>Effects: Behaves like an formatted inserter (as described in
4575 lib.ostream.formatted.reqmts) of out. After a sentry object is
4576 constructed it inserts characters. The number of characters starting
4577 at s to be inserted is traits::length(s). Padding is determined as
4578 described in lib.facet.num.put.virtuals. The traits::length(s)
4579 characters starting at s are widened using out.widen
4580 (lib.basic.ios.members). The widened characters and any required
4581 padding are inserted into out. Calls width(0).</p>
4585 <p>Effects: Behaves like a formatted inserter (as described in
4586 lib.ostream.formatted.reqmts) of out. After a sentry object is
4587 constructed it inserts <i>n</i> characters starting at <i>s</i>,
4588 where <i>n</i> is the number that would be computed as if by:</p>
4590 <li>traits::length(s) for the overload where the first argument is of
4591 type basic_ostream<charT, traits>& and the second is
4592 of type const charT*, and also for the overload where the first
4593 argument is of type basic_ostream<char, traits>& and
4594 the second is of type const char*.</li>
4595 <li>std::char_traits<char>::length(s)
4596 for the overload where the first argument is of type
4597 basic_ostream<charT, traits>& and the second is of type
4599 <li>traits::length(reinterpret_cast<const char*>(s))
4600 for the other two overloads.</li>
4602 <p>Padding is determined as described in
4603 lib.facet.num.put.virtuals. The <i>n</i> characters starting at
4604 <i>s</i> are widened using out.widen (lib.basic.ios.members). The
4605 widened characters and any required padding are inserted into
4606 out. Calls width(0).</p>
4609 <p><i>[Santa Cruz: Matt supplied new wording]</i></p>
4611 <p><i>[Kona: changed "where <i>n</i> is" to " where <i>n</i> is the
4612 number that would be computed as if by"]</i></p>
4614 <p><b>Rationale:</b></p>
4615 <p>We have five separate cases. In two of them we can use the
4616 user-supplied traits class without any fuss. In the other three we
4617 try to use something as close to that user-supplied class as possible.
4618 In two cases we've got a traits class that's appropriate for
4619 char and what we've got is a const signed char* or a const
4620 unsigned char*; that's close enough so we can just use a reinterpret
4621 cast, and continue to use the user-supplied traits class. Finally,
4622 there's one case where we just have to give up: where we've got a
4623 traits class for some arbitrary charT type, and we somehow have to
4624 deal with a const char*. There's nothing better to do but fall back
4625 to char_traits<char></p>
4627 <a name="168"><h3>168. Typo: formatted vs. unformatted</h3></a><p><b>Section:</b> 27.6.2.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.unformatted"> [lib.ostream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4628 <p>The first paragraph begins with a descriptions what has to be done
4629 in <i>formatted</i> output functions. Probably this is a typo and the
4630 paragraph really want to describe unformatted output functions...</p>
4631 <p><b>Proposed resolution:</b></p>
4632 <p>In 27.6.2.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.unformatted"> [lib.ostream.unformatted]</a> paragraph 1, the first and last
4633 sentences, change the word "formatted" to
4636 <p>"Each <b>unformatted </b> output function begins ..."<br>
4637 "... value specified for the <b>unformatted </b> output
4641 <a name="169"><h3>169. Bad efficiency of <tt>overflow()</tt> mandated</h3></a><p><b>Section:</b> 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4642 <p>Paragraph 8, Notes, of this section seems to mandate an extremely
4643 inefficient way of buffer handling for <tt>basic_stringbuf</tt>,
4644 especially in view of the restriction that <tt>basic_ostream</tt>
4645 member functions are not allowed to use <tt>xsputn()</tt> (see 27.6.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream"> [lib.ostream]</a>): For each character to be inserted, a new buffer
4646 is to be created.</p>
4647 <p>Of course, the resolution below requires some handling of
4648 simultaneous input and output since it is no longer possible to update
4649 <tt>egptr()</tt> whenever <tt>epptr()</tt> is changed. A possible
4650 solution is to handle this in <tt>underflow()</tt>.</p>
4651 <p><b>Proposed resolution:</b></p>
4652 <p>In 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a> paragraph 8, Notes, insert the words
4653 "at least" as in the following:</p>
4655 <p>To make a write position available, the function reallocates (or initially
4656 allocates) an array object with a sufficient number of elements to hold the
4657 current array object (if any), plus <b>at least</b> one additional write
4661 <a name="170"><h3>170. Inconsistent definition of <tt>traits_type</tt>
4662 </h3></a><p><b>Section:</b> 27.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringstream"> [lib.stringstream]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4663 <p>The classes <tt>basic_stringstream</tt> (27.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringstream"> [lib.stringstream]</a>),
4664 <tt>basic_istringstream</tt> (27.7.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istringstream"> [lib.istringstream]</a>), and
4665 <tt>basic_ostringstream</tt> (27.7.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostringstream"> [lib.ostringstream]</a>) are inconsistent
4666 in their definition of the type <tt>traits_type</tt>: For
4667 <tt>istringstream</tt>, this type is defined, for the other two it is
4668 not. This should be consistent.</p>
4669 <p><b>Proposed resolution:</b></p>
4670 <p><b>Proposed resolution:</b></p> <p>To the declarations of
4671 <tt>basic_ostringstream</tt> (27.7.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostringstream"> [lib.ostringstream]</a>) and
4672 <tt>basic_stringstream</tt> (27.7.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringstream"> [lib.stringstream]</a>) add:</p>
4674 <pre>typedef traits traits_type;</pre>
4677 <a name="171"><h3>171. Strange <tt>seekpos()</tt> semantics due to joint position</h3></a><p><b>Section:</b> 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Jul 1999</p>
4678 <p>Overridden virtual functions, seekpos()</p> <p>In 27.8.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf"> [lib.filebuf]</a> paragraph 3, it is stated that a joint input and
4679 output position is maintained by <tt>basic_filebuf</tt>. Still, the
4680 description of <tt>seekpos()</tt> seems to talk about different file
4681 positions. In particular, it is unclear (at least to me) what is
4682 supposed to happen to the output buffer (if there is one) if only the
4683 input position is changed. The standard seems to mandate that the
4684 output buffer is kept and processed as if there was no positioning of
4685 the output position (by changing the input position). Of course, this
4686 can be exactly what you want if the flag <tt>ios_base::ate</tt> is
4687 set. However, I think, the standard should say something like
4690 <li>If <tt>(which & mode) == 0</tt> neither read nor write position is
4691 changed and the call fails. Otherwise, the joint read and write position is
4692 altered to correspond to <tt>sp</tt>.</li>
4693 <li>If there is an output buffer, the output sequences is updated and any
4694 unshift sequence is written before the position is altered.</li>
4695 <li>If there is an input buffer, the input sequence is updated after the
4696 position is altered.</li>
4698 <p>Plus the appropriate error handling, that is...</p>
4699 <p><b>Proposed resolution:</b></p>
4700 <p>Change the unnumbered paragraph in 27.8.1.4 (lib.filebuf.virtuals) before
4701 paragraph 14 from:</p>
4703 <p>pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in |
4705 <p>Alters the file position, if possible, to correspond to the position stored
4706 in sp (as described below).</p>
4707 <p>- if (which&ios_base::in)!=0, set the file position to sp, then update
4708 the input sequence</p>
4709 <p>- if (which&ios_base::out)!=0, then update the output sequence, write
4710 any unshift sequence, and set the file position to sp.</p>
4714 <p>pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in |
4716 <p>Alters the file position, if possible, to correspond to the position stored
4717 in sp (as described below). Altering the file position performs as follows:</p>
4718 <p>1. if (om & ios_base::out)!=0, then update the output sequence and
4719 write any unshift sequence;</p>
4720 <p>2. set the file position to sp;</p>
4721 <p>3. if (om & ios_base::in)!=0, then update the input sequence;</p>
4722 <p>where om is the open mode passed to the last call to open(). The operation
4723 fails if is_open() returns false.</p>
4726 <p><i>[Kona: Dietmar is working on a proposed resolution.]</i></p>
4727 <p><i>[Post-Tokyo: Dietmar supplied the above wording.]</i></p>
4729 <a name="172"><h3>172. Inconsistent types for <tt>basic_istream::ignore()</tt>
4730 </h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Greg Comeau, Dietmar Kühl <b>Date:</b> 23 Jul 1999</p>
4731 <p>In 27.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream"> [lib.istream]</a> the function
4732 <tt>ignore()</tt> gets an object of type <tt>streamsize</tt> as first
4733 argument. However, in 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>
4734 paragraph 23 the first argument is of type <tt>int.</tt></p>
4736 <p>As far as I can see this is not really a contradiction because
4737 everything is consistent if <tt>streamsize</tt> is typedef to be
4738 <tt>int</tt>. However, this is almost certainly not what was
4739 intended. The same thing happened to <tt>basic_filebuf::setbuf()</tt>,
4740 as described in issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#173">173</a>.</p>
4743 submitted this issue, commenting: Either 27.6.1.1 should be modified
4744 to show a first parameter of type int, or 27.6.1.3 should be modified
4745 to show a first parameter of type streamsize and use
4746 numeric_limits<streamsize>::max.</p>
4747 <p><b>Proposed resolution:</b></p>
4748 <p>In 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> paragraph 23 and 24, change both uses
4749 of <tt>int</tt> in the description of <tt>ignore()</tt> to
4750 <tt>streamsize</tt>.</p>
4752 <a name="173"><h3>173. Inconsistent types for <tt>basic_filebuf::setbuf()</tt>
4753 </h3></a><p><b>Section:</b> 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Greg Comeau, Dietmar Kühl <b>Date:</b> 23 Jul 1999</p>
4756 In 27.8.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf"> [lib.filebuf]</a> the function <tt>setbuf()</tt> gets an
4757 object of type <tt>streamsize</tt> as second argument. However, in
4758 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a> paragraph 9 the second argument is of type
4763 As far as I can see this is not really a contradiction because
4764 everything is consistent if <tt>streamsize</tt> is typedef to be
4765 <tt>int</tt>. However, this is almost certainly not what was
4766 intended. The same thing happened to <tt>basic_istream::ignore()</tt>,
4767 as described in issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#172">172</a>.
4770 <p><b>Proposed resolution:</b></p>
4771 <p>In 27.8.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.virtuals"> [lib.filebuf.virtuals]</a> paragraph 9, change all uses of
4772 <tt>int</tt> in the description of <tt>setbuf()</tt> to
4773 <tt>streamsize</tt>.</p>
4775 <a name="174"><h3>174. Typo: <tt>OFF_T</tt> vs. <tt>POS_T</tt>
4776 </h3></a><p><b>Section:</b> D.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ios.members"> [depr.ios.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 23 Jul 1999</p>
4777 <p>According to paragraph 1 of this section, <tt>streampos</tt> is the
4778 type <tt>OFF_T</tt>, the same type as <tt>streamoff</tt>. However, in
4779 paragraph 6 the <tt>streampos</tt> gets the type <tt>POS_T</tt></p>
4780 <p><b>Proposed resolution:</b></p>
4781 <p>Change D.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ios.members"> [depr.ios.members]</a> paragraph 1 from "<tt>typedef
4782 OFF_T streampos;</tt>" to "<tt>typedef POS_T
4783 streampos;</tt>"</p>
4785 <a name="175"><h3>175. Ambiguity for <tt>basic_streambuf::pubseekpos()</tt> and a few other functions.</h3></a><p><b>Section:</b> D.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ios.members"> [depr.ios.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 23 Jul 1999</p>
4786 <p>According to paragraph 8 of this section, the methods
4787 <tt>basic_streambuf::pubseekpos()</tt>,
4788 <tt>basic_ifstream::open()</tt>, and <tt>basic_ofstream::open</tt>
4789 "may" be overloaded by a version of this function taking the
4790 type <tt>ios_base::open_mode</tt> as last argument argument instead of
4791 <tt>ios_base::openmode</tt> (<tt>ios_base::open_mode</tt> is defined
4792 in this section to be an alias for one of the integral types). The
4793 clause specifies, that the last argument has a default argument in
4794 three cases. However, this generates an ambiguity with the overloaded
4795 version because now the arguments are absolutely identical if the last
4796 argument is not specified.</p>
4797 <p><b>Proposed resolution:</b></p>
4798 <p>In D.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ios.members"> [depr.ios.members]</a> paragraph 8, remove the default arguments for
4799 <tt>basic_streambuf::pubseekpos()</tt>,
4800 <tt>basic_ifstream::open()</tt>, and
4801 <tt>basic_ofstream::open().</tt></p>
4803 <a name="176"><h3>176. <tt>exceptions()</tt> in <tt>ios_base</tt>...?</h3></a><p><b>Section:</b> D.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ios.members"> [depr.ios.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 23 Jul 1999</p>
4804 <p>The "overload" for the function <tt>exceptions()</tt> in
4805 paragraph 8 gives the impression that there is another function of
4806 this function defined in class <tt>ios_base</tt>. However, this is not
4807 the case. Thus, it is hard to tell how the semantics (paragraph 9) can
4808 be implemented: "Call the corresponding member function specified
4809 in clause 27 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.input.output"> [lib.input.output]</a>."</p>
4810 <p><b>Proposed resolution:</b></p>
4811 <p>In D.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.ios.members"> [depr.ios.members]</a> paragraph 8, move the declaration of the
4812 function <tt>exceptions()</tt>into class <tt>basic_ios</tt>.</p>
4814 <a name="179"><h3>179. Comparison of const_iterators to iterators doesn't work</h3></a><p><b>Section:</b> 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 2 Jul 1998</p>
4815 <p>Currently the following will not compile on two well-known standard
4816 library implementations:</p>
4819 <pre>#include <set>
4820 using namespace std;
4822 void f(const set<int> &s)
4824 set<int>::iterator i;
4825 if (i==s.end()); // s.end() returns a const_iterator
4830 The reason this doesn't compile is because operator== was implemented
4831 as a member function of the nested classes set:iterator and
4832 set::const_iterator, and there is no conversion from const_iterator to
4833 iterator. Surprisingly, (s.end() == i) does work, though, because of
4834 the conversion from iterator to const_iterator.
4838 I don't see a requirement anywhere in the standard that this must
4839 work. Should there be one? If so, I think the requirement would need
4840 to be added to the tables in section 24.1.1. I'm not sure about the
4841 wording. If this requirement existed in the standard, I would think
4842 that implementors would have to make the comparison operators
4843 non-member functions.</p>
4845 <p>This issues was also raised on comp.std.c++ by Darin
4846 Adler. The example given was:</p>
4849 <pre>bool check_equal(std::deque<int>::iterator i,
4850 std::deque<int>::const_iterator ci)
4856 <p>Comment from John Potter:</p>
4859 In case nobody has noticed, accepting it will break reverse_iterator.
4863 The fix is to make the comparison operators templated on two types.
4866 <pre> template <class Iterator1, class Iterator2>
4867 bool operator== (reverse_iterator<Iterator1> const& x,
4868 reverse_iterator<Iterator2> const& y);
4872 Obviously: return x.base() == y.base();
4876 Currently, no reverse_iterator to const_reverse_iterator compares are
4881 BTW, I think the issue is in support of bad code. Compares should be
4882 between two iterators of the same type. All std::algorithms require
4883 the begin and end iterators to be of the same type.
4886 <p><b>Proposed resolution:</b></p>
4887 <p>Insert this paragraph after 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> paragraph 7:</p>
4889 <p>In the expressions</p>
4898 <p>Where i and j denote objects of a container's iterator type,
4899 either or both may be replaced by an object of the container's
4900 const_iterator type referring to the same element with no
4901 change in semantics.</p>
4904 <p><i>[post-Toronto: Judy supplied a proposed resolution saying that
4905 <tt>iterator</tt> and <tt>const_iterator</tt> could be freely mixed in
4906 iterator comparison and difference operations.]</i></p>
4908 <p><i>[Redmond: Dave and Howard supplied a new proposed resolution which
4909 explicitly listed expressions; there was concern that the previous
4910 proposed resolution was too informal.]</i></p>
4911 <p><b>Rationale:</b></p>
4913 The LWG believes it is clear that the above wording applies only to
4914 the nested types <tt>X::iterator</tt> and <tt>X::const_iterator</tt>,
4915 where <tt>X</tt> is a container. There is no requirement that
4916 <tt>X::reverse_iterator</tt> and <tt>X::const_reverse_iterator</tt>
4917 can be mixed. If mixing them is considered important, that's a
4918 separate issue. (Issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#280">280</a>.)
4921 <a name="181"><h3>181. make_pair() unintended behavior</h3></a><p><b>Section:</b> 20.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.pairs"> [lib.pairs]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 3 Aug 1999</p>
4922 <p>The claim has surfaced in Usenet that expressions such as<br>
4924 <tt>make_pair("abc", 3)</tt><br>
4926 are illegal, notwithstanding their use in examples, because template instantiation tries to bind the first template
4927 parameter to <tt> const char (&)[4]</tt>, which type is uncopyable.<br>
4929 I doubt anyone intended that behavior...
4931 <p><b>Proposed resolution:</b></p>
4932 <p>In 20.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.utility"> [lib.utility]</a>, paragraph 1 change the following
4933 declaration of make_pair():</p>
4935 <pre>template <class T1, class T2> pair<T1,T2> make_pair(const T1&, const T2&);</pre>
4939 <pre>template <class T1, class T2> pair<T1,T2> make_pair(T1, T2);</pre>
4941 <p> In 20.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.pairs"> [lib.pairs]</a> paragraph 7 and the line before, change:</p>
4943 <pre>template <class T1, class T2>
4944 pair<T1, T2> make_pair(const T1& x, const T2& y);</pre>
4948 <pre>template <class T1, class T2>
4949 pair<T1, T2> make_pair(T1 x, T2 y);</pre>
4951 <p>and add the following footnote to the effects clause:</p>
4953 <p> According to 12.8 [class.copy], an implementation is permitted
4954 to not perform a copy of an argument, thus avoiding unnecessary
4957 <p><b>Rationale:</b></p>
4958 <p>Two potential fixes were suggested by Matt Austern and Dietmar
4959 Kühl, respectively, 1) overloading with array arguments, and 2) use of
4960 a reference_traits class with a specialization for arrays. Andy
4961 Koenig suggested changing to pass by value. In discussion, it appeared
4962 that this was a much smaller change to the standard that the other two
4963 suggestions, and any efficiency concerns were more than offset by the
4964 advantages of the solution. Two implementors reported that the
4965 proposed resolution passed their test suites.</p>
4967 <a name="182"><h3>182. Ambiguous references to size_t</h3></a><p><b>Section:</b> 17 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.library"> [lib.library]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Al Stevens <b>Date:</b> 15 Aug 1999</p>
4968 <p>Many references to <tt> size_t</tt> throughout the document
4969 omit the <tt> std::</tt> namespace qualification.</p> <p>For
4970 example, 17.4.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.replacement.functions"> [lib.replacement.functions]</a> paragraph 2:</p>
4972 <pre>— operator new(size_t)
4973 — operator new(size_t, const std::nothrow_t&)
4974 — operator new[](size_t)
4975 — operator new[](size_t, const std::nothrow_t&)</pre>
4977 <p><b>Proposed resolution:</b></p>
4978 <p> In 17.4.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.replacement.functions"> [lib.replacement.functions]</a> paragraph 2: replace:</p>
4980 <p><tt> - operator new(size_t)<br>
4981 - operator new(size_t, const std::nothrow_t&)<br>
4982 - operator new[](size_t)<br>
4983 - operator new[](size_t, const std::nothrow_t&)</tt></p>
4987 <pre>- operator new(std::size_t)
4988 - operator new(std::size_t, const std::nothrow_t&)
4989 - operator new[](std::size_t)
4990 - operator new[](std::size_t, const std::nothrow_t&)</pre>
4992 <p>In [lib.allocator.requirements] 20.1.5, paragraph 4: replace:</p>
4994 <p>The typedef members pointer, const_pointer, size_type, and difference_type
4995 are required to be T*, T const*, size_t, and ptrdiff_t, respectively.</p>
4999 <p>The typedef members pointer, const_pointer, size_type, and difference_type
5000 are required to be T*, T const*, std::size_t, and std::ptrdiff_t,
5003 <p>In [lib.allocator.members] 20.4.1.1, paragraphs 3 and 6: replace:</p>
5005 <p>3 Notes: Uses ::operator new(size_t) (18.4.1).</p>
5006 <p>6 Note: the storage is obtained by calling ::operator new(size_t), but it
5007 is unspecified when or how often this function is called. The use of hint is
5008 unspecified, but intended as an aid to locality if an implementation so
5013 <p>3 Notes: Uses ::operator new(std::size_t) (18.4.1).</p>
5014 <p>6 Note: the storage is obtained by calling ::operator new(std::size_t), but
5015 it is unspecified when or how often this function is called. The use of hint
5016 is unspecified, but intended as an aid to locality if an implementation so
5019 <p>In [lib.char.traits.require] 21.1.1, paragraph 1: replace:</p>
5021 <p>In Table 37, X denotes a Traits class defining types and functions for the
5022 character container type CharT; c and d denote values of type CharT; p and q
5023 denote values of type const CharT*; s denotes a value of type CharT*; n, i and
5024 j denote values of type size_t; e and f denote values of type X::int_type; pos
5025 denotes a value of type X::pos_type; and state denotes a value of type X::state_type.</p>
5029 <p>In Table 37, X denotes a Traits class defining types and functions for the
5030 character container type CharT; c and d denote values of type CharT; p and q
5031 denote values of type const CharT*; s denotes a value of type CharT*; n, i and
5032 j denote values of type std::size_t; e and f denote values of type X::int_type;
5033 pos denotes a value of type X::pos_type; and state denotes a value of type X::state_type.</p>
5035 <p>In [lib.char.traits.require] 21.1.1, table 37: replace the return type of
5036 X::length(p): "size_t" by "std::size_t".</p>
5037 <p> In [lib.std.iterator.tags] 24.3.3, paragraph 2: replace:<br>
5038 typedef ptrdiff_t difference_type;<br>
5040 typedef std::ptrdiff_t difference_type;</p>
5041 <p> In [lib.locale.ctype] 22.2.1.1 put namespace std { ...} around the
5042 declaration of template <class charT> class ctype.<br>
5044 In [lib.iterator.traits] 24.3.1, paragraph 2 put namespace std { ...} around the declaration of:<br>
5046 template<class Iterator> struct iterator_traits<br>
5047 template<class T> struct iterator_traits<T*><br>
5048 template<class T> struct iterator_traits<const T*></p>
5049 <p><b>Rationale:</b></p>
5050 <p>The LWG believes correcting names like <tt>size_t</tt> and
5051 <tt>ptrdiff_t</tt> to <tt>std::size_t</tt> and <tt>std::ptrdiff_t</tt>
5052 to be essentially editorial. There there can't be another size_t or
5053 ptrdiff_t meant anyway because, according to 17.4.3.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.extern.types"> [lib.extern.types]</a>,</p>
5056 For each type T from the Standard C library, the types ::T and std::T
5057 are reserved to the implementation and, when defined, ::T shall be
5058 identical to std::T.
5061 <p>The issue is treated as a Defect Report to make explicit the Project
5062 Editor's authority to make this change.</p>
5064 <p><i>[Post-Tokyo: Nico Josuttis provided the above wording at the
5065 request of the LWG.]</i></p>
5067 <p><i>[Toronto: This is tangentially related to issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#229">229</a>, but only tangentially: the intent of this issue is to
5068 address use of the name <tt>size_t</tt> in contexts outside of
5069 namespace std, such as in the description of <tt>::operator new</tt>.
5070 The proposed changes should be reviewed to make sure they are
5073 <p><i>[pre-Copenhagen: Nico has reviewed the changes and believes
5074 them to be correct.]</i></p>
5077 <a name="183"><h3>183. I/O stream manipulators don't work for wide character streams</h3></a><p><b>Section:</b> 27.6.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.std.manip"> [lib.std.manip]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andy Sawyer <b>Date:</b> 7 Jul 1999</p>
5078 <p>27.6.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.std.manip"> [lib.std.manip]</a> paragraph 3 says (clause numbering added for
5081 <p>Returns: An object s of unspecified type such that if [1] out is an (instance
5082 of) basic_ostream then the expression out<<s behaves as if f(s) were
5083 called, and if [2] in is an (instance of) basic_istream then the expression
5084 in>>s behaves as if f(s) were called. Where f can be defined as: ios_base&
5085 f(ios_base& str, ios_base::fmtflags mask) { // reset specified flags
5086 str.setf(ios_base::fmtflags(0), mask); return str; } [3] The expression
5087 out<<s has type ostream& and value out. [4] The expression in>>s
5088 has type istream& and value in.</p>
5090 <p>Given the definitions [1] and [2] for out and in, surely [3] should read:
5091 "The expression out << s has type basic_ostream& ..." and
5092 [4] should read: "The expression in >> s has type basic_istream&
5094 <p>If the wording in the standard is correct, I can see no way of implementing
5095 any of the manipulators so that they will work with wide character streams.</p>
5096 <p>e.g. wcout << setbase( 16 );</p>
5097 <p>Must have value 'wcout' (which makes sense) and type 'ostream&' (which
5099 <p>The same "cut'n'paste" type also seems to occur in Paras 4,5,7 and
5100 8. In addition, Para 6 [setfill] has a similar error, but relates only to
5102 <p>I'd be happier if there was a better way of saying this, to make it clear
5103 that the value of the expression is "the same specialization of
5104 basic_ostream as out"&</p>
5105 <p><b>Proposed resolution:</b></p>
5106 <p>Replace section 27.6.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.std.manip"> [lib.std.manip]</a> except paragraph 1 with the
5109 <p>2- The type designated smanip in each of the following function
5110 descriptions is implementation-specified and may be different for each
5113 <tt>smanip resetiosflags(ios_base::fmtflags mask);</tt><br>
5115 -3- Returns: An object s of unspecified type such that if out is an
5116 instance of basic_ostream<charT,traits> then the expression
5117 out<<s behaves
5118 as if f(s, mask) were called, or if in is an instance of
5119 basic_istream<charT,traits> then the expression in>>s
5121 f(s, mask) were called. The function f can be defined as:*<br>
5123 [Footnote: The expression cin >> resetiosflags(ios_base::skipws)
5124 clears ios_base::skipws in the format flags stored in the
5125 basic_istream<charT,traits> object cin (the same as cin >>
5126 noskipws), and the expression cout <<
5127 resetiosflags(ios_base::showbase) clears
5128 ios_base::showbase in the format flags stored in the
5129 basic_ostream<charT,traits> object cout (the same as cout
5131 noshowbase). --- end footnote]<br>
5133 <tt>ios_base& f(ios_base& str, ios_base::fmtflags mask)<br>
5135 // reset specified flags<br>
5136 str.setf(ios_base::fmtflags(0), mask);<br>
5137 return str;<br>
5140 The expression out<<s has type basic_ostream<charT,traits>& and value out.
5141 The expression in>>s has type basic_istream<charT,traits>& and value in.<br>
5143 <tt>smanip setiosflags(ios_base::fmtflags mask);</tt><br>
5145 -4- Returns: An object s of unspecified type such that if out is an
5146 instance of basic_ostream<charT,traits> then the expression
5147 out<<s behaves
5148 as if f(s, mask) were called, or if in is an instance of
5149 basic_istream<charT,traits> then the expression in>>s
5151 mask) were called. The function f can be defined as:<br>
5153 <tt>ios_base& f(ios_base& str, ios_base::fmtflags mask)<br>
5155 // set specified flags<br>
5156 str.setf(mask);<br>
5157 return str;<br>
5160 The expression out<<s has type basic_ostream<charT,traits>& and value out.
5161 The expression in>>s has type basic_istream<charT,traits>& and value in.<br>
5163 <tt>smanip setbase(int base);</tt><br>
5165 -5- Returns: An object s of unspecified type such that if out is an
5166 instance of basic_ostream<charT,traits> then the expression
5167 out<<s behaves
5168 as if f(s, base) were called, or if in is an instance of
5169 basic_istream<charT,traits> then the expression in>>s
5171 base) were called. The function f can be defined as:<br>
5173 <tt>ios_base& f(ios_base& str, int base)<br>
5175 // set basefield<br>
5176 str.setf(base == 8 ? ios_base::oct :<br>
5177 base == 10 ? ios_base::dec :<br>
5178 base == 16 ? ios_base::hex :<br>
5179 ios_base::fmtflags(0), ios_base::basefield);<br>
5180 return str;<br>
5183 The expression out<<s has type basic_ostream<charT,traits>& and value out.
5184 The expression in>>s has type basic_istream<charT,traits>& and value in.<br>
5186 <tt>smanip setfill(char_type c);<br>
5188 -6- Returns: An object s of unspecified type such that if out is (or is
5189 derived from) basic_ostream<charT,traits> and c has type charT
5191 expression out<<s behaves as if f(s, c) were called. The function
5195 <tt>template<class charT, class traits><br>
5196 basic_ios<charT,traits>& f(basic_ios<charT,traits>& str, charT c)<br>
5198 // set fill character<br>
5199 str.fill(c);<br>
5200 return str;<br>
5203 The expression out<<s has type basic_ostream<charT,traits>& and value out.<br>
5205 <tt>smanip setprecision(int n);</tt><br>
5207 -7- Returns: An object s of unspecified type such that if out is an
5208 instance of basic_ostream<charT,traits> then the expression
5209 out<<s behaves
5210 as if f(s, n) were called, or if in is an instance of
5211 basic_istream<charT,traits> then the expression in>>s
5212 behaves as if f(s, n)
5213 were called. The function f can be defined as:<br>
5215 <tt>ios_base& f(ios_base& str, int n)<br>
5217 // set precision<br>
5218 str.precision(n);<br>
5219 return str;<br>
5222 The expression out<<s has type basic_ostream<charT,traits>& and value out.
5223 The expression in>>s has type basic_istream<charT,traits>& and value in<br>
5225 <tt>smanip setw(int n);<br>
5227 -8- Returns: An object s of unspecified type such that if out is an
5228 instance of basic_ostream<charT,traits> then the expression
5229 out<<s behaves
5230 as if f(s, n) were called, or if in is an instance of
5231 basic_istream<charT,traits> then the expression in>>s
5232 behaves as if f(s, n)
5233 were called. The function f can be defined as:<br>
5235 <tt>ios_base& f(ios_base& str, int n)<br>
5237 // set width<br>
5238 str.width(n);<br>
5239 return str;<br>
5242 The expression out<<s has type
5243 basic_ostream<charT,traits>& and value out. The expression
5244 in>>s has type basic_istream<charT,traits>& and value
5249 <p><i>[Kona: Andy Sawyer and Beman Dawes will work to improve the wording of
5250 the proposed resolution.]</i></p>
5252 <p><i>[Tokyo - The LWG noted that issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#216">216</a> involves
5253 the same paragraphs.]</i></p>
5255 <p><i>[Post-Tokyo: The issues list maintainer combined the proposed
5256 resolution of this issue with the proposed resolution for issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#216">216</a> as they both involved the same paragraphs, and were so
5257 intertwined that dealing with them separately appear fraught with
5258 error. The full text was supplied by Bill Plauger; it was cross
5259 checked against changes supplied by Andy Sawyer. It should be further
5260 checked by the LWG.]</i></p>
5262 <a name="184"><h3>184. numeric_limits<bool> wording problems</h3></a><p><b>Section:</b> 18.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.numeric.special"> [lib.numeric.special]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Gabriel Dos Reis <b>Date:</b> 21 Jul 1999</p>
5263 <p>bools are defined by the standard to be of integer types, as per
5264 3.9.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/basic.html#basic.fundamental"> [basic.fundamental]</a> paragraph 7. However "integer types"
5265 seems to have a special meaning for the author of 18.2. The net effect
5266 is an unclear and confusing specification for
5267 numeric_limits<bool> as evidenced below.</p>
5269 <p>18.2.1.2/7 says numeric_limits<>::digits is, for built-in integer
5270 types, the number of non-sign bits in the representation.</p>
5272 <p>4.5/4 states that a bool promotes to int ; whereas 4.12/1 says any non zero
5273 arithmetical value converts to true.</p>
5275 <p>I don't think it makes sense at all to require
5276 numeric_limits<bool>::digits and numeric_limits<bool>::digits10 to
5279 <p>The standard defines what constitutes a signed (resp. unsigned) integer
5280 types. It doesn't categorize bool as being signed or unsigned. And the set of
5281 values of bool type has only two elements.</p>
5283 <p>I don't think it makes sense to require numeric_limits<bool>::is_signed
5284 to be meaningful.</p>
5286 <p>18.2.1.2/18 for numeric_limits<integer_type>::radix says:</p>
5288 <p>For integer types, specifies the base of the representation.186)</p>
5291 <p>This disposition is at best misleading and confusing for the standard
5292 requires a "pure binary numeration system" for integer types as per
5295 <p>The footnote 186) says: "Distinguishes types with base other than 2 (e.g
5296 BCD)." This also erroneous as the standard never defines any integer
5297 types with base representation other than 2.</p>
5299 <p>Furthermore, numeric_limits<bool>::is_modulo and
5300 numeric_limits<bool>::is_signed have similar problems.</p>
5301 <p><b>Proposed resolution:</b></p>
5302 <p>Append to the end of 18.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.numeric.special"> [lib.numeric.special]</a>:</p>
5304 <p>The specialization for bool shall be provided as follows:</p>
5305 <pre> namespace std {
5306 template<> class numeric_limits<bool> {
5308 static const bool is_specialized = true;
5309 static bool min() throw() { return false; }
5310 static bool max() throw() { return true; }
5312 static const int digits = 1;
5313 static const int digits10 = 0;
5314 static const bool is_signed = false;
5315 static const bool is_integer = true;
5316 static const bool is_exact = true;
5317 static const int radix = 2;
5318 static bool epsilon() throw() { return 0; }
5319 static bool round_error() throw() { return 0; }
5321 static const int min_exponent = 0;
5322 static const int min_exponent10 = 0;
5323 static const int max_exponent = 0;
5324 static const int max_exponent10 = 0;
5326 static const bool has_infinity = false;
5327 static const bool has_quiet_NaN = false;
5328 static const bool has_signaling_NaN = false;
5329 static const float_denorm_style has_denorm = denorm_absent;
5330 static const bool has_denorm_loss = false;
5331 static bool infinity() throw() { return 0; }
5332 static bool quiet_NaN() throw() { return 0; }
5333 static bool signaling_NaN() throw() { return 0; }
5334 static bool denorm_min() throw() { return 0; }
5336 static const bool is_iec559 = false;
5337 static const bool is_bounded = true;
5338 static const bool is_modulo = false;
5340 static const bool traps = false;
5341 static const bool tinyness_before = false;
5342 static const float_round_style round_style = round_toward_zero;
5347 <p><i>[Tokyo: The LWG desires wording that specifies exact values
5348 rather than more general wording in the original proposed
5349 resolution.]</i></p>
5351 <p><i>[Post-Tokyo: At the request of the LWG in Tokyo, Nico
5352 Josuttis provided the above wording.]</i></p>
5354 <a name="185"><h3>185. Questionable use of term "inline"</h3></a><p><b>Section:</b> 20.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.tuple"> [lib.tuple]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> UK Panel <b>Date:</b> 26 Jul 1999</p>
5355 <p>Paragraph 4 of 20.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.tuple"> [lib.tuple]</a> says:</p>
5357 <p> [Example: To negate every element of a: transform(a.begin(), a.end(),
5358 a.begin(), negate<double>()); The corresponding functions will inline
5359 the addition and the negation. end example]</p>
5361 <p>(Note: The "addition" referred to in the above is in para 3) we can
5362 find no other wording, except this (non-normative) example which suggests that
5363 any "inlining" will take place in this case.</p>
5366 <p>17.4.4.3 Global Functions [lib.global.functions] 1 It is
5367 unspecified whether any global functions in the C++ Standard Library
5368 are defined as inline (7.1.2).</p>
5372 <p>17.4.4.4 Member Functions [lib.member.functions] 1 It is
5373 unspecified whether any member functions in the C++ Standard Library
5374 are defined as inline (7.1.2).</p>
5376 <p>take care to state that this may indeed NOT be the case.</p>
5377 <p>Thus the example "mandates" behavior that is explicitly
5378 not required elsewhere.</p>
5379 <p><b>Proposed resolution:</b></p>
5380 <p>In 20.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.tuple"> [lib.tuple]</a> paragraph 1, remove the sentence:</p>
5382 <p>They are important for the effective use of the library.</p>
5384 <p>Remove 20.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.tuple"> [lib.tuple]</a> paragraph 2, which reads:</p>
5386 <p> Using function objects together with function templates
5387 increases the expressive power of the library as well as making the
5388 resulting code much more efficient.</p>
5390 <p>In 20.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.tuple"> [lib.tuple]</a> paragraph 4, remove the sentence:</p>
5392 <p>The corresponding functions will inline the addition and the
5396 <p><i>[Kona: The LWG agreed there was a defect.]</i></p>
5397 <p><i>[Tokyo: The LWG crafted the proposed resolution.]</i></p>
5399 <a name="186"><h3>186. bitset::set() second parameter should be bool</h3></a><p><b>Section:</b> 23.3.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.members"> [lib.bitset.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Darin Adler <b>Date:</b> 13 Aug 1999</p>
5400 <p>In section 23.3.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.members"> [lib.bitset.members]</a>, paragraph 13 defines the
5401 bitset::set operation to take a second parameter of type int. The
5402 function tests whether this value is non-zero to determine whether to
5403 set the bit to true or false. The type of this second parameter should
5404 be bool. For one thing, the intent is to specify a Boolean value. For
5405 another, the result type from test() is bool. In addition, it's
5406 possible to slice an integer that's larger than an int. This can't
5407 happen with bool, since conversion to bool has the semantic of
5408 translating 0 to false and any non-zero value to true.</p>
5409 <p><b>Proposed resolution:</b></p>
5410 <p>In 23.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.template.bitset"> [lib.template.bitset]</a> Para 1 Replace:</p>
5412 <pre>bitset<N>& set(size_t pos, int val = true ); </pre>
5416 <pre>bitset<N>& set(size_t pos, bool val = true );</pre>
5418 <p>In 23.3.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.members"> [lib.bitset.members]</a> Para 12(.5) Replace:</p>
5420 <pre>bitset<N>& set(size_t pos, int val = 1 );</pre>
5424 <pre>bitset<N>& set(size_t pos, bool val = true );</pre>
5427 <p><i>[Kona: The LWG agrees with the description. Andy Sawyer will work
5428 on better P/R wording.]</i></p>
5429 <p><i>[Post-Tokyo: Andy provided the above wording.]</i></p>
5430 <p><b>Rationale:</b></p>
5431 <p><tt>bool</tt> is a better choice. It is believed that binary
5432 compatibility is not an issue, because this member function is
5433 usually implemented as <tt>inline</tt>, and because it is already
5434 the case that users cannot rely on the type of a pointer to a
5435 nonvirtual member of a standard library class.</p>
5437 <a name="187"><h3>187. iter_swap underspecified</h3></a><p><b>Section:</b> 25.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.swap"> [lib.alg.swap]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 14 Aug 1999</p>
5438 <p>The description of iter_swap in 25.2.2 paragraph 7,says that it
5439 ``exchanges the values'' of the objects to which two iterators
5440 refer.<br> <br> What it doesn't say is whether it does so using swap
5441 or using the assignment operator and copy constructor.<br> <br> This
5442 question is an important one to answer, because swap is specialized to
5443 work efficiently for standard containers.<br> For example:</p>
5445 <pre>vector<int> v1, v2;
5446 iter_swap(&v1, &v2);</pre>
5448 <p>Is this call to iter_swap equivalent to calling swap(v1, v2)?
5449 Or is it equivalent to</p>
5452 vector<int> temp = v1;
5457 <p>The first alternative is O(1); the second is O(n).</p>
5458 <p>A LWG member, Dave Abrahams, comments:</p>
5460 <p>Not an objection necessarily, but I want to point out the cost of
5461 that requirement:</p>
5463 <p><tt>iter_swap(list<T>::iterator, list<T>::iterator)</tt></p>
5465 <p>can currently be specialized to be more efficient than
5466 iter_swap(T*,T*) for many T (by using splicing). Your proposal would
5467 make that optimization illegal. </p>
5470 <p><i>[Kona: The LWG notes the original need for iter_swap was proxy iterators
5471 which are no longer permitted.]</i></p>
5472 <p><b>Proposed resolution:</b></p>
5473 <p>Change the effect clause of iter_swap in 25.2.2 paragraph 7 from:</p>
5475 <p>Exchanges the values pointed to by the two iterators a and b.</p>
5479 <p><tt>swap(*a, *b)</tt>.</p>
5482 <p><b>Rationale:</b></p>
5483 <p>It's useful to say just what <tt>iter_swap</tt> does. There may be
5484 some iterators for which we want to specialize <tt>iter_swap</tt>,
5485 but the fully general version should have a general specification.</p>
5487 <p>Note that in the specific case of <tt>list<T>::iterator</tt>,
5488 iter_swap should not be specialized as suggested above. That would do
5489 much more than exchanging the two iterators' values: it would change
5490 predecessor/successor relationships, possibly moving the iterator from
5491 one list to another. That would surely be inappropriate.</p>
5493 <a name="189"><h3>189. setprecision() not specified correctly</h3></a><p><b>Section:</b> 27.4.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fmtflags.state"> [lib.fmtflags.state]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 25 Aug 1999</p>
5494 <p>27.4.2.2 paragraph 9 claims that setprecision() sets the precision,
5495 and includes a parenthetical note saying that it is the number of
5496 digits after the decimal point.<br>
5498 This claim is not strictly correct. For example, in the default
5499 floating-point output format, setprecision sets the number of
5500 significant digits printed, not the number of digits after the decimal
5503 I would like the committee to look at the definition carefully and
5504 correct the statement in 27.4.2.2</p>
5505 <p><b>Proposed resolution:</b></p>
5506 <p>Remove from 27.4.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fmtflags.state"> [lib.fmtflags.state]</a>, paragraph 9, the text
5507 "(number of digits after the decimal point)".</p>
5509 <a name="193"><h3>193. Heap operations description incorrect</h3></a><p><b>Section:</b> 25.3.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.heap.operations"> [lib.alg.heap.operations]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Markus Mauhart <b>Date:</b> 24 Sep 1999</p>
5510 <p>25.3.6 [lib.alg.heap.operations] states two key properties of a heap [a,b), the first of them
5513 `"(1) *a is the largest element"<br>
5515 I think this is incorrect and should be changed to the wording in the proposed
5517 <p>Actually there are two independent changes:</p>
5519 <p>A-"part of largest equivalence class" instead of "largest", cause 25.3
5520 [lib.alg.sorting] asserts "strict weak ordering" for all its sub clauses.</p>
5522 'an oldest' from that equivalence class, otherwise the heap functions
5523 could not be used for a priority queue as explained in 23.2.3.2.2
5524 [lib.priqueue.members] (where I assume that a "priority queue" respects
5525 priority AND time).</p>
5527 <p><b>Proposed resolution:</b></p>
5528 <p>Change 25.3.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.heap.operations"> [lib.alg.heap.operations]</a> property (1) from:</p>
5530 <p>(1) *a is the largest element</p>
5534 <p>(1) There is no element greater than <tt>*a</tt></p>
5537 <a name="195"><h3>195. Should <tt>basic_istream::sentry</tt>'s constructor ever set eofbit?</h3></a><p><b>Section:</b> 27.6.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::sentry"> [lib.istream::sentry]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 13 Oct 1999</p>
5538 <p>Suppose that <tt>is.flags() & ios_base::skipws</tt> is nonzero.
5539 What should <tt>basic_istream<>::sentry</tt>'s constructor do if it
5540 reaches eof while skipping whitespace? 27.6.1.1.2/5 suggests it
5541 should set failbit. Should it set eofbit as well? The standard
5542 doesn't seem to answer that question.</p>
5544 <p>On the one hand, nothing in 27.6.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::sentry"> [lib.istream::sentry]</a> says that
5545 <tt>basic_istream<>::sentry</tt> should ever set eofbit. On the
5546 other hand, 27.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream"> [lib.istream]</a> paragraph 4 says that if
5547 extraction from a <tt>streambuf</tt> "returns
5548 <tt>traits::eof()</tt>, then the input function, except as explicitly
5549 noted otherwise, completes its actions and does
5550 <tt>setstate(eofbit)"</tt>. So the question comes down to
5551 whether <tt>basic_istream<>::sentry</tt>'s constructor is an
5554 <p>Comments from Jerry Schwarz:</p>
5556 <p>It was always my intention that eofbit should be set any time that a
5557 virtual returned something to indicate eof, no matter what reason
5558 iostream code had for calling the virtual.</p>
5560 The motivation for this is that I did not want to require streambufs
5561 to behave consistently if their virtuals are called after they have
5564 The classic case is a streambuf reading from a UNIX file. EOF isn't
5565 really a state for UNIX file descriptors. The convention is that a
5566 read on UNIX returns 0 bytes to indicate "EOF", but the file
5567 descriptor isn't shut down in any way and future reads do not
5568 necessarily also return 0 bytes. In particular, you can read from
5569 tty's on UNIX even after they have signaled "EOF". (It
5570 isn't always understood that a ^D on UNIX is not an EOF indicator, but
5571 an EOL indicator. By typing a "line" consisting solely of
5572 ^D you cause a read to return 0 bytes, and by convention this is
5573 interpreted as end of file.)</p>
5575 <p><b>Proposed resolution:</b></p>
5576 <p>Add a sentence to the end of 27.6.1.1.2 paragraph 2:</p>
5578 <p>If <tt>is.rdbuf()->sbumpc()</tt> or <tt>is.rdbuf()->sgetc()</tt>
5579 returns <tt>traits::eof()</tt>, the function calls
5580 <tt>setstate(failbit | eofbit)</tt> (which may throw
5581 <tt>ios_base::failure</tt>).
5585 <a name="198"><h3>198. Validity of pointers and references unspecified after iterator destruction</h3></a><p><b>Section:</b> 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 3 Nov 1999</p>
5587 Is a pointer or reference obtained from an iterator still valid after
5588 destruction of the iterator?
5591 Is a pointer or reference obtained from an iterator still valid after the value
5592 of the iterator changes?
5595 <pre>#include <iostream>
5596 #include <vector>
5597 #include <iterator>
5601 typedef std::vector<int> vec_t;
5605 // Is a pointer or reference obtained from an iterator still
5606 // valid after destruction of the iterator?
5607 int * p = &*v.begin();
5608 std::cout << *p << '\n'; // OK?
5610 // Is a pointer or reference obtained from an iterator still
5611 // valid after the value of the iterator changes?
5612 vec_t::iterator iter( v.begin() );
5614 std::cout << *p << '\n'; // OK?
5621 <p>The standard doesn't appear to directly address these
5622 questions. The standard needs to be clarified. At least two real-world
5623 cases have been reported where library implementors wasted
5624 considerable effort because of the lack of clarity in the
5625 standard. The question is important because requiring pointers and
5626 references to remain valid has the effect for practical purposes of
5627 prohibiting iterators from pointing to cached rather than actual
5628 elements of containers.</p>
5630 <p>The standard itself assumes that pointers and references obtained
5631 from an iterator are still valid after iterator destruction or
5632 change. The definition of reverse_iterator::operator*(), 24.4.1.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.conv"> [lib.reverse.iter.conv]</a>, which returns a reference, defines
5636 <pre>Iterator tmp = current;
5637 return *--tmp;</pre>
5639 <p>The definition of reverse_iterator::operator->(), 24.4.1.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.op.star"> [lib.reverse.iter.op.star]</a>, which returns a pointer, defines effects:</p>
5641 <pre>return &(operator*());</pre>
5644 <p>Because the standard itself assumes pointers and references remain
5645 valid after iterator destruction or change, the standard should say so
5646 explicitly. This will also reduce the chance of user code breaking
5647 unexpectedly when porting to a different standard library
5649 <p><b>Proposed resolution:</b></p>
5650 <p>Add a new paragraph to 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a>:</p>
5652 Destruction of an iterator may invalidate pointers and references
5653 previously obtained from that iterator.
5656 <p>Replace paragraph 1 of 24.4.1.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.conv"> [lib.reverse.iter.conv]</a> with:</p>
5659 <p><b>Effects:</b></p>
5660 <pre> this->tmp = current;
5662 return *this->tmp;
5666 [<i>Note:</i> This operation must use an auxiliary member variable,
5667 rather than a temporary variable, to avoid returning a reference that
5668 persists beyond the lifetime of its associated iterator. (See
5669 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a>.) The name of this member variable is shown for
5670 exposition only. <i>--end note</i>]
5674 <p><i>[Post-Tokyo: The issue has been reformulated purely
5675 in terms of iterators.]</i></p>
5677 <p><i>[Pre-Toronto: Steve Cleary pointed out the no-invalidation
5678 assumption by reverse_iterator. The issue and proposed resolution was
5679 reformulated yet again to reflect this reality.]</i></p>
5681 <p><i>[Copenhagen: Steve Cleary pointed out that reverse_iterator
5682 assumes its underlying iterator has persistent pointers and
5683 references. Andy Koenig pointed out that it is possible to rewrite
5684 reverse_iterator so that it no longer makes such an assupmption.
5685 However, this issue is related to issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#299">299</a>. If we
5686 decide it is intentional that <tt>p[n]</tt> may return by value
5687 instead of reference when <tt>p</tt> is a Random Access Iterator,
5688 other changes in reverse_iterator will be necessary.]</i></p>
5689 <p><b>Rationale:</b></p>
5690 <p>This issue has been discussed extensively. Note that it is
5691 <i>not</i> an issue about the behavior of predefined iterators. It is
5692 asking whether or not user-defined iterators are permitted to have
5693 transient pointers and references. Several people presented examples
5694 of useful user-defined iterators that have such a property; examples
5695 include a B-tree iterator, and an "iota iterator" that doesn't point
5696 to memory. Library implementors already seem to be able to cope with
5697 such iterators: they take pains to avoid forming references to memory
5698 that gets iterated past. The only place where this is a problem is
5699 <tt>reverse_iterator</tt>, so this issue changes
5700 <tt>reverse_iterator</tt> to make it work.</p>
5702 <p>This resolution does not weaken any guarantees provided by
5703 predefined iterators like <tt>list<int>::iterator</tt>.
5704 Clause 23 should be reviewed to make sure that guarantees for
5705 predefined iterators are as strong as users expect.</p>
5708 <a name="199"><h3>199. What does <tt>allocate(0)</tt> return?</h3></a><p><b>Section:</b> 20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 19 Nov 1999</p>
5710 Suppose that <tt>A</tt> is a class that conforms to the
5711 Allocator requirements of Table 32, and <tt>a</tt> is an
5712 object of class <tt>A</tt> What should be the return
5713 value of <tt>a.allocate(0)</tt>? Three reasonable
5714 possibilities: forbid the argument <tt>0</tt>, return
5715 a null pointer, or require that the return value be a
5716 unique non-null pointer.
5718 <p><b>Proposed resolution:</b></p>
5720 Add a note to the <tt>allocate</tt> row of Table 32:
5721 "[<i>Note:</i> If <tt>n == 0</tt>, the return value is unspecified. <i>--end note</i>]"</p>
5722 <p><b>Rationale:</b></p>
5723 <p>A key to understanding this issue is that the ultimate use of
5724 allocate() is to construct an iterator, and that iterator for zero
5725 length sequences must be the container's past-the-end
5726 representation. Since this already implies special case code, it
5727 would be over-specification to mandate the return value.
5730 <a name="200"><h3>200. Forward iterator requirements don't allow constant iterators</h3></a><p><b>Section:</b> 24.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.forward.iterators"> [lib.forward.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 19 Nov 1999</p>
5732 In table 74, the return type of the expression <tt>*a</tt> is given
5733 as <tt>T&</tt>, where <tt>T</tt> is the iterator's value type.
5734 For constant iterators, however, this is wrong. ("Value type"
5735 is never defined very precisely, but it is clear that the value type
5736 of, say, <tt>std::list<int>::const_iterator</tt> is supposed to be
5737 <tt>int</tt>, not <tt>const int</tt>.)
5739 <p><b>Proposed resolution:</b></p>
5741 In table 74, in the <tt>*a</tt> and <tt>*r++</tt> rows, change the
5742 return type from "<tt>T&</tt>" to "<tt>T&</tt>
5743 if <tt>X</tt> is mutable, otherwise <tt>const T&</tt>".
5744 In the <tt>a->m</tt> row, change the return type from
5745 "<tt>U&</tt>" to "<tt>U&</tt> if <tt>X</tt> is mutable,
5746 otherwise <tt>const U&</tt>".
5749 <p><i>[Tokyo: The LWG believes this is the tip of a larger iceberg;
5750 there are multiple const problems with the STL portion of the library
5751 and that these should be addressed as a single package. Note
5752 that issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#180">180</a> has already been declared NAD Future for
5753 that very reason.]</i></p>
5755 <p><i>[Redmond: the LWG thinks this is separable from other constness
5756 issues. This issue is just cleanup; it clarifies language that was
5757 written before we had iterator_traits. Proposed resolution was
5758 modified: the original version only discussed *a. It was pointed out
5759 that we also need to worry about *r++ and a->m.]</i></p>
5762 <a name="202"><h3>202. unique() effects unclear when predicate not an equivalence relation</h3></a><p><b>Section:</b> 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andrew Koenig <b>Date:</b> 13 Jan 2000</p>
5764 What should unique() do if you give it a predicate that is not an
5765 equivalence relation? There are at least two plausible answers:
5771 1. You can't, because 25.2.8 says that it it "eliminates all but
5772 the first element from every consecutive group of equal
5773 elements..." and it wouldn't make sense to interpret "equal" as
5774 meaning anything but an equivalence relation. [It also doesn't
5775 make sense to interpret "equal" as meaning ==, because then there
5776 would never be any sense in giving a predicate as an argument at
5781 2. The word "equal" should be interpreted to mean whatever the
5782 predicate says, even if it is not an equivalence relation
5783 (and in particular, even if it is not transitive).
5789 The example that raised this question is from Usenet:
5794 <pre>int f[] = { 1, 3, 7, 1, 2 };
5795 int* z = unique(f, f+5, greater<int>());</pre>
5800 If one blindly applies the definition using the predicate
5801 greater<int>, and ignore the word "equal", you get:
5807 Eliminates all but the first element from every consecutive group
5808 of elements referred to by the iterator i in the range [first, last)
5809 for which *i > *(i - 1).
5815 The first surprise is the order of the comparison. If we wanted to
5816 allow for the predicate not being an equivalence relation, then we
5817 should surely compare elements the other way: pred(*(i - 1), *i). If
5818 we do that, then the description would seem to say: "Break the
5819 sequence into subsequences whose elements are in strictly increasing
5820 order, and keep only the first element of each subsequence". So the
5821 result would be 1, 1, 2. If we take the description at its word, it
5822 would seem to call for strictly DEcreasing order, in which case the
5823 result should be 1, 3, 7, 2.<br>
5825 In fact, the SGI implementation of unique() does neither: It yields 1,
5828 <p><b>Proposed resolution:</b></p>
5829 <p>Change 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> paragraph 1 to:</p>
5831 For a nonempty range, eliminates all but the first element from every
5832 consecutive group of equivalent elements referred to by the iterator
5833 <tt>i</tt> in the range [first+1, last) for which the following
5834 conditions hold: <tt>*(i-1) == *i</tt> or <tt>pred(*(i-1), *i) !=
5839 Also insert a new paragraph, paragraph 2a, that reads: "Requires: The
5840 comparison function must be an equivalence relation."
5843 <p><i>[Redmond: discussed arguments for and against requiring the
5844 comparison function to be an equivalence relation. Straw poll:
5845 14-2-5. First number is to require that it be an equivalence
5846 relation, second number is to explicitly not require that it be an
5847 equivalence relation, third number is people who believe they need
5848 more time to consider the issue. A separate issue: Andy Sawyer
5849 pointed out that "i-1" is incorrect, since "i" can refer to the first
5850 iterator in the range. Matt provided wording to address this
5853 <p><i>[Curaçao: The LWG changed "... the range (first,
5854 last)..." to "... the range [first+1, last)..." for
5855 clarity. They considered this change close enough to editorial to not
5856 require another round of review.]</i></p>
5858 <p><b>Rationale:</b></p>
5859 <p>The LWG also considered an alternative resolution: change
5860 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> paragraph 1 to:</p>
5863 For a nonempty range, eliminates all but the first element from every
5864 consecutive group of elements referred to by the iterator
5865 <tt>i</tt> in the range (first, last) for which the following
5866 conditions hold: <tt>*(i-1) == *i</tt> or <tt>pred(*(i-1), *i) !=
5871 Also insert a new paragraph, paragraph 1a, that reads: "Notes: The
5872 comparison function need not be an equivalence relation."
5876 <p>Informally: the proposed resolution imposes an explicit requirement
5877 that the comparison function be an equivalence relation. The
5878 alternative resolution does not, and it gives enough information so
5879 that the behavior of unique() for a non-equivalence relation is
5880 specified. Both resolutions are consistent with the behavior of
5881 existing implementations.</p>
5883 <a name="208"><h3>208. Unnecessary restriction on past-the-end iterators</h3></a><p><b>Section:</b> 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Stephen Cleary <b>Date:</b> 02 Feb 2000</p>
5884 <p>In 24.1 paragraph 5, it is stated ". . . Dereferenceable and
5885 past-the-end values are always non-singular."</p>
5886 <p>This places an unnecessary restriction on past-the-end iterators for
5887 containers with forward iterators (for example, a singly-linked list). If the
5888 past-the-end value on such a container was a well-known singular value, it would
5889 still satisfy all forward iterator requirements.</p>
5890 <p>Removing this restriction would allow, for example, a singly-linked list
5891 without a "footer" node.</p>
5892 <p>This would have an impact on existing code that expects past-the-end
5893 iterators obtained from different (generic) containers being not equal.</p>
5894 <p><b>Proposed resolution:</b></p>
5895 <p>Change 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a> paragraph 5, the last sentence, from:</p>
5897 <p>Dereferenceable and past-the-end values are always non-singular.</p>
5901 <p>Dereferenceable values are always non-singular. </p>
5903 <p><b>Rationale:</b></p>
5904 <p>For some kinds of containers, including singly linked lists and
5905 zero-length vectors, null pointers are perfectly reasonable past-the-end
5906 iterators. Null pointers are singular.
5909 <a name="209"><h3>209. basic_string declarations inconsistent</h3></a><p><b>Section:</b> 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Igor Stauder <b>Date:</b> 11 Feb 2000</p>
5910 <p>In Section 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> the basic_string member function
5911 declarations use a consistent style except for the following functions:</p>
5913 <pre>void push_back(const charT);
5914 basic_string& assign(const basic_string&);
5915 void swap(basic_string<charT,traits,Allocator>&);</pre>
5917 <p>- push_back, assign, swap: missing argument name <br>
5918 - push_back: use of const with charT (i.e. POD type passed by value
5919 not by reference - should be charT or const charT& )<br>
5920 - swap: redundant use of template parameters in argument
5921 basic_string<charT,traits,Allocator>&</p>
5922 <p><b>Proposed resolution:</b></p>
5923 <p>In Section 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> change the basic_string member
5924 function declarations push_back, assign, and swap to:</p>
5926 <pre>void push_back(charT c);
5928 basic_string& assign(const basic_string& str);
5929 void swap(basic_string& str);</pre>
5931 <p><b>Rationale:</b></p>
5932 <p>Although the standard is in general not consistent in declaration
5933 style, the basic_string declarations are consistent other than the
5934 above. The LWG felt that this was sufficient reason to merit the
5938 <a name="210"><h3>210. distance first and last confused</h3></a><p><b>Section:</b> 25 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.algorithms"> [lib.algorithms]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Lisa Lippincott <b>Date:</b> 15 Feb 2000</p>
5939 <p>In paragraph 9 of section 25 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.algorithms"> [lib.algorithms]</a>, it is written:</p>
5941 <p> In the description of the algorithms operators + and - are used
5942 for some of the iterator categories for which they do not have to
5943 be defined. In these cases the semantics of [...] a-b is the same
5946 <tt>return distance(a, b);</tt></p>
5948 <p><b>Proposed resolution:</b></p>
5949 <p>On the last line of paragraph 9 of section 25 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.algorithms"> [lib.algorithms]</a> change
5950 <tt>"a-b"</tt> to <tt>"b-a".</tt></p>
5951 <p><b>Rationale:</b></p>
5952 <p>There are two ways to fix the defect; change the description to b-a
5953 or change the return to distance(b,a). The LWG preferred the
5954 former for consistency.</p>
5956 <a name="211"><h3>211. operator>>(istream&, string&) doesn't set failbit</h3></a><p><b>Section:</b> 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Scott Snyder <b>Date:</b> 4 Feb 2000</p>
5957 <p>The description of the stream extraction operator for std::string (section
5958 21.3.7.9 [lib.string.io]) does not contain a requirement that failbit be set in
5959 the case that the operator fails to extract any characters from the input
5961 <p>This implies that the typical construction</p>
5963 <pre>std::istream is;
5966 while (is >> str) ... ;</pre>
5968 <p>(which tests failbit) is not required to terminate at EOF.</p>
5969 <p>Furthermore, this is inconsistent with other extraction operators,
5970 which do include this requirement. (See sections 27.6.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted"> [lib.istream.formatted]</a> and 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>), where this
5971 requirement is present, either explicitly or implicitly, for the
5972 extraction operators. It is also present explicitly in the description
5973 of getline (istream&, string&, charT) in section 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> paragraph 8.)</p>
5974 <p><b>Proposed resolution:</b></p>
5975 <p>Insert new paragraph after paragraph 2 in section 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a>:</p>
5978 <p>If the function extracts no characters, it calls
5979 is.setstate(ios::failbit) which may throw ios_base::failure
5983 <a name="212"><h3>212. Empty range behavior unclear for several algorithms</h3></a><p><b>Section:</b> 25.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.min.max"> [lib.alg.min.max]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Nico Josuttis <b>Date:</b> 26 Feb 2000</p>
5984 <p>The standard doesn't specify what min_element() and max_element() shall
5985 return if the range is empty (first equals last). The usual implementations
5986 return last. This problem seems also apply to partition(), stable_partition(),
5987 next_permutation(), and prev_permutation().</p>
5988 <p><b>Proposed resolution:</b></p>
5989 <p>In 25.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.min.max"> [lib.alg.min.max]</a> - Minimum and maximum, paragraphs 7 and
5990 9, append: Returns last if first==last.</p>
5991 <p><b>Rationale:</b></p>
5992 <p>The LWG looked in some detail at all of the above mentioned
5993 algorithms, but believes that except for min_element() and
5994 max_element() it is already clear that last is returned if first ==
5997 <a name="214"><h3>214. set::find() missing const overload</h3></a><p><b>Section:</b> 23.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.set"> [lib.set]</a>, 23.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.multiset"> [lib.multiset]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 28 Feb 2000</p>
5998 <p>The specification for the associative container requirements in
5999 Table 69 state that the find member function should "return
6000 iterator; const_iterator for constant a". The map and multimap
6001 container descriptions have two overloaded versions of find, but set
6002 and multiset do not, all they have is:</p>
6004 <pre>iterator find(const key_type & x) const;</pre>
6006 <p><b>Proposed resolution:</b></p>
6007 <p>Change the prototypes for find(), lower_bound(), upper_bound(), and
6008 equal_range() in section 23.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.set"> [lib.set]</a> and section 23.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.multiset"> [lib.multiset]</a> to each have two overloads:</p>
6010 <pre>iterator find(const key_type & x);
6011 const_iterator find(const key_type & x) const;</pre>
6012 <pre>iterator lower_bound(const key_type & x);
6013 const_iterator lower_bound(const key_type & x) const;</pre>
6014 <pre>iterator upper_bound(const key_type & x);
6015 const_iterator upper_bound(const key_type & x) const;</pre>
6016 <pre>pair<iterator, iterator> equal_range(const key_type & x);
6017 pair<const_iterator, const_iterator> equal_range(const key_type & x) const;</pre>
6020 <p><i>[Tokyo: At the request of the LWG, Judy Ward provided wording
6021 extending the proposed resolution to lower_bound, upper_bound, and
6022 equal_range.]</i></p>
6024 <a name="217"><h3>217. Facets example (Classifying Japanese characters) contains errors</h3></a><p><b>Section:</b> 22.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facets.examples"> [lib.facets.examples]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 29 Feb 2000</p>
6025 <p>The example in 22.2.8, paragraph 11 contains the following errors:</p>
6026 <p>1) The member function `My::JCtype::is_kanji()' is non-const; the function
6027 must be const in order for it to be callable on a const object (a reference to
6028 which which is what std::use_facet<>() returns).</p>
6029 <p>2) In file filt.C, the definition of `JCtype::id' must be qualified with the
6030 name of the namespace `My'.</p>
6031 <p>3) In the definition of `loc' and subsequently in the call to use_facet<>()
6032 in main(), the name of the facet is misspelled: it should read `My::JCtype'
6033 rather than `My::JCType'.</p>
6034 <p><b>Proposed resolution:</b></p>
6035 <p>Replace the "Classifying Japanese characters" example in 22.2.8,
6036 paragraph 11 with the following:</p>
6037 <pre>#include <locale></pre>
6039 using namespace std;
6040 class JCtype : public locale::facet {
6042 static locale::id id; // required for use as a new locale facet
6043 bool is_kanji (wchar_t c) const;
6049 <pre>// file: filt.C
6050 #include <iostream>
6051 #include <locale>
6052 #include "jctype" // above
6053 std::locale::id My::JCtype::id; // the static JCtype member
6054 declared above.</pre>
6057 using namespace std;
6058 typedef ctype<wchar_t> wctype;
6059 locale loc(locale(""), // the user's preferred locale...
6060 new My::JCtype); // and a new feature ...
6061 wchar_t c = use_facet<wctype>(loc).widen('!');
6062 if (!use_facet<My::JCtype>(loc).is_kanji(c))
6063 cout << "no it isn't!" << endl;
6067 <a name="220"><h3>220. ~ios_base() usage valid?</h3></a><p><b>Section:</b> 27.4.2.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios.base.cons"> [lib.ios.base.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Jonathan Schilling, Howard Hinnant <b>Date:</b> 13 Mar 2000</p>
6068 <p>The pre-conditions for the ios_base destructor are described in 27.4.2.7
6071 <p>Effects: Destroys an object of class ios_base. Calls each registered
6072 callback pair (fn,index) (27.4.2.6) as (*fn)(erase_event,*this,index) at such
6073 time that any ios_base member function called from within fn has well defined
6076 <p>But what is not clear is: If no callback functions were ever registered, does
6077 it matter whether the ios_base members were ever initialized?</p>
6078 <p>For instance, does this program have defined behavior:</p>
6080 <pre>#include <ios></pre>
6081 <pre>class D : public std::ios_base { };</pre>
6082 <pre>int main() { D d; }</pre>
6084 <p>It seems that registration of a callback function would surely affect the
6085 state of an ios_base. That is, when you register a callback function with an
6086 ios_base, the ios_base must record that fact somehow.</p>
6087 <p>But if after construction the ios_base is in an indeterminate state, and that
6088 state is not made determinate before the destructor is called, then how would
6089 the destructor know if any callbacks had indeed been registered? And if the
6090 number of callbacks that had been registered is indeterminate, then is not the
6091 behavior of the destructor undefined?</p>
6092 <p>By comparison, the basic_ios class description in 27.4.4.1 paragraph 2 makes
6093 it explicit that destruction before initialization results in undefined
6095 <p><b>Proposed resolution:</b></p>
6096 <p>Modify 27.4.2.7 paragraph 1 from</p>
6098 <p>Effects: Each ios_base member has an indeterminate value after
6103 <p>Effects: Each ios_base member has an indeterminate
6104 value after construction. These members must be initialized by calling
6105 basic_ios::init. If an ios_base object is destroyed before these
6106 initializations have taken place, the behavior is undefined.</p>
6109 <a name="221"><h3>221. num_get<>::do_get stage 2 processing broken</h3></a><p><b>Section:</b> 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 14 Mar 2000</p>
6110 <p>Stage 2 processing of numeric conversion is broken.</p>
6112 <p>Table 55 in 22.2.2.1.2 says that when basefield is 0 the integral
6113 conversion specifier is %i. A %i specifier determines a number's base
6114 by its prefix (0 for octal, 0x for hex), so the intention is clearly
6115 that a 0x prefix is allowed. Paragraph 8 in the same section,
6116 however, describes very precisely how characters are processed. (It
6117 must be done "as if" by a specified code fragment.) That
6118 description does not allow a 0x prefix to be recognized.</p>
6120 <p>Very roughly, stage 2 processing reads a char_type ct. It converts
6121 ct to a char, not by using narrow but by looking it up in a
6122 translation table that was created by widening the string literal
6123 "0123456789abcdefABCDEF+-". The character "x" is
6124 not found in that table, so it can't be recognized by stage 2
6126 <p><b>Proposed resolution:</b></p>
6127 <p>In 22.2.2.1.2 paragraph 8, replace the line:</p>
6129 <pre>static const char src[] = "0123456789abcdefABCDEF+-";</pre>
6131 <p>with the line:</p>
6133 <pre>static const char src[] = "0123456789abcdefxABCDEFX+-";</pre>
6135 <p><b>Rationale:</b></p>
6136 <p>If we're using the technique of widening a string literal, the
6137 string literal must contain every character we wish to recognize.
6138 This technique has the consequence that alternate representations
6139 of digits will not be recognized. This design decision was made
6140 deliberately, with full knowledge of that limitation.</p>
6142 <a name="222"><h3>222. Are throw clauses necessary if a throw is already implied by the effects clause?</h3></a><p><b>Section:</b> 17.3.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.structure.specifications"> [lib.structure.specifications]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 17 Mar 2000</p>
6143 <p>Section 21.3.6.8 describes the basic_string::compare function this way:</p>
6145 <pre>21.3.6.8 - basic_string::compare [lib.string::compare]
6147 int compare(size_type pos1, size_type n1,
6148 const basic_string<charT,traits,Allocator>& str ,
6149 size_type pos2 , size_type n2 ) const;
6153 basic_string<charT,traits,Allocator>(*this,pos1,n1).compare(
6154 basic_string<charT,traits,Allocator>(str,pos2,n2)) .</pre>
6156 <p>and the constructor that's implicitly called by the above is
6157 defined to throw an out-of-range exception if pos > str.size(). See
6158 section 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a> paragraph 4.</p>
6160 <p>On the other hand, the compare function descriptions themselves don't have
6161 "Throws: " clauses and according to 17.3.1.3, paragraph 3, elements
6162 that do not apply to a function are omitted.</p>
6163 <p>So it seems there is an inconsistency in the standard -- are the
6164 "Effects" clauses correct, or are the "Throws" clauses
6166 <p><b>Proposed resolution:</b></p>
6167 <p>In 17.3.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.structure.specifications"> [lib.structure.specifications]</a> paragraph 3, the footnote 148 attached to
6168 the sentence "Descriptions of function semantics contain the
6169 following elements (as appropriate):", insert the word
6170 "further" so that the foot note reads:</p>
6172 <p>To save space, items that do not apply to a function are
6173 omitted. For example, if a function does not specify any further
6174 preconditions, there will be no "Requires" paragraph.</p>
6176 <p><b>Rationale:</b></p>
6177 <p>The standard is somewhat inconsistent, but a failure to note a
6178 throw condition in a throws clause does not grant permission not to
6179 throw. The inconsistent wording is in a footnote, and thus
6180 non-normative. The proposed resolution from the LWG clarifies the
6183 <a name="223"><h3>223. reverse algorithm should use iter_swap rather than swap</h3></a><p><b>Section:</b> 25.2.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.reverse"> [lib.alg.reverse]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 21 Mar 2000</p>
6184 <p>Shouldn't the effects say "applies iter_swap to all pairs..."?</p>
6185 <p><b>Proposed resolution:</b></p>
6186 <p>In 25.2.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.reverse"> [lib.alg.reverse]</a>, replace:</p>
6188 Effects: For each non-negative integer i <= (last - first)/2,
6189 applies swap to all pairs of iterators first + i, (last - i) - 1.
6193 Effects: For each non-negative integer i <= (last - first)/2,
6194 applies iter_swap to all pairs of iterators first + i, (last - i) - 1.
6197 <a name="224"><h3>224. clear() complexity for associative containers refers to undefined N</h3></a><p><b>Section:</b> 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Ed Brey <b>Date:</b> 23 Mar 2000</p>
6198 <p>In the associative container requirements table in 23.1.2 paragraph 7,
6199 a.clear() has complexity "log(size()) + N". However, the meaning of N
6201 <p><b>Proposed resolution:</b></p>
6202 <p>In the associative container requirements table in 23.1.2 paragraph
6203 7, the complexity of a.clear(), change "log(size()) + N" to
6204 "linear in <tt>size()</tt>".</p>
6205 <p><b>Rationale:</b></p>
6206 <p>It's the "log(size())", not the "N", that is in
6207 error: there's no difference between <i>O(N)</i> and <i>O(N +
6208 log(N))</i>. The text in the standard is probably an incorrect
6209 cut-and-paste from the range version of <tt>erase</tt>.</p>
6211 <a name="225"><h3>225. std:: algorithms use of other unqualified algorithms</h3></a><p><b>Section:</b> 17.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.global.functions"> [lib.global.functions]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 01 Apr 2000</p>
6212 <p>Are algorithms in std:: allowed to use other algorithms without qualification, so functions in
6213 user namespaces might be found through Koenig lookup?</p>
6214 <p>For example, a popular standard library implementation includes this
6215 implementation of std::unique:</p>
6217 <pre>namespace std {
6218 template <class _ForwardIter>
6219 _ForwardIter unique(_ForwardIter __first, _ForwardIter __last) {
6220 __first = adjacent_find(__first, __last);
6221 return unique_copy(__first, __last, __first);
6225 <p>Imagine two users on opposite sides of town, each using unique on his own
6226 sequences bounded by my_iterators . User1 looks at his standard library
6227 implementation and says, "I know how to implement a more efficient
6228 unique_copy for my_iterators", and writes:</p>
6230 <pre>namespace user1 {
6232 // faster version for my_iterator
6233 my_iterator unique_copy(my_iterator, my_iterator, my_iterator);
6236 <p>user1::unique_copy() is selected by Koenig lookup, as he intended.</p>
6237 <p>User2 has other needs, and writes:</p>
6239 <pre>namespace user2 {
6241 // Returns true iff *c is a unique copy of *a and *b.
6242 bool unique_copy(my_iterator a, my_iterator b, my_iterator c);
6245 <p>User2 is shocked to find later that his fully-qualified use of
6246 std::unique(user2::my_iterator, user2::my_iterator, user2::my_iterator) fails to
6247 compile (if he's lucky). Looking in the standard, he sees the following Effects
6248 clause for unique():</p>
6250 <p>Effects: Eliminates all but the first element from every consecutive group
6251 of equal elements referred to by the iterator i in the range [first, last) for
6252 which the following corresponding conditions hold: *i == *(i - 1) or pred(*i,
6253 *(i - 1)) != false</p>
6255 <p>The standard gives user2 absolutely no reason to think he can interfere with
6256 std::unique by defining names in namespace user2. His standard library has been
6257 built with the template export feature, so he is unable to inspect the
6258 implementation. User1 eventually compiles his code with another compiler, and
6259 his version of unique_copy silently stops being called. Eventually, he realizes
6260 that he was depending on an implementation detail of his library and had no
6261 right to expect his unique_copy() to be called portably.</p>
6262 <p>On the face of it, and given above scenario, it may seem obvious that the
6263 implementation of unique() shown is non-conforming because it uses unique_copy()
6264 rather than ::std::unique_copy(). Most standard library implementations,
6265 however, seem to disagree with this notion.</p>
6266 <p> <i>[Tokyo: Steve Adamczyk from
6267 the core working group indicates that "std::" is sufficient;
6268 leading "::" qualification is not required because any namespace
6269 qualification is sufficient to suppress Koenig lookup.]</i></p>
6270 <p><b>Proposed resolution:</b></p>
6271 <p>Add a paragraph and a note at the end of
6272 17.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.global.functions"> [lib.global.functions]</a>:</p>
6275 <p>Unless otherwise specified, no global or non-member function in the
6276 standard library shall use a function from another namespace which is
6277 found through <i>argument-dependent name lookup</i> (3.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/basic.html#basic.lookup.koenig"> [basic.lookup.koenig]</a>).</p>
6279 <p>[Note: the phrase "unless otherwise specified" is intended to
6280 allow Koenig lookup in cases like that of ostream_iterators:<br>
6285 <p>*out_stream << value;<br>
6286 if(delim != 0) *out_stream << delim;<br>
6292 <p><i>[Tokyo: The LWG agrees that this is a defect in the standard, but
6293 is as yet unsure if the proposed resolution is the best
6294 solution. Furthermore, the LWG believes that the same problem of
6295 unqualified library names applies to wording in the standard itself,
6296 and has opened issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#229">229</a> accordingly. Any resolution of
6297 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">225</a> should be coordinated with the resolution of
6298 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#229">229</a>.]</i></p>
6300 <p><i>[Toronto: The LWG is not sure if this is a defect in the
6301 standard. Most LWG members believe that an implementation of
6302 <tt>std::unique</tt> like the one quoted in this issue is already
6303 illegal, since, under certain circumstances, its semantics are not
6304 those specified in the standard. The standard's description of
6305 <tt>unique</tt> does not say that overloading <tt>adjacent_find</tt>
6306 should have any effect.]</i></p>
6308 <p><i>[Curaçao: An LWG-subgroup spent an afternoon working on issues
6309 225, 226, and 229. Their conclusion was that the issues should be
6310 separated into an LWG portion (Howard's paper, N1387=02-0045), and a
6311 EWG portion (Dave will write a proposal). The LWG and EWG had
6312 (separate) discussions of this plan the next day. The proposed
6313 resolution for this issue is in accordance with Howard's paper.]</i></p>
6315 <p><b>Rationale:</b></p>
6316 <p>It could be argued that this proposed isn't strictly necessary,
6317 that the Standard doesn't grant implementors license to write a
6318 standard function that behaves differently than specified in the
6319 Standard just because of an unrelated user-defined name in some
6320 other namespace. However, this is at worst a clarification. It is
6321 surely right that algorithsm shouldn't pick up random names, that
6322 user-defined names should have no effect unless otherwise specified.
6323 Issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#226">226</a> deals with the question of when it is
6324 appropriate for the standard to explicitly specify otherwise.</p>
6326 <a name="226"><h3>226. User supplied specializations or overloads of namespace std function templates</h3></a><p><b>Section:</b> 17.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.reserved.names"> [lib.reserved.names]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 01 Apr 2000</p>
6327 <p>The issues are: </p>
6328 <p>1. How can a 3rd party library implementor (lib1) write a version of a standard
6329 algorithm which is specialized to work with his own class template? </p>
6330 <p>2. How can another library implementor (lib2) write a generic algorithm which
6331 will take advantage of the specialized algorithm in lib1?</p>
6332 <p>This appears to be the only viable answer under current language rules:</p>
6336 // arbitrary-precision numbers using T as a basic unit
6337 template <class T>
6338 class big_num { //...
6341 <pre> // defining this in namespace std is illegal (it would be an
6342 // overload), so we hope users will rely on Koenig lookup
6343 template <class T>
6344 void swap(big_int<T>&, big_int<T>&);
6346 <pre>#include <algorithm>
6349 template <class T>
6350 void generic_sort(T* start, T* end)
6353 // using-declaration required so we can work on built-in types
6355 // use Koenig lookup to find specialized algorithm if available
6360 <p>This answer has some drawbacks. First of all, it makes writing lib2 difficult
6361 and somewhat slippery. The implementor needs to remember to write the
6362 using-declaration, or generic_sort will fail to compile when T is a built-in
6363 type. The second drawback is that the use of this style in lib2 effectively
6364 "reserves" names in any namespace which defines types which may
6365 eventually be used with lib2. This may seem innocuous at first when applied to
6366 names like swap, but consider more ambiguous names like unique_copy() instead.
6367 It is easy to imagine the user wanting to define these names differently in his
6368 own namespace. A definition with semantics incompatible with the standard
6369 library could cause serious problems (see issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">225</a>).</p>
6370 <p>Why, you may ask, can't we just partially specialize std::swap()? It's
6371 because the language doesn't allow for partial specialization of function
6372 templates. If you write:</p>
6376 template <class T>
6377 void swap(lib1::big_int<T>&, lib1::big_int<T>&);
6380 <p>You have just overloaded std::swap, which is illegal under the current
6381 language rules. On the other hand, the following full specialization is legal:</p>
6386 void swap(lib1::other_type&, lib1::other_type&);
6390 <p>This issue reflects concerns raised by the "Namespace issue
6391 with specialized swap" thread on comp.lang.c++.moderated. A
6392 similar set of concerns was earlier raised on the boost.org mailing
6393 list and the ACCU-general mailing list. Also see library reflector
6394 message c++std-lib-7354.</p>
6397 J. C. van Winkel points out (in c++std-lib-9565) another unexpected
6398 fact: it's impossible to output a container of std::pair's using copy
6399 and an ostream_iterator, as long as both pair-members are built-in or
6400 std:: types. That's because a user-defined operator<< for (for
6401 example) std::pair<const std::string, int> will not be found:
6402 lookup for operator<< will be performed only in namespace std.
6403 Opinions differed on whether or not this was a defect, and, if so,
6404 whether the defect is that something is wrong with user-defined
6405 functionality and std, or whether it's that the standard library does
6406 not provide an operator<< for std::pair<>.
6409 <p><b>Proposed resolution:</b></p>
6411 <p>Adopt the wording proposed in Howard Hinnant's paper
6412 N1523=03-0106, "Proposed Resolution To LWG issues 225, 226, 229".</p>
6415 <p><i>[Tokyo: Summary, "There is no conforming way to extend
6416 std::swap for user defined templates." The LWG agrees that
6417 there is a problem. Would like more information before
6418 proceeding. This may be a core issue. Core issue 229 has been opened
6419 to discuss the core aspects of this problem. It was also noted that
6420 submissions regarding this issue have been received from several
6421 sources, but too late to be integrated into the issues list.
6424 <p><i>[Post-Tokyo: A paper with several proposed resolutions,
6425 J16/00-0029==WG21/N1252, "Shades of namespace std functions
6426 " by Alan Griffiths, is in the Post-Tokyo mailing. It
6427 should be considered a part of this issue.]</i></p>
6429 <p><i>[Toronto: Dave Abrahams and Peter Dimov have proposed a
6430 resolution that involves core changes: it would add partial
6431 specialization of function template. The Core Working Group is
6432 reluctant to add partial specialization of function templates. It is
6433 viewed as a large change, CWG believes that proposal presented leaves
6434 some syntactic issues unanswered; if the CWG does add partial
6435 specialization of function templates, it wishes to develop its own
6436 proposal. The LWG continues to believe that there is a serious
6437 problem: there is no good way for users to force the library to use
6438 user specializations of generic standard library functions, and in
6439 certain cases (e.g. transcendental functions called by
6440 <tt>valarray</tt> and <tt>complex</tt>) this is important. Koenig
6441 lookup isn't adequate, since names within the library must be
6442 qualified with <tt>std</tt> (see issue 225), specialization doesn't
6443 work (we don't have partial specialization of function templates), and
6444 users aren't permitted to add overloads within namespace std.
6447 <p><i>[Copenhagen: Discussed at length, with no consensus. Relevant
6448 papers in the pre-Copenhagen mailing: N1289, N1295, N1296. Discussion
6449 focused on four options. (1) Relax restrictions on overloads within
6450 namespace std. (2) Mandate that the standard library use unqualified
6451 calls for <tt>swap</tt> and possibly other functions. (3) Introduce
6452 helper class templates for <tt>swap</tt> and possibly other functions.
6453 (4) Introduce partial specialization of function templates. Every
6454 option had both support and opposition. Straw poll (first number is
6455 support, second is strongly opposed): (1) 6, 4; (2) 6, 7; (3) 3, 8;
6458 <p><i>[Redmond: Discussed, again no consensus. Herb presented an
6459 argument that a user who is defining a type <tt>T</tt> with an
6460 associated <tt>swap</tt> should not be expected to put that
6461 <tt>swap</tt> in namespace std, either by overloading or by partial
6462 specialization. The argument is that <tt>swap</tt> is part of
6463 <tt>T</tt>'s interface, and thus should to in the same namespace as
6464 <tt>T</tt> and only in that namespace. If we accept this argument,
6465 the consequence is that standard library functions should use
6466 unqualified call of <tt>swap</tt>. (And which other functions? Any?)
6467 A small group (Nathan, Howard, Jeremy, Dave, Matt, Walter, Marc) will
6468 try to put together a proposal before the next meeting.]</i></p>
6470 <p><i>[Curaçao: An LWG-subgroup spent an afternoon working on issues
6471 225, 226, and 229. Their conclusion was that the issues should be
6472 separated into an LWG portion (Howard's paper, N1387=02-0045), and a
6473 EWG portion (Dave will write a proposal). The LWG and EWG had
6474 (separate) discussions of this plan the next day. The proposed
6475 resolution is the one proposed by Howard.]</i></p>
6477 <p><i>[Santa Cruz: the LWG agreed with the general direction of
6478 Howard's paper, N1387. (Roughly: Koenig lookup is disabled unless
6479 we say otherwise; this issue is about when we do say otherwise.)
6480 However, there were concerns about wording. Howard will provide new
6481 wording. Bill and Jeremy will review it.]</i></p>
6483 <p><i>[Kona: Howard proposed the new wording. The LWG accepted his
6484 proposed resolution.]</i></p>
6486 <p><b>Rationale:</b></p>
6487 <p>Informally: introduce a Swappable concept, and specify that the
6488 value types of the iterators passed to certain standard algorithms
6489 (such as iter_swap, swap_ranges, reverse, rotate, and sort) conform
6490 to that concept. The Swappable concept will make it clear that
6491 these algorithms use unqualified lookup for the calls
6492 to <tt>swap</tt>. Also, in <font color="red">26.3.3.3</font> paragraph 1,
6493 state that the valarray transcendentals use unqualified lookup.</p>
6495 <a name="227"><h3>227. std::swap() should require CopyConstructible or DefaultConstructible arguments</h3></a><p><b>Section:</b> 25.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.swap"> [lib.alg.swap]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#TC">TC</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 09 Apr 2000</p>
6496 <p>25.2.2 reads:</p>
6498 <p><tt> template<class T> void swap(T& a, T& b);</tt><br>
6500 Requires: Type T is Assignable (_lib.container.requirements_).<br>
6501 Effects: Exchanges values stored in two locations.</p>
6503 <p>The only reasonable** generic implementation of swap requires construction of a
6504 new temporary copy of one of its arguments:</p>
6506 <pre>template<class T> void swap(T& a, T& b);
6513 <p>But a type which is only Assignable cannot be swapped by this implementation.</p>
6514 <p>**Yes, there's also an unreasonable implementation which would require T to be
6515 DefaultConstructible instead of CopyConstructible. I don't think this is worthy
6516 of consideration:</p>
6518 <pre>template<class T> void swap(T& a, T& b);
6526 <p><b>Proposed resolution:</b></p>
6527 <p>Change 25.2.2 paragraph 1 from:</p>
6529 <p> Requires: Type T is Assignable (23.1).</p>
6533 <p> Requires: Type T is CopyConstructible (20.1.3) and Assignable (23.1)</p>
6536 <a name="228"><h3>228. Incorrect specification of "..._byname" facets</h3></a><p><b>Section:</b> 22.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.categories"> [lib.locale.categories]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 20 Apr 2000</p>
6537 <p>The sections 22.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.byname"> [lib.locale.ctype.byname]</a>, 22.2.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt"> [lib.locale.codecvt]</a>,
6538 <font color="red">22.2.1.6</font>, 22.2.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.numpunct.byname"> [lib.locale.numpunct.byname]</a>, 22.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.collate.byname"> [lib.locale.collate.byname]</a>, 22.2.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.put.byname"> [lib.locale.time.put.byname]</a>, 22.2.6.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.moneypunct.byname"> [lib.locale.moneypunct.byname]</a>, and 22.2.7.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.messages.byname"> [lib.locale.messages.byname]</a> overspecify the
6539 definitions of the "..._byname" classes by listing a bunch
6540 of virtual functions. At the same time, no semantics of these
6541 functions are defined. Real implementations do not define these
6542 functions because the functional part of the facets is actually
6543 implemented in the corresponding base classes and the constructor of
6544 the "..._byname" version just provides suitable date used by
6545 these implementations. For example, the 'numpunct' methods just return
6546 values from a struct. The base class uses a statically initialized
6547 struct while the derived version reads the contents of this struct
6548 from a table. However, no virtual function is defined in
6549 'numpunct_byname'.</p>
6551 <p>For most classes this does not impose a problem but specifically
6552 for 'ctype' it does: The specialization for 'ctype_byname<char>'
6553 is required because otherwise the semantics would change due to the
6554 virtual functions defined in the general version for 'ctype_byname':
6555 In 'ctype<char>' the method 'do_is()' is not virtual but it is
6556 made virtual in both 'ctype<cT>' and 'ctype_byname<cT>'.
6557 Thus, a class derived from 'ctype_byname<char>' can tell whether
6558 this class is specialized or not under the current specification:
6559 Without the specialization, 'do_is()' is virtual while with
6560 specialization it is not virtual.</p>
6561 <p><b>Proposed resolution:</b></p>
6562 <p> Change section 22.2.1.2 (lib.locale.ctype.byname) to become:</p>
6563 <pre> namespace std {
6564 template <class charT>
6565 class ctype_byname : public ctype<charT> {
6567 typedef ctype<charT>::mask mask;
6568 explicit ctype_byname(const char*, size_t refs = 0);
6570 ~ctype_byname(); // virtual
6573 <p> Change section 22.2.1.6 (lib.locale.codecvt.byname) to become:</p>
6574 <pre> namespace std {
6575 template <class internT, class externT, class stateT>
6576 class codecvt_byname : public codecvt<internT, externT, stateT> {
6578 explicit codecvt_byname(const char*, size_t refs = 0);
6580 ~codecvt_byname(); // virtual
6584 <p> Change section 22.2.3.2 (lib.locale.numpunct.byname) to become:</p>
6585 <pre> namespace std {
6586 template <class charT>
6587 class numpunct_byname : public numpunct<charT> {
6588 // this class is specialized for char and wchar_t.
6590 typedef charT char_type;
6591 typedef basic_string<charT> string_type;
6592 explicit numpunct_byname(const char*, size_t refs = 0);
6594 ~numpunct_byname(); // virtual
6597 <p> Change section 22.2.4.2 (lib.locale.collate.byname) to become:</p>
6598 <pre> namespace std {
6599 template <class charT>
6600 class collate_byname : public collate<charT> {
6602 typedef basic_string<charT> string_type;
6603 explicit collate_byname(const char*, size_t refs = 0);
6605 ~collate_byname(); // virtual
6608 <p> Change section 22.2.5.2 (lib.locale.time.get.byname) to become:</p>
6609 <pre> namespace std {
6610 template <class charT, class InputIterator = istreambuf_iterator<charT> >
6611 class time_get_byname : public time_get<charT, InputIterator> {
6613 typedef time_base::dateorder dateorder;
6614 typedef InputIterator iter_type</pre>
6615 <pre> explicit time_get_byname(const char*, size_t refs = 0);
6617 ~time_get_byname(); // virtual
6620 <p> Change section 22.2.5.4 (lib.locale.time.put.byname) to become:</p>
6621 <pre> namespace std {
6622 template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
6623 class time_put_byname : public time_put<charT, OutputIterator>
6626 typedef charT char_type;
6627 typedef OutputIterator iter_type;</pre>
6628 <pre> explicit time_put_byname(const char*, size_t refs = 0);
6630 ~time_put_byname(); // virtual
6633 <p> Change section 22.2.6.4 (lib.locale.moneypunct.byname) to become:</p>
6634 <pre> namespace std {
6635 template <class charT, bool Intl = false>
6636 class moneypunct_byname : public moneypunct<charT, Intl> {
6638 typedef money_base::pattern pattern;
6639 typedef basic_string<charT> string_type;</pre>
6640 <pre> explicit moneypunct_byname(const char*, size_t refs = 0);
6642 ~moneypunct_byname(); // virtual
6645 <p> Change section 22.2.7.2 (lib.locale.messages.byname) to become:</p>
6646 <pre> namespace std {
6647 template <class charT>
6648 class messages_byname : public messages<charT> {
6650 typedef messages_base::catalog catalog;
6651 typedef basic_string<charT> string_type;</pre>
6652 <pre> explicit messages_byname(const char*, size_t refs = 0);
6654 ~messages_byname(); // virtual
6657 <p>Remove section 22.2.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt"> [lib.locale.codecvt]</a> completely (because in
6658 this case only those members are defined to be virtual which are
6659 defined to be virtual in 'ctype<cT>'.)</p>
6661 <p><i>[Post-Tokyo: Dietmar Kühl submitted this issue at the request of
6662 the LWG to solve the underlying problems raised by issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#138">138</a>.]</i></p>
6664 <p><i>[Copenhagen: proposed resolution was revised slightly, to remove
6665 three last virtual functions from <tt>messages_byname</tt>.]</i></p>
6668 <a name="229"><h3>229. Unqualified references of other library entities</h3></a><p><b>Section:</b> 17.4.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.contents"> [lib.contents]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 19 Apr 2000</p>
6669 <p>Throughout the library chapters, the descriptions of library entities refer
6670 to other library entities without necessarily qualifying the names.</p>
6672 <p>For example, section 25.2.2 "Swap" describes the effect of
6673 swap_ranges in terms of the unqualified name "swap". This section
6674 could reasonably be interpreted to mean that the library must be implemented so
6675 as to do a lookup of the unqualified name "swap", allowing users to
6676 override any ::std::swap function when Koenig lookup applies.</p>
6678 <p>Although it would have been best to use explicit qualification with
6679 "::std::" throughout, too many lines in the standard would have to be
6680 adjusted to make that change in a Technical Corrigendum.</p>
6682 <p>Issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#182">182</a>, which addresses qualification of
6683 <tt>size_t</tt>, is a special case of this.
6685 <p><b>Proposed resolution:</b></p>
6686 <p>To section 17.4.1.1 "Library contents" Add the following paragraph:</p>
6688 <p>Whenever a name x defined in the standard library is mentioned, the name x
6689 is assumed to be fully qualified as ::std::x, unless explicitly described
6690 otherwise. For example, if the Effects section for library function F is
6691 described as calling library function G, the function ::std::G is meant.</p>
6694 <p><i>[Post-Tokyo: Steve Clamage submitted this issue at the request of
6695 the LWG to solve a problem in the standard itself similar to the
6696 problem within implementations of library identified by issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">225</a>. Any resolution of issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#225">225</a> should be
6697 coordinated with the resolution of this issue.]</i></p>
6699 <p><i>[post-Toronto: Howard is undecided about whether it is
6700 appropriate for all standard library function names referred to in
6701 other standard library functions to be explicitly qualified by
6702 <tt>std</tt>: it is common advice that users should define global
6703 functions that operate on their class in the same namespace as the
6704 class, and this requires argument-dependent lookup if those functions
6705 are intended to be called by library code. Several LWG members are
6706 concerned that valarray appears to require argument-dependent lookup,
6707 but that the wording may not be clear enough to fall under
6708 "unless explicitly described otherwise".]</i></p>
6710 <p><i>[Curaçao: An LWG-subgroup spent an afternoon working on issues
6711 225, 226, and 229. Their conclusion was that the issues should be
6712 separated into an LWG portion (Howard's paper, N1387=02-0045), and a
6713 EWG portion (Dave will write a proposal). The LWG and EWG had
6714 (separate) discussions of this plan the next day. This paper resolves
6715 issues 225 and 226. In light of that resolution, the proposed
6716 resolution for the current issue makes sense.]</i></p>
6719 <a name="230"><h3>230. Assignable specified without also specifying CopyConstructible</h3></a><p><b>Section:</b> 17 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.library"> [lib.library]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 26 Apr 2000</p>
6720 <p>Issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#227">227</a> identified an instance (std::swap) where
6721 Assignable was specified without also specifying
6722 CopyConstructible. The LWG asked that the standard be searched to
6723 determine if the same defect existed elsewhere.</p>
6725 <p>There are a number of places (see proposed resolution below) where
6726 Assignable is specified without also specifying
6727 CopyConstructible. There are also several cases where both are
6728 specified. For example, 26.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.rand.req"> [lib.rand.req]</a>.</p>
6729 <p><b>Proposed resolution:</b></p>
6730 <p>In 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> table 65 for value_type:
6731 change "T is Assignable" to "T is CopyConstructible and
6735 <p>In 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> table 69 X::key_type; change
6736 "Key is Assignable" to "Key is
6737 CopyConstructible and Assignable"<br>
6740 <p>In 24.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.output.iterators"> [lib.output.iterators]</a> paragraph 1, change:
6743 <p> A class or a built-in type X satisfies the requirements of an
6744 output iterator if X is an Assignable type (23.1) and also the
6745 following expressions are valid, as shown in Table 73:
6751 <p> A class or a built-in type X satisfies the requirements of an
6752 output iterator if X is a CopyConstructible (20.1.3) and Assignable
6753 type (23.1) and also the following expressions are valid, as shown in
6758 <p><i>[Post-Tokyo: Beman Dawes submitted this issue at the request of
6759 the LWG. He asks that the 25.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.replace"> [lib.alg.replace]</a> and 25.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.fill"> [lib.alg.fill]</a> changes be studied carefully, as it is not clear that
6760 CopyConstructible is really a requirement and may be
6761 overspecification.]</i></p>
6763 <p><i>[Portions of the resolution for issue 230 have been superceded by
6764 the resolution of issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#276">276</a>.]</i></p>
6766 <p><b>Rationale:</b></p>
6767 <p>The original proposed resolution also included changes to input
6768 iterator, fill, and replace. The LWG believes that those changes are
6769 not necessary. The LWG considered some blanket statement, where an
6770 Assignable type was also required to be Copy Constructible, but
6771 decided against this because fill and replace really don't require the
6772 Copy Constructible property.</p>
6774 <a name="231"><h3>231. Precision in iostream?</h3></a><p><b>Section:</b> 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> James Kanze, Stephen Clamage <b>Date:</b> 25 Apr 2000</p>
6775 <p>What is the following program supposed to output?</p>
6776 <pre>#include <iostream>
6781 std::cout.setf( std::ios::scientific , std::ios::floatfield ) ;
6782 std::cout.precision( 0 ) ;
6783 std::cout << 1.00 << '\n' ;
6786 <p>From my C experience, I would expect "1e+00"; this is what
6787 <tt>printf("%.0e" , 1.00 );</tt> does. G++ outputs
6790 <p>The only indication I can find in the standard is 22.2.2.2.2/11,
6791 where it says "For conversion from a floating-point type, if
6792 (flags & fixed) != 0 or if str.precision() > 0, then
6793 str.precision() is specified in the conversion specification."
6794 This is an obvious error, however, fixed is not a mask for a field,
6795 but a value that a multi-bit field may take -- the results of and'ing
6796 fmtflags with ios::fixed are not defined, at least not if
6797 ios::scientific has been set. G++'s behavior corresponds to what might
6798 happen if you do use (flags & fixed) != 0 with a typical
6799 implementation (floatfield == 3 << something, fixed == 1
6800 << something, and scientific == 2 << something).</p>
6802 <p>Presumably, the intent is either (flags & floatfield) != 0, or
6803 (flags & floatfield) == fixed; the first gives something more or
6804 less like the effect of precision in a printf floating point
6805 conversion. Only more or less, of course. In order to implement printf
6806 formatting correctly, you must know whether the precision was
6807 explicitly set or not. Say by initializing it to -1, instead of 6, and
6808 stating that for floating point conversions, if precision < -1, 6
6809 will be used, for fixed point, if precision < -1, 1 will be used,
6810 etc. Plus, of course, if precision == 0 and flags & floatfield ==
6811 0, 1 should be = used. But it probably isn't necessary to emulate all
6812 of the anomalies of printf:-).</p>
6813 <p><b>Proposed resolution:</b></p>
6815 Replace 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a>, paragraph 11, with the following
6819 For conversion from a floating-point type,
6820 <tt><i>str</i>.precision()</tt> is specified in the conversion
6823 <p><b>Rationale:</b></p>
6824 <p>The floatfield determines whether numbers are formatted as if
6825 with %f, %e, or %g. If the <tt>fixed</tt> bit is set, it's %f,
6826 if <tt>scientific</tt> it's %e, and if both bits are set, or
6827 neither, it's %g.</p>
6828 <p>Turning to the C standard, a precision of 0 is meaningful
6829 for %f and %e. For %g, precision 0 is taken to be the same as
6831 <p>The proposed resolution has the effect that if neither
6832 <tt>fixed</tt> nor <tt>scientific</tt> is set we'll be
6833 specifying a precision of 0, which will be internally
6834 turned into 1. There's no need to call it out as a special
6836 <p>The output of the above program will be "1e+00".</p>
6838 <p><i>[Post-Curaçao: Howard provided improved wording covering the case
6839 where precision is 0 and mode is %g.]</i></p>
6842 <a name="232"><h3>232. "depends" poorly defined in 17.4.3.1</h3></a><p><b>Section:</b> 17.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.reserved.names"> [lib.reserved.names]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Peter Dimov <b>Date:</b> 18 Apr 2000</p>
6843 <p>17.4.3.1/1 uses the term "depends" to limit the set of allowed
6844 specializations of standard templates to those that "depend on a
6845 user-defined name of external linkage."</p>
6846 <p>This term, however, is not adequately defined, making it possible to
6847 construct a specialization that is, I believe, technically legal according to
6848 17.4.3.1/1, but that specializes a standard template for a built-in type such as
6850 <p>The following code demonstrates the problem:</p>
6852 <pre>#include <algorithm></pre>
6853 <pre>template<class T> struct X
6859 template<> void swap(::X<int>::type& i, ::X<int>::type& j);
6862 <p><b>Proposed resolution:</b></p>
6863 <p>Change "user-defined name" to "user-defined
6865 <p><b>Rationale:</b></p>
6866 <p>This terminology is used in section 2.5.2 and 4.1.1 of <i>The C++
6867 Programming Language</i>. It disallows the example in the issue,
6868 since the underlying type itself is not user-defined. The only
6869 possible problem I can see is for non-type templates, but there's no
6870 possible way for a user to come up with a specialization for bitset,
6871 for example, that might not have already been specialized by the
6874 <p><i>[Toronto: this may be related to issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#120">120</a>.]</i></p>
6876 <p><i>[post-Toronto: Judy provided the above proposed resolution and
6879 <a name="234"><h3>234. Typos in allocator definition</h3></a><p><b>Section:</b> 20.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.allocator.members"> [lib.allocator.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 24 Apr 2000</p>
6880 <p>In paragraphs 12 and 13 the effects of <tt>construct()</tt> and
6881 <tt>destruct()</tt> are described as returns but the functions actually
6882 return <tt>void</tt>.</p>
6883 <p><b>Proposed resolution:</b></p>
6884 <p>Substitute "Returns" by "Effect".</p>
6886 <a name="235"><h3>235. No specification of default ctor for reverse_iterator</h3></a><p><b>Section:</b> 24.4.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iterator"> [lib.reverse.iterator]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 24 Apr 2000</p>
6887 <p>The declaration of <tt>reverse_iterator</tt> lists a default
6888 constructor. However, no specification is given what this constructor
6890 <p><b>Proposed resolution:</b></p>
6891 <p>In section 24.4.1.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.cons"> [lib.reverse.iter.cons]</a> add the following
6894 <p><tt>reverse_iterator()</tt></p>
6896 <p>Default initializes <tt>current</tt>. Iterator operations
6897 applied to the resulting iterator have defined behavior if and
6898 only if the corresponding operations are defined on a default
6899 constructed iterator of type <tt>Iterator</tt>.</p>
6901 <p><i>[pre-Copenhagen: Dietmar provide wording for proposed
6902 resolution.]</i></p>
6904 <a name="237"><h3>237. Undefined expression in complexity specification</h3></a><p><b>Section:</b> 23.2.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.cons"> [lib.deque.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 24 Apr 2000</p>
6905 <p>The complexity specification in paragraph 6 says that the complexity
6906 is linear in <tt>first - last</tt>. Even if <tt>operator-()</tt> is
6907 defined on iterators this term is in general undefined because it
6908 would have to be <tt>last - first</tt>.</p>
6909 <p><b>Proposed resolution:</b></p>
6910 <p>Change paragraph 6 from</p>
6911 <blockquote>Linear in <i>first - last</i>.</blockquote>
6913 <blockquote>Linear in <i>distance(first, last)</i>.</blockquote>
6915 <a name="238"><h3>238. Contradictory results of stringbuf initialization.</h3></a><p><b>Section:</b> 27.7.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.cons"> [lib.stringbuf.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dietmar Kühl <b>Date:</b> 11 May 2000</p>
6916 <p>In 27.7.1.1 paragraph 4 the results of calling the constructor of
6917 'basic_stringbuf' are said to be <tt>str() == str</tt>. This is fine
6918 that far but consider this code:</p>
6920 <pre> std::basic_stringbuf<char> sbuf("hello, world", std::ios_base::openmode(0));
6921 std::cout << "'" << sbuf.str() << "'\n";
6924 <p>Paragraph 3 of 27.7.1.1 basically says that in this case neither
6925 the output sequence nor the input sequence is initialized and
6926 paragraph 2 of 27.7.1.2 basically says that <tt>str()</tt> either
6927 returns the input or the output sequence. None of them is initialized,
6928 ie. both are empty, in which case the return from <tt>str()</tt> is
6929 defined to be <tt>basic_string<cT>()</tt>.</p>
6931 <p>However, probably only test cases in some testsuites will detect this
6933 <p><b>Proposed resolution:</b></p>
6934 <p>Remove 27.7.1.1 paragraph 4.</p>
6935 <p><b>Rationale:</b></p>
6936 <p>We could fix 27.7.1.1 paragraph 4, but there would be no point. If
6937 we fixed it, it would say just the same thing as text that's already
6938 in the standard.</p>
6940 <a name="239"><h3>239. Complexity of unique() and/or unique_copy incorrect</h3></a><p><b>Section:</b> 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> May 15 2000</p>
6941 <p>The complexity of unique and unique_copy are inconsistent with each
6942 other and inconsistent with the implementations. The standard
6945 <p>for unique():</p>
6947 <blockquote>-3- Complexity: If the range (last - first) is not empty, exactly
6948 (last - first) - 1 applications of the corresponding predicate, otherwise
6949 no applications of the predicate.</blockquote>
6951 <p>for unique_copy():</p>
6953 <blockquote>-7- Complexity: Exactly last - first applications of the corresponding
6954 predicate.</blockquote>
6957 The implementations do it the other way round: unique() applies the
6958 predicate last-first times and unique_copy() applies it last-first-1
6961 <p>As both algorithms use the predicate for pair-wise comparison of
6962 sequence elements I don't see a justification for unique_copy()
6963 applying the predicate last-first times, especially since it is not
6964 specified to which pair in the sequence the predicate is applied
6966 <p><b>Proposed resolution:</b></p>
6967 <p>Change both complexity sections in 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> to:</p>
6969 <blockquote>Complexity: For nonempty ranges, exactly last - first - 1
6970 applications of the corresponding predicate.</blockquote>
6973 <a name="240"><h3>240. Complexity of adjacent_find() is meaningless</h3></a><p><b>Section:</b> 25.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.adjacent.find"> [lib.alg.adjacent.find]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> May 15 2000</p>
6974 <p>The complexity section of adjacent_find is defective:</p>
6977 <pre>template <class ForwardIterator>
6978 ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last
6979 BinaryPredicate pred);
6982 <p>-1- Returns: The first iterator i such that both i and i + 1 are in
6983 the range [first, last) for which the following corresponding
6984 conditions hold: *i == *(i + 1), pred(*i, *(i + 1)) != false. Returns
6985 last if no such iterator is found.</p>
6987 <p>-2- Complexity: Exactly find(first, last, value) - first applications
6988 of the corresponding predicate.
6992 <p>In the Complexity section, it is not defined what "value"
6993 is supposed to mean. My best guess is that "value" means an
6994 object for which one of the conditions pred(*i,value) or
6995 pred(value,*i) is true, where i is the iterator defined in the Returns
6996 section. However, the value type of the input sequence need not be
6997 equality-comparable and for this reason the term find(first, last,
6998 value) - first is meaningless.</p>
7000 <p>A term such as find_if(first, last, bind2nd(pred,*i)) - first or
7001 find_if(first, last, bind1st(pred,*i)) - first might come closer to
7002 the intended specification. Binders can only be applied to function
7003 objects that have the function call operator declared const, which is
7004 not required of predicates because they can have non-const data
7005 members. For this reason, a specification using a binder could only be
7006 an "as-if" specification.</p>
7007 <p><b>Proposed resolution:</b></p>
7008 <p>Change the complexity section in 25.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.adjacent.find"> [lib.alg.adjacent.find]</a> to:</p>
7010 For a nonempty range, exactly <tt>min((<i>i</i> - <i>first</i>) + 1,
7011 (<i>last</i> - <i>first</i>) - 1)</tt> applications of the
7012 corresponding predicate, where <i>i</i> is <tt>adjacent_find</tt>'s
7016 <p><i>[Copenhagen: the original resolution specified an upper
7017 bound. The LWG preferred an exact count.]</i></p>
7020 <a name="241"><h3>241. Does unique_copy() require CopyConstructible and Assignable?</h3></a><p><b>Section:</b> 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> May 15 2000</p>
7022 <p>Some popular implementations of unique_copy() create temporary
7023 copies of values in the input sequence, at least if the input iterator
7024 is a pointer. Such an implementation is built on the assumption that
7025 the value type is CopyConstructible and Assignable.</p>
7027 <p>It is common practice in the standard that algorithms explicitly
7028 specify any additional requirements that they impose on any of the
7029 types used by the algorithm. An example of an algorithm that creates
7030 temporary copies and correctly specifies the additional requirements
7031 is accumulate(), 26.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.rand.req"> [lib.rand.req]</a>.</p>
7033 <p>Since the specifications of unique() and unique_copy() do not
7034 require CopyConstructible and Assignable of the InputIterator's value
7035 type the above mentioned implementations are not standard-compliant. I
7036 cannot judge whether this is a defect in the standard or a defect in
7037 the implementations.</p>
7038 <p><b>Proposed resolution:</b></p>
7039 <p>In 25.2.8 change:</p>
7042 -4- Requires: The ranges [first, last) and [result, result+(last-first))
7049 <p>-4- Requires: The ranges [first, last) and [result,
7050 result+(last-first)) shall not overlap. The expression *result =
7051 *first must be valid. If neither InputIterator nor OutputIterator
7052 meets the requirements of forward iterator then the value type of
7053 InputIterator must be copy constructible. Otherwise copy
7054 constructible is not required. </p>
7057 <p><i>[Redmond: the original proposed resolution didn't impose an
7058 explicit requirement that the iterator's value type must be copy
7059 constructible, on the grounds that an input iterator's value type must
7060 always be copy constructible. Not everyone in the LWG thought that
7061 this requirement was clear from table 72. It has been suggested that
7062 it might be possible to implement <tt>unique_copy</tt> without
7063 requiring assignability, although current implementations do impose
7064 that requirement. Howard provided new wording.]</i></p>
7067 Curaçao: The LWG changed the PR editorially to specify
7068 "neither...nor...meet..." as clearer than
7069 "both...and...do not meet...". Change believed to be so
7070 minor as not to require re-review.
7074 <a name="242"><h3>242. Side effects of function objects</h3></a><p><b>Section:</b> 25.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.transform"> [lib.alg.transform]</a>, 26.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.rand"> [lib.rand]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Angelika Langer <b>Date:</b> May 15 2000</p>
7075 <p>The algorithms transform(), accumulate(), inner_product(),
7076 partial_sum(), and adjacent_difference() require that the function
7077 object supplied to them shall not have any side effects.</p>
7079 <p>The standard defines a side effect in 1.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/intro.html#intro.execution"> [intro.execution]</a> as:</p>
7080 <blockquote>-7- Accessing an object designated by a volatile lvalue (basic.lval),
7081 modifying an object, calling a library I/O function, or calling a function
7082 that does any of those operations are all side effects, which are changes
7083 in the state of the execution environment.</blockquote>
7085 <p>As a consequence, the function call operator of a function object supplied
7086 to any of the algorithms listed above cannot modify data members, cannot
7087 invoke any function that has a side effect, and cannot even create and
7088 modify temporary objects. It is difficult to imagine a function object
7089 that is still useful under these severe limitations. For instance, any
7090 non-trivial transformator supplied to transform() might involve creation
7091 and modification of temporaries, which is prohibited according to the current
7092 wording of the standard.</p>
7094 <p>On the other hand, popular implementations of these algorithms exhibit
7095 uniform and predictable behavior when invoked with a side-effect-producing
7096 function objects. It looks like the strong requirement is not needed for
7097 efficient implementation of these algorithms.</p>
7099 <p>The requirement of side-effect-free function objects could be
7100 replaced by a more relaxed basic requirement (which would hold for all
7101 function objects supplied to any algorithm in the standard library):</p>
7102 <blockquote>A function objects supplied to an algorithm shall not invalidate
7103 any iterator or sequence that is used by the algorithm. Invalidation of
7104 the sequence includes destruction of the sorting order if the algorithm
7105 relies on the sorting order (see section 25.3 - Sorting and related operations
7106 [lib.alg.sorting]).</blockquote>
7108 <p>I can't judge whether it is intended that the function objects supplied
7109 to transform(), accumulate(), inner_product(), partial_sum(), or adjacent_difference()
7110 shall not modify sequence elements through dereferenced iterators.</p>
7112 <p>It is debatable whether this issue is a defect or a change request.
7113 Since the consequences for user-supplied function objects are drastic and
7114 limit the usefulness of the algorithms significantly I would consider it
7116 <p><b>Proposed resolution:</b></p>
7118 <p><i>Things to notice about these changes:</i></p>
7121 <li> <i>The fully-closed ("[]" as opposed to half-closed "[)" ranges
7122 are intentional. we want to prevent side-effects from
7123 invalidating the end iterators.</i>
7126 <li> <i>That has the unintentional side-effect of prohibiting
7127 modification of the end element as a side-effect. This could
7128 conceivably be significant in some cases.</i>
7131 <li> <i>The wording also prevents side-effects from modifying elements
7132 of the output sequence. I can't imagine why anyone would want
7133 to do this, but it is arguably a restriction that implementors
7134 don't need to place on users.</i>
7137 <li> <i>Lifting the restrictions imposed in #2 and #3 above is possible
7138 and simple, but would require more verbiage.</i>
7142 <p>Change 25.2.3/2 from:</p>
7145 -2- Requires: op and binary_op shall not have any side effects.
7151 -2- Requires: in the ranges [first1, last1], [first2, first2 +
7152 (last1 - first1)] and [result, result + (last1- first1)], op and
7153 binary_op shall neither modify elements nor invalidate iterators or
7155 [Footnote: The use of fully closed ranges is intentional --end footnote]
7159 <p>Change 25.2.3/2 from:</p>
7162 -2- Requires: op and binary_op shall not have any side effects.
7168 -2- Requires: op and binary_op shall not invalidate iterators or
7169 subranges, or modify elements in the ranges [first1, last1],
7170 [first2, first2 + (last1 - first1)], and [result, result + (last1
7172 [Footnote: The use of fully closed ranges is intentional --end footnote]
7176 <p>Change 26.4.1/2 from:</p>
7179 -2- Requires: T must meet the requirements of CopyConstructible
7180 (lib.copyconstructible) and Assignable (lib.container.requirements)
7181 types. binary_op shall not cause side effects.
7187 -2- Requires: T must meet the requirements of CopyConstructible
7188 (lib.copyconstructible) and Assignable
7189 (lib.container.requirements) types. In the range [first, last],
7190 binary_op shall neither modify elements nor invalidate iterators
7192 [Footnote: The use of a fully closed range is intentional --end footnote]
7195 <p>Change 26.4.2/2 from:</p>
7198 -2- Requires: T must meet the requirements of CopyConstructible
7199 (lib.copyconstructible) and Assignable (lib.container.requirements)
7200 types. binary_op1 and binary_op2 shall not cause side effects.
7206 -2- Requires: T must meet the requirements of CopyConstructible
7207 (lib.copyconstructible) and Assignable (lib.container.requirements)
7208 types. In the ranges [first, last] and [first2, first2 + (last -
7209 first)], binary_op1 and binary_op2 shall neither modify elements
7210 nor invalidate iterators or subranges.
7211 [Footnote: The use of fully closed ranges is intentional --end footnote]
7215 <p>Change 26.4.3/4 from:</p>
7218 -4- Requires: binary_op is expected not to have any side effects.
7224 -4- Requires: In the ranges [first, last] and [result, result +
7225 (last - first)], binary_op shall neither modify elements nor
7226 invalidate iterators or subranges.
7227 [Footnote: The use of fully closed ranges is intentional --end footnote]
7230 <p>Change 26.4.4/2 from:</p>
7233 -2- Requires: binary_op shall not have any side effects.
7239 -2- Requires: In the ranges [first, last] and [result, result +
7240 (last - first)], binary_op shall neither modify elements nor
7241 invalidate iterators or subranges.
7242 [Footnote: The use of fully closed ranges is intentional --end footnote]
7245 <p><i>[Toronto: Dave Abrahams supplied wording.]</i></p>
7247 <p><i>[Copenhagen: Proposed resolution was modified slightly. Matt
7248 added footnotes pointing out that the use of closed ranges was
7249 intentional.]</i></p>
7252 <a name="243"><h3>243. <tt>get</tt> and <tt>getline</tt> when sentry reports failure</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> May 15 2000</p>
7253 <p>basic_istream<>::get(), and basic_istream<>::getline(),
7254 are unclear with respect to the behavior and side-effects of the named
7255 functions in case of an error.</p>
7257 <p>27.6.1.3, p1 states that "... If the sentry object returns
7258 true, when converted to a value of type bool, the function endeavors
7259 to obtain the requested input..." It is not clear from this (or
7260 the rest of the paragraph) what precisely the behavior should be when
7261 the sentry ctor exits by throwing an exception or when the sentry
7262 object returns false. In particular, what is the number of characters
7263 extracted that gcount() returns supposed to be?</p>
7265 <p>27.6.1.3 p8 and p19 say about the effects of get() and getline():
7266 "... In any case, it then stores a null character (using
7267 charT()) into the next successive location of the array." Is not
7268 clear whether this sentence applies if either of the conditions above
7269 holds (i.e., when sentry fails).</p>
7270 <p><b>Proposed resolution:</b></p>
7271 <p>Add to 27.6.1.3, p1 after the sentence</p>
7274 "... If the sentry object returns true, when converted to a value of
7275 type bool, the function endeavors to obtain the requested input."
7278 <p>the following</p>
7282 "Otherwise, if the sentry constructor exits by throwing an exception or
7283 if the sentry object returns false, when converted to a value of type
7284 bool, the function returns without attempting to obtain any input. In
7285 either case the number of extracted characters is set to 0; unformatted
7286 input functions taking a character array of non-zero size as an argument
7287 shall also store a null character (using charT()) in the first location
7290 <p><b>Rationale:</b></p>
7291 <p>Although the general philosophy of the input functions is that the
7292 argument should not be modified upon failure, <tt>getline</tt>
7293 historically added a terminating null unconditionally. Most
7294 implementations still do that. Earlier versions of the draft standard
7295 had language that made this an unambiguous requirement; those words
7296 were moved to a place where their context made them less clear. See
7297 Jerry Schwarz's message c++std-lib-7618.</p>
7299 <a name="247"><h3>247. <tt>vector</tt>, <tt>deque::insert</tt> complexity</h3></a><p><b>Section:</b> 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Lisa Lippincott <b>Date:</b> 06 June 2000</p>
7300 <p>Paragraph 2 of 23.2.4.3 [lib.vector.modifiers] describes the complexity
7301 of <tt>vector::insert</tt>:</p>
7304 Complexity: If first and last are forward iterators, bidirectional
7305 iterators, or random access iterators, the complexity is linear in
7306 the number of elements in the range [first, last) plus the distance
7307 to the end of the vector. If they are input iterators, the complexity
7308 is proportional to the number of elements in the range [first, last)
7309 times the distance to the end of the vector.
7312 <p>First, this fails to address the non-iterator forms of
7313 <tt>insert</tt>.</p>
7315 <p>Second, the complexity for input iterators misses an edge case --
7316 it requires that an arbitrary number of elements can be added at
7317 the end of a <tt>vector</tt> in constant time.</p>
7319 <p>I looked to see if <tt>deque</tt> had a similar problem, and was
7320 surprised to find that <tt>deque</tt> places no requirement on the
7321 complexity of inserting multiple elements (23.2.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.array.size"> [lib.array.size]</a>,
7325 Complexity: In the worst case, inserting a single element into a
7326 deque takes time linear in the minimum of the distance from the
7327 insertion point to the beginning of the deque and the distance
7328 from the insertion point to the end of the deque. Inserting a
7329 single element either at the beginning or end of a deque always
7330 takes constant time and causes a single call to the copy constructor
7333 <p><b>Proposed resolution:</b></p>
7335 <p>Change Paragraph 2 of 23.2.4.3 [lib.vector.modifiers] to</p>
7337 Complexity: The complexity is linear in the number of elements
7338 inserted plus the distance to the end of the vector.
7341 <p><i>[For input iterators, one may achieve this complexity by first
7342 inserting at the end of the <tt>vector</tt>, and then using
7343 <tt>rotate</tt>.]</i></p>
7345 <p>Change 23.2.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.array.size"> [lib.array.size]</a>, paragraph 3, to:</p>
7348 Complexity: The complexity is linear in the number of elements
7349 inserted plus the shorter of the distances to the beginning and
7350 end of the deque. Inserting a single element at either the
7351 beginning or the end of a deque causes a single call to the copy
7355 <p><b>Rationale:</b></p>
7356 <p>This is a real defect, and proposed resolution fixes it: some
7357 complexities aren't specified that should be. This proposed
7358 resolution does constrain deque implementations (it rules out the
7359 most naive possible implementations), but the LWG doesn't see a
7360 reason to permit that implementation.</p>
7362 <a name="248"><h3>248. time_get fails to set eofbit</h3></a><p><b>Section:</b> 22.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.category.time"> [lib.category.time]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 22 June 2000</p>
7363 <p>There is no requirement that any of time_get member functions set
7364 ios::eofbit when they reach the end iterator while parsing their input.
7365 Since members of both the num_get and money_get facets are required to
7366 do so (22.2.2.1.2, and 22.2.6.1.2, respectively), time_get members
7367 should follow the same requirement for consistency.</p>
7368 <p><b>Proposed resolution:</b></p>
7369 <p>Add paragraph 2 to section 22.2.5.1 with the following text:</p>
7372 If the end iterator is reached during parsing by any of the get()
7373 member functions, the member sets ios_base::eofbit in err.
7375 <p><b>Rationale:</b></p>
7376 <p>Two alternative resolutions were proposed. The LWG chose this one
7377 because it was more consistent with the way eof is described for other
7380 <a name="250"><h3>250. splicing invalidates iterators</h3></a><p><b>Section:</b> 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Brian Parker <b>Date:</b> 14 Jul 2000</p>
7382 Section 23.2.2.4 [lib.list.ops] states that
7384 <pre> void splice(iterator position, list<T, Allocator>& x);
7387 <i>invalidates</i> all iterators and references to list <tt>x</tt>.
7391 This is unnecessary and defeats an important feature of splice. In
7392 fact, the SGI STL guarantees that iterators to <tt>x</tt> remain valid
7393 after <tt>splice</tt>.
7395 <p><b>Proposed resolution:</b></p>
7397 <p>Add a footnote to 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, paragraph 1:</p>
7399 [<i>Footnote:</i> As specified in 20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a>, paragraphs
7400 4-5, the semantics described in this clause applies only to the case
7401 where allocators compare equal. --end footnote]
7404 <p>In 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, replace paragraph 4 with:</p>
7406 Effects: Inserts the contents of x before position and x becomes
7407 empty. Pointers and references to the moved elements of x now refer to
7408 those same elements but as members of *this. Iterators referring to the
7409 moved elements will continue to refer to their elements, but they now
7410 behave as iterators into *this, not into x.
7413 <p>In 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, replace paragraph 7 with:</p>
7415 Effects: Inserts an element pointed to by i from list x before
7416 position and removes the element from x. The result is unchanged if
7417 position == i or position == ++i. Pointers and references to *i continue
7418 to refer to this same element but as a member of *this. Iterators to *i
7419 (including i itself) continue to refer to the same element, but now
7420 behave as iterators into *this, not into x.
7423 <p>In 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, replace paragraph 12 with:</p>
7425 Requires: [first, last) is a valid range in x. The result is
7426 undefined if position is an iterator in the range [first, last).
7427 Pointers and references to the moved elements of x now refer to those
7428 same elements but as members of *this. Iterators referring to the moved
7429 elements will continue to refer to their elements, but they now behave as
7430 iterators into *this, not into x.
7433 <p><i>[pre-Copenhagen: Howard provided wording.]</i></p>
7434 <p><b>Rationale:</b></p>
7435 <p>The original proposed resolution said that iterators and references
7436 would remain "valid". The new proposed resolution clarifies what that
7437 means. Note that this only applies to the case of equal allocators.
7438 From 20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a> paragraph 4, the behavior of list when
7439 allocators compare nonequal is outside the scope of the standard.</p>
7441 <a name="251"><h3>251. basic_stringbuf missing allocator_type</h3></a><p><b>Section:</b> 27.7.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf"> [lib.stringbuf]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 28 Jul 2000</p>
7442 <p>The synopsis for the template class <tt>basic_stringbuf</tt>
7443 doesn't list a typedef for the template parameter
7444 <tt>Allocator</tt>. This makes it impossible to determine the type of
7445 the allocator at compile time. It's also inconsistent with all other
7446 template classes in the library that do provide a typedef for the
7447 <tt>Allocator</tt> parameter.</p>
7448 <p><b>Proposed resolution:</b></p>
7449 <p>Add to the synopses of the class templates basic_stringbuf (27.7.1),
7450 basic_istringstream (27.7.2), basic_ostringstream (27.7.3), and
7451 basic_stringstream (27.7.4) the typedef:</p>
7452 <pre> typedef Allocator allocator_type;
7455 <a name="252"><h3>252. missing casts/C-style casts used in iostreams</h3></a><p><b>Section:</b> 27.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.string.streams"> [lib.string.streams]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 28 Jul 2000</p>
7456 <p>27.7.2.2, p1 uses a C-style cast rather than the more appropriate
7457 const_cast<> in the Returns clause for basic_istringstream<>::rdbuf().
7458 The same C-style cast is being used in 27.7.3.2, p1, D.7.2.2, p1, and
7459 D.7.3.2, p1, and perhaps elsewhere. 27.7.6, p1 and D.7.2.2, p1 are missing
7460 the cast altogether.</p>
7462 <p>C-style casts have not been deprecated, so the first part of this
7463 issue is stylistic rather than a matter of correctness.</p>
7464 <p><b>Proposed resolution:</b></p>
7465 <p>In 27.7.2.2, p1 replace </p>
7466 <pre> -1- Returns: (basic_stringbuf<charT,traits,Allocator>*)&sb.</pre>
7469 <pre> -1- Returns: const_cast<basic_stringbuf<charT,traits,Allocator>*>(&sb).</pre>
7472 <p>In 27.7.3.2, p1 replace</p>
7473 <pre> -1- Returns: (basic_stringbuf<charT,traits,Allocator>*)&sb.</pre>
7476 <pre> -1- Returns: const_cast<basic_stringbuf<charT,traits,Allocator>*>(&sb).</pre>
7478 <p>In 27.7.6, p1, replace</p>
7479 <pre> -1- Returns: &sb</pre>
7482 <pre> -1- Returns: const_cast<basic_stringbuf<charT,traits,Allocator>*>(&sb).</pre>
7484 <p>In D.7.2.2, p1 replace</p>
7485 <pre> -2- Returns: &sb. </pre>
7488 <pre> -2- Returns: const_cast<strstreambuf*>(&sb).</pre>
7490 <a name="253"><h3>253. valarray helper functions are almost entirely useless</h3></a><p><b>Section:</b> 26.5.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.valarray.cons"> [lib.valarray.cons]</a>, 26.5.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.valarray.assign"> [lib.valarray.assign]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Robert Klarer <b>Date:</b> 31 Jul 2000</p>
7491 <p>This discussion is adapted from message c++std-lib-7056 posted
7492 November 11, 1999. I don't think that anyone can reasonably claim
7493 that the problem described below is NAD.</p>
7495 <p>These valarray constructors can never be called:</p>
7497 <pre> template <class T>
7498 valarray<T>::valarray(const slice_array<T> &);
7499 template <class T>
7500 valarray<T>::valarray(const gslice_array<T> &);
7501 template <class T>
7502 valarray<T>::valarray(const mask_array<T> &);
7503 template <class T>
7504 valarray<T>::valarray(const indirect_array<T> &);
7507 <p>Similarly, these valarray assignment operators cannot be
7510 <pre> template <class T>
7511 valarray<T> valarray<T>::operator=(const slice_array<T> &);
7512 template <class T>
7513 valarray<T> valarray<T>::operator=(const gslice_array<T> &);
7514 template <class T>
7515 valarray<T> valarray<T>::operator=(const mask_array<T> &);
7516 template <class T>
7517 valarray<T> valarray<T>::operator=(const indirect_array<T> &);
7520 <p>Please consider the following example:</p>
7522 <pre> #include <valarray>
7523 using namespace std;
7527 valarray<double> va1(12);
7528 valarray<double> va2(va1[slice(1,4,3)]); // line 1
7533 <p>Since the valarray va1 is non-const, the result of the sub-expression
7534 va1[slice(1,4,3)] at line 1 is an rvalue of type const
7535 std::slice_array<double>. This slice_array rvalue is then used to
7536 construct va2. The constructor that is used to construct va2 is
7537 declared like this:</p>
7539 <pre> template <class T>
7540 valarray<T>::valarray(const slice_array<T> &);
7543 <p>Notice the constructor's const reference parameter. When the
7544 constructor is called, a slice_array must be bound to this reference.
7545 The rules for binding an rvalue to a const reference are in 8.5.3,
7546 paragraph 5 (see also 13.3.3.1.4). Specifically, paragraph 5
7547 indicates that a second slice_array rvalue is constructed (in this
7548 case copy-constructed) from the first one; it is this second rvalue
7549 that is bound to the reference parameter. Paragraph 5 also requires
7550 that the constructor that is used for this purpose be callable,
7551 regardless of whether the second rvalue is elided. The
7552 copy-constructor in this case is not callable, however, because it is
7553 private. Therefore, the compiler should report an error.</p>
7555 <p>Since slice_arrays are always rvalues, the valarray constructor that has a
7556 parameter of type const slice_array<T> & can never be called. The
7557 same reasoning applies to the three other constructors and the four
7558 assignment operators that are listed at the beginning of this post.
7559 Furthermore, since these functions cannot be called, the valarray helper
7560 classes are almost entirely useless.</p>
7561 <p><b>Proposed resolution:</b></p>
7564 <li> Make the copy constructor and copy-assignment operator declarations
7565 public in the slice_array class template definition in 26.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.slice.array"> [lib.template.slice.array]</a> </li>
7566 <li> remove paragraph 3 of 26.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.slice.array"> [lib.template.slice.array]</a>
7568 <li> remove the copy constructor declaration from 26.5.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.cons.slice.arr"> [lib.cons.slice.arr]</a>
7570 <li> change paragraph 1 of 26.5.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.cons.slice.arr"> [lib.cons.slice.arr]</a> to read "This constructor is declared
7571 to be private. This constructor need not be defined."</li>
7572 <li> remove the first sentence of paragraph 1 of 26.5.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.slice.arr.assign"> [lib.slice.arr.assign]</a>
7574 <li> Change the first three words of the second sentence of paragraph 1 of
7575 26.5.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.slice.arr.assign"> [lib.slice.arr.assign]</a> to "These assignment operators have"</li>
7578 <p>gslice_array:</p>
7580 <li> Make the copy constructor and copy-assignment operator declarations
7581 public in the gslice_array class template definition in 26.5.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.gslice.array"> [lib.template.gslice.array]</a> </li>
7582 <li> remove the note in paragraph 3 of 26.5.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.gslice.array"> [lib.template.gslice.array]</a>
7584 <li> remove the copy constructor declaration from 26.5.7.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.gslice.array.cons"> [lib.gslice.array.cons]</a>
7586 <li> change paragraph 1 of 26.5.7.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.gslice.array.cons"> [lib.gslice.array.cons]</a> to read "This constructor is declared
7587 to be private. This constructor need not be defined."</li>
7588 <li> remove the first sentence of paragraph 1 of 26.5.7.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.gslice.array.assign"> [lib.gslice.array.assign]</a>
7590 <li> Change the first three words of the second sentence of paragraph 1 of
7591 26.5.7.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.gslice.array.assign"> [lib.gslice.array.assign]</a> to "These assignment operators have"</li>
7596 <li> Make the copy constructor and copy-assignment operator declarations
7597 public in the mask_array class template definition in 26.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.mask.array"> [lib.template.mask.array]</a> </li>
7598 <li> remove the note in paragraph 2 of 26.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.mask.array"> [lib.template.mask.array]</a>
7600 <li> remove the copy constructor declaration from 26.5.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.mask.array.cons"> [lib.mask.array.cons]</a>
7602 <li> change paragraph 1 of 26.5.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.mask.array.cons"> [lib.mask.array.cons]</a> to read "This constructor is declared
7603 to be private. This constructor need not be defined."</li>
7604 <li> remove the first sentence of paragraph 1 of 26.5.8.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.mask.array.assign"> [lib.mask.array.assign]</a>
7606 <li> Change the first three words of the second sentence of paragraph 1 of
7607 26.5.8.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.mask.array.assign"> [lib.mask.array.assign]</a> to "These assignment operators have"</li>
7610 <p>indirect_array:</p>
7612 <li>Make the copy constructor and copy-assignment operator declarations
7613 public in the indirect_array class definition in 26.5.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.indirect.array"> [lib.template.indirect.array]</a>
7615 <li> remove the note in paragraph 2 of 26.5.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.template.indirect.array"> [lib.template.indirect.array]</a>
7617 <li> remove the copy constructor declaration from 26.5.9.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.indirect.array.cons"> [lib.indirect.array.cons]</a>
7619 <li> change the descriptive text in 26.5.9.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.indirect.array.cons"> [lib.indirect.array.cons]</a> to read "This constructor is
7620 declared to be private. This constructor need not be defined."</li>
7621 <li> remove the first sentence of paragraph 1 of 26.5.9.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.indirect.array.assign"> [lib.indirect.array.assign]</a>
7623 <li> Change the first three words of the second sentence of paragraph 1 of
7624 26.5.9.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.indirect.array.assign"> [lib.indirect.array.assign]</a> to "These assignment operators have"</li>
7626 <p><i>[Proposed resolution was modified in Santa Cruz: explicitly make
7627 copy constructor and copy assignment operators public, instead of
7628 removing them.]</i></p>
7629 <p><b>Rationale:</b></p>
7630 <p>Keeping the valarray constructors private is untenable. Merely
7631 making valarray a friend of the helper classes isn't good enough,
7632 because access to the copy constructor is checked in the user's
7635 <p>Making the assignment operator public is not strictly necessary to
7636 solve this problem. A majority of the LWG <i>(straw poll: 13-4)</i>
7637 believed we should make the assignment operators public, in addition
7638 to the copy constructors, for reasons of symmetry and user
7641 <a name="256"><h3>256. typo in 27.4.4.2, p17: copy_event does not exist</h3></a><p><b>Section:</b> 27.4.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.members"> [lib.basic.ios.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 21 Aug 2000</p>
7647 -17- Before copying any parts of rhs, calls each registered callback
7648 pair (fn,index) as (*fn)(erase_event,*this,index). After all parts but
7649 exceptions() have been replaced, calls each callback pair that was
7650 copied from rhs as (*fn)(copy_event,*this,index).
7654 The name copy_event isn't defined anywhere. The intended name was
7657 <p><b>Proposed resolution:</b></p>
7658 <p>Replace copy_event with copyfmt_event in the named paragraph.</p>
7660 <a name="259"><h3>259. <tt>basic_string::operator[]</tt> and const correctness</h3></a><p><b>Section:</b> 21.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.access"> [lib.string.access]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Chris Newton <b>Date:</b> 27 Aug 2000</p>
7662 <i>Paraphrased from a message that Chris Newton posted to comp.std.c++:</i>
7666 The standard's description of <tt>basic_string<>::operator[]</tt>
7667 seems to violate const correctness.
7671 The standard (21.3.4/1) says that "If <tt>pos < size()</tt>,
7672 returns <tt>data()[pos]</tt>." The types don't work. The
7673 return value of <tt>data()</tt> is <tt>const charT*</tt>, but
7674 <tt>operator[]</tt> has a non-const version whose return type is <tt>reference</tt>.
7676 <p><b>Proposed resolution:</b></p>
7678 In section 21.3.4, paragraph 1, change
7679 "<tt>data()[<i>pos</i>]</tt>" to "<tt>*(begin() +
7683 <a name="260"><h3>260. Inconsistent return type of <tt>istream_iterator::operator++(int)</tt>
7684 </h3></a><p><b>Section:</b> 24.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istream.iterator.ops"> [lib.istream.iterator.ops]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 27 Aug 2000</p>
7685 <p>The synopsis of istream_iterator::operator++(int) in 24.5.1 shows
7686 it as returning the iterator by value. 24.5.1.2, p5 shows the same
7687 operator as returning the iterator by reference. That's incorrect
7688 given the Effects clause below (since a temporary is returned). The
7689 `&' is probably just a typo.</p>
7690 <p><b>Proposed resolution:</b></p>
7691 <p>Change the declaration in 24.5.1.2, p5 from</p>
7692 <pre> istream_iterator<T,charT,traits,Distance>& operator++(int);
7695 <pre> istream_iterator<T,charT,traits,Distance> operator++(int);
7697 <p>(that is, remove the `&').</p>
7699 <a name="261"><h3>261. Missing description of <tt>istream_iterator::operator!=</tt>
7700 </h3></a><p><b>Section:</b> 24.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istream.iterator.ops"> [lib.istream.iterator.ops]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 27 Aug 2000</p>
7702 24.5.1, p3 lists the synopsis for
7705 <pre> template <class T, class charT, class traits, class Distance>
7706 bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
7707 const istream_iterator<T,charT,traits,Distance>& y);
7711 but there is no description of what the operator does (i.e., no Effects
7712 or Returns clause) in 24.5.1.2.
7714 <p><b>Proposed resolution:</b></p>
7716 Add paragraph 7 to the end of section 24.5.1.2 with the following text:
7719 <pre> template <class T, class charT, class traits, class Distance>
7720 bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
7721 const istream_iterator<T,charT,traits,Distance>& y);
7724 <p>-7- Returns: !(x == y).</p>
7726 <a name="262"><h3>262. Bitmask operator ~ specified incorrectly</h3></a><p><b>Section:</b> 17.3.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.bitmask.types"> [lib.bitmask.types]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 03 Sep 2000</p>
7728 The ~ operation should be applied after the cast to int_type.
7730 <p><b>Proposed resolution:</b></p>
7732 Change 17.3.2.1.2 [lib.bitmask.types] operator~ from:
7735 <pre> bitmask operator~ ( bitmask X )
7736 { return static_cast< bitmask>(static_cast<int_type>(~ X)); }
7743 <pre> bitmask operator~ ( bitmask X )
7744 { return static_cast< bitmask>(~static_cast<int_type>(X)); }
7747 <a name="263"><h3>263. Severe restriction on <tt>basic_string</tt> reference counting</h3></a><p><b>Section:</b> 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Kevlin Henney <b>Date:</b> 04 Sep 2000</p>
7749 The note in paragraph 6 suggests that the invalidation rules for
7750 references, pointers, and iterators in paragraph 5 permit a reference-
7751 counted implementation (actually, according to paragraph 6, they permit
7752 a "reference counted implementation", but this is a minor editorial fix).
7756 However, the last sub-bullet is so worded as to make a reference-counted
7757 implementation unviable. In the following example none of the
7758 conditions for iterator invalidation are satisfied:
7761 <pre> // first example: "*******************" should be printed twice
7762 string original = "some arbitrary text", copy = original;
7763 const string & alias = original;
7765 string::const_iterator i = alias.begin(), e = alias.end();
7766 for(string::iterator j = original.begin(); j != original.end(); ++j)
7771 cout << original << endl;
7775 Similarly, in the following example:
7778 <pre> // second example: "some arbitrary text" should be printed out
7779 string original = "some arbitrary text", copy = original;
7780 const string & alias = original;
7782 string::const_iterator i = alias.begin();
7784 while(i != alias.end())
7789 I have tested this on three string implementations, two of which were
7790 reference counted. The reference-counted implementations gave
7791 "surprising behavior" because they invalidated iterators on
7792 the first call to non-const begin since construction. The current
7793 wording does not permit such invalidation because it does not take
7794 into account the first call since construction, only the first call
7795 since various member and non-member function calls.
7797 <p><b>Proposed resolution:</b></p>
7799 Change the following sentence in 21.3 paragraph 5 from
7803 Subsequent to any of the above uses except the forms of insert() and
7804 erase() which return iterators, the first call to non-const member
7805 functions operator[](), at(), begin(), rbegin(), end(), or rend().
7811 Following construction or any of the above uses, except the forms of
7812 insert() and erase() that return iterators, the first call to non-
7813 const member functions operator[](), at(), begin(), rbegin(), end(),
7817 <a name="264"></a><h3><a name="264">264. Associative container <tt>insert(i, j)</tt> complexity requirements are not feasible.</a></h3><p><b>Section:</b> 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> John Potter <b>Date:</b> 07 Sep 2000</p>
7819 Table 69 requires linear time if [i, j) is sorted. Sorted is necessary but not sufficient.
7820 Consider inserting a sorted range of even integers into a set<int> containing the odd
7821 integers in the same range.
7824 <p><i>Related issue: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#102">102</a></i></p>
7825 <p><b>Proposed resolution:</b></p>
7827 In Table 69, in section 23.1.2, change the complexity clause for
7828 insertion of a range from "N log(size() + N) (N is the distance
7829 from i to j) in general; linear if [i, j) is sorted according to
7830 value_comp()" to "N log(size() + N), where N is the distance
7834 <p><i>[Copenhagen: Minor fix in proposed resolution: fixed unbalanced
7835 parens in the revised wording.]</i></p>
7837 <p><b>Rationale:</b></p>
7839 Testing for valid insertions could be less efficient than simply
7840 inserting the elements when the range is not both sorted and between
7841 two adjacent existing elements; this could be a QOI issue.
7845 The LWG considered two other options: (a) specifying that the
7846 complexity was linear if [i, j) is sorted according to value_comp()
7847 and between two adjacent existing elements; or (b) changing to
7848 Klog(size() + N) + (N - K) (N is the distance from i to j and K is the
7849 number of elements which do not insert immediately after the previous
7850 element from [i, j) including the first). The LWG felt that, since
7851 we can't guarantee linear time complexity whenever the range to be
7852 inserted is sorted, it's more trouble than it's worth to say that it's
7853 linear in some special cases.
7856 <a name="265"><h3>265. std::pair::pair() effects overly restrictive</h3></a><p><b>Section:</b> 20.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.pairs"> [lib.pairs]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 11 Sep 2000</p>
7858 I don't see any requirements on the types of the elements of the
7859 std::pair container in 20.2.2. From the descriptions of the member
7860 functions it appears that they must at least satisfy the requirements of
7861 20.1.3 [lib.copyconstructible] and 20.1.4 [lib.default.con.req], and in
7862 the case of the [in]equality operators also the requirements of 20.1.1
7863 [lib.equalitycomparable] and 20.1.2 [lib.lessthancomparable].
7867 I believe that the the CopyConstructible requirement is unnecessary in
7868 the case of 20.2.2, p2.
7870 <p><b>Proposed resolution:</b></p>
7871 <p>Change the Effects clause in 20.2.2, p2 from</p>
7874 -2- <b>Effects</b>: Initializes its members as if implemented: <tt> pair() :
7875 first(T1()), second(T2()) {} </tt>
7881 -2- <b>Effects</b>: Initializes its members as if implemented: <tt> pair() :
7882 first(), second() {} </tt>
7884 <p><b>Rationale:</b></p>
7885 <p>The existing specification of pair's constructor appears to be a
7886 historical artifact: there was concern that pair's members be properly
7887 zero-initialized when they are built-in types. At one time there was
7888 uncertainty about whether they would be zero-initialized if the
7889 default constructor was written the obvious way. This has been
7890 clarified by core issue 178, and there is no longer any doubt that
7891 the straightforward implementation is correct.</p>
7893 <a name="266"><h3>266. bad_exception::~bad_exception() missing Effects clause</h3></a><p><b>Section:</b> 18.7.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.bad.exception"> [lib.bad.exception]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 24 Sep 2000</p>
7895 The synopsis for std::bad_exception lists the function ~bad_exception()
7896 but there is no description of what the function does (the Effects
7899 <p><b>Proposed resolution:</b></p>
7901 Remove the destructor from the class synopses of
7902 <tt>bad_alloc</tt> (<font color="red">18.4.2.1</font>),
7903 <tt>bad_cast</tt> (18.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.alloc.errors"> [lib.alloc.errors]</a>),
7904 <tt>bad_typeid</tt> (<font color="red">18.5.3</font>),
7905 and <tt>bad_exception</tt> (18.7.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.bad.exception"> [lib.bad.exception]</a>).
7907 <p><b>Rationale:</b></p>
7909 This is a general problem with the exception classes in clause 18.
7910 The proposed resolution is to remove the destructors from the class
7911 synopses, rather than to document the destructors' behavior, because
7912 removing them is more consistent with how exception classes are
7913 described in clause 19.
7916 <a name="268"><h3>268. Typo in locale synopsis</h3></a><p><b>Section:</b> 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 5 Oct 2000</p>
7917 <p>The synopsis of the class std::locale in 22.1.1 contains two typos:
7918 the semicolons after the declarations of the default ctor
7919 locale::locale() and the copy ctor locale::locale(const locale&)
7921 <p><b>Proposed resolution:</b></p>
7922 <p>Add the missing semicolons, i.e., change</p>
7924 <pre> // construct/copy/destroy:
7926 locale(const locale& other) throw()
7929 <p>in the synopsis in 22.1.1 to</p>
7931 <pre> // construct/copy/destroy:
7933 locale(const locale& other) throw();
7936 <a name="270"><h3>270. Binary search requirements overly strict</h3></a><p><b>Section:</b> 25.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.binary.search"> [lib.alg.binary.search]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 18 Oct 2000</p>
7938 Each of the four binary search algorithms (lower_bound, upper_bound,
7939 equal_range, binary_search) has a form that allows the user to pass a
7940 comparison function object. According to 25.3, paragraph 2, that
7941 comparison function object has to be a strict weak ordering.
7945 This requirement is slightly too strict. Suppose we are searching
7946 through a sequence containing objects of type X, where X is some
7947 large record with an integer key. We might reasonably want to look
7948 up a record by key, in which case we would want to write something
7951 <pre> struct key_comp {
7952 bool operator()(const X& x, int n) const {
7953 return x.key() < n;
7957 std::lower_bound(first, last, 47, key_comp());
7961 key_comp is not a strict weak ordering, but there is no reason to
7962 prohibit its use in lower_bound.
7966 There's no difficulty in implementing lower_bound so that it allows
7967 the use of something like key_comp. (It will probably work unless an
7968 implementor takes special pains to forbid it.) What's difficult is
7969 formulating language in the standard to specify what kind of
7970 comparison function is acceptable. We need a notion that's slightly
7971 more general than that of a strict weak ordering, one that can encompass
7972 a comparison function that involves different types. Expressing that
7973 notion may be complicated.
7976 <p><i>Additional questions raised at the Toronto meeting:</i></p>
7978 <li> Do we really want to specify what ordering the implementor must
7979 use when calling the function object? The standard gives
7980 specific expressions when describing these algorithms, but it also
7981 says that other expressions (with different argument order) are
7983 <li> If we are specifying ordering, note that the standard uses both
7984 orderings when describing <tt>equal_range</tt>.</li>
7985 <li> Are we talking about requiring these algorithms to work properly
7986 when passed a binary function object whose two argument types
7987 are not the same, or are we talking about requirements when
7988 they are passed a binary function object with several overloaded
7989 versions of <tt>operator()</tt>?</li>
7990 <li> The definition of a strict weak ordering does not appear to give
7991 any guidance on issues of overloading; it only discusses expressions,
7992 and all of the values in these expressions are of the same type.
7993 Some clarification would seem to be in order.</li>
7996 <p><i>Additional discussion from Copenhagen:</i></p>
7998 <li>It was generally agreed that there is a real defect here: if
7999 the predicate is merely required to be a Strict Weak Ordering, then
8000 it's possible to pass in a function object with an overloaded
8001 operator(), where the version that's actually called does something
8002 completely inappropriate. (Such as returning a random value.)</li>
8004 <li>An alternative formulation was presented in a paper distributed by
8005 David Abrahams at the meeting, "Binary Search with Heterogeneous
8006 Comparison", J16-01/0027 = WG21 N1313: Instead of viewing the
8007 predicate as a Strict Weak Ordering acting on a sorted sequence, view
8008 the predicate/value pair as something that partitions a sequence.
8009 This is almost equivalent to saying that we should view binary search
8010 as if we are given a unary predicate and a sequence, such that f(*p)
8011 is true for all p below a specific point and false for all p above it.
8012 The proposed resolution is based on that alternative formulation.</li>
8014 <p><b>Proposed resolution:</b></p>
8016 <p>Change 25.3 [lib.alg.sorting] paragraph 3 from:</p>
8019 3 For all algorithms that take Compare, there is a version that uses
8020 operator< instead. That is, comp(*i, *j) != false defaults to *i <
8021 *j != false. For the algorithms to work correctly, comp has to
8022 induce a strict weak ordering on the values.
8028 3 For all algorithms that take Compare, there is a version that uses
8029 operator< instead. That is, comp(*i, *j) != false defaults to *i
8030 < *j != false. For algorithms other than those described in
8031 lib.alg.binary.search (25.3.3) to work correctly, comp has to induce
8032 a strict weak ordering on the values.
8035 <p>Add the following paragraph after 25.3 [lib.alg.sorting] paragraph 5:</p>
8038 -6- A sequence [start, finish) is partitioned with respect to an
8039 expression f(e) if there exists an integer n such that
8040 for all 0 <= i < distance(start, finish), f(*(begin+i)) is true if
8041 and only if i < n.
8044 <p>Change 25.3.3 [lib.alg.binary.search] paragraph 1 from:</p>
8047 -1- All of the algorithms in this section are versions of binary
8048 search and assume that the sequence being searched is in order
8049 according to the implied or explicit comparison function. They work
8050 on non-random access iterators minimizing the number of
8051 comparisons, which will be logarithmic for all types of
8052 iterators. They are especially appropriate for random access
8053 iterators, because these algorithms do a logarithmic number of
8054 steps through the data structure. For non-random access iterators
8055 they execute a linear number of steps.
8061 -1- All of the algorithms in this section are versions of binary
8062 search and assume that the sequence being searched is partitioned
8063 with respect to an expression formed by binding the search key to
8064 an argument of the implied or explicit comparison function. They
8065 work on non-random access iterators minimizing the number of
8066 comparisons, which will be logarithmic for all types of
8067 iterators. They are especially appropriate for random access
8068 iterators, because these algorithms do a logarithmic number of
8069 steps through the data structure. For non-random access iterators
8070 they execute a linear number of steps.
8073 <p>Change 25.3.3.1 [lib.lower.bound] paragraph 1 from:</p>
8076 -1- Requires: Type T is LessThanComparable
8077 (lib.lessthancomparable).
8083 -1- Requires: The elements e of [first, last) are partitioned with
8084 respect to the expression e < value or comp(e, value)
8088 <p>Remove 25.3.3.1 [lib.lower.bound] paragraph 2:</p>
8091 -2- Effects: Finds the first position into which value can be
8092 inserted without violating the ordering.
8095 <p>Change 25.3.3.2 [lib.upper.bound] paragraph 1 from:</p>
8098 -1- Requires: Type T is LessThanComparable (lib.lessthancomparable).
8104 -1- Requires: The elements e of [first, last) are partitioned with
8105 respect to the expression !(value < e) or !comp(value, e)
8108 <p>Remove 25.3.3.2 [lib.upper.bound] paragraph 2:</p>
8111 -2- Effects: Finds the furthermost position into which value can be
8112 inserted without violating the ordering.
8115 <p>Change 25.3.3.3 [lib.equal.range] paragraph 1 from:</p>
8118 -1- Requires: Type T is LessThanComparable
8119 (lib.lessthancomparable).
8125 -1- Requires: The elements e of [first, last) are partitioned with
8126 respect to the expressions e < value and !(value < e) or
8127 comp(e, value) and !comp(value, e). Also, for all elements e of
8128 [first, last), e < value implies !(value < e) or comp(e,
8129 value) implies !comp(value, e)
8132 <p>Change 25.3.3.3 [lib.equal.range] paragraph 2 from:</p>
8135 -2- Effects: Finds the largest subrange [i, j) such that the value
8136 can be inserted at any iterator k in it without violating the
8137 ordering. k satisfies the corresponding conditions: !(*k < value)
8138 && !(value < *k) or comp(*k, value) == false && comp(value, *k) ==
8145 make_pair(lower_bound(first, last, value),
8146 upper_bound(first, last, value))
8148 make_pair(lower_bound(first, last, value, comp),
8149 upper_bound(first, last, value, comp))
8152 <p>Change 25.3.3.3 [lib.binary.search] paragraph 1 from:</p>
8155 -1- Requires: Type T is LessThanComparable
8156 (lib.lessthancomparable).
8162 -1- Requires: The elements e of [first, last) are partitioned with
8163 respect to the expressions e < value and !(value < e) or comp(e,
8164 value) and !comp(value, e). Also, for all elements e of [first,
8165 last), e < value implies !(value < e) or comp(e, value) implies
8169 <p><i>[Copenhagen: Dave Abrahams provided this wording]</i></p>
8171 <p><i>[Redmond: Minor changes in wording. (Removed "non-negative", and
8172 changed the "other than those described in" wording.) Also, the LWG
8173 decided to accept the "optional" part.]</i></p>
8175 <p><b>Rationale:</b></p>
8176 <p>The proposed resolution reinterprets binary search. Instead of
8177 thinking about searching for a value in a sorted range, we view that
8178 as an important special case of a more general algorithm: searching
8179 for the partition point in a partitioned range.</p>
8181 <p>We also add a guarantee that the old wording did not: we ensure
8182 that the upper bound is no earlier than the lower bound, that
8183 the pair returned by equal_range is a valid range, and that the first
8184 part of that pair is the lower bound.</p>
8186 <a name="271"><h3>271. basic_iostream missing typedefs</h3></a><p><b>Section:</b> 27.6.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostreamclass"> [lib.iostreamclass]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 02 Nov 2000</p>
8188 Class template basic_iostream has no typedefs. The typedefs it
8189 inherits from its base classes can't be used, since (for example)
8190 basic_iostream<T>::traits_type is ambiguous.
8192 <p><b>Proposed resolution:</b></p>
8194 <p>Add the following to basic_iostream's class synopsis in
8195 27.6.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostreamclass"> [lib.iostreamclass]</a>, immediately after <tt>public</tt>:</p>
8198 typedef charT char_type;
8199 typedef typename traits::int_type int_type;
8200 typedef typename traits::pos_type pos_type;
8201 typedef typename traits::off_type off_type;
8202 typedef traits traits_type;
8205 <a name="272"><h3>272. Missing parentheses around subexpression</h3></a><p><b>Section:</b> 27.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostate.flags"> [lib.iostate.flags]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 02 Nov 2000</p>
8207 27.4.4.3, p4 says about the postcondition of the function: If
8208 rdbuf()!=0 then state == rdstate(); otherwise
8209 rdstate()==state|ios_base::badbit.
8213 The expression on the right-hand-side of the operator==() needs to be
8214 parenthesized in order for the whole expression to ever evaluate to
8215 anything but non-zero.
8217 <p><b>Proposed resolution:</b></p>
8219 Add parentheses like so: rdstate()==(state|ios_base::badbit).
8222 <a name="273"><h3>273. Missing ios_base qualification on members of a dependent class</h3></a><p><b>Section:</b> 27 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.input.output"> [lib.input.output]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 02 Nov 2000</p>
8223 <p>27.5.2.4.2, p4, and 27.8.1.6, p2, 27.8.1.7, p3, 27.8.1.9, p2,
8224 27.8.1.10, p3 refer to in and/or out w/o ios_base:: qualification.
8225 That's incorrect since the names are members of a dependent base
8226 class (14.6.2 [temp.dep]) and thus not visible.</p>
8227 <p><b>Proposed resolution:</b></p>
8228 <p>Qualify the names with the name of the class of which they are
8229 members, i.e., ios_base.</p>
8231 <a name="274"><h3>274. a missing/impossible allocator requirement</h3></a><p><b>Section:</b> 20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 02 Nov 2000</p>
8233 I see that table 31 in 20.1.5, p3 allows T in std::allocator<T> to be of
8234 any type. But the synopsis in 20.4.1 calls for allocator<>::address() to
8235 be overloaded on reference and const_reference, which is ill-formed for
8236 all T = const U. In other words, this won't work:
8240 template class std::allocator<const int>;
8244 The obvious solution is to disallow specializations of allocators on
8245 const types. However, while containers' elements are required to be
8246 assignable (which rules out specializations on const T's), I think that
8247 allocators might perhaps be potentially useful for const values in other
8248 contexts. So if allocators are to allow const types a partial
8249 specialization of std::allocator<const T> would probably have to be
8252 <p><b>Proposed resolution:</b></p>
8253 <p>Change the text in row 1, column 2 of table 32 in 20.1.5, p3 from</p>
8261 any non-const, non-reference type
8264 <p><i>[Redmond: previous proposed resolution was "any non-const,
8265 non-volatile, non-reference type". Got rid of the "non-volatile".]</i></p>
8267 <p><b>Rationale:</b></p>
8269 Two resolutions were originally proposed: one that partially
8270 specialized std::allocator for const types, and one that said an
8271 allocator's value type may not be const. The LWG chose the second.
8272 The first wouldn't be appropriate, because allocators are intended for
8273 use by containers, and const value types don't work in containers.
8274 Encouraging the use of allocators with const value types would only
8275 lead to unsafe code.
8278 The original text for proposed resolution 2 was modified so that it
8279 also forbids volatile types and reference types.
8282 <p><i>[Curaçao: LWG double checked and believes volatile is correctly
8283 excluded from the PR.]</i></p>
8286 <a name="275"><h3>275. Wrong type in num_get::get() overloads</h3></a><p><b>Section:</b> 22.2.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.members"> [lib.facet.num.get.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 02 Nov 2000</p>
8288 In 22.2.2.1.1, we have a list of overloads for num_get<>::get().
8289 There are eight overloads, all of which are identical except for the
8290 last parameter. The overloads are:
8293 <li> long& </li>
8294 <li> unsigned short& </li>
8295 <li> unsigned int& </li>
8296 <li> unsigned long& </li>
8297 <li> short& </li>
8298 <li> double& </li>
8299 <li> long double& </li>
8300 <li> void*& </li>
8304 There is a similar list, in 22.2.2.1.2, of overloads for
8305 num_get<>::do_get(). In this list, the last parameter has
8309 <li> long& </li>
8310 <li> unsigned short& </li>
8311 <li> unsigned int& </li>
8312 <li> unsigned long& </li>
8313 <li> float& </li>
8314 <li> double& </li>
8315 <li> long double& </li>
8316 <li> void*& </li>
8320 These two lists are not identical. They should be, since
8321 <tt>get</tt> is supposed to call <tt>do_get</tt> with exactly
8322 the arguments it was given.
8324 <p><b>Proposed resolution:</b></p>
8325 <p>In 22.2.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.members"> [lib.facet.num.get.members]</a>, change</p>
8326 <pre> iter_type get(iter_type in, iter_type end, ios_base& str,
8327 ios_base::iostate& err, short& val) const;
8330 <pre> iter_type get(iter_type in, iter_type end, ios_base& str,
8331 ios_base::iostate& err, float& val) const;
8334 <a name="276"></a><h3><a name="276">276. Assignable requirement for container value type overly strict</a></h3><p><b>Section:</b> 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Peter Dimov <b>Date:</b> 07 Nov 2000</p>
8336 23.1/3 states that the objects stored in a container must be
8337 Assignable. 23.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map"> [lib.map]</a>, paragraph 2,
8338 states that map satisfies all requirements for a container, while in
8339 the same time defining value_type as pair<const Key, T> - a type
8340 that is not Assignable.
8344 It should be noted that there exists a valid and non-contradictory
8345 interpretation of the current text. The wording in 23.1/3 avoids
8346 mentioning value_type, referring instead to "objects stored in a
8347 container." One might argue that map does not store objects of
8348 type map::value_type, but of map::mapped_type instead, and that the
8349 Assignable requirement applies to map::mapped_type, not
8354 However, this makes map a special case (other containers store objects of
8355 type value_type) and the Assignable requirement is needlessly restrictive in
8360 For example, the proposed resolution of active library issue
8361 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#103">103</a> is to make set::iterator a constant iterator; this
8362 means that no set operations can exploit the fact that the stored
8363 objects are Assignable.
8367 This is related to, but slightly broader than, closed issue
8368 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#140">140</a>.
8370 <p><b>Proposed resolution:</b></p>
8371 <p>23.1/3: Strike the trailing part of the sentence:</p>
8373 , and the additional requirements of Assignable types from 23.1/3
8375 <p>so that it reads:</p>
8377 -3- The type of objects stored in these components must meet the
8378 requirements of CopyConstructible types (lib.copyconstructible).
8381 <p>23.1/4: Modify to make clear that this requirement is not for all
8382 containers. Change to:</p>
8385 -4- Table 64 defines the Assignable requirement. Some containers
8386 require this property of the types to be stored in the container. T is
8387 the type used to instantiate the container. t is a value of T, and u is
8388 a value of (possibly const) T.
8391 <p>23.1, Table 65: in the first row, change "T is Assignable" to "T is
8392 CopyConstructible".</p>
8394 <p>23.2.1/2: Add sentence for Assignable requirement. Change to:</p>
8397 -2- A deque satisfies all of the requirements of a container and of a
8398 reversible container (given in tables in lib.container.requirements) and
8399 of a sequence, including the optional sequence requirements
8400 (lib.sequence.reqmts). In addition to the requirements on the stored
8401 object described in 23.1[lib.container.requirements], the stored object
8402 must also meet the requirements of Assignable. Descriptions are
8403 provided here only for operations on deque that are not described in one
8404 of these tables or for operations where there is additional semantic
8408 <p>23.2.2/2: Add Assignable requirement to specific methods of list.
8412 <p>-2- A list satisfies all of the requirements of a container and of a
8413 reversible container (given in two tables in lib.container.requirements)
8414 and of a sequence, including most of the the optional sequence
8415 requirements (lib.sequence.reqmts). The exceptions are the operator[]
8416 and at member functions, which are not provided.
8418 [Footnote: These member functions are only provided by containers whose
8419 iterators are random access iterators. --- end foonote]
8422 <p>list does not require the stored type T to be Assignable unless the
8423 following methods are instantiated:
8425 [Footnote: Implementors are permitted but not required to take advantage
8426 of T's Assignable properties for these methods. -- end foonote]
8428 <pre> list<T,Allocator>& operator=(const list<T,Allocator>& x );
8429 template <class InputIterator>
8430 void assign(InputIterator first, InputIterator last);
8431 void assign(size_type n, const T& t);
8435 <p>Descriptions are provided here only for operations on list that are not
8436 described in one of these tables or for operations where there is
8437 additional semantic information.</p>
8440 <p>23.2.4/2: Add sentence for Assignable requirement. Change to:</p>
8443 -2- A vector satisfies all of the requirements of a container and of a
8444 reversible container (given in two tables in lib.container.requirements)
8445 and of a sequence, including most of the optional sequence requirements
8446 (lib.sequence.reqmts). The exceptions are the push_front and pop_front
8447 member functions, which are not provided. In addition to the
8448 requirements on the stored object described in
8449 23.1[lib.container.requirements], the stored object must also meet the
8450 requirements of Assignable. Descriptions are provided here only for
8451 operations on vector that are not described in one of these tables or
8452 for operations where there is additional semantic information.
8454 <p><b>Rationale:</b></p>
8455 <p>list, set, multiset, map, multimap are able to store non-Assignables.
8456 However, there is some concern about <tt>list<T></tt>:
8457 although in general there's no reason for T to be Assignable, some
8458 implementations of the member functions <tt>operator=</tt> and
8459 <tt>assign</tt> do rely on that requirement. The LWG does not want
8460 to forbid such implementations.</p>
8462 <p>Note that the type stored in a standard container must still satisfy
8463 the requirements of the container's allocator; this rules out, for
8464 example, such types as "const int". See issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#274">274</a>
8468 <p>In principle we could also relax the "Assignable" requirement for
8469 individual <tt>vector</tt> member functions, such as
8470 <tt>push_back</tt>. However, the LWG did not see great value in such
8471 selective relaxation. Doing so would remove implementors' freedom to
8472 implement <tt>vector::push_back</tt> in terms of
8473 <tt>vector::insert</tt>.</p>
8476 <a name="278"><h3>278. What does iterator validity mean?</h3></a><p><b>Section:</b> 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> P.J. Plauger <b>Date:</b> 27 Nov 2000</p>
8478 Section 23.2.2.4 [lib.list.ops] states that
8480 <pre> void splice(iterator position, list<T, Allocator>& x);
8483 <i>invalidates</i> all iterators and references to list <tt>x</tt>.
8487 But what does the C++ Standard mean by "invalidate"? You
8488 can still dereference the iterator to a spliced list element, but
8489 you'd better not use it to delimit a range within the original
8490 list. For the latter operation, it has definitely lost some of its
8495 If we accept the proposed resolution to issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#250">250</a>,
8496 then we'd better clarify that a "valid" iterator need no
8497 longer designate an element within the same container as it once did.
8498 We then have to clarify what we mean by invalidating a past-the-end
8499 iterator, as when a vector or string grows by reallocation. Clearly,
8500 such an iterator has a different kind of validity. Perhaps we should
8501 introduce separate terms for the two kinds of "validity."
8503 <p><b>Proposed resolution:</b></p>
8504 <p>Add the following text to the end of section 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a>,
8505 after paragraph 5:</p>
8507 An <i>invalid</i> iterator is an iterator that may be
8508 singular. [Footnote: This definition applies to pointers, since
8509 pointers are iterators. The effect of dereferencing an iterator that
8510 has been invalidated is undefined.]
8513 <p><i>[post-Copenhagen: Matt provided wording.]</i></p>
8515 <p><i>[Redmond: General agreement with the intent, some objections to
8516 the wording. Dave provided new wording.]</i></p>
8517 <p><b>Rationale:</b></p>
8518 <p>This resolution simply defines a term that the Standard uses but
8519 never defines, "invalid", in terms of a term that is defined,
8522 <p>Why do we say "may be singular", instead of "is singular"? That's
8523 becuase a valid iterator is one that is known to be nonsingular.
8524 Invalidating an iterator means changing it in such a way that it's
8525 no longer known to be nonsingular. An example: inserting an
8526 element into the middle of a vector is correctly said to invalidate
8527 all iterators pointing into the vector. That doesn't necessarily
8528 mean they all become singular.</p>
8530 <a name="280"><h3>280. Comparison of reverse_iterator to const reverse_iterator</h3></a><p><b>Section:</b> 24.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iterators"> [lib.reverse.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Steve Cleary <b>Date:</b> 27 Nov 2000</p>
8532 This came from an email from Steve Cleary to Fergus in reference to
8533 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#179">179</a>. The library working group briefly discussed
8534 this in Toronto and believed it should be a separate issue. There was
8535 also some reservations about whether this was a worthwhile problem to
8540 Steve said: "Fixing reverse_iterator. std::reverse_iterator can
8541 (and should) be changed to preserve these additional
8542 requirements." He also said in email that it can be done without
8543 breaking user's code: "If you take a look at my suggested
8544 solution, reverse_iterator doesn't have to take two parameters; there
8545 is no danger of breaking existing code, except someone taking the
8546 address of one of the reverse_iterator global operator functions, and
8547 I have to doubt if anyone has ever done that. . . <i>But</i>, just in
8548 case they have, you can leave the old global functions in as well --
8549 they won't interfere with the two-template-argument functions. With
8550 that, I don't see how <i>any</i> user code could break."
8552 <p><b>Proposed resolution:</b></p>
8554 <b>Section:</b> 24.4.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iterator"> [lib.reverse.iterator]</a>
8555 add/change the following declarations:</p>
8556 <pre> A) Add a templated assignment operator, after the same manner
8557 as the templated copy constructor, i.e.:
8559 template < class U >
8560 reverse_iterator < Iterator >& operator=(const reverse_iterator< U >& u);
8562 B) Make all global functions (except the operator+) have
8563 two template parameters instead of one, that is, for
8564 operator ==, !=, <, >, <=, >=, - replace:
8566 template < class Iterator >
8567 typename reverse_iterator< Iterator >::difference_type operator-(
8568 const reverse_iterator< Iterator >& x,
8569 const reverse_iterator< Iterator >& y);
8573 template < class Iterator1, class Iterator2 >
8574 typename reverse_iterator < Iterator1 >::difference_type operator-(
8575 const reverse_iterator < Iterator1 > & x,
8576 const reverse_iterator < Iterator2 > & y);
8579 Also make the addition/changes for these signatures in
8580 24.4.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.ops"> [lib.reverse.iter.ops]</a>.
8584 Copenhagen: The LWG is concerned that the proposed resolution
8585 introduces new overloads. Experience shows that introducing
8586 overloads is always risky, and that it would be inappropriate to
8587 make this change without implementation experience. It may be
8588 desirable to provide this feature in a different way.
8592 Lillehammer: We now have implementation experience, and agree that
8593 this solution is safe and correct.
8597 <a name="281"><h3>281. std::min() and max() requirements overly restrictive</h3></a><p><b>Section:</b> 25.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.min.max"> [lib.alg.min.max]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 02 Dec 2000</p>
8598 <p>The requirements in 25.3.7, p1 and 4 call for T to satisfy the
8599 requirements of <tt>LessThanComparable</tt> (20.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.lessthancomparable"> [lib.lessthancomparable]</a>)
8600 and <tt>CopyConstructible</tt> (20.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.copyconstructible"> [lib.copyconstructible]</a>).
8601 Since the functions take and return their arguments and result by
8602 const reference, I believe the <tt>CopyConstructible</tt> requirement
8605 <p><b>Proposed resolution:</b></p>
8606 <p>Remove the <tt>CopyConstructible</tt> requirement. Specifically, replace
8608 <p><b>-1- Requires:</b> Type T is <tt>LessThanComparable</tt>
8609 (20.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.lessthancomparable"> [lib.lessthancomparable]</a>).
8611 <p>and replace 25.3.7, p4 with</p>
8612 <p><b>-4- Requires:</b> Type T is <tt>LessThanComparable</tt>
8613 (20.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.lessthancomparable"> [lib.lessthancomparable]</a>).
8616 <a name="282"><h3>282. What types does numpunct grouping refer to?</h3></a><p><b>Section:</b> 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 5 Dec 2000</p>
8618 Paragraph 16 mistakenly singles out integral types for inserting
8619 thousands_sep() characters. This conflicts with the syntax for floating
8620 point numbers described under 22.2.3.1/2.
8622 <p><b>Proposed resolution:</b></p>
8623 <p>Change paragraph 16 from:</p>
8626 For integral types, punct.thousands_sep() characters are inserted into
8627 the sequence as determined by the value returned by punct.do_grouping()
8628 using the method described in 22.2.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.numpunct.virtuals"> [lib.facet.numpunct.virtuals]</a>.
8634 For arithmetic types, punct.thousands_sep() characters are inserted into
8635 the sequence as determined by the value returned by punct.do_grouping()
8636 using the method described in 22.2.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.numpunct.virtuals"> [lib.facet.numpunct.virtuals]</a>.
8640 Copenhagen: Opinions were divided about whether this is actually an
8641 inconsistency, but at best it seems to have been unintentional. This
8642 is only an issue for floating-point output: The standard is
8643 unambiguous that implementations must parse thousands_sep characters
8644 when performing floating-point. The standard is also unambiguous that
8645 this requirement does not apply to the "C" locale.
8649 A survey of existing practice is needed; it is believed that some
8650 implementations do insert thousands_sep characters for floating-point
8651 output and others fail to insert thousands_sep characters for
8652 floating-point input even though this is unambiguously required by the
8656 <p><i>[Post-Curaçao: the above proposed resolution is the consensus of
8657 Howard, Bill, Pete, Benjamin, Nathan, Dietmar, Boris, and Martin.]</i></p>
8660 <a name="283"><h3>283. std::replace() requirement incorrect/insufficient</h3></a><p><b>Section:</b> 25.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.replace"> [lib.alg.replace]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 15 Dec 2000</p>
8662 (revision of the further discussion)
8663 There are a number of problems with the requires clauses for the
8664 algorithms in 25.1 and 25.2. The requires clause of each algorithm
8665 should describe the necessary and sufficient requirements on the inputs
8666 to the algorithm such that the algorithm compiles and runs properly.
8667 Many of the requires clauses fail to do this. Here is a summary of the kinds
8673 Use of EqualityComparable, which only puts requirements on a single
8674 type, when in fact an equality operator is required between two
8675 different types, typically either T and the iterator's value type
8676 or between the value types of two different iterators.
8679 Use of Assignable for T when in fact what was needed is Assignable
8680 for the value_type of the iterator, and convertability from T to the
8681 value_type of the iterator. Or for output iterators, the requirement
8682 should be that T is writable to the iterator (output iterators do
8683 not have value types).
8688 Here is the list of algorithms that contain mistakes:
8692 <li>25.1.2 std::find</li>
8693 <li>25.1.6 std::count</li>
8694 <li>25.1.8 std::equal</li>
8695 <li>25.1.9 std::search, std::search_n</li>
8696 <li>25.2.4 std::replace, std::replace_copy</li>
8697 <li>25.2.5 std::fill</li>
8698 <li>25.2.7 std::remove, std::remove_copy</li>
8702 Also, in the requirements for EqualityComparable, the requirement that
8703 the operator be defined for const objects is lacking.
8706 <p><b>Proposed resolution:</b></p>
8708 <p>20.1.1 Change p1 from</p>
8710 <p>In Table 28, <tt>T</tt> is a type to be supplied by a C++ program
8711 instantiating a template, <tt>a</tt>, <tt>b</tt>, and <tt>c</tt> are
8712 values of type <tt>T</tt>.
8718 In Table 28, <tt>T</tt> is a type to be supplied by a C++ program
8719 instantiating a template, <tt>a</tt>, <tt>b</tt>, and <tt>c</tt> are
8720 values of type <tt>const T</tt>.
8723 <p>25 Between p8 and p9</p>
8725 <p>Add the following sentence:</p>
8727 <p>When the description of an algorithm gives an expression such as
8728 <tt>*first == value</tt> for a condition, it is required that the expression
8729 evaluate to either true or false in boolean contexts.</p>
8731 <p>25.1.2 Change p1 by deleting the requires clause.</p>
8733 <p>25.1.6 Change p1 by deleting the requires clause.</p>
8737 <p>Change p4 from</p>
8739 <p>-4- Requires: Type <tt>T</tt> is <tt>EqualityComparable</tt>
8740 (20.1.1), type Size is convertible to integral type (4.7.12.3).
8745 <p>-4- Requires: The type <tt>Size</tt> is convertible to integral
8746 type (4.7.12.3).</p>
8748 <p>25.2.4 Change p1 from</p>
8750 <p>-1- Requires: Type <tt>T</tt> is <tt>Assignable</tt> (23.1 ) (and, for <tt>replace()</tt>, <tt>EqualityComparable</tt> (20.1.1 )).</p>
8754 <p>-1- Requires: The expression <tt>*first = new_value</tt> must be valid.</p>
8756 <p>and change p4 from</p>
8758 <p>-4- Requires: Type <tt>T</tt> is <tt>Assignable</tt> (23.1) (and,
8759 for <tt>replace_copy()</tt>, <tt>EqualityComparable</tt>
8760 (20.1.1)). The ranges <tt>[first, last)</tt> and <tt>[result, result +
8761 (last - first))</tt> shall not overlap.</p>
8765 <p>-4- Requires: The results of the expressions <tt>*first</tt> and
8766 <tt>new_value</tt> must be writable to the result output iterator. The
8767 ranges <tt>[first, last)</tt> and <tt>[result, result + (last -
8768 first))</tt> shall not overlap.</p>
8771 <p>25.2.5 Change p1 from</p>
8773 <p>-1- Requires: Type <tt>T</tt> is <tt>Assignable</tt> (23.1). The
8774 type <tt>Size</tt> is convertible to an integral type (4.7.12.3).</p>
8778 <p>-1- Requires: The expression <tt>value</tt> must be is writable to
8779 the output iterator. The type <tt>Size</tt> is convertible to an
8780 integral type (4.7.12.3).</p>
8782 <p>25.2.7 Change p1 from</p>
8784 <p>-1- Requires: Type <tt>T</tt> is <tt>EqualityComparable</tt> (20.1.1).</p>
8789 -1- Requires: The value type of the iterator must be
8790 <tt>Assignable</tt> (23.1).
8793 <p><b>Rationale:</b></p>
8795 The general idea of the proposed solution is to remove the faulty
8796 requires clauses and let the returns and effects clauses speak for
8797 themselves. That is, the returns clauses contain expressions that must
8798 be valid, and therefore already imply the correct requirements. In
8799 addition, a sentence is added at the beginning of chapter 25 saying
8800 that expressions given as conditions must evaluate to true or false in
8801 a boolean context. An alternative would be to say that the type of
8802 these condition expressions must be literally bool, but that would be
8803 imposing a greater restriction that what the standard currently says
8804 (which is convertible to bool).
8807 <a name="284"><h3>284. unportable example in 20.3.7, p6</h3></a><p><b>Section:</b> 20.5.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.comparisons"> [lib.comparisons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 26 Dec 2000</p>
8808 <p>The example in 20.5.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.comparisons"> [lib.comparisons]</a>, p6 shows how to use the C
8809 library function <tt>strcmp()</tt> with the function pointer adapter
8810 <tt>ptr_fun()</tt>. But since it's unspecified whether the C library
8811 functions have <tt>extern "C"</tt> or <tt>extern
8812 "C++"</tt> linkage [17.4.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.using.linkage"> [lib.using.linkage]</a>], and since
8813 function pointers with different the language linkage specifications
8814 (7.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/dcl.html#dcl.link"> [dcl.link]</a>) are incompatible, whether this example is
8815 well-formed is unspecified.
8817 <p><b>Proposed resolution:</b></p>
8818 <p>Change 20.5.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.comparisons"> [lib.comparisons]</a> paragraph 6 from:</p>
8820 <p>[<i>Example:</i></p>
8821 <pre> replace_if(v.begin(), v.end(), not1(bind2nd(ptr_fun(strcmp), "C")), "C++");
8823 <p>replaces each <tt>C</tt> with <tt>C++</tt> in sequence <tt>v</tt>.</p>
8829 <p>[<i>Example:</i></p>
8830 <pre> int compare(const char*, const char*);
8831 replace_if(v.begin(), v.end(),
8832 not1(bind2nd(ptr_fun(compare), "abc")), "def");
8834 <p>replaces each <tt>abc</tt> with <tt>def</tt> in sequence <tt>v</tt>.</p>
8837 <p>Also, remove footnote 215 in that same paragraph.</p>
8839 <p><i>[Copenhagen: Minor change in the proposed resolution. Since this
8840 issue deals in part with C and C++ linkage, it was believed to be too
8841 confusing for the strings in the example to be "C" and "C++".
8844 <p><i>[Redmond: More minor changes. Got rid of the footnote (which
8845 seems to make a sweeping normative requirement, even though footnotes
8846 aren't normative), and changed the sentence after the footnote so that
8847 it corresponds to the new code fragment.]</i></p>
8850 <a name="285"><h3>285. minor editorial errors in fstream ctors</h3></a><p><b>Section:</b> 27.8.1.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.cons"> [lib.ifstream.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 31 Dec 2000</p>
8851 <p>27.8.1.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.cons"> [lib.ifstream.cons]</a>, p2, 27.8.1.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ofstream.cons"> [lib.ofstream.cons]</a>, p2, and
8852 27.8.1.12 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstream.cons"> [lib.fstream.cons]</a>, p2 say about the effects of each constructor:
8855 <p>... If that function returns a null pointer, calls
8856 <tt>setstate(failbit)</tt> (which may throw <tt>ios_base::failure</tt>).
8859 <p>The parenthetical note doesn't apply since the ctors cannot throw an
8860 exception due to the requirement in 27.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.cons"> [lib.basic.ios.cons]</a>, p3
8861 that <tt>exceptions()</tt> be initialized to <tt>ios_base::goodbit</tt>.
8863 <p><b>Proposed resolution:</b></p>
8865 Strike the parenthetical note from the Effects clause in each of the
8866 paragraphs mentioned above.
8869 <a name="286"><h3>286. <cstdlib> requirements missing size_t typedef</h3></a><p><b>Section:</b> 25.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.c.library"> [lib.alg.c.library]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 30 Dec 2000</p>
8871 The <cstdlib> header file contains prototypes for bsearch and
8872 qsort (C++ Standard section 25.4 paragraphs 3 and 4) and other
8873 prototypes (C++ Standard section 21.4 paragraph 1 table 49) that
8874 require the typedef size_t. Yet size_t is not listed in the
8875 <cstdlib> synopsis table 78 in section 25.4.
8877 <p><b>Proposed resolution:</b></p>
8879 Add the type size_t to Table 78 (section 25.4) and add
8880 the type size_t <cstdlib> to Table 97 (section C.2).
8882 <p><b>Rationale:</b></p>
8883 <p>Since size_t is in <stdlib.h>, it must also be in <cstdlib>.</p>
8885 <a name="288"><h3>288. <cerrno> requirements missing macro EILSEQ</h3></a><p><b>Section:</b> 19.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-diagnostics.html#lib.errno"> [lib.errno]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Judy Ward <b>Date:</b> 30 Dec 2000</p>
8887 ISO/IEC 9899:1990/Amendment1:1994 Section 4.3 States: "The list
8888 of macros defined in <errno.h> is adjusted to include a new
8893 ISO/IEC 14882:1998(E) section 19.3 does not refer
8894 to the above amendment.
8897 <p><b>Proposed resolution:</b></p>
8899 Update Table 26 (section 19.3) "Header <cerrno> synopsis"
8900 and Table 95 (section C.2) "Standard Macros" to include EILSEQ.
8903 <a name="291"><h3>291. Underspecification of set algorithms</h3></a><p><b>Section:</b> 25.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.set.operations"> [lib.alg.set.operations]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 03 Jan 2001</p>
8905 The standard library contains four algorithms that compute set
8906 operations on sorted ranges: <tt>set_union</tt>, <tt>set_intersection</tt>,
8907 <tt>set_difference</tt>, and <tt>set_symmetric_difference</tt>. Each
8908 of these algorithms takes two sorted ranges as inputs, and writes the
8909 output of the appropriate set operation to an output range. The elements
8910 in the output range are sorted.
8914 The ordinary mathematical definitions are generalized so that they
8915 apply to ranges containing multiple copies of a given element. Two
8916 elements are considered to be "the same" if, according to an
8917 ordering relation provided by the user, neither one is less than the
8918 other. So, for example, if one input range contains five copies of an
8919 element and another contains three, the output range of <tt>set_union</tt>
8920 will contain five copies, the output range of
8921 <tt>set_intersection</tt> will contain three, the output range of
8922 <tt>set_difference</tt> will contain two, and the output range of
8923 <tt>set_symmetric_difference</tt> will contain two.
8927 Because two elements can be "the same" for the purposes
8928 of these set algorithms, without being identical in other respects
8929 (consider, for example, strings under case-insensitive comparison),
8930 this raises a number of unanswered questions:
8934 <li>If we're copying an element that's present in both of the
8935 input ranges, which one do we copy it from?</li>
8936 <li>If there are <i>n</i> copies of an element in the relevant
8937 input range, and the output range will contain fewer copies (say
8938 <i>m</i>) which ones do we choose? The first <i>m</i>, or the last
8939 <i>m</i>, or something else?</li>
8940 <li>Are these operations stable? That is, does a run of equivalent
8941 elements appear in the output range in the same order as as it
8942 appeared in the input range(s)?</li>
8946 The standard should either answer these questions, or explicitly
8947 say that the answers are unspecified. I prefer the former option,
8948 since, as far as I know, all existing implementations behave the
8952 <p><b>Proposed resolution:</b></p>
8954 <p>Add the following to the end of 25.3.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.set.union"> [lib.set.union]</a> paragraph 5:</p>
8956 If [first1, last1) contains <i>m</i> elements that are equivalent to
8957 each other and [first2, last2) contains <i>n</i> elements that are
8958 equivalent to them, then max(<i>m</i>, <i>n</i>) of these elements
8959 will be copied to the output range: all <i>m</i> of these elements
8960 from [first1, last1), and the last max(<i>n-m</i>, 0) of them from
8961 [first2, last2), in that order.
8964 <p>Add the following to the end of 25.3.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.set.intersection"> [lib.set.intersection]</a> paragraph 5:</p>
8966 If [first1, last1) contains <i>m</i> elements that are equivalent to each
8967 other and [first2, last2) contains <i>n</i> elements that are
8968 equivalent to them, the first min(<i>m</i>, <i>n</i>) of those
8969 elements from [first1, last1) are copied to the output range.
8972 <p>Add a new paragraph, <b>Notes</b>, after 25.3.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.set.difference"> [lib.set.difference]</a>
8975 If [first1, last1) contains <i>m</i> elements that are equivalent to each
8976 other and [first2, last2) contains <i>n</i> elements that are
8977 equivalent to them, the last max(<i>m-n</i>, 0) elements from
8978 [first1, last1) are copied to the output range.
8981 <p>Add a new paragraph, <b>Notes</b>, after 25.3.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.set.symmetric.difference"> [lib.set.symmetric.difference]</a>
8984 If [first1, last1) contains <i>m</i> elements that are equivalent to
8985 each other and [first2, last2) contains <i>n</i> elements that are
8986 equivalent to them, then |<i>m - n</i>| of those elements will be
8987 copied to the output range: the last <i>m - n</i> of these elements
8988 from [first1, last1) if <i>m</i> > <i>n</i>, and the last <i>n -
8989 m</i> of these elements from [first2, last2) if <i>m</i> < <i>n</i>.
8992 <p><i>[Santa Cruz: it's believed that this language is clearer than
8993 what's in the Standard. However, it's also believed that the
8994 Standard may already make these guarantees (although not quite in
8995 these words). Bill and Howard will check and see whether they think
8996 that some or all of these changes may be redundant. If so, we may
8997 close this issue as NAD.]</i></p>
8999 <p><b>Rationale:</b></p>
9000 <p>For simple cases, these descriptions are equivalent to what's
9001 already in the Standard. For more complicated cases, they describe
9002 the behavior of existing implementations.</p>
9004 <a name="292"><h3>292. effects of a.copyfmt (a)</h3></a><p><b>Section:</b> 27.4.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.basic.ios.members"> [lib.basic.ios.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 05 Jan 2001</p>
9005 <p>The Effects clause of the member function <tt>copyfmt()</tt> in
9006 27.4.4.2, p15 doesn't consider the case where the left-hand side
9007 argument is identical to the argument on the right-hand side, that is
9008 <tt>(this == &rhs)</tt>. If the two arguments are identical there
9009 is no need to copy any of the data members or call any callbacks
9010 registered with <tt>register_callback()</tt>. Also, as Howard Hinnant
9011 points out in message c++std-lib-8149 it appears to be incorrect to
9012 allow the object to fire <tt>erase_event</tt> followed by
9013 <tt>copyfmt_event</tt> since the callback handling the latter event
9014 may inadvertently attempt to access memory freed by the former.
9016 <p><b>Proposed resolution:</b></p>
9017 <p>Change the Effects clause in 27.4.4.2, p15 from</p>
9020 <b>-15- Effects:</b>Assigns to the member objects of <tt>*this</tt>
9021 the corresponding member objects of <tt>rhs</tt>, except that...
9027 <b>-15- Effects:</b>If <tt>(this == &rhs)</tt> does nothing. Otherwise
9028 assigns to the member objects of <tt>*this</tt> the corresponding member
9029 objects of <tt>rhs</tt>, except that...
9032 <a name="294"><h3>294. User defined macros and standard headers</h3></a><p><b>Section:</b> 17.4.3.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.macro.names"> [lib.macro.names]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> James Kanze <b>Date:</b> 11 Jan 2001</p>
9033 <p>Paragraph 2 of 17.4.3.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.macro.names"> [lib.macro.names]</a> reads: "A
9034 translation unit that includes a header shall not contain any macros
9035 that define names declared in that header." As I read this, it
9036 would mean that the following program is legal:</p>
9038 <pre> #define npos 3.14
9039 #include <sstream>
9042 <p>since npos is not defined in <sstream>. It is, however, defined
9043 in <string>, and it is hard to imagine an implementation in
9044 which <sstream> didn't include <string>.</p>
9046 <p>I think that this phrase was probably formulated before it was
9047 decided that a standard header may freely include other standard
9048 headers. The phrase would be perfectly appropriate for C, for
9049 example. In light of 17.4.4.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.res.on.headers"> [lib.res.on.headers]</a> paragraph 1, however,
9050 it isn't stringent enough.</p>
9051 <p><b>Proposed resolution:</b></p>
9052 <p>For 17.4.3.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.macro.names"> [lib.macro.names]</a>, replace the current wording, which reads:</p>
9054 <p>Each name defined as a macro in a header is reserved to the
9055 implementation for any use if the translation unit includes
9058 <p>A translation unit that includes a header shall not contain any
9059 macros that define names declared or defined in that header. Nor shall
9060 such a translation unit define macros for names lexically
9061 identical to keywords.</p>
9063 <p>168) It is not permissible to remove a library macro definition by
9064 using the #undef directive.</p>
9067 <p>with the wording:</p>
9070 <p>A translation unit that includes a standard library header shall not
9071 #define or #undef names declared in any standard library header.</p>
9073 <p>A translation unit shall not #define or #undef names lexically
9074 identical to keywords.</p>
9077 <p><i>[Lillehammer: Beman provided new wording]</i></p>
9080 <a name="295"><h3>295. Is abs defined in <cmath>?</h3></a><p><b>Section:</b> 26.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.numarray"> [lib.numarray]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Jens Maurer <b>Date:</b> 12 Jan 2001</p>
9082 Table 80 lists the contents of the <cmath> header. It does not
9083 list <tt>abs()</tt>. However, 26.5, paragraph 6, which lists added
9084 signatures present in <cmath>, does say that several overloads
9085 of <tt>abs()</tt> should be defined in <cmath>.
9087 <p><b>Proposed resolution:</b></p>
9089 Add <tt>abs</tt> to Table 80. Also, remove the parenthetical list
9090 of functions "(abs(), div(), rand(), srand())" from 26.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.numarray"> [lib.numarray]</a>,
9094 <p><i>[Copenhagen: Modified proposed resolution so that it also gets
9095 rid of that vestigial list of functions in paragraph 1.]</i></p>
9097 <p><b>Rationale:</b></p>
9098 <p>All this DR does is fix a typo; it's uncontroversial. A
9099 separate question is whether we're doing the right thing in
9100 putting some overloads in <cmath> that we aren't also
9101 putting in <cstdlib>. That's issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#323">323</a>.</p>
9103 <a name="297"><h3>297. const_mem_fun_t<>::argument_type should be const T*</h3></a><p><b>Section:</b> 20.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.logical.operations"> [lib.logical.operations]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 6 Jan 2001</p>
9104 <p>The class templates <tt>const_mem_fun_t</tt> in 20.5.8, p8 and
9105 <tt>const_mem_fun1_t</tt>
9106 in 20.5.8, p9 derive from <tt>unary_function<T*, S></tt>, and
9107 <tt>binary_function<T*,
9108 A, S></tt>, respectively. Consequently, their <tt>argument_type</tt>, and
9109 <tt>first_argument_type</tt>
9110 members, respectively, are both defined to be <tt>T*</tt> (non-const).
9111 However, their function call member operator takes a <tt>const T*</tt>
9112 argument. It is my opinion that <tt>argument_type</tt> should be <tt>const
9113 T*</tt> instead, so that one can easily refer to it in generic code. The
9114 example below derived from existing code fails to compile due to the
9118 <p><tt>template <class T></tt>
9119 <br><tt>void foo (typename T::argument_type arg) // #1</tt>
9121 <br><tt> typename T::result_type (T::*pf) (typename
9123 const = // #2</tt>
9124 <br><tt> &T::operator();</tt>
9128 <p><tt>struct X { /* ... */ };</tt></p>
9130 <p><tt>int main ()</tt>
9132 <br><tt> const X x;</tt>
9133 <br><tt> foo<std::const_mem_fun_t<void, X>
9134 >(&x);
9139 <p>#1 <tt>foo()</tt> takes a plain unqualified <tt>X*</tt> as an argument
9140 <br>#2 the type of the pointer is incompatible with the type of the member
9142 <br>#3 the address of a constant being passed to a function taking a non-const
9145 <p><b>Proposed resolution:</b></p>
9146 <p>Replace the top portion of the definition of the class template
9147 const_mem_fun_t in 20.5.8, p8
9149 <p><tt>template <class S, class T> class const_mem_fun_t</tt>
9150 <br><tt> : public
9151 unary_function<T*, S> {</tt>
9154 <p><tt>template <class S, class T> class const_mem_fun_t</tt>
9155 <br><tt> : public
9156 unary_function<<b>const</b> T*, S> {</tt>
9158 <p>Also replace the top portion of the definition of the class template
9159 const_mem_fun1_t in 20.5.8, p9</p>
9160 <p><tt>template <class S, class T, class A> class const_mem_fun1_t</tt>
9161 <br><tt> : public
9162 binary_function<T*, A, S> {</tt>
9165 <p><tt>template <class S, class T, class A> class const_mem_fun1_t</tt>
9166 <br><tt> : public
9167 binary_function<<b>const</b> T*, A, S> {</tt>
9169 <p><b>Rationale:</b></p>
9170 <p>This is simply a contradiction: the <tt>argument_type</tt> typedef,
9171 and the argument type itself, are not the same.</p>
9173 <a name="298"><h3>298. ::operator delete[] requirement incorrect/insufficient</h3></a><p><b>Section:</b> 18.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.array"> [lib.new.delete.array]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> John A. Pedretti <b>Date:</b> 10 Jan 2001</p>
9175 The default behavior of <tt>operator delete[]</tt> described in 18.5.1.2, p12 -
9176 namely that for non-null value of <i>ptr</i>, the operator reclaims storage
9177 allocated by the earlier call to the default <tt>operator new[]</tt> - is not
9178 correct in all cases. Since the specified <tt>operator new[]</tt> default
9179 behavior is to call <tt>operator new</tt> (18.5.1.2, p4, p8), which can be
9180 replaced, along with <tt>operator delete</tt>, by the user, to implement their
9181 own memory management, the specified default behavior of<tt> operator
9182 delete[]</tt> must be to call <tt>operator delete</tt>.
9184 <p><b>Proposed resolution:</b></p>
9185 <p>Change 18.5.1.2, p12 from</p>
9187 <b>-12-</b> <b>Default behavior:</b>
9190 For a null value of <i><tt>ptr</tt></i> , does nothing.
9193 Any other value of <i><tt>ptr</tt></i> shall be a value returned
9194 earlier by a call to the default <tt>operator new[](std::size_t)</tt>.
9195 [Footnote: The value must not have been invalidated by an intervening
9196 call to <tt>operator delete[](void*)</tt> (17.4.3.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.res.on.arguments"> [lib.res.on.arguments]</a>).
9198 For such a non-null value of <i><tt>ptr</tt></i> , reclaims storage
9199 allocated by the earlier call to the default <tt>operator new[]</tt>.
9207 <b>-12-</b> <b>Default behavior: </b>Calls <tt>operator
9208 delete(</tt><i>ptr</i>)
9209 or <tt>operator delete(<i>ptr</i>, std::nothrow)</tt> respectively.
9211 <p>and expunge paragraph 13.</p>
9213 <a name="300"><h3>300. list::merge() specification incomplete</h3></a><p><b>Section:</b> 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> John Pedretti <b>Date:</b> 23 Jan 2001</p>
9215 The "Effects" clause for list::merge() (23.2.2.4, p23)
9216 appears to be incomplete: it doesn't cover the case where the argument
9217 list is identical to *this (i.e., this == &x). The requirement in the
9218 note in p24 (below) is that x be empty after the merge which is surely
9219 unintended in this case.
9221 <p><b>Proposed resolution:</b></p>
9222 <p>In 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, replace paragraps 23-25 with:</p>
9225 23 Effects: if (&x == this) does nothing; otherwise, merges the two
9226 sorted ranges [begin(), end()) and [x.begin(), x.end()). The result
9227 is a range in which the elements will be sorted in non-decreasing
9228 order according to the ordering defined by comp; that is, for every
9229 iterator i in the range other than the first, the condition comp(*i,
9230 *(i - 1)) will be false.
9234 24 Notes: Stable: if (&x != this), then for equivalent elements in the
9235 two original ranges, the elements from the original range [begin(),
9236 end()) always precede the elements from the original range [x.begin(),
9237 x.end()). If (&x != this) the range [x.begin(), x.end()) is empty
9242 25 Complexity: At most size() + x.size() - 1 applications of comp if
9243 (&x ! = this); otherwise, no applications of comp are performed. If
9244 an exception is thrown other than by a comparison there are no
9250 <p><i>[Copenhagen: The original proposed resolution did not fix all of
9251 the problems in 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, p22-25. Three different
9252 paragraphs (23, 24, 25) describe the effects of <tt>merge</tt>.
9253 Changing p23, without changing the other two, appears to introduce
9254 contradictions. Additionally, "merges the argument list into the
9255 list" is excessively vague.]</i></p>
9257 <p><i>[Post-Curaçao: Robert Klarer provided new wording.]</i></p>
9260 <a name="301"><h3>301. basic_string template ctor effects clause omits allocator argument</h3></a><p><b>Section:</b> 21.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.cons"> [lib.string.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 27 Jan 2001</p>
9262 The effects clause for the basic_string template ctor in 21.3.1, p15
9263 leaves out the third argument of type Allocator. I believe this to be
9266 <p><b>Proposed resolution:</b></p>
9270 <p><b>-15- Effects:</b> If <i><tt>InputIterator</tt></i> is an integral
9271 type, equivalent to</p>
9273 <blockquote><tt>basic_string(static_cast<size_type>(begin),
9274 static_cast<value_type>(end))</tt></blockquote>
9280 <p><b>-15- Effects:</b> If <i><tt>InputIterator</tt></i> is an integral
9281 type, equivalent to</p>
9283 <blockquote><tt>basic_string(static_cast<size_type>(begin),
9284 static_cast<value_type>(end), <b>a</b>)</tt></blockquote>
9287 <a name="303"><h3>303. Bitset input operator underspecified</h3></a><p><b>Section:</b> 23.3.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.operators"> [lib.bitset.operators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 5 Feb 2001</p>
9289 In 23.3.5.3, we are told that <tt>bitset</tt>'s input operator
9290 "Extracts up to <i>N</i> (single-byte) characters from
9291 <i>is</i>.", where <i>is</i> is a stream of type
9292 <tt>basic_istream<charT, traits></tt>.
9296 The standard does not say what it means to extract single byte
9297 characters from a stream whose character type, <tt>charT</tt>, is in
9298 general not a single-byte character type. Existing implementations
9303 A reasonable solution will probably involve <tt>widen()</tt> and/or
9304 <tt>narrow()</tt>, since they are the supplied mechanism for
9305 converting a single character between <tt>char</tt> and
9306 arbitrary <tt>charT</tt>.
9309 <p>Narrowing the input characters is not the same as widening the
9310 literals <tt>'0'</tt> and <tt>'1'</tt>, because there may be some
9311 locales in which more than one wide character maps to the narrow
9312 character <tt>'0'</tt>. Narrowing means that alternate
9313 representations may be used for bitset input, widening means that
9314 they may not be.</p>
9316 <p>Note that for numeric input, <tt>num_get<></tt>
9317 (22.2.2.1.2/8) compares input characters to widened version of narrow
9318 character literals.</p>
9320 <p>From Pete Becker, in c++std-lib-8224:</p>
9323 Different writing systems can have different representations for the
9324 digits that represent 0 and 1. For example, in the Unicode representation
9325 of the Devanagari script (used in many of the Indic languages) the digit 0
9326 is 0x0966, and the digit 1 is 0x0967. Calling narrow would translate those
9327 into '0' and '1'. But Unicode also provides the ASCII values 0x0030 and
9328 0x0031 for for the Latin representations of '0' and '1', as well as code
9329 points for the same numeric values in several other scripts (Tamil has no
9330 character for 0, but does have the digits 1-9), and any of these values
9331 would also be narrowed to '0' and '1'.
9337 It's fairly common to intermix both native and Latin
9338 representations of numbers in a document. So I think the rule has to be
9339 that if a wide character represents a digit whose value is 0 then the bit
9340 should be cleared; if it represents a digit whose value is 1 then the bit
9341 should be set; otherwise throw an exception. So in a Devanagari locale,
9342 both 0x0966 and 0x0030 would clear the bit, and both 0x0967 and 0x0031
9343 would set it. Widen can't do that. It would pick one of those two values,
9344 and exclude the other one.
9349 <p>From Jens Maurer, in c++std-lib-8233:</p>
9353 Whatever we decide, I would find it most surprising if
9354 bitset conversion worked differently from int conversion
9355 with regard to alternate local representations of
9359 <p>Thus, I think the options are:</p>
9361 <li> Have a new defect issue for 22.2.2.1.2/8 so that it will
9362 require the use of narrow().</li>
9364 <li> Have a defect issue for bitset() which describes clearly
9365 that widen() is to be used.</li>
9368 <p><b>Proposed resolution:</b></p>
9370 <p>Replace the first two sentences of paragraph 5 with:</p>
9373 Extracts up to <i>N</i> characters from <i>is</i>. Stores these
9374 characters in a temporary object <i>str</i> of type
9375 <tt>basic_string<charT, traits></tt>, then evaluates the
9376 expression <tt><i>x</i> = bitset<N>(<i>str</i>)</tt>.
9379 <p>Replace the third bullet item in paragraph 5 with:</p>
9381 the next input character is neither <tt><i>is</i>.widen(0)</tt>
9382 nor <tt><i>is</i>.widen(1)</tt> (in which case the input character
9386 <p><b>Rationale:</b></p>
9387 <p>Input for <tt>bitset</tt> should work the same way as numeric
9388 input. Using <tt>widen</tt> does mean that alternative digit
9389 representations will not be recognized, but this was a known
9390 consequence of the design choice.</p>
9392 <a name="305"><h3>305. Default behavior of codecvt<wchar_t, char, mbstate_t>::length()</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 24 Jan 2001</p>
9393 <p>22.2.1.5/3 introduces codecvt in part with:</p>
9396 codecvt<wchar_t,char,mbstate_t> converts between the native
9397 character sets for tiny and wide characters. Instantiations on
9398 mbstate_t perform conversion between encodings known to the library
9402 <p>But 22.2.1.5.2/10 describes do_length in part with:</p>
9405 ... codecvt<wchar_t, char, mbstate_t> ... return(s) the lesser of max and
9410 The semantics of do_in and do_length are linked. What one does must
9411 be consistent with what the other does. 22.2.1.5/3 leads me to
9412 believe that the vendor is allowed to choose the algorithm that
9413 codecvt<wchar_t,char,mbstate_t>::do_in performs so that it makes
9414 his customers happy on a given platform. But 22.2.1.5.2/10 explicitly
9415 says what codecvt<wchar_t,char,mbstate_t>::do_length must
9416 return. And thus indirectly specifies the algorithm that
9417 codecvt<wchar_t,char,mbstate_t>::do_in must perform. I believe
9418 that this is not what was intended and is a defect.
9421 <p>Discussion from the -lib reflector:
9423 <br>This proposal would have the effect of making the semantics of
9424 all of the virtual functions in <tt>codecvt<wchar_t, char,
9425 mbstate_t></tt> implementation specified. Is that what we want, or
9426 do we want to mandate specific behavior for the base class virtuals
9427 and leave the implementation specified behavior for the codecvt_byname
9428 derived class? The tradeoff is that former allows implementors to
9429 write a base class that actually does something useful, while the
9430 latter gives users a way to get known and specified---albeit
9431 useless---behavior, and is consistent with the way the standard
9432 handles other facets. It is not clear what the original intention
9436 Nathan has suggest a compromise: a character that is a widened version
9437 of the characters in the basic execution character set must be
9438 converted to a one-byte sequence, but there is no such requirement
9439 for characters that are not part of the basic execution character set.
9441 <p><b>Proposed resolution:</b></p>
9443 Change 22.2.1.5.2/5 from:
9446 The instantiations required in Table 51 (lib.locale.category), namely
9447 codecvt<wchar_t,char,mbstate_t> and
9448 codecvt<char,char,mbstate_t>, store no characters. Stores no more
9449 than (to_limit-to) destination elements. It always leaves the to_next
9450 pointer pointing one beyond the last element successfully stored.
9456 Stores no more than (to_limit-to) destination elements, and leaves the
9457 to_next pointer pointing one beyond the last element successfully
9458 stored. codecvt<char,char,mbstate_t> stores no characters.
9461 <p>Change 22.2.1.5.2/10 from:</p>
9464 -10- Returns: (from_next-from) where from_next is the largest value in
9465 the range [from,from_end] such that the sequence of values in the
9466 range [from,from_next) represents max or fewer valid complete
9467 characters of type internT. The instantiations required in Table 51
9468 (21.1.1.1.1), namely codecvt<wchar_t, char, mbstate_t> and
9469 codecvt<char, char, mbstate_t>, return the lesser of max and
9476 -10- Returns: (from_next-from) where from_next is the largest value in
9477 the range [from,from_end] such that the sequence of values in the range
9478 [from,from_next) represents max or fewer valid complete characters of
9479 type internT. The instantiation codecvt<char, char, mbstate_t> returns
9480 the lesser of max and (from_end-from).
9483 <p><i>[Redmond: Nathan suggested an alternative resolution: same as
9484 above, but require that, in the default encoding, a character from the
9485 basic execution character set would map to a single external
9486 character. The straw poll was 8-1 in favor of the proposed
9487 resolution.]</i></p>
9489 <p><b>Rationale:</b></p>
9490 <p>The default encoding should be whatever users of a given platform
9491 would expect to be the most natural. This varies from platform to
9492 platform. In many cases there is a preexisting C library, and users
9493 would expect the default encoding to be whatever C uses in the default
9494 "C" locale. We could impose a guarantee like the one Nathan suggested
9495 (a character from the basic execution character set must map to a
9496 single external character), but this would rule out important
9497 encodings that are in common use: it would rule out JIS, for
9498 example, and it would rule out a fixed-width encoding of UCS-4.</p>
9500 <p><i>[Curaçao: fixed rationale typo at the request of Ichiro Koshida;
9501 "shift-JIS" changed to "JIS".]</i></p>
9504 <a name="306"><h3>306. offsetof macro and non-POD types</h3></a><p><b>Section:</b> 18.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.support.types"> [lib.support.types]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 21 Feb 2001</p>
9505 <p>Spliced together from reflector messages c++std-lib-8294 and -8295:</p>
9507 <p>18.1, paragraph 5, reads: "The macro <tt>offsetof</tt>
9508 accepts a restricted set of <i>type</i> arguments in this
9509 International Standard. <i>type</i> shall be a POD structure or a POD
9510 union (clause 9). The result of applying the offsetof macro to a field
9511 that is a static data member or a function member is
9514 <p>For the POD requirement, it doesn't say "no diagnostic
9515 required" or "undefined behavior". I read 1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/intro.html#intro.compliance"> [intro.compliance]</a>, paragraph 1, to mean that a diagnostic is required.
9516 It's not clear whether this requirement was intended. While it's
9517 possible to provide such a diagnostic, the extra complication doesn't
9518 seem to add any value.
9520 <p><b>Proposed resolution:</b></p>
9521 <p>Change 18.1, paragraph 5, to "If <i>type</i> is not a POD
9522 structure or a POD union the results are undefined."</p>
9524 <p><i>[Copenhagen: straw poll was 7-4 in favor. It was generally
9525 agreed that requiring a diagnostic was inadvertent, but some LWG
9526 members thought that diagnostics should be required whenever
9530 <a name="307"><h3>307. Lack of reference typedefs in container adaptors</h3></a><p><b>Section:</b> 23.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list"> [lib.list]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 13 Mar 2001</p>
9532 <p>From reflector message c++std-lib-8330. See also lib-8317.</p>
9535 The standard is currently inconsistent in 23.2.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.capacity"> [lib.list.capacity]</a>
9536 paragraph 1 and 23.2.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.modifiers"> [lib.list.modifiers]</a> paragraph 1.
9537 23.2.3.3/1, for example, says:
9541 -1- Any sequence supporting operations back(), push_back() and pop_back()
9542 can be used to instantiate stack. In particular, vector (lib.vector), list
9543 (lib.list) and deque (lib.deque) can be used.
9546 <p>But this is false: vector<bool> can not be used, because the
9547 container adaptors return a T& rather than using the underlying
9548 container's reference type.</p>
9550 <p>This is a contradiction that can be fixed by:</p>
9553 <li>Modifying these paragraphs to say that vector<bool>
9554 is an exception.</li>
9555 <li>Removing the vector<bool> specialization.</li>
9556 <li>Changing the return types of stack and priority_queue to use
9557 reference typedef's.</li>
9561 I propose 3. This does not preclude option 2 if we choose to do it
9562 later (see issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#96">96</a>); the issues are independent. Option
9563 3 offers a small step towards support for proxied containers. This
9564 small step fixes a current contradiction, is easy for vendors to
9565 implement, is already implemented in at least one popular lib, and
9566 does not break any code.
9569 <p><b>Proposed resolution:</b></p>
9570 <p>Summary: Add reference and const_reference typedefs to queue,
9571 priority_queue and stack. Change return types of "value_type&" to
9572 "reference". Change return types of "const value_type&" to
9573 "const_reference". Details:</p>
9575 <p>Change 23.2.3.1/1 from:</p>
9577 <pre> namespace std {
9578 template <class T, class Container = deque<T> >
9581 typedef typename Container::value_type value_type;
9582 typedef typename Container::size_type size_type;
9583 typedef Container container_type;
9588 explicit queue(const Container& = Container());
9590 bool empty() const { return c.empty(); }
9591 size_type size() const { return c.size(); }
9592 value_type& front() { return c.front(); }
9593 const value_type& front() const { return c.front(); }
9594 value_type& back() { return c.back(); }
9595 const value_type& back() const { return c.back(); }
9596 void push(const value_type& x) { c.push_back(x); }
9597 void pop() { c.pop_front(); }
9603 <pre> namespace std {
9604 template <class T, class Container = deque<T> >
9607 typedef typename Container::value_type value_type;
9608 typedef typename Container::reference reference;
9609 typedef typename Container::const_reference const_reference;
9610 typedef typename Container::value_type value_type;
9611 typedef typename Container::size_type size_type;
9612 typedef Container container_type;
9617 explicit queue(const Container& = Container());
9619 bool empty() const { return c.empty(); }
9620 size_type size() const { return c.size(); }
9621 reference front() { return c.front(); }
9622 const_reference front() const { return c.front(); }
9623 reference back() { return c.back(); }
9624 const_reference back() const { return c.back(); }
9625 void push(const value_type& x) { c.push_back(x); }
9626 void pop() { c.pop_front(); }
9630 <p>Change 23.2.3.2/1 from:</p>
9632 <pre> namespace std {
9633 template <class T, class Container = vector<T>,
9634 class Compare = less<typename Container::value_type> >
9635 class priority_queue {
9637 typedef typename Container::value_type value_type;
9638 typedef typename Container::size_type size_type;
9639 typedef Container container_type;
9645 explicit priority_queue(const Compare& x = Compare(),
9646 const Container& = Container());
9647 template <class InputIterator>
9648 priority_queue(InputIterator first, InputIterator last,
9649 const Compare& x = Compare(),
9650 const Container& = Container());
9652 bool empty() const { return c.empty(); }
9653 size_type size() const { return c.size(); }
9654 const value_type& top() const { return c.front(); }
9655 void push(const value_type& x);
9658 // no equality is provided
9664 <pre> namespace std {
9665 template <class T, class Container = vector<T>,
9666 class Compare = less<typename Container::value_type> >
9667 class priority_queue {
9669 typedef typename Container::value_type value_type;
9670 typedef typename Container::reference reference;
9671 typedef typename Container::const_reference const_reference;
9672 typedef typename Container::size_type size_type;
9673 typedef Container container_type;
9679 explicit priority_queue(const Compare& x = Compare(),
9680 const Container& = Container());
9681 template <class InputIterator>
9682 priority_queue(InputIterator first, InputIterator last,
9683 const Compare& x = Compare(),
9684 const Container& = Container());
9686 bool empty() const { return c.empty(); }
9687 size_type size() const { return c.size(); }
9688 const_reference top() const { return c.front(); }
9689 void push(const value_type& x);
9692 // no equality is provided
9696 <p>And change 23.2.3.3/1 from:</p>
9698 <pre> namespace std {
9699 template <class T, class Container = deque<T> >
9702 typedef typename Container::value_type value_type;
9703 typedef typename Container::size_type size_type;
9704 typedef Container container_type;
9709 explicit stack(const Container& = Container());
9711 bool empty() const { return c.empty(); }
9712 size_type size() const { return c.size(); }
9713 value_type& top() { return c.back(); }
9714 const value_type& top() const { return c.back(); }
9715 void push(const value_type& x) { c.push_back(x); }
9716 void pop() { c.pop_back(); }
9719 template <class T, class Container>
9720 bool operator==(const stack<T, Container>& x,
9721 const stack<T, Container>& y);
9722 template <class T, class Container>
9723 bool operator< (const stack<T, Container>& x,
9724 const stack<T, Container>& y);
9725 template <class T, class Container>
9726 bool operator!=(const stack<T, Container>& x,
9727 const stack<T, Container>& y);
9728 template <class T, class Container>
9729 bool operator> (const stack<T, Container>& x,
9730 const stack<T, Container>& y);
9731 template <class T, class Container>
9732 bool operator>=(const stack<T, Container>& x,
9733 const stack<T, Container>& y);
9734 template <class T, class Container>
9735 bool operator<=(const stack<T, Container>& x,
9736 const stack<T, Container>& y);
9742 <pre> namespace std {
9743 template <class T, class Container = deque<T> >
9746 typedef typename Container::value_type value_type;
9747 typedef typename Container::reference reference;
9748 typedef typename Container::const_reference const_reference;
9749 typedef typename Container::size_type size_type;
9750 typedef Container container_type;
9755 explicit stack(const Container& = Container());
9757 bool empty() const { return c.empty(); }
9758 size_type size() const { return c.size(); }
9759 reference top() { return c.back(); }
9760 const_reference top() const { return c.back(); }
9761 void push(const value_type& x) { c.push_back(x); }
9762 void pop() { c.pop_back(); }
9765 template <class T, class Container>
9766 bool operator==(const stack<T, Container>& x,
9767 const stack<T, Container>& y);
9768 template <class T, class Container>
9769 bool operator< (const stack<T, Container>& x,
9770 const stack<T, Container>& y);
9771 template <class T, class Container>
9772 bool operator!=(const stack<T, Container>& x,
9773 const stack<T, Container>& y);
9774 template <class T, class Container>
9775 bool operator> (const stack<T, Container>& x,
9776 const stack<T, Container>& y);
9777 template <class T, class Container>
9778 bool operator>=(const stack<T, Container>& x,
9779 const stack<T, Container>& y);
9780 template <class T, class Container>
9781 bool operator<=(const stack<T, Container>& x,
9782 const stack<T, Container>& y);
9786 <p><i>[Copenhagen: This change was discussed before the IS was released
9787 and it was deliberately not adopted. Nevertheless, the LWG believes
9788 (straw poll: 10-2) that it is a genuine defect.]</i></p>
9791 <a name="308"><h3>308. Table 82 mentions unrelated headers</h3></a><p><b>Section:</b> 27 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.input.output"> [lib.input.output]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 15 Mar 2001</p>
9793 Table 82 in section 27 mentions the header <cstdlib> for String
9794 streams (27.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.string.streams"> [lib.string.streams]</a>) and the headers <cstdio> and
9795 <cwchar> for File streams (27.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.file.streams"> [lib.file.streams]</a>). It's not clear
9796 why these headers are mentioned in this context since they do not
9797 define any of the library entities described by the
9798 subclauses. According to 17.4.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.contents"> [lib.contents]</a>, only such headers
9799 are to be listed in the summary.
9801 <p><b>Proposed resolution:</b></p>
9802 <p>Remove <cstdlib> and <cwchar> from
9805 <p><i>[Copenhagen: changed the proposed resolution slightly. The
9806 original proposed resolution also said to remove <cstdio> from
9807 Table 82. However, <cstdio> is mentioned several times within
9808 section 27.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.file.streams"> [lib.file.streams]</a>, including 27.8.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.c.files"> [lib.c.files]</a>.]</i></p>
9811 <a name="310"><h3>310. Is errno a macro?</h3></a><p><b>Section:</b> 17.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.headers"> [lib.headers]</a>, 19.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-diagnostics.html#lib.errno"> [lib.errno]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 21 Mar 2001</p>
9813 Exactly how should errno be declared in a conforming C++ header?
9817 The C standard says in 7.1.4 that it is unspecified whether errno is a
9818 macro or an identifier with external linkage. In some implementations
9819 it can be either, depending on compile-time options. (E.g., on
9820 Solaris in multi-threading mode, errno is a macro that expands to a
9821 function call, but is an extern int otherwise. "Unspecified" allows
9825 <p>The C++ standard:</p>
9827 <li>17.4.1.2 says in a note that errno must be macro in C. (false)</li>
9828 <li>17.4.3.1.3 footnote 166 says errno is reserved as an external
9829 name (true), and implies that it is an identifier.</li>
9830 <li>19.3 simply lists errno as a macro (by what reasoning?) and goes
9831 on to say that the contents of of C++ <errno.h> are the
9832 same as in C, begging the question.</li>
9833 <li>C.2, table 95 lists errno as a macro, without comment.</li>
9836 <p>I find no other references to errno.</p>
9838 <p>We should either explicitly say that errno must be a macro, even
9839 though it need not be a macro in C, or else explicitly leave it
9840 unspecified. We also need to say something about namespace std.
9841 A user who includes <cerrno> needs to know whether to write
9842 <tt>errno</tt>, or <tt>::errno</tt>, or <tt>std::errno</tt>, or
9843 else <cerrno> is useless.</p>
9845 <p>Two acceptable fixes:</p>
9847 <li><p>errno must be a macro. This is trivially satisfied by adding<br>
9848 #define errno (::std::errno)<br>
9849 to the headers if errno is not already a macro. You then always
9850 write errno without any scope qualification, and it always expands
9851 to a correct reference. Since it is always a macro, you know to
9852 avoid using errno as a local identifer.</p></li>
9853 <li><p>errno is in the global namespace. This fix is inferior, because
9854 ::errno is not guaranteed to be well-formed.</p></li>
9858 This issue was first raised in 1999, but it slipped through
9861 <p><b>Proposed resolution:</b></p>
9862 <p>Change the Note in section 17.4.1.2p5 from</p>
9865 Note: the names defined as macros in C include the following:
9866 assert, errno, offsetof, setjmp, va_arg, va_end, and va_start.
9872 Note: the names defined as macros in C include the following:
9873 assert, offsetof, setjmp, va_arg, va_end, and va_start.
9876 <p>In section 19.3, change paragraph 2 from</p>
9879 The contents are the same as the Standard C library header
9886 The contents are the same as the Standard C library header
9887 <errno.h>, except that errno shall be defined as a macro.
9889 <p><b>Rationale:</b></p>
9890 <p>C++ must not leave it up to the implementation to decide whether or
9891 not a name is a macro; it must explicitly specify exactly which names
9892 are required to be macros. The only one that really works is for it
9895 <p><i>[Curaçao: additional rationale added.]</i></p>
9898 <a name="311"><h3>311. Incorrect wording in basic_ostream class synopsis</h3></a><p><b>Section:</b> 27.6.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream"> [lib.ostream]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andy Sawyer <b>Date:</b> 21 Mar 2001</p>
9900 <p>In 27.6.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream"> [lib.ostream]</a>, the synopsis of class basic_ostream says:</p>
9902 <pre> // partial specializationss
9903 template<class traits>
9904 basic_ostream<char,traits>& operator<<( basic_ostream<char,traits>&,
9910 <li>Too many 's's at the end of "specializationss" </li>
9911 <li>This is an overload, not a partial specialization</li>
9914 <p><b>Proposed resolution:</b></p>
9915 <p>In the synopsis in 27.6.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream"> [lib.ostream]</a>, remove the
9916 <i>// partial specializationss</i> comment. Also remove the same
9917 comment (correctly spelled, but still incorrect) from the synopsis in
9918 27.6.2.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.inserters.character"> [lib.ostream.inserters.character]</a>.
9922 Pre-Redmond: added 27.6.2.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.inserters.character"> [lib.ostream.inserters.character]</a> because of Martin's
9923 comment in c++std-lib-8939.
9927 <a name="312"><h3>312. Table 27 is missing headers</h3></a><p><b>Section:</b> 20 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.utilities"> [lib.utilities]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 29 Mar 2001</p>
9928 <p>Table 27 in section 20 lists the header <memory> (only) for
9929 Memory (lib.memory) but neglects to mention the headers
9930 <cstdlib> and <cstring> that are discussed in 20.4.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.rel"> [lib.meta.rel]</a>.</p>
9931 <p><b>Proposed resolution:</b></p>
9932 <p>Add <cstdlib> and <cstring> to Table 27, in the same row
9933 as <memory>.</p>
9935 <a name="315"><h3>315. Bad "range" in list::unique complexity</h3></a><p><b>Section:</b> 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andy Sawyer <b>Date:</b> 1 May 2001</p>
9937 23.2.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.special"> [lib.deque.special]</a>, Para 21 describes the complexity of
9938 list::unique as: "If the range (last - first) is not empty, exactly
9939 (last - first) -1 applications of the corresponding predicate,
9940 otherwise no applications of the predicate)".
9944 "(last - first)" is not a range.
9946 <p><b>Proposed resolution:</b></p>
9948 Change the "range" from (last - first) to [first, last).
9951 <a name="316"><h3>316. Vague text in Table 69</h3></a><p><b>Section:</b> 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 4 May 2001</p>
9952 <p>Table 69 says this about a_uniq.insert(t):</p>
9955 inserts t if and only if there is no element in the container with key
9956 equivalent to the key of t. The bool component of the returned pair
9957 indicates whether the insertion takes place and the iterator component of the
9958 pair points to the element with key equivalent to the key of t.
9961 <p>The description should be more specific about exactly how the bool component
9962 indicates whether the insertion takes place.</p>
9963 <p><b>Proposed resolution:</b></p>
9964 <p>Change the text in question to</p>
9967 ...The bool component of the returned pair is true if and only if the insertion
9971 <a name="317"><h3>317. Instantiation vs. specialization of facets</h3></a><p><b>Section:</b> 22 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.localization"> [lib.localization]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 4 May 2001</p>
9973 The localization section of the standard refers to specializations of
9974 the facet templates as instantiations even though the required facets
9975 are typically specialized rather than explicitly (or implicitly)
9976 instantiated. In the case of ctype<char> and
9977 ctype_byname<char> (and the wchar_t versions), these facets are
9978 actually required to be specialized. The terminology should be
9979 corrected to make it clear that the standard doesn't mandate explicit
9980 instantiation (the term specialization encompasses both explicit
9981 instantiations and specializations).
9983 <p><b>Proposed resolution:</b></p>
9985 In the following paragraphs, replace all occurrences of the word
9986 instantiation or instantiations with specialization or specializations,
9991 22.1.1.1.1, p4, Table 52, 22.2.1.1, p2, 22.2.1.5, p3, 22.2.1.5.1, p5,
9992 22.2.1.5.2, p10, 22.2.2, p2, 22.2.3.1, p1, 22.2.3.1.2, p1, p2 and p3,
9993 22.2.4.1, p1, 22.2.4.1.2, p1, 22,2,5, p1, 22,2,6, p2, 22.2.6.3.2, p7, and
9997 <p>And change the text in 22.1.1.1.1, p4 from</p>
10000 An implementation is required to provide those instantiations
10001 for facet templates identified as members of a category, and
10002 for those shown in Table 52:
10008 An implementation is required to provide those specializations...
10011 <p><i>[Nathan will review these changes, and will look for places where
10012 explicit specialization is necessary.]</i></p>
10014 <p><b>Rationale:</b></p>
10015 <p>This is a simple matter of outdated language. The language to
10016 describe templates was clarified during the standardization process,
10017 but the wording in clause 22 was never updated to reflect that
10020 <a name="318"><h3>318. Misleading comment in definition of numpunct_byname</h3></a><p><b>Section:</b> 22.2.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.numpunct.byname"> [lib.locale.numpunct.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 12 May 2001</p>
10021 <p>The definition of the numpunct_byname template contains the following
10024 <pre> namespace std {
10025 template <class charT>
10026 class numpunct_byname : public numpunct<charT> {
10027 // this class is specialized for char and wchar_t.
10031 <p>There is no documentation of the specializations and it seems
10032 conceivable that an implementation will not explicitly specialize the
10033 template at all, but simply provide the primary template.</p>
10034 <p><b>Proposed resolution:</b></p>
10035 <p>Remove the comment from the text in 22.2.3.2 and from the proposed
10036 resolution of library issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#228">228</a>.</p>
10038 <a name="319"><h3>319. Storage allocation wording confuses "Required behavior", "Requires"</h3></a><p><b>Section:</b> 18.5.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.single"> [lib.new.delete.single]</a>, 18.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.array"> [lib.new.delete.array]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 15 May 2001</p>
10039 <p>The standard specifies 17.3.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.structure.specifications"> [lib.structure.specifications]</a> that "Required
10040 behavior" elements describe "the semantics of a function definition
10041 provided by either the implementation or a C++ program."</p>
10043 <p>The standard specifies 17.3.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.structure.specifications"> [lib.structure.specifications]</a> that "Requires"
10044 elements describe "the preconditions for calling the function."</p>
10046 <p>In the sections noted below, the current wording specifies
10047 "Required Behavior" for what are actually preconditions, and thus
10048 should be specified as "Requires".</p>
10050 <p><b>Proposed resolution:</b></p>
10052 <p>In 18.5.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.single"> [lib.new.delete.single]</a> Para 12 Change:</p>
10054 <p>Required behavior: accept a value of ptr that is null or that was
10055 returned by an earlier call ...</p>
10059 <p>Requires: the value of ptr is null or the value returned by an
10060 earlier call ...</p>
10063 <p>In 18.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.array"> [lib.new.delete.array]</a> Para 11 Change:</p>
10065 <p>Required behavior: accept a value of ptr that is null or that was
10066 returned by an earlier call ...</p>
10070 <p>Requires: the value of ptr is null or the value returned by an
10071 earlier call ...</p>
10075 <a name="320"><h3>320. list::assign overspecified</h3></a><p><b>Section:</b> 23.2.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.deque.cons"> [lib.deque.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 17 May 2001</p>
10077 Section 23.2.2.1, paragraphs 6-8 specify that list assign (both forms) have
10078 the "effects" of a call to erase followed by a call to insert.
10082 I would like to document that implementers have the freedom to implement
10083 assign by other methods, as long as the end result is the same and the
10084 exception guarantee is as good or better than the basic guarantee.
10088 The motivation for this is to use T's assignment operator to recycle
10089 existing nodes in the list instead of erasing them and reallocating
10090 them with new values. It is also worth noting that, with careful
10091 coding, most common cases of assign (everything but assignment with
10092 true input iterators) can elevate the exception safety to strong if
10093 T's assignment has a nothrow guarantee (with no extra memory cost).
10094 Metrowerks does this. However I do not propose that this subtlety be
10095 standardized. It is a QoI issue. </p>
10097 <p>Existing practise:
10098 Metrowerks and SGI recycle nodes, Dinkumware and Rogue Wave don't.
10100 <p><b>Proposed resolution:</b></p>
10101 <p>Change 23.2.2.1/7 from:</p>
10106 <pre> erase(begin(), end());
10107 insert(begin(), first, last);
10114 <p>Effects: Replaces the contents of the list with the range [first, last).</p>
10117 <p>In 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a>, in Table 67 (sequence requirements),
10118 add two new rows:</p>
10119 <pre> a.assign(i,j) void pre: i,j are not iterators into a.
10120 Replaces elements in a with a copy
10123 a.assign(n,t) void pre: t is not a reference into a.
10124 Replaces elements in a with n copies
10128 <p>Change 23.2.2.1/8 from:</p>
10132 <pre> erase(begin(), end());
10133 insert(begin(), n, t);
10139 <p>Effects: Replaces the contents of the list with n copies of t.</p>
10142 <p><i>[Redmond: Proposed resolution was changed slightly. Previous
10143 version made explicit statement about exception safety, which wasn't
10144 consistent with the way exception safety is expressed elsewhere.
10145 Also, the change in the sequence requirements is new. Without that
10146 change, the proposed resolution would have required that assignment of
10147 a subrange would have to work. That too would have been
10148 overspecification; it would effectively mandate that assignment use a
10149 temporary. Howard provided wording.
10152 <p><i>[Curaçao: Made editorial improvement in wording; changed
10153 "Replaces elements in a with copies of elements in [i, j)."
10154 with "Replaces the elements of a with a copy of [i, j)."
10155 Changes not deemed serious enough to requre rereview.]</i></p>
10158 <a name="321"><h3>321. Typo in num_get</h3></a><p><b>Section:</b> 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Kevin Djang <b>Date:</b> 17 May 2001</p>
10160 Section 22.2.2.1.2 at p7 states that "A length specifier is added to
10161 the conversion function, if needed, as indicated in Table 56."
10162 However, Table 56 uses the term "length modifier", not "length
10165 <p><b>Proposed resolution:</b></p>
10167 In 22.2.2.1.2 at p7, change the text "A length specifier is added ..."
10168 to be "A length modifier is added ..."
10170 <p><b>Rationale:</b></p>
10171 <p>C uses the term "length modifier". We should be consistent.</p>
10173 <a name="322"><h3>322. iterator and const_iterator should have the same value type</h3></a><p><b>Section:</b> 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 17 May 2001</p>
10175 It's widely assumed that, if X is a container,
10176 iterator_traits<X::iterator>::value_type and
10177 iterator_traits<X::const_iterator>::value_type should both be
10178 X::value_type. However, this is nowhere stated. The language in
10179 Table 65 is not precise about the iterators' value types (it predates
10180 iterator_traits), and could even be interpreted as saying that
10181 iterator_traits<X::const_iterator>::value_type should be "const
10185 <p>Related issue: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#279">279</a>.</p>
10186 <p><b>Proposed resolution:</b></p>
10187 <p>In Table 65 ("Container Requirements"), change the return type for
10188 X::iterator to "iterator type whose value type is T". Change the
10189 return type for X::const_iterator to "constant iterator type whose
10190 value type is T".</p>
10191 <p><b>Rationale:</b></p>
10193 This belongs as a container requirement, rather than an iterator
10194 requirement, because the whole notion of iterator/const_iterator
10195 pairs is specific to containers' iterator.
10198 It is existing practice that (for example)
10199 iterator_traits<list<int>::const_iterator>::value_type
10200 is "int", rather than "const int". This is consistent with
10201 the way that const pointers are handled: the standard already
10202 requires that iterator_traits<const int*>::value_type is int.
10205 <a name="324"><h3>324. Do output iterators have value types?</h3></a><p><b>Section:</b> 24.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.output.iterators"> [lib.output.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 7 June 2001</p>
10207 <p>Table 73 suggests that output iterators have value types. It
10208 requires the expression "*a = t". Additionally, although Table 73
10209 never lists "a = t" or "X(a) = t" in the "expressions" column, it
10210 contains a note saying that "a = t" and "X(a) = t" have equivalent
10211 (but nowhere specified!) semantics.</p>
10213 <p>According to 24.1/9, t is supposed to be "a value of value type
10217 In the following sections, a and b denote values of X, n denotes a
10218 value of the difference type Distance, u, tmp, and m denote
10219 identifiers, r denotes a value of X&, t denotes a value of
10223 <p>Two other parts of the standard that are relevant to whether
10224 output iterators have value types:</p>
10227 <li>24.1/1 says "All iterators i support the expression *i,
10228 resulting in a value of some class, enumeration, or built-in type
10229 T, called the value type of the iterator".</li>
10232 24.3.1/1, which says "In the case of an output iterator, the types
10233 iterator_traits<Iterator>::difference_type
10234 iterator_traits<Iterator>::value_type are both defined as void."
10238 <p>The first of these passages suggests that "*i" is supposed to
10239 return a useful value, which contradicts the note in 24.1.2/2 saying
10240 that the only valid use of "*i" for output iterators is in an
10241 expression of the form "*i = t". The second of these passages appears
10242 to contradict Table 73, because it suggests that "*i"'s return value
10243 should be void. The second passage is also broken in the case of a an
10244 iterator type, like non-const pointers, that satisfies both the output
10245 iterator requirements and the forward iterator requirements.</p>
10247 <p>What should the standard say about <tt>*i</tt>'s return value when
10248 i is an output iterator, and what should it say about that t is in the
10249 expression "*i = t"? Finally, should the standard say anything about
10250 output iterators' pointer and reference types?</p>
10252 <p><b>Proposed resolution:</b></p>
10253 <p>24.1 p1, change</p>
10256 <p>All iterators <tt>i</tt> support the expression <tt>*i</tt>, resulting
10257 in a value of some class, enumeration, or built-in type <tt>T</tt>,
10258 called the value type of the iterator.</p>
10264 <p>All input iterators <tt>i</tt> support the expression <tt>*i</tt>,
10265 resulting in a value of some class, enumeration, or built-in type
10266 <tt>T</tt>, called the value type of the iterator. All output
10267 iterators support the expression <tt>*i = o</tt> where <tt>o</tt> is a
10268 value of some type that is in the set of types that are <i>writable</i> to
10269 the particular iterator type of <tt>i</tt>.
10273 <p>24.1 p9, add</p>
10276 <p><tt>o</tt> denotes a value of some type that is writable to the
10281 <p>Table 73, change</p>
10309 <p><i>[post-Redmond: Jeremy provided wording]</i></p>
10311 <p><b>Rationale:</b></p>
10312 <p>The LWG considered two options: change all of the language that
10313 seems to imply that output iterators have value types, thus making it
10314 clear that output iterators have no value types, or else define value
10315 types for output iterator consistently. The LWG chose the former
10316 option, because it seems clear that output iterators were never
10317 intended to have value types. This was a deliberate design decision,
10318 and any language suggesting otherwise is simply a mistake.</p>
10320 <p>A future revision of the standard may wish to revisit this design
10323 <a name="325"><h3>325. Misleading text in moneypunct<>::do_grouping</h3></a><p><b>Section:</b> 22.2.6.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.moneypunct.virtuals"> [lib.locale.moneypunct.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 02 Jul 2001</p>
10324 <p>The Returns clause in 22.2.6.3.2, p3 says about
10325 moneypunct<charT>::do_grouping()
10329 Returns: A pattern defined identically as the result of
10330 numpunct<charT>::do_grouping().241)
10333 <p>Footnote 241 then reads</p>
10336 This is most commonly the value "\003" (not "3").
10340 The returns clause seems to imply that the two member functions must
10341 return an identical value which in reality may or may not be true,
10342 since the facets are usually implemented in terms of struct std::lconv
10343 and return the value of the grouping and mon_grouping, respectively.
10344 The footnote also implies that the member function of the moneypunct
10345 facet (rather than the overridden virtual functions in moneypunct_byname)
10346 most commonly return "\003", which contradicts the C standard which
10347 specifies the value of "" for the (most common) C locale.
10350 <p><b>Proposed resolution:</b></p>
10351 <p>Replace the text in Returns clause in 22.2.6.3.2, p3 with the following:</p>
10354 Returns: A pattern defined identically as, but not necessarily
10355 equal to, the result of numpunct<charT>::do_grouping().241)
10358 <p>and replace the text in Footnote 241 with the following:</p>
10361 To specify grouping by 3s the value is "\003", not "3".
10363 <p><b>Rationale:</b></p>
10365 The fundamental problem is that the description of the locale facet
10366 virtuals serves two purposes: describing the behavior of the base
10367 class, and describing the meaning of and constraints on the behavior
10368 in arbitrary derived classes. The new wording makes that separation a
10369 little bit clearer. The footnote (which is nonnormative) is not
10370 supposed to say what the grouping is in the "C" locale or in any other
10371 locale. It is just a reminder that the values are interpreted as small
10372 integers, not ASCII characters.
10375 <a name="327"><h3>327. Typo in time_get facet in table 52</h3></a><p><b>Section:</b> 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Tiki Wan <b>Date:</b> 06 Jul 2001</p>
10376 <p>The <tt>wchar_t</tt> versions of <tt>time_get</tt> and
10377 <tt>time_get_byname</tt> are listed incorrectly in table 52,
10378 required instantiations. In both cases the second template
10379 parameter is given as OutputIterator. It should instead be
10380 InputIterator, since these are input facets.</p>
10381 <p><b>Proposed resolution:</b></p>
10383 In table 52, required instantiations, in
10384 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a>, change</p>
10385 <pre> time_get<wchar_t, OutputIterator>
10386 time_get_byname<wchar_t, OutputIterator>
10389 <pre> time_get<wchar_t, InputIterator>
10390 time_get_byname<wchar_t, InputIterator>
10393 <p><i>[Redmond: Very minor change in proposed resolution. Original had
10394 a typo, wchart instead of wchar_t.]</i></p>
10397 <a name="328"><h3>328. Bad sprintf format modifier in money_put<>::do_put()</h3></a><p><b>Section:</b> 22.2.6.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.money.put.virtuals"> [lib.locale.money.put.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 07 Jul 2001</p>
10398 <p>The sprintf format string , "%.01f" (that's the digit one), in the
10399 description of the do_put() member functions of the money_put facet in
10400 22.2.6.2.2, p1 is incorrect. First, the f format specifier is wrong
10401 for values of type long double, and second, the precision of 01
10402 doesn't seem to make sense. What was most likely intended was
10403 "%.0Lf"., that is a precision of zero followed by the L length
10405 <p><b>Proposed resolution:</b></p>
10406 <p>Change the format string to "%.0Lf".</p>
10407 <p><b>Rationale:</b></p>
10408 <p>Fixes an obvious typo</p>
10410 <a name="329"><h3>329. vector capacity, reserve and reallocation</h3></a><p><b>Section:</b> 23.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.priority.queue"> [lib.priority.queue]</a>, 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Anthony Williams <b>Date:</b> 13 Jul 2001</p>
10412 There is an apparent contradiction about which circumstances can cause
10413 a reallocation of a vector in Section 23.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.priority.queue"> [lib.priority.queue]</a> and
10414 section 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a>.
10417 <p>23.2.4.2p5 says:</p>
10419 Notes: Reallocation invalidates all the references, pointers, and iterators
10420 referring to the elements in the sequence. It is guaranteed that no
10421 reallocation takes place during insertions that happen after a call to
10422 reserve() until the time when an insertion would make the size of the vector
10423 greater than the size specified in the most recent call to reserve().
10426 <p>Which implies if I do</p>
10428 <pre> std::vector<int> vec;
10431 vec.insert(vec.end(),1);
10434 <p>then the implementation may reallocate the vector for the insert,
10435 as the size specified in the previous call to reserve was zero.</p>
10437 <p>However, the previous paragraphs (23.2.4.2, p1-2) state:</p>
10440 (capacity) Returns: The total number of elements the vector
10441 can hold without requiring reallocation
10444 ...After reserve(), capacity() is greater or equal to the
10445 argument of reserve if reallocation happens; and equal to the previous value
10446 of capacity() otherwise...
10451 This implies that vec.capacity() is still 23, and so the insert()
10452 should not require a reallocation, as vec.size() is 0. This is backed
10456 (insert) Notes: Causes reallocation if the new size is greater than the old
10461 Though this doesn't rule out reallocation if the new size is less
10462 than the old capacity, I think the intent is clear.
10465 <p><b>Proposed resolution:</b></p>
10466 <p>Change the wording of 23.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.priority.queue"> [lib.priority.queue]</a> paragraph 5 to:</p>
10469 Notes: Reallocation invalidates all the references, pointers, and
10470 iterators referring to the elements in the sequence. It is guaranteed
10471 that no reallocation takes place during insertions that happen after a
10472 call to reserve() until the time when an insertion would make the size
10473 of the vector greater than the value of capacity().
10476 <p><i>[Redmond: original proposed resolution was modified slightly. In
10477 the original, the guarantee was that there would be no reallocation
10478 until the size would be greater than the value of capacity() after the
10479 most recent call to reserve(). The LWG did not believe that the
10480 "after the most recent call to reserve()" added any useful
10481 information.]</i></p>
10483 <p><b>Rationale:</b></p>
10484 <p>There was general agreement that, when reserve() is called twice in
10485 succession and the argument to the second invocation is smaller than
10486 the argument to the first, the intent was for the second invocation to
10487 have no effect. Wording implying that such cases have an effect on
10488 reallocation guarantees was inadvertant.</p>
10490 <a name="331"><h3>331. bad declaration of destructor for ios_base::failure</h3></a><p><b>Section:</b> 27.4.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios::failure"> [lib.ios::failure]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> PremAnand M. Rao <b>Date:</b> 23 Aug 2001</p>
10492 With the change in 17.4.4.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.res.on.exception.handling"> [lib.res.on.exception.handling]</a> to state
10493 "An implementation may strengthen the exception-specification for a
10494 non-virtual function by removing listed exceptions."
10495 (issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#119">119</a>)
10496 and the following declaration of ~failure() in ios_base::failure
10498 <pre> namespace std {
10499 class ios_base::failure : public exception {
10502 virtual ~failure();
10507 <p>the class failure cannot be implemented since in 18.6.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.type.info"> [lib.type.info]</a> the destructor of class exception has an empty
10508 exception specification:</p>
10509 <pre> namespace std {
10513 virtual ~exception() throw();
10518 <p><b>Proposed resolution:</b></p>
10519 <p>Remove the declaration of ~failure().</p>
10520 <p><b>Rationale:</b></p>
10521 <p>The proposed resolution is consistent with the way that destructors
10522 of other classes derived from <tt>exception</tt> are handled.</p>
10524 <a name="333"><h3>333. does endl imply synchronization with the device?</h3></a><p><b>Section:</b> 27.6.2.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.manip"> [lib.ostream.manip]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> PremAnand M. Rao <b>Date:</b> 27 Aug 2001</p>
10525 <p>A footnote in 27.6.2.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.manip"> [lib.ostream.manip]</a> states:</p>
10527 [Footnote: The effect of executing cout << endl is to insert a
10528 newline character in the output sequence controlled by cout, then
10529 synchronize it with any external file with which it might be
10530 associated. --- end foonote]
10534 Does the term "file" here refer to the external device?
10535 This leads to some implementation ambiguity on systems with fully
10536 buffered files where a newline does not cause a flush to the device.
10540 Choosing to sync with the device leads to significant performance
10541 penalties for each call to endl, while not sync-ing leads to
10542 errors under special circumstances.
10546 I could not find any other statement that explicitly defined
10547 the behavior one way or the other.
10549 <p><b>Proposed resolution:</b></p>
10550 <p>Remove footnote 300 from section 27.6.2.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.manip"> [lib.ostream.manip]</a>.</p>
10551 <p><b>Rationale:</b></p>
10552 <p>We already have normative text saying what <tt>endl</tt> does: it
10553 inserts a newline character and calls <tt>flush</tt>. This footnote
10554 is at best redundant, at worst (as this issue says) misleading,
10555 because it appears to make promises about what <tt>flush</tt>
10558 <a name="334"><h3>334. map::operator[] specification forces inefficient implementation</h3></a><p><b>Section:</b> 23.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map.access"> [lib.map.access]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andrea Griffini <b>Date:</b> 02 Sep 2001</p>
10560 The current standard describes map::operator[] using a
10561 code example. That code example is however quite
10562 inefficient because it requires several useless copies
10563 of both the passed key_type value and of default
10564 constructed mapped_type instances.
10565 My opinion is that was not meant by the comitee to
10566 require all those temporary copies.
10569 <p>Currently map::operator[] behaviour is specified as: </p>
10571 (*((insert(make_pair(x, T()))).first)).second.
10575 This specification however uses make_pair that is a
10576 template function of which parameters in this case
10577 will be deduced being of type const key_type& and
10578 const T&. This will create a pair<key_type,T> that
10579 isn't the correct type expected by map::insert so
10580 another copy will be required using the template
10581 conversion constructor available in pair to build
10582 the required pair<const key_type,T> instance.
10585 <p>If we consider calling of key_type copy constructor
10586 and mapped_type default constructor and copy
10587 constructor as observable behaviour (as I think we
10588 should) then the standard is in this place requiring
10589 two copies of a key_type element plus a default
10590 construction and two copy construction of a mapped_type
10591 (supposing the addressed element is already present
10592 in the map; otherwise at least another copy
10593 construction for each type).
10596 <p>A simple (half) solution would be replacing the description with:</p>
10598 (*((insert(value_type(x, T()))).first)).second.
10601 <p>This will remove the wrong typed pair construction that
10602 requires one extra copy of both key and value.</p>
10604 <p>However still the using of map::insert requires temporary
10605 objects while the operation, from a logical point of view,
10606 doesn't require any. </p>
10608 <p>I think that a better solution would be leaving free an
10609 implementer to use a different approach than map::insert
10610 that, because of its interface, forces default constructed
10611 temporaries and copies in this case.
10612 The best solution in my opinion would be just requiring
10613 map::operator[] to return a reference to the mapped_type
10614 part of the contained element creating a default element
10615 with the specified key if no such an element is already
10616 present in the container. Also a logarithmic complexity
10617 requirement should be specified for the operation.
10621 This would allow library implementers to write alternative
10622 implementations not using map::insert and reaching optimal
10623 performance in both cases of the addressed element being
10624 present or absent from the map (no temporaries at all and
10625 just the creation of a new pair inside the container if
10626 the element isn't present).
10627 Some implementer has already taken this option but I think
10628 that the current wording of the standard rules that as
10632 <p><b>Proposed resolution:</b></p>
10635 Replace 23.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map.access"> [lib.map.access]</a> paragraph 1 with
10639 -1- Effects: If there is no key equivalent to x in the map, inserts
10640 value_type(x, T()) into the map.
10643 -2- Returns: A reference to the mapped_type corresponding to x in *this.
10646 -3- Complexity: logarithmic.
10650 <p><i>[This is the second option mentioned above. Howard provided
10651 wording. We may also wish to have a blanket statement somewhere in
10652 clause 17 saying that we do not intend the semantics of sample code
10653 fragments to be interpreted as specifing exactly how many copies are
10654 made. See issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#98">98</a> for a similar problem.]</i></p>
10656 <p><b>Rationale:</b></p>
10658 This is the second solution described above; as noted, it is
10659 consistent with existing practice.
10662 <p>Note that we now need to specify the complexity explicitly, because
10663 we are no longer defining <tt>operator[]</tt> in terms of
10664 <tt>insert</tt>.</p>
10666 <a name="335"><h3>335. minor issue with char_traits, table 37</h3></a><p><b>Section:</b> 21.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.require"> [lib.char.traits.require]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andy Sawyer <b>Date:</b> 06 Sep 2001</p>
10668 Table 37, in 21.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.require"> [lib.char.traits.require]</a>, descibes char_traits::assign
10671 <pre> X::assign(c,d) assigns c = d.
10674 <p>And para 1 says:</p>
10677 [...] c and d denote values of type CharT [...]
10681 Naturally, if c and d are <i>values</i>, then the assignment is
10682 (effectively) meaningless. It's clearly intended that (in the case of
10683 assign, at least), 'c' is intended to be a reference type.
10686 <p>I did a quick survey of the four implementations I happened to have
10687 lying around, and sure enough they all have signatures:</p>
10688 <pre> assign( charT&, const charT& );
10691 <p>(or the equivalent). It's also described this way in Nico's book.
10692 (Not to mention the synopses of char_traits<char> in 21.1.3.1
10693 and char_traits<wchar_t> in 21.1.3.2...)
10695 <p><b>Proposed resolution:</b></p>
10696 <p>Add the following to 21.1.1 para 1:</p>
10698 r denotes an lvalue of CharT
10701 <p>and change the description of assign in the table to:</p>
10702 <pre> X::assign(r,d) assigns r = d
10705 <a name="336"><h3>336. Clause 17 lack of references to deprecated headers</h3></a><p><b>Section:</b> 17 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.library"> [lib.library]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Detlef Vollmann <b>Date:</b> 05 Sep 2001</p>
10706 <p>From c++std-edit-873:</p>
10708 <p>17.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.headers"> [lib.headers]</a>, Table 11. In this table, the header
10709 <strstream> is missing.</p>
10711 <p>This shows a general problem: The whole clause 17 refers quite
10712 often to clauses 18 through 27, but D.7 is also a part of the standard
10713 library (though a deprecated one).</p>
10715 <p><b>Proposed resolution:</b></p>
10717 <p>To 17.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.headers"> [lib.headers]</a> Table 11, C++ Library Headers, add
10718 "<strstream>".</p>
10720 <p>In the following places, change "clauses 17 through 27" to "clauses
10721 17 through 27 and Annex D":</p>
10724 <li>1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/intro.html#intro.refs"> [intro.refs]</a> Normative references/1/footnote 1</li>
10725 <li>1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/intro.html#intro.defs"> [intro.defs]</a> Definitions/1</li>
10726 <li>7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/dcl.html#dcl.dcl"> [dcl.dcl]</a> Library introduction/9</li>
10727 <li>17.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.description"> [lib.description]</a> Method of description (Informative)/1</li>
10728 <li>17.3.2.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.character.seq"> [lib.character.seq]</a> Character sequences/1/bullet 2</li>
10729 <li>17.3.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.functions.within.classes"> [lib.functions.within.classes]</a> Functions within classes/1</li>
10730 <li>17.3.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.objects.within.classes"> [lib.objects.within.classes]</a> Private members/1/(2 places)</li>
10731 <li>17.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.requirements"> [lib.requirements]</a> Library-wide requirements/1</li>
10732 <li>17.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.headers"> [lib.headers]</a> Headers/4</li>
10733 <li>17.4.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.replacement.functions"> [lib.replacement.functions]</a> Replacement functions/1</li>
10734 <li>17.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.global.functions"> [lib.global.functions]</a> Global or non-member functions/2</li>
10735 <li>17.4.4.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.protection.within.classes"> [lib.protection.within.classes]</a> Protection within classes/1</li>
10740 <a name="337"><h3>337. replace_copy_if's template parameter should be InputIterator</h3></a><p><b>Section:</b> 25.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.replace"> [lib.alg.replace]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Detlef Vollmann <b>Date:</b> 07 Sep 2001</p>
10741 <p>From c++std-edit-876:</p>
10744 In section 25.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.replace"> [lib.alg.replace]</a> before p4: The name of the first
10745 parameter of template replace_copy_if should be "InputIterator"
10746 instead of "Iterator". According to 17.3.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.type.descriptions"> [lib.type.descriptions]</a> p1 the
10747 parameter name conveys real normative meaning.
10749 <p><b>Proposed resolution:</b></p>
10750 <p>Change <tt>Iterator</tt> to <tt>InputIterator</tt>.</p>
10752 <a name="338"><h3>338. is whitespace allowed between `-' and a digit?</h3></a><p><b>Section:</b> 22.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.categories"> [lib.locale.categories]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 17 Sep 2001</p>
10754 From Stage 2 processing in 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a>, p8 and 9 (the
10755 original text or the text corrected by the proposed resolution of
10756 issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#221">221</a>) it seems clear that no whitespace is allowed
10757 within a number, but 22.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.numpunct"> [lib.locale.numpunct]</a>, p2, which gives the
10758 format for integer and floating point values, says that whitespace is
10759 optional between a plusminus and a sign.
10763 The text needs to be clarified to either consistently allow or
10764 disallow whitespace between a plusminus and a sign. It might be
10765 worthwhile to consider the fact that the C library stdio facility does
10766 not permit whitespace embedded in numbers and neither does the C or
10767 C++ core language (the syntax of integer-literals is given in 2.13.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lex.html#lex.icon"> [lex.icon]</a>, that of floating-point-literals in 2.13.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lex.html#lex.fcon"> [lex.fcon]</a> of the C++ standard).
10769 <p><b>Proposed resolution:</b></p>
10770 <p>Change the first part of 22.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.numpunct"> [lib.locale.numpunct]</a> paragraph 2 from:</p>
10773 The syntax for number formats is as follows, where <tt>digit</tt>
10774 represents the radix set specified by the <tt>fmtflags</tt> argument
10775 value, <tt>whitespace</tt> is as determined by the facet
10776 <tt>ctype<charT></tt> (22.2.1.1), and <tt>thousands-sep</tt> and
10777 <tt>decimal-point</tt> are the results of corresponding
10778 <tt>numpunct<charT></tt> members. Integer values have the
10781 <pre> integer ::= [sign] units
10782 sign ::= plusminus [whitespace]
10783 plusminus ::= '+' | '-'
10784 units ::= digits [thousands-sep units]
10785 digits ::= digit [digits]
10791 The syntax for number formats is as follows, where <tt>digit</tt>
10792 represents the radix set specified by the <tt>fmtflags</tt> argument
10793 value, and <tt>thousands-sep</tt> and <tt>decimal-point</tt> are the
10794 results of corresponding <tt>numpunct<charT></tt> members.
10795 Integer values have the format:
10797 <pre> integer ::= [sign] units
10799 plusminus ::= '+' | '-'
10800 units ::= digits [thousands-sep units]
10801 digits ::= digit [digits]
10804 <p><b>Rationale:</b></p>
10805 <p>It's not clear whether the format described in 22.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.numpunct"> [lib.locale.numpunct]</a> paragraph 2 has any normative weight: nothing in the
10806 standard says how, or whether, it's used. However, there's no reason
10807 for it to differ gratuitously from the very specific description of
10808 numeric processing in 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a>. The proposed
10809 resolution removes all mention of "whitespace" from that format.</p>
10811 <a name="339"><h3>339. definition of bitmask type restricted to clause 27</h3></a><p><b>Section:</b> 22.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.category.ctype"> [lib.category.ctype]</a>, 17.3.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.bitmask.types"> [lib.bitmask.types]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 17 September 2001</p>
10813 The ctype_category::mask type is declared to be an enum in 22.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.category.ctype"> [lib.category.ctype]</a> with p1 then stating that it is a bitmask type, most
10814 likely referring to the definition of bitmask type in 17.3.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.bitmask.types"> [lib.bitmask.types]</a>, p1. However, the said definition only applies to
10815 clause 27, making the reference in 22.2.1 somewhat dubious.
10817 <p><b>Proposed resolution:</b></p>
10818 <p>Clarify 17.3.2.1.2, p1 by changing the current text from</p>
10820 Several types defined in clause 27 are bitmask types. Each bitmask type
10821 can be implemented as an enumerated type that overloads certain operators,
10822 as an integer type, or as a bitset (23.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.template.bitset"> [lib.template.bitset]</a>).
10826 Several types defined in clauses lib.language.support through
10827 lib.input.output and Annex D are bitmask types. Each bitmask type can
10828 be implemented as an enumerated type that overloads certain operators,
10829 as an integer type, or as a bitset (lib.template.bitset).
10833 Additionally, change the definition in 22.2.1 to adopt the same
10834 convention as in clause 27 by replacing the existing text with the
10835 following (note, in particluar, the cross-reference to 17.3.2.1.2 in
10840 <p>22.2.1 The ctype category [lib.category.ctype]</p>
10841 <pre>namespace std {
10844 typedef <b><i>T</i></b> mask;
10846 // numeric values are for exposition only.
10847 static const mask space = 1 << 0;
10848 static const mask print = 1 << 1;
10849 static const mask cntrl = 1 << 2;
10850 static const mask upper = 1 << 3;
10851 static const mask lower = 1 << 4;
10852 static const mask alpha = 1 << 5;
10853 static const mask digit = 1 << 6;
10854 static const mask punct = 1 << 7;
10855 static const mask xdigit = 1 << 8;
10856 static const mask alnum = alpha | digit;
10857 static const mask graph = alnum | punct;
10862 <p>The type <tt>mask</tt> is a bitmask type (17.3.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.bitmask.types"> [lib.bitmask.types]</a>).</p>
10865 <p><i>[Curaçao: The LWG notes that T above should be bold-italics to be
10866 consistent with the rest of the standard.]</i></p>
10869 <a name="340"><h3>340. interpretation of <tt>has_facet<Facet>(loc)</tt>
10870 </h3></a><p><b>Section:</b> 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 18 Sep 2001</p>
10872 It's unclear whether 22.1.1.1.1, p3 says that
10873 <tt>has_facet<Facet>(loc)</tt> returns true for any <tt>Facet</tt>
10874 from Table 51 or whether it includes Table 52 as well:
10878 For any locale <tt>loc</tt> either constructed, or returned by
10879 locale::classic(), and any facet <tt>Facet</tt> that is a member of a
10880 standard category, <tt>has_facet<Facet>(loc)</tt> is true. Each
10881 locale member function which takes a <tt>locale::category</tt>
10882 argument operates on the corresponding set of facets.
10886 It seems that it comes down to which facets are considered to be members of a
10887 standard category. Intuitively, I would classify all the facets in Table 52 as
10888 members of their respective standard categories, but there are an unbounded set
10893 The paragraph implies that, for instance, <tt>has_facet<num_put<C,
10894 OutputIterator> >(loc)</tt> must always return true. I don't think that's
10895 possible. If it were, then <tt>use_facet<num_put<C, OutputIterator>
10896 >(loc)</tt> would have to return a reference to a distinct object for each
10897 valid specialization of <tt>num_put<C, OutputIteratory></tt>, which is
10898 clearly impossible.
10902 On the other hand, if none of the facets in Table 52 is a member of a standard
10903 category then none of the locale member functions that operate on entire
10904 categories of facets will work properly.
10908 It seems that what p3 should mention that it's required (permitted?)
10909 to hold only for specializations of <tt>Facet</tt> from Table 52 on
10910 <tt>C</tt> from the set { <tt>char</tt>, <tt>wchar_t</tt> }, and
10911 <tt>InputIterator</tt> and <tt>OutputIterator</tt> from the set of
10913 {i,o}<tt>streambuf_iterator</tt><{<tt>char</tt>,<tt>wchar_t</tt>}<tt>></tt>
10916 <p><b>Proposed resolution:</b></p>
10917 <p>In 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a>, paragraph 3, change
10918 "that is a member of a standard category" to "shown in Table 51".</p>
10919 <p><b>Rationale:</b></p>
10920 <p>The facets in Table 52 are an unbounded set. Locales should not be
10921 required to contain an infinite number of facets.</p>
10923 <p>It's not necessary to talk about which values of InputIterator and
10924 OutputIterator must be supported. Table 51 already contains a
10925 complete list of the ones we need.</p>
10927 <a name="341"><h3>341. Vector reallocation and swap</h3></a><p><b>Section:</b> 23.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.priority.queue"> [lib.priority.queue]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Anthony Williams <b>Date:</b> 27 Sep 2001</p>
10928 <p>It is a common idiom to reduce the capacity of a vector by swapping it with
10930 <pre> std::vector<SomeType> vec;
10931 // fill vec with data
10932 std::vector<SomeType>().swap(vec);
10933 // vec is now empty, with minimal capacity
10936 <p>However, the wording of 23.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.priority.queue"> [lib.priority.queue]</a>paragraph 5 prevents
10937 the capacity of a vector being reduced, following a call to
10938 reserve(). This invalidates the idiom, as swap() is thus prevented
10939 from reducing the capacity. The proposed wording for issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#329">329</a> does not affect this. Consequently, the example above
10940 requires the temporary to be expanded to cater for the contents of
10941 vec, and the contents be copied across. This is a linear-time
10944 <p>However, the container requirements state that swap must have constant
10945 complexity (23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> note to table 65).</p>
10947 <p>This is an important issue, as reallocation affects the validity of
10948 references and iterators.</p>
10950 <p>If the wording of 23.2.4.2p5 is taken to be the desired intent, then
10951 references and iterators remain valid after a call to swap, if they refer to
10952 an element before the new end() of the vector into which they originally
10953 pointed, in which case they refer to the element at the same index position.
10954 Iterators and references that referred to an element whose index position
10955 was beyond the new end of the vector are invalidated.</p>
10957 <p>If the note to table 65 is taken as the desired intent, then there are two
10958 possibilities with regard to iterators and references:</p>
10961 <li>All Iterators and references into both vectors are invalidated.</li>
10962 <li>Iterators and references into either vector remain valid, and remain
10963 pointing to the same element. Consequently iterators and references that
10964 referred to one vector now refer to the other, and vice-versa.</li>
10966 <p><b>Proposed resolution:</b></p>
10967 <p>Add a new paragraph after 23.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.priority.queue"> [lib.priority.queue]</a> paragraph 5:</p>
10969 <pre> void swap(vector<T,Allocator>& x);
10971 <p><b>Effects:</b> Exchanges the contents and capacity() of <tt>*this</tt>
10972 with that of <tt>x</tt>.</p>
10973 <p><b>Complexity:</b> Constant time.</p>
10976 <p><i>[This solves the problem reported for this issue. We may also
10977 have a problem with a circular definition of swap() for other
10978 containers.]</i></p>
10980 <p><b>Rationale:</b></p>
10982 swap should be constant time. The clear intent is that it should just
10983 do pointer twiddling, and that it should exchange all properties of
10984 the two vectors, including their reallocation guarantees.
10987 <a name="345"><h3>345. type tm in <cwchar></h3></a><p><b>Section:</b> 21.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.c.strings"> [lib.c.strings]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Clark Nelson <b>Date:</b> 19 Oct 2001</p>
10989 C99, and presumably amendment 1 to C90, specify that <wchar.h>
10990 declares struct tm as an incomplete type. However, table 48 in 21.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.c.strings"> [lib.c.strings]</a> does not mention the type tm as being declared in
10991 <cwchar>. Is this omission intentional or accidental?
10993 <p><b>Proposed resolution:</b></p>
10994 <p>In section 21.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.c.strings"> [lib.c.strings]</a>, add "tm" to table 48.</p>
10996 <a name="346"></a><h3><a name="346">346. Some iterator member functions should be const</a></h3><p><b>Section:</b> 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Jeremy Siek <b>Date:</b> 20 Oct 2001</p>
10997 <p>Iterator member functions and operators that do not change the state
10998 of the iterator should be defined as const member functions or as
10999 functions that take iterators either by const reference or by
11000 value. The standard does not explicitly state which functions should
11001 be const. Since this a fairly common mistake, the following changes
11002 are suggested to make this explicit.</p>
11004 <p>The tables almost indicate constness properly through naming: r
11005 for non-const and a,b for const iterators. The following changes
11006 make this more explicit and also fix a couple problems.</p>
11007 <p><b>Proposed resolution:</b></p>
11008 <p>In 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a> Change the first section of p9 from
11009 "In the following sections, a and b denote values of X..." to
11010 "In the following sections, a and b denote values of type const X...".</p>
11012 <p>In Table 73, change</p>
11013 <pre> a->m U& ...
11018 <pre> a->m const U& ...
11022 <p>In Table 73 expression column, change</p>
11032 <p><i>[Redmond: The container requirements should be reviewed to see if
11033 the same problem appears there.]</i></p>
11036 <a name="347"><h3>347. locale::category and bitmask requirements</h3></a><p><b>Section:</b> 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> P.J. Plauger, Nathan Myers <b>Date:</b> 23 Oct 2001</p>
11038 In 22.1.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.category"> [lib.locale.category]</a> paragraph 1, the category members
11039 are described as bitmask elements. In fact, the bitmask requirements
11040 in 17.3.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.bitmask.types"> [lib.bitmask.types]</a> don't seem quite right: <tt>none</tt>
11041 and <tt>all</tt> are bitmask constants, not bitmask elements.</p>
11043 <p>In particular, the requirements for <tt>none</tt> interact poorly
11044 with the requirement that the LC_* constants from the C library must
11045 be recognizable as C++ locale category constants. LC_* values should
11046 not be mixed with these values to make category values.</p>
11048 <p>We have two options for the proposed resolution. Informally:
11049 option 1 removes the requirement that LC_* values be recognized as
11050 category arguments. Option 2 changes the category type so that this
11051 requirement is implementable, by allowing <tt>none</tt> to be some
11052 value such as 0x1000 instead of 0.</p>
11054 <p>Nathan writes: "I believe my proposed resolution [Option 2] merely
11055 re-expresses the status quo more clearly, without introducing any
11056 changes beyond resolving the DR.</p>
11058 <p><b>Proposed resolution:</b></p>
11059 <p>Replace the first two paragraphs of 22.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.types"> [lib.locale.types]</a> with:</p>
11061 <pre> typedef int category;
11064 <p>Valid category values include the <tt>locale</tt> member bitmask
11065 elements <tt>collate</tt>, <tt>ctype</tt>, <tt>monetary</tt>,
11066 <tt>numeric</tt>, <tt>time</tt>, and <tt>messages</tt>, each of which
11067 represents a single locale category. In addition, <tt>locale</tt> member
11068 bitmask constant <tt>none</tt> is defined as zero and represents no
11069 category. And locale member bitmask constant <tt>all</tt> is defined such that
11071 <pre> (collate | ctype | monetary | numeric | time | messages | all) == all
11074 is <tt>true</tt>, and represents the union of all categories. Further
11075 the expression <tt>(X | Y)</tt>, where <tt>X</tt> and <tt>Y</tt> each
11076 represent a single category, represents the union of the two
11081 <tt>locale</tt> member functions expecting a <tt>category</tt>
11082 argument require one of the <tt>category</tt> values defined above, or
11083 the union of two or more such values. Such a <tt>category</tt>
11084 argument identifies a set of locale categories. Each locale category,
11085 in turn, identifies a set of locale facets, including at least those
11089 <p><i>[Curaçao: need input from locale experts.]</i></p>
11091 <p><b>Rationale:</b></p>
11093 <p>The LWG considered, and rejected, an alternate proposal (described
11094 as "Option 2" in the discussion). The main reason for rejecting it
11095 was that library implementors were concerened about implementation
11096 difficult, given that getting a C++ library to work smoothly with a
11097 separately written C library is already a delicate business. Some
11098 library implementers were also concerned about the issue of adding
11099 extra locale categories.</p>
11102 <p><b>Option 2:</b> <br>
11103 Replace the first paragraph of 22.1.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.types"> [lib.locale.types]</a> with:</p>
11106 Valid category values include the enumerated values. In addition, the
11107 result of applying commutative operators | and & to any two valid
11108 values is valid, and results in the setwise union and intersection,
11109 respectively, of the argument categories. The values <tt>all</tt> and
11110 <tt>none</tt> are defined such that for any valid value <tt>cat</tt>, the
11111 expressions <tt>(cat | all == all)</tt>, <tt>(cat & all == cat)</tt>,
11112 <tt>(cat | none == cat)</tt> and <tt>(cat & none == none)</tt> are
11113 true. For non-equal values <tt>cat1</tt> and <tt>cat2</tt> of the
11114 remaining enumerated values, <tt>(cat1 & cat2 == none)</tt> is true.
11115 For any valid categories <tt>cat1</tt> and <tt>cat2</tt>, the result
11116 of <tt>(cat1 & ~cat2)</tt> is valid, and equals the setwise union of
11117 those categories found in <tt>cat1</tt> but not found in <tt>cat2</tt>.
11118 [Footnote: it is not required that <tt>all</tt> equal the setwise union
11119 of the other enumerated values; implementations may add extra categories.]
11124 <a name="349"><h3>349. Minor typographical error in ostream_iterator</h3></a><p><b>Section:</b> 24.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.ostream.iterator"> [lib.ostream.iterator]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andy Sawyer <b>Date:</b> 24 Oct 2001</p>
11125 <p>24.5.2 [lib.ostream.iterator] states:</p>
11129 // basic_ostream<charT,traits>* out_stream; exposition only
11130 // const char* delim; exposition only
11133 <p>Whilst it's clearly marked "exposition only", I suspect 'delim'
11134 should be of type 'const charT*'.</p>
11135 <p><b>Proposed resolution:</b></p>
11137 In 24.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.ostream.iterator"> [lib.ostream.iterator]</a>, replace <tt>const char* delim</tt> with
11138 <tt>const charT* delim</tt>.
11141 <a name="352"><h3>352. missing fpos requirements</h3></a><p><b>Section:</b> 21.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.typedefs"> [lib.char.traits.typedefs]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 2 Dec 2001</p>
11144 There are no requirements on the <tt>stateT</tt> template parameter of
11145 <tt>fpos</tt> listed in 27.4.3. The interface appears to require that
11146 the type be at least Assignable and CopyConstructible (27.4.3.1, p1),
11147 and I think also DefaultConstructible (to implement the operations in
11151 21.1.2, p3, however, only requires that
11152 <tt>char_traits<charT>::state_type</tt> meet the requirements of
11153 CopyConstructible types.
11157 Additionally, the <tt>stateT</tt> template argument has no
11158 corresponding typedef in fpos which might make it difficult to use in
11161 <p><b>Proposed resolution:</b></p>
11163 Modify 21.1.2, p4 from
11166 Requires: <tt>state_type</tt> shall meet the requirements of
11167 CopyConstructible types (20.1.3).
11170 Requires: state_type shall meet the requirements of Assignable
11171 (23.1, p4), CopyConstructible (20.1.3), and
11172 DefaultConstructible (20.1.4) types.
11175 <p><b>Rationale:</b></p>
11176 <p>The LWG feels this is two issues, as indicated above. The first is
11177 a defect---std::basic_fstream is unimplementable without these
11178 additional requirements---and the proposed resolution fixes it. The
11179 second is questionable; who would use that typedef? The class
11180 template fpos is used only in a very few places, all of which know the
11181 state type already. Unless motivation is provided, the second should
11182 be considered NAD.</p>
11184 <a name="354"><h3>354. Associative container lower/upper bound requirements</h3></a><p><b>Section:</b> 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Hans Aberg <b>Date:</b> 17 Dec 2001</p>
11186 Discussions in the thread "Associative container lower/upper bound
11187 requirements" on comp.std.c++ suggests that there is a defect in the
11188 C++ standard, Table 69 of section 23.1.2, "Associative containers",
11189 [lib.associative.reqmts]. It currently says:</p>
11193 a.find(k): returns an iterator pointing to an element with the key equivalent to
11194 k, or a.end() if such an element is not found.
11198 a.lower_bound(k): returns an iterator pointing to the first element with
11199 key not less than k.
11203 a.upper_bound(k): returns an iterator pointing to the first element with
11204 key greater than k.
11209 We have "or a.end() if such an element is not found" for
11210 <tt>find</tt>, but not for <tt>upper_bound</tt> or
11211 <tt>lower_bound</tt>. As the text stands, one would be forced to
11212 insert a new element into the container and return an iterator to that
11213 in case the sought iterator does not exist, which does not seem to be
11214 the intention (and not possible with the "const" versions).
11216 <p><b>Proposed resolution:</b></p>
11218 <p>Change Table 69 of section 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> indicated entries
11223 a.lower_bound(k): returns an iterator pointing to the first element with
11224 key not less than k, or a.end() if such an element is not found.
11228 a.upper_bound(k): returns an iterator pointing to the first element with
11229 key greater than k, or a.end() if such an element is not found.
11233 <p><i>[Curaçao: LWG reviewed PR.]</i></p>
11236 <a name="355"><h3>355. Operational semantics for a.back()</h3></a><p><b>Section:</b> 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Yaroslav Mironov <b>Date:</b> 23 Jan 2002</p>
11238 <p>Table 68 "Optional Sequence Operations" in 23.1.1/12
11239 specifies operational semantics for "a.back()" as
11240 "*--a.end()", which may be ill-formed <i>[because calling
11241 operator-- on a temporary (the return) of a built-in type is
11242 ill-formed]</i>, provided a.end() returns a simple pointer rvalue
11243 (this is almost always the case for std::vector::end(), for
11244 example). Thus, the specification is not only incorrect, it
11245 demonstrates a dangerous construct: "--a.end()" may
11246 successfully compile and run as intended, but after changing the type
11247 of the container or the mode of compilation it may produce
11248 compile-time error. </p>
11250 <p><b>Proposed resolution:</b></p>
11251 <p>Change the specification in table 68 "Optional Sequence
11252 Operations" in 23.1.1/12 for "a.back()" from</p>
11262 { iterator tmp = a.end(); --tmp; return *tmp; }
11265 <p>and the specification for "a.pop_back()" from</p>
11274 { iterator tmp = a.end(); --tmp; a.erase(tmp); }
11277 <p><i>[Curaçao: LWG changed PR from "{ X::iterator tmp =
11278 a.end(); return *--tmp; }" to "*a.rbegin()", and from
11279 "{ X::iterator tmp = a.end(); a.erase(--tmp); }" to
11280 "a.erase(rbegin())".]</i></p>
11282 <p><i>[There is a second possible defect; table 68 "Optional
11283 Sequence Operations" in the "Operational Semantics"
11284 column uses operations present only in the "Reversible
11285 Container" requirements, yet there is no stated dependency
11286 between these separate requirements tables. Ask in Santa Cruz if the
11287 LWG would like a new issue opened.]</i></p>
11289 <p><i>[Santa Cruz: the proposed resolution is even worse than what's in
11290 the current standard: erase is undefined for reverse iterator. If
11291 we're going to make the change, we need to define a temporary and
11292 use operator--. Additionally, we don't know how prevalent this is:
11293 do we need to make this change in more than one place? Martin has
11294 volunteered to review the standard and see if this problem occurs
11295 elsewhere.]</i></p>
11297 <p><i>[Oxford: Matt provided new wording to address the concerns raised
11298 in Santa Cruz. It does not appear that this problem appears
11299 anywhere else in clauses 23 or 24.]</i></p>
11301 <p><i>[Kona: In definition of operational semantics of back(), change
11302 "*tmp" to "return *tmp;"]</i></p>
11305 <a name="358"><h3>358. interpreting <tt>thousands_sep</tt> after a <tt>decimal_point</tt>
11306 </h3></a><p><b>Section:</b> 22.2.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.get.virtuals"> [lib.facet.num.get.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 12 Mar 2002</p>
11308 I don't think <tt>thousands_sep</tt> is being treated correctly after
11309 decimal_point has been seen. Since grouping applies only to the
11310 integral part of the number, the first such occurrence should, IMO,
11311 terminate Stage 2. (If it does not terminate it, then 22.2.2.1.2, p12
11312 and 22.2.3.1.2, p3 need to explain how <tt>thousands_sep</tt> is to be
11313 interpreted in the fractional part of a number.)
11317 The easiest change I can think of that resolves this issue would be
11318 something like below.
11320 <p><b>Proposed resolution:</b></p>
11322 Change the first sentence of 22.2.2.1.2, p9 from
11326 If discard is true then the position of the character is
11327 remembered, but the character is otherwise ignored. If it is not
11328 discarded, then a check is made to determine if c is allowed as
11329 the next character of an input field of the conversion specifier
11330 returned by stage 1. If so it is accumulated.
11336 If <tt>discard</tt> is true, then if <tt>'.'</tt> has not yet been
11337 accumulated, then the position of the character is remembered, but
11338 the character is otherwise ignored. Otherwise, if <tt>'.'</tt> has
11339 already been accumulated, the character is discarded and Stage 2
11343 <p><b>Rationale:</b></p>
11344 <p>We believe this reflects the intent of the Standard. Thousands sep
11345 characters after the decimal point are not useful in any locale.
11346 Some formatting conventions do group digits that follow the decimal
11347 point, but they usually introduce a different grouping character
11348 instead of reusing the thousand sep character. If we want to add
11349 support for such conventions, we need to do so explicitly.</p>
11352 <a name="359"><h3>359. num_put<>::do_put (..., bool) undocumented</h3></a><p><b>Section:</b> 22.2.2.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.members"> [lib.facet.num.put.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 12 Mar 2002</p>
11353 <p>22.2.2.2.1, p1:</p>
11355 <pre> iter_type put (iter_type out, ios_base& str, char_type fill,
11359 1 Returns: do_put (out, str, fill, val).
11362 <p>AFAICS, the behavior of do_put (..., bool) is not documented anywhere,
11363 however, 22.2.2.2.2, p23:</p>
11366 <pre>iter_type put (iter_type out, ios_base& str, char_type fill,
11371 Effects: If (str.flags() & ios_base::boolalpha) == 0 then do
11372 out = do_put(out, str, fill, (int)val)
11374 <pre> string_type s =
11375 val ? use_facet<ctype<charT> >(loc).truename()
11376 : use_facet<ctype<charT> >(loc).falsename();
11378 and then insert the characters of s into out. <i>out</i>.
11382 This means that the bool overload of <tt>do_put()</tt> will never be called,
11383 which contradicts the first paragraph. Perhaps the declaration
11384 should read <tt>do_put()</tt>, and not <tt>put()</tt>?
11388 Note also that there is no <b>Returns</b> clause for this function, which
11389 should probably be corrected, just as should the second occurrence
11390 of <i>"out."</i> in the text.
11394 I think the least invasive change to fix it would be something like
11397 <p><b>Proposed resolution:</b></p>
11398 <p>In 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a>, just above paragraph 1, remove
11399 the <tt>bool</tt> overload.</p>
11402 In 22.2.2.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.facet.num.put.virtuals"> [lib.facet.num.put.virtuals]</a>, p23, make the following changes
11406 Replace <tt>put()</tt> with <tt>do_put()</tt> in the declaration
11407 of the member function.
11411 Change the <b>Effects</b> clause to a <b>Returns</b> clause (to
11412 avoid the requirement to call <tt>do_put(..., int)</tt> from <tt>
11413 do_put (..., bool))</tt>
11418 23 <b>Returns</b>: If <tt>(str.flags() &
11419 ios_base::boolalpha) == 0</tt> then
11420 <tt>do_put (out, str, fill, (long)val)</tt>
11421 Otherwise the function obtains a string <tt>s</tt> as if by
11422 <pre> string_type s =
11423 val ? use_facet<ctype<charT> >(loc).truename()
11424 : use_facet<ctype<charT> >(loc).falsename();
11426 and then inserts each character <tt>c</tt> of s into out via
11427 <tt>*out++ = c</tt>
11428 and returns <tt>out</tt>.
11431 <p><b>Rationale:</b></p>
11433 This fixes a couple of obvious typos, and also fixes what appears to
11434 be a requirement of gratuitous inefficiency.
11437 <a name="360"><h3>360. locale mandates inefficient implementation</h3></a><p><b>Section:</b> 22.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale"> [lib.locale]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 12 Mar 2002</p>
11439 22.1.1, p7 (copied below) allows iostream formatters and extractors
11440 to make assumptions about the values returned from facet members.
11441 However, such assumptions are apparently not guaranteed to hold
11442 in other cases (e.g., when the facet members are being called directly
11443 rather than as a result of iostream calls, or between successive
11444 calls to the same iostream functions with no interevening calls to
11445 <tt>imbue()</tt>, or even when the facet member functions are called
11446 from other member functions of other facets). This restriction
11447 prevents locale from being implemented efficiently.
11449 <p><b>Proposed resolution:</b></p>
11450 <p>Change the first sentence in 22.1.1, p7 from</p>
11452 In successive calls to a locale facet member function during
11453 a call to an iostream inserter or extractor or a streambuf member
11454 function, the returned result shall be identical. [Note: This
11455 implies that such results may safely be reused without calling
11456 the locale facet member function again, and that member functions
11457 of iostream classes cannot safely call <tt>imbue()</tt>
11458 themselves, except as specified elsewhere. --end note]
11464 In successive calls to a locale facet member function on a facet
11465 object installed in the same locale, the returned result shall be
11469 <p><b>Rationale:</b></p>
11470 <p>This change is reasonable becuase it clarifies the intent of this
11471 part of the standard.</p>
11473 <a name="362"><h3>362. bind1st/bind2nd type safety</h3></a><p><b>Section:</b> D.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/future.html#depr.lib.binders"> [depr.lib.binders]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Andrew Demkin <b>Date:</b> 26 Apr 2002</p>
11475 The definition of bind1st() (<font color="red">20.5.6.2</font>) can result in
11476 the construction of an unsafe binding between incompatible pointer
11477 types. For example, given a function whose first parameter type is
11478 'pointer to T', it's possible without error to bind an argument of
11479 type 'pointer to U' when U does not derive from T:
11481 <pre> foo(T*, int);
11491 for_each(p, q, bind1st(ptr_fun(foo), &u)); // unsafe binding
11495 The definition of bind1st() includes a functional-style conversion to
11496 map its argument to the expected argument type of the bound function
11499 <pre> typename Operation::first_argument_type(x)
11503 A functional-style conversion (5.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/expr.html#expr.type.conv"> [expr.type.conv]</a>) is defined to be
11504 semantically equivalent to an explicit cast expression (5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/expr.html#expr.cast"> [expr.cast]</a>), which may (according to 5.4, paragraph 5) be interpreted
11505 as a reinterpret_cast, thus masking the error.
11508 <p>The problem and proposed change also apply to <font color="red">20.5.6.4</font>.</p>
11509 <p><b>Proposed resolution:</b></p>
11510 <p>Add this sentence to the end of 20.5.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.arithmetic.operations"> [lib.arithmetic.operations]</a>/1:
11511 "Binders <tt>bind1st</tt> and <tt>bind2nd</tt> are deprecated in
11512 favor of <tt>std::tr1::bind</tt>."</p>
11514 <p>(Notes to editor: (1) when and if tr1::bind is incorporated into
11515 the standard, "std::tr1::bind" should be changed to "std::bind". (2)
11516 20.5.6 should probably be moved to Annex D.</p>
11517 <p><b>Rationale:</b></p>
11518 <p>There is no point in fixing bind1st and bind2nd. tr1::bind is a
11519 superior solution. It solves this problem and others.</p>
11521 <a name="363"><h3>363. Missing exception specification in 27.4.2.1.1</h3></a><p><b>Section:</b> 27.4.2.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios::failure"> [lib.ios::failure]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Walter Brown and Marc Paterno <b>Date:</b> 20 May 2002</p>
11523 The destructor of ios_base::failure should have an empty throw
11524 specification, because the destructor of its base class, exception, is
11525 declared in this way.
11527 <p><b>Proposed resolution:</b></p>
11528 <p>Change the destructor to</p>
11529 <pre> virtual ~failure() throw();
11531 <p><b>Rationale:</b></p>
11532 <p>Fixes an obvious glitch. This is almost editorial.</p>
11534 <a name="364"><h3>364. Inconsistent wording in 27.5.2.4.2</h3></a><p><b>Section:</b> 27.5.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.buffer"> [lib.streambuf.virt.buffer]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Walter Brown, Marc Paterno <b>Date:</b> 10 May 2002</p>
11536 27.5.2.4.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.streambuf.virt.buffer"> [lib.streambuf.virt.buffer]</a> paragraph 1 is inconsistent with the Effects
11537 clause for seekoff.
11539 <p><b>Proposed resolution:</b></p>
11541 Make this paragraph, the Effects clause for setbuf, consistent in wording
11542 with the Effects clause for seekoff in paragraph 3 by amending paragraph 1
11543 to indicate the purpose of setbuf:
11546 <p>Original text:</p>
11549 1 Effects: Performs an operation that is defined separately for each
11550 class derived from basic_streambuf in this clause (27.7.1.3, 27.8.1.4).
11553 <p>Proposed text:</p>
11556 1 Effects: Influences stream buffering in a way that is defined separately
11557 for each class derived from basic_streambuf in this clause
11558 (27.7.1.3, 27.8.1.4).
11561 <p><b>Rationale:</b></p>
11562 <p>The LWG doesn't believe there is any normative difference between
11563 the existing wording and what's in the proposed resolution, but the
11564 change may make the intent clearer.</p>
11566 <a name="365"><h3>365. Lack of const-qualification in clause 27</h3></a><p><b>Section:</b> 27 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.input.output"> [lib.input.output]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Walter Brown, Marc Paterno <b>Date:</b> 10 May 2002</p>
11568 Some stream and streambuf member functions are declared non-const,
11569 even thought they appear only to report information rather than to
11570 change an object's logical state. They should be declared const. See
11571 document N1360 for details and rationale.
11574 <p>The list of member functions under discussion: <tt>in_avail</tt>,
11575 <tt>showmanyc</tt>, <tt>tellg</tt>, <tt>tellp</tt>, <tt>is_open</tt>.</p>
11577 <p>Related issue: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#73">73</a></p>
11579 <p><b>Proposed resolution:</b></p>
11580 <p>In 27.8.1.5, 27.8.1.7, 27.8.1.8, 27.8.1.10, 27.8.1.11, and 27.8.1.13</p>
11582 <pre> bool is_open();
11585 <pre> bool is_open() const;
11587 <p><b>Rationale:</b></p>
11588 <p>Of the changes proposed in N1360, the only one that is safe is
11589 changing the filestreams' is_open to const. The LWG believed that
11590 this was NAD the first time it considered this issue (issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#73">73</a>), but now thinks otherwise. The corresponding streambuf
11591 member function, after all,is already const.</p>
11593 <p>The other proposed changes are less safe, because some streambuf
11594 functions that appear merely to report a value do actually perform
11595 mutating operations. It's not even clear that they should be
11596 considered "logically const", because streambuf has two interfaces, a
11597 public one and a protected one. These functions may, and often do,
11598 change the state as exposed by the protected interface, even if the
11599 state exposed by the public interface is unchanged.</p>
11601 <p>Note that implementers can make this change in a binary compatible
11602 way by providing both overloads; this would be a conforming extension.</p>
11605 <a name="369"><h3>369. io stream objects and static ctors</h3></a><p><b>Section:</b> 27.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostream.objects"> [lib.iostream.objects]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Ruslan Abdikeev <b>Date:</b> 8 Jul 2002</p>
11607 Is it safe to use standard iostream objects from constructors of
11608 static objects? Are standard iostream objects constructed and are
11609 their associations established at that time?
11612 <p>Surpisingly enough, Standard does NOT require that.</p>
11615 27.3/2 [lib.iostream.objects] guarantees that standard iostream
11616 objects are constructed and their associations are established before
11617 the body of main() begins execution. It also refers to ios_base::Init
11618 class as the panacea for constructors of static objects.
11622 However, there's nothing in 27.3 [lib.iostream.objects],
11623 in 27.4.2 [lib.ios.base], and in 27.4.2.1.6 [lib.ios::Init],
11624 that would require implementations to allow access to standard
11625 iostream objects from constructors of static objects.
11630 <p>Core text refers to some magic object ios_base::Init, which will
11631 be discussed below:</p>
11634 "The [standard iostream] objects are constructed, and their
11635 associations are established at some time prior to or during
11636 first time an object of class basic_ios<charT,traits>::Init
11637 is constructed, and in any case before the body of main
11638 begins execution." (27.3/2 [lib.iostream.objects])
11642 The first <i>non-normative</i> footnote encourages implementations
11643 to initialize standard iostream objects earlier than required.
11646 <p>However, the second <i>non-normative</i> footnote makes an explicit
11647 and unsupported claim:</p>
11650 "Constructors and destructors for static objects can access these
11651 [standard iostream] objects to read input from stdin or write output
11652 to stdout or stderr." (27.3/2 footnote 265 [lib.iostream.objects])
11656 The only bit of magic is related to that ios_base::Init class. AFAIK,
11657 the rationale behind ios_base::Init was to bring an instance of this
11658 class to each translation unit which #included <iostream> or
11659 related header. Such an inclusion would support the claim of footnote
11660 quoted above, because in order to use some standard iostream object it
11661 is necessary to #include <iostream>.
11665 However, while Standard explicitly describes ios_base::Init as
11666 an appropriate class for doing the trick, I failed to found a
11667 mention of an _instance_ of ios_base::Init in Standard.
11669 <p><b>Proposed resolution:</b></p>
11671 <p>Add to 27.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostream.objects"> [lib.iostream.objects]</a>, p2, immediately before the last sentence
11672 of the paragraph, the following two sentences:</p>
11675 If a translation unit includes <iostream>, or explicitly
11676 constructs an ios_base::Init object, these stream objects shall
11677 be constructed before dynamic initialization of non-local
11678 objects defined later in that translation unit, and these stream
11679 objects shall be destroyed after the destruction of dynamically
11680 initialized non-local objects defined later in that translation unit.
11683 <p><i>[Lillehammer: Matt provided wording.]</i></p>
11684 <p><i>[Mont Tremblant: Matt provided revised wording.]</i></p>
11685 <p><b>Rationale:</b></p>
11687 The original proposed resolution unconditionally required
11688 implementations to define an ios_base::Init object of some
11689 implementation-defined name in the header <iostream>. That's an
11690 overspecification. First, defining the object may be unnecessary
11691 and even detrimental to performance if an implementation can
11692 guarantee that the 8 standard iostream objects will be initialized
11693 before any other user-defined object in a program. Second, there
11694 is no need to require implementations to document the name of the
11698 The new proposed resolution gives users guidance on what they need to
11699 do to ensure that stream objects are constructed during startup.</p>
11701 <a name="370"><h3>370. Minor error in basic_istream::get</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Ray Lischner <b>Date:</b> 15 Jul 2002</p>
11702 <p>Defect report for description of basic_istream::get (section 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a>), paragraph 15. The description for the get function
11703 with the following signature:</p>
11705 <pre> basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>&
11709 <p>is incorrect. It reads</p>
11712 Effects: Calls get(s,n,widen('\n'))
11715 <p>which I believe should be:</p>
11718 Effects: Calls get(sb,widen('\n'))
11720 <p><b>Proposed resolution:</b></p>
11721 <p>Change the <b>Effects</b> paragraph to:</p>
11723 Effects: Calls get(sb,this->widen('\n'))
11726 <p><i>[Pre-Oxford: Minor correction from Howard: replaced 'widen'
11727 with 'this->widen'.]</i></p>
11729 <p><b>Rationale:</b></p>
11730 <p>Fixes an obvious typo.</p>
11732 <a name="371"><h3>371. Stability of multiset and multimap member functions</h3></a><p><b>Section:</b> 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Frank Compagner <b>Date:</b> 20 Jul 2002</p>
11734 The requirements for multiset and multimap containers (23.1
11735 [lib.containers.requirements], 23.1.2 [lib.associative.reqmnts],
11736 23.3.2 [lib.multimap] and 23.3.4 [lib.multiset]) make no mention of
11737 the stability of the required (mutating) member functions. It appears
11738 the standard allows these functions to reorder equivalent elements of
11739 the container at will, yet the pervasive red-black tree implementation
11740 appears to provide stable behaviour.
11743 <p>This is of most concern when considering the behaviour of erase().
11744 A stability requirement would guarantee the correct working of the
11745 following 'idiom' that removes elements based on a certain predicate
11749 <pre> multimap<int, int> m;
11750 multimap<int, int>::iterator i = m.begin();
11751 while (i != m.end()) {
11760 Although clause 23.1.2/8 guarantees that i remains a valid iterator
11761 througout this loop, absence of the stability requirement could
11762 potentially result in elements being skipped. This would make
11763 this code incorrect, and, furthermore, means that there is no way
11764 of erasing these elements without iterating first over the entire
11765 container, and second over the elements to be erased. This would
11766 be unfortunate, and have a negative impact on both performance and
11771 If the stability requirement is intended, it should be made explicit
11772 (probably through an extra paragraph in clause 23.1.2).
11775 If it turns out stability cannot be guaranteed, i'd argue that a
11776 remark or footnote is called for (also somewhere in clause 23.1.2) to
11777 warn against relying on stable behaviour (as demonstrated by the code
11778 above). If most implementations will display stable behaviour, any
11779 problems emerging on an implementation without stable behaviour will
11780 be hard to track down by users. This would also make the need for an
11781 erase_if() member function that much greater.
11784 <p>This issue is somewhat related to LWG issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#130">130</a>.</p>
11786 <p><b>Proposed resolution:</b></p>
11788 <p>Add the following to the end of 23.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.associative.reqmts"> [lib.associative.reqmts]</a> paragraph 4:
11789 "For <tt>multiset</tt> and <tt>multimap</tt>, <tt>insert</tt>and <tt>erase</tt>
11790 are <i>stable</i>: they preserve the relative ordering of equivalent
11793 <p><i>[Lillehammer: Matt provided wording]</i></p>
11794 <p><i>[Joe Gottman points out that the provided wording does not address
11795 multimap and multiset. N1780 also addresses this issue and suggests
11798 <p><i>[Mont Tremblant: Changed set and map to multiset and multimap.]</i></p>
11800 <p><b>Rationale:</b></p>
11801 <p>The LWG agrees that this guarantee is necessary for common user
11802 idioms to work, and that all existing implementations provide this
11803 property. Note that this resolution guarantees stability for
11804 multimap and multiset, not for all associative containers in
11808 <a name="373"><h3>373. Are basic_istream and basic_ostream to use (exceptions()&badbit) != 0 ?</h3></a><p><b>Section:</b> 27.6.1.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.reqmts"> [lib.istream.formatted.reqmts]</a>, 27.6.2.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.formatted.reqmts"> [lib.ostream.formatted.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Keith Baker <b>Date:</b> 23 Jul 2002</p>
11811 In 27.6.1.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.reqmts"> [lib.istream.formatted.reqmts]</a> and 27.6.2.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.formatted.reqmts"> [lib.ostream.formatted.reqmts]</a>
11812 (exception()&badbit) != 0 is used in testing for rethrow, yet
11813 exception() is the constructor to class std::exception in 18.6.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.type.info"> [lib.type.info]</a> that has no return type. Should member function
11814 exceptions() found in 27.4.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ios"> [lib.ios]</a> be used instead?
11817 <p><b>Proposed resolution:</b></p>
11819 In 27.6.1.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.formatted.reqmts"> [lib.istream.formatted.reqmts]</a> and 27.6.2.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.formatted.reqmts"> [lib.ostream.formatted.reqmts]</a>, change
11820 "(exception()&badbit) != 0" to "(exceptions()&badbit) != 0".
11822 <p><b>Rationale:</b></p>
11823 <p>Fixes an obvious typo.</p>
11825 <a name="375"><h3>375. basic_ios should be ios_base in 27.7.1.3</h3></a><p><b>Section:</b> 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Ray Lischner <b>Date:</b> 14 Aug 2002</p>
11827 In Section 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a>: Table 90, Table 91, and paragraph
11828 14 all contain references to "basic_ios::" which should be
11831 <p><b>Proposed resolution:</b></p>
11833 Change all references to "basic_ios" in Table 90, Table 91, and
11834 paragraph 14 to "ios_base".
11836 <p><b>Rationale:</b></p>
11837 <p>Fixes an obvious typo.</p>
11839 <a name="376"><h3>376. basic_streambuf semantics</h3></a><p><b>Section:</b> 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Ray Lischner <b>Date:</b> 14 Aug 2002</p>
11841 In Section 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a>, Table 90, the implication is that
11842 the four conditions should be mutually exclusive, but they are not.
11843 The first two cases, as written, are subcases of the third.</p>
11846 As written, it is unclear what should be the result if cases 1 and 2
11847 are both true, but case 3 is false.
11850 <p><b>Proposed resolution:</b></p>
11852 <p>Rewrite these conditions as:</p>
11855 (which & (ios_base::in|ios_base::out)) == ios_base::in
11859 (which & (ios_base::in|ios_base::out)) == ios_base::out
11863 (which & (ios_base::in|ios_base::out)) ==
11864 (ios_base::in|ios_base::out)
11865 and way == either ios_base::beg or ios_base::end
11871 <p><b>Rationale:</b></p>
11872 <p>It's clear what we wanted to say, we just failed to say it. This
11875 <a name="379"><h3>379. nonsensical ctype::do_widen() requirement</h3></a><p><b>Section:</b> 22.2.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.virtuals"> [lib.locale.ctype.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 6 Sep 2002</p>
11877 The last sentence in 22.2.1.1.2, p11 below doesn't seem to make sense.
11879 <pre> charT do_widen (char c) const;
11881 -11- Effects: Applies the simplest reasonable transformation from
11882 a char value or sequence of char values to the corresponding
11883 charT value or values. The only characters for which unique
11884 transformations are required are those in the basic source
11885 character set (2.2). For any named ctype category with a
11886 ctype<charT> facet ctw and valid ctype_base::mask value
11887 M (is(M, c) || !ctw.is(M, do_widen(c))) is true.
11890 Shouldn't the last sentence instead read
11892 <pre> For any named ctype category with a ctype<char> facet ctc
11893 and valid ctype_base::mask value M
11894 (ctc.is(M, c) || !is(M, do_widen(c))) is true.
11897 I.e., if the narrow character c is not a member of a class of
11898 characters then neither is the widened form of c. (To paraphrase
11901 <p><b>Proposed resolution:</b></p>
11903 Replace the last sentence of 22.2.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.ctype.virtuals"> [lib.locale.ctype.virtuals]</a>, p11 with the
11906 <pre> For any named ctype category with a ctype<char> facet ctc
11907 and valid ctype_base::mask value M,
11908 (ctc.is(M, c) || !is(M, do_widen(c))) is true.
11911 <p><i>[Kona: Minor edit. Added a comma after the <i>M</i> for clarity.]</i></p>
11913 <p><b>Rationale:</b></p>
11914 <p>The LWG believes this is just a typo, and that this is the correct fix.</p>
11916 <a name="380"><h3>380. typos in codecvt tables 53 and 54</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 6 Sep 2002</p>
11918 Tables 53 and 54 in 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> are both titled "convert
11919 result values," when surely "do_in/do_out result values" must have
11920 been intended for Table 53 and "do_unshift result values" for Table
11924 Table 54, row 3 says that the meaning of partial is "more characters
11925 needed to be supplied to complete termination." The function is not
11926 supplied any characters, it is given a buffer which it fills with
11927 characters or, more precisely, destination elements (i.e., an escape
11928 sequence). So partial means that space for more than (to_limit - to)
11929 destination elements was needed to terminate a sequence given the
11932 <p><b>Proposed resolution:</b></p>
11934 Change the title of Table 53 to "do_in/do_out result values" and
11935 the title of Table 54 to "do_unshift result values."
11938 Change the text in Table 54, row 3 (the <b>partial</b> row), under the
11939 heading Meaning, to "space for more than (to_limit - to) destination
11940 elements was needed to terminate a sequence given the value of state."
11943 <a name="381"><h3>381. detection of invalid mbstate_t in codecvt</h3></a><p><b>Section:</b> 22.2.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.codecvt.byname"> [lib.locale.codecvt.byname]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 6 Sep 2002</p>
11945 All but one codecvt member functions that take a state_type argument
11946 list as one of their preconditions that the state_type argument have
11947 a valid value. However, according to 22.2.1.5.2, p6,
11948 codecvt::do_unshift() is the only codecvt member that is supposed to
11949 return error if the state_type object is invalid.
11953 It seems to me that the treatment of state_type by all codecvt member
11954 functions should be the same and the current requirements should be
11955 changed. Since the detection of invalid state_type values may be
11956 difficult in general or computationally expensive in some specific
11957 cases, I propose the following:
11959 <p><b>Proposed resolution:</b></p>
11961 Add a new paragraph before 22.2.1.5.2, p5, and after the function
11964 <pre> result do_unshift(stateT& state,
11965 externT* to, externT* to_limit, externT*& to_next) const;
11970 <pre> Requires: (to <= to_end) well defined and true; state initialized,
11971 if at the beginning of a sequence, or else equal to the result of
11972 converting the preceding characters in the sequence.
11975 and change the text in Table 54, row 4, the <b>error</b> row, under
11976 the heading Meaning, from
11978 <pre> state has invalid value
11983 <pre> an unspecified error has occurred
11985 <p><b>Rationale:</b></p>
11986 <p>The intent is that implementations should not be required to detect
11987 invalid state values; such a requirement appears nowhere else. An
11988 invalid state value is a precondition violation, <i>i.e.</i> undefined
11989 behavior. Implementations that do choose to detect invalid state
11990 values, or that choose to detect any other kind of error, may return
11991 <b>error</b> as an indication.</p>
11993 <a name="383"><h3>383. Bidirectional iterator assertion typo</h3></a><p><b>Section:</b> 24.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.bidirectional.iterators"> [lib.bidirectional.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> ysapir (submitted via comp.std.c++) <b>Date:</b> 17 Oct 2002</p>
11995 Following a discussion on the boost list regarding end iterators and
11996 the possibility of performing operator--() on them, it seems to me
11997 that there is a typo in the standard. This typo has nothing to do
11998 with that discussion.
12002 I have checked this newsgroup, as well as attempted a search of the
12003 Active/Defect/Closed Issues List on the site for the words "s is
12004 derefer" so I believe this has not been proposed before. Furthermore,
12005 the "Lists by Index" mentions only DR <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#299">299</a> on section
12006 24.1.4, and DR <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#299">299</a> is not related to this issue.
12010 The standard makes the following assertion on bidirectional iterators,
12011 in section 24.1.4 [lib.bidirectional.iterators], Table 75:
12014 <pre> operational assertion/note
12015 expression return type semantics pre/post-condition
12017 --r X& pre: there exists s such
12019 post: s is dereferenceable.
12021 --r == --s implies r == s.
12022 &r == &--r.
12026 (See <a href="http://aspn.activestate.com/ASPN/Mail/Message/boost/1395763">http://aspn.activestate.com/ASPN/Mail/Message/boost/1395763</a>.)
12030 In particular, "s is dereferenceable" seems to be in error. It seems
12031 that the intention was to say "r is dereferenceable".
12035 If it were to say "r is dereferenceable" it would
12036 make perfect sense. Since s must be dereferenceable prior to
12037 operator++, then the natural result of operator-- (to undo operator++)
12038 would be to make r dereferenceable. Furthermore, without other
12039 assertions, and basing only on precondition and postconditions, we
12040 could not otherwise know this. So it is also interesting information.
12043 <p><b>Proposed resolution:</b></p>
12045 Change the guarantee to "postcondition: r is dereferenceable."
12047 <p><b>Rationale:</b></p>
12048 <p>Fixes an obvious typo</p>
12050 <a name="384"><h3>384. equal_range has unimplementable runtime complexity</h3></a><p><b>Section:</b> 25.3.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.equal.range"> [lib.equal.range]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Hans Bos <b>Date:</b> 18 Oct 2002</p>
12052 Section 25.3.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.equal.range"> [lib.equal.range]</a>
12053 states that at most 2 * log(last - first) + 1
12054 comparisons are allowed for equal_range.
12057 <p>It is not possible to implement equal_range with these constraints.</p>
12059 <p>In a range of one element as in:</p>
12061 equal_range(&x, &x + 1, 1)
12064 <p>it is easy to see that at least 2 comparison operations are needed.</p>
12066 <p>For this case at most 2 * log(1) + 1 = 1 comparison is allowed.</p>
12068 <p>I have checked a few libraries and they all use the same (nonconforming)
12069 algorithm for equal_range that has a complexity of</p>
12070 <pre> 2* log(distance(first, last)) + 2.
12072 <p>I guess this is the algorithm that the standard assumes for equal_range.</p>
12075 It is easy to see that 2 * log(distance) + 2 comparisons are enough
12076 since equal range can be implemented with lower_bound and upper_bound
12077 (both log(distance) + 1).
12081 I think it is better to require something like 2log(distance) + O(1) (or
12082 even logarithmic as multiset::equal_range).
12083 Then an implementation has more room to optimize for certain cases (e.g.
12084 have log(distance) characteristics when at most match is found in the range
12085 but 2log(distance) + 4 for the worst case).
12088 <p><b>Proposed resolution:</b></p>
12089 <p>In 25.3.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.lower.bound"> [lib.lower.bound]</a>/4, change <tt>log(last - first) + 1</tt>
12090 to <tt>log<sub>2</sub>(last - first) + <i>O</i>(1)</tt>.</p>
12092 <p>In 25.3.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.upper.bound"> [lib.upper.bound]</a>/4, change <tt>log(last - first) + 1</tt>
12093 to <tt>log<sub>2</sub>(last - first) + <i>O</i>(1)</tt>.</p>
12095 <p>In 25.3.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.equal.range"> [lib.equal.range]</a>/4, change <tt>2*log(last - first) + 1</tt>
12096 to <tt>2*log<sub>2</sub>(last - first) + <i>O</i>(1)</tt>.</p>
12098 <p><i>[Matt provided wording]</i></p>
12099 <p><b>Rationale:</b></p>
12100 <p>The LWG considered just saying <i>O</i>(log n) for all three, but
12101 Ê decided that threw away too much valuable information.Ê The fact
12102 Ê that lower_bound is twice as fast as equal_range is important.
12103 Ê However, it's better to allow an arbitrary additive constant than to
12104 Ê specify an exact count.Ê An exact count would have to
12105 Ê involve <tt>floor</tt> or <tt>ceil</tt>.Ê It would be too easy to
12106 Ê get this wrong, and don't provide any substantial value for users.</p>
12108 <a name="386"><h3>386. Reverse iterator's operator[] has impossible return type</h3></a><p><b>Section:</b> 24.4.1.3.11 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.op-="> [lib.reverse.iter.op-=]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 23 Oct 2002</p>
12109 <p>In 24.4.1.3.11 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.op-="> [lib.reverse.iter.op-=]</a>, <tt>reverse_iterator<>::operator[]</tt>
12110 is specified as having a return type of <tt>reverse_iterator::reference</tt>,
12111 which is the same as <tt>iterator_traits<Iterator>::reference</tt>.
12112 (Where <tt>Iterator</tt> is the underlying iterator type.)</p>
12114 <p>The trouble is that <tt>Iterator</tt>'s own operator[] doesn't
12115 necessarily have a return type
12116 of <tt>iterator_traits<Iterator>::reference</tt>. Its
12117 return type is merely required to be convertible
12118 to <tt>Iterator</tt>'s value type. The return type specified for
12119 reverse_iterator's operator[] would thus appear to be impossible.</p>
12121 <p>With the resolution of issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#299">299</a>, the type of
12122 <tt>a[n]</tt> will continue to be required (for random access
12123 iterators) to be convertible to the value type, and also <tt>a[n] =
12124 t</tt> will be a valid expression. Implementations of
12125 <tt>reverse_iterator</tt> will likely need to return a proxy from
12126 <tt>operator[]</tt> to meet these requirements. As mentioned in the
12127 comment from Dave Abrahams, the simplest way to specify that
12128 <tt>reverse_iterator</tt> meet this requirement to just mandate
12129 it and leave the return type of <tt>operator[]</tt> unspecified.</p>
12131 <p><b>Proposed resolution:</b></p>
12133 <p>In 24.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.reverse.iter.requirements"> [lib.reverse.iter.requirements]</a> change:</p>
12136 <pre>reference operator[](difference_type n) const;
12143 <pre><b><i>unspecified</i></b> operator[](difference_type n) const; // see <font color="red">lib.random.access.iterators</font>
12151 Comments from Dave Abrahams: IMO we should resolve 386 by just saying
12152 that the return type of reverse_iterator's operator[] is
12153 unspecified, allowing the random access iterator requirements to
12154 impose an appropriate return type. If we accept 299's proposed
12155 resolution (and I think we should), the return type will be
12156 readable and writable, which is about as good as we can do.
12159 <a name="389"><h3>389. Const overload of valarray::operator[] returns by value</h3></a><p><b>Section:</b> 26.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex"> [lib.complex]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Gabriel Dos Reis <b>Date:</b> 8 Nov 2002</p>
12160 <p>Consider the following program:</p>
12161 <pre> #include <iostream>
12162 #include <ostream>
12163 #include <vector>
12164 #include <valarray>
12165 #include <algorithm>
12166 #include <iterator>
12167 template<typename Array>
12168 void print(const Array& a)
12170 using namespace std;
12171 typedef typename Array::value_type T;
12172 copy(&a[0], &a[0] + a.size(),
12173 ostream_iterator<T>(std::cout, " "));
12175 template<typename T, unsigned N>
12176 unsigned size(T(&)[N]) { return N; }
12179 double array[] = { 0.89, 9.3, 7, 6.23 };
12180 std::vector<double> v(array, array + size(array));
12181 std::valarray<double> w(array, size(array));
12183 std::cout << std::endl;
12185 std::cout << std::endl;
12189 <p>While the call numbered #1 succeeds, the call numbered #2 fails
12190 because the const version of the member function
12191 valarray<T>::operator[](size_t) returns a value instead of a
12192 const-reference. That seems to be so for no apparent reason, no
12193 benefit. Not only does that defeats users' expectation but it also
12194 does hinder existing software (written either in C or Fortran)
12195 integration within programs written in C++. There is no reason why
12196 subscripting an expression of type valarray<T> that is const-qualified
12197 should not return a const T&.</p>
12198 <p><b>Proposed resolution:</b></p>
12199 <p>In the class synopsis in 26.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.complex"> [lib.complex]</a>, and in
12200 <font color="red">26.3.2.3</font> just above paragraph 1, change</p>
12201 <pre> T operator[](size_t const);
12204 <pre> const T& operator[](size_t const);
12207 <p><i>[Kona: fixed a minor typo: put semicolon at the end of the line
12208 wehre it belongs.]</i></p>
12210 <p><b>Rationale:</b></p>
12211 <p>Return by value seems to serve no purpose. Valaray was explicitly
12212 designed to have a specified layout so that it could easily be
12213 integrated with libraries in other languages, and return by value
12214 defeats that purpose. It is believed that this change will have no
12215 impact on allowable optimizations.</p>
12217 <a name="391"><h3>391. non-member functions specified as const</h3></a><p><b>Section:</b> 22.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.conversions"> [lib.conversions]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> James Kanze <b>Date:</b> 10 Dec 2002</p>
12219 The specifications of toupper and tolower both specify the functions as
12220 const, althought they are not member functions, and are not specified as
12221 const in the header file synopsis in section 22.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locales"> [lib.locales]</a>.
12223 <p><b>Proposed resolution:</b></p>
12224 <p>In 22.1.3.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.conversions"> [lib.conversions]</a>, remove <tt>const</tt> from the function
12225 declarations of std::toupper and std::tolower</p>
12226 <p><b>Rationale:</b></p>
12227 <p>Fixes an obvious typo</p>
12229 <a name="395"><h3>395. inconsistencies in the definitions of rand() and random_shuffle()</h3></a><p><b>Section:</b> 26.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.numarray"> [lib.numarray]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> James Kanze <b>Date:</b> 3 Jan 2003</p>
12231 In 26.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-numerics.html#lib.numarray"> [lib.numarray]</a>, the C++ standard refers to the C standard for the
12232 definition of rand(); in the C standard, it is written that "The
12233 implementation shall behave as if no library function calls the rand
12238 In 25.2.11 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.random.shuffle"> [lib.alg.random.shuffle]</a>, there is no specification as to
12239 how the two parameter version of the function generates its random
12240 value. I believe that all current implementations in fact call rand()
12241 (in contradiction with the requirement avove); if an implementation does
12242 not call rand(), there is the question of how whatever random generator
12243 it does use is seeded. Something is missing.
12246 <p><b>Proposed resolution:</b></p>
12248 In [lib.c.math], add a paragraph specifying that the C definition of
12249 rand shal be modified to say that "Unless otherwise specified, the
12250 implementation shall behave as if no library function calls the rand
12255 In [lib.alg.random.shuffle], add a sentence to the effect that "In
12256 the two argument form of the function, the underlying source of
12257 random numbers is implementation defined. [Note: in particular, an
12258 implementation is permitted to use <tt>rand</tt>.]
12260 <p><b>Rationale:</b></p>
12261 <p>The original proposed resolution proposed requiring the
12262 two-argument from of <tt>random_shuffle</tt> to
12263 use <tt>rand</tt>. We don't want to do that, because some existing
12264 implementations already use something else: gcc
12265 uses <tt>lrand48</tt>, for example. Using <tt>rand</tt> presents a
12266 problem if the number of elements in the sequence is greater than
12269 <a name="400"><h3>400. redundant type cast in lib.allocator.members</h3></a><p><b>Section:</b> 20.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.allocator.members"> [lib.allocator.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Markus Mauhart <b>Date:</b> 27 Feb 2003</p>
12271 20.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.allocator.members"> [lib.allocator.members]</a> allocator members, contains
12272 the following 3 lines:
12275 <pre> 12 Returns: new((void *) p) T( val)
12276 void destroy(pointer p);
12277 13 Returns: ((T*) p)->~T()
12281 The type cast "(T*) p" in the last line is redundant cause
12282 we know that std::allocator<T>::pointer is a typedef for T*.
12284 <p><b>Proposed resolution:</b></p>
12286 Replace "((T*) p)" with "p".
12288 <p><b>Rationale:</b></p>
12289 <p>Just a typo, this is really editorial.</p>
12291 <a name="402"><h3>402. wrong new expression in [some_]allocator::construct</h3></a><p><b>Section:</b> 20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a>, 20.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.allocator.members"> [lib.allocator.members]</a>, <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Markus Mauhart <b>Date:</b> 27 Feb 2003</p>
12293 This applies to the new expression that is contained in both par12 of
12294 20.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.allocator.members"> [lib.allocator.members]</a> and in par2 (table 32) of 20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a>.
12295 I think this new expression is wrong, involving unintended side
12300 <p>20.6.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.allocator.members"> [lib.allocator.members]</a> contains the following 3 lines:</p>
12302 <pre> 11 Returns: the largest value N for which the call allocate(N,0) might succeed.
12303 void construct(pointer p, const_reference val);
12304 12 Returns: new((void *) p) T( val)
12308 <p>20.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.default.con.req"> [lib.default.con.req]</a> in table 32 has the following line:</p>
12309 <pre> a.construct(p,t) Effect: new((void*)p) T(t)
12313 .... with the prerequisits coming from the preceding two paragraphs,
12314 especially from table 31:
12317 <pre> alloc<T> a ;// an allocator for T
12318 alloc<T>::pointer p ;// random access iterator
12319 // (may be different from T*)
12320 alloc<T>::reference r = *p;// T&
12325 Cause of using "new" but not "::new", any existing "T::operator new"
12326 function will hide the global placement new function. When there is no
12327 "T::operator new" with adequate signature,
12328 every_alloc<T>::construct(..) is ill-formed, and most
12329 std::container<T,every_alloc<T>> use it; a workaround
12330 would be adding placement new and delete functions with adequate
12331 signature and semantic to class T, but class T might come from another
12332 party. Maybe even worse is the case when T has placement new and
12333 delete functions with adequate signature but with "unknown" semantic:
12334 I dont like to speculate about it, but whoever implements
12335 any_container<T,any_alloc> and wants to use construct(..)
12336 probably must think about it.
12338 <p><b>Proposed resolution:</b></p>
12340 Replace "new" with "::new" in both cases.
12343 <a name="403"><h3>403. basic_string::swap should not throw exceptions</h3></a><p><b>Section:</b> 21.3.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::swap"> [lib.string::swap]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 25 Mar 2003</p>
12346 std::basic_string, 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> paragraph 2 says that
12347 basic_string "conforms to the requirements of a Sequence, as specified
12348 in (23.1.1)." The sequence requirements specified in (23.1.1) to not
12349 include any prohibition on swap members throwing exceptions.
12353 Section 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> paragraph 10 does limit conditions under
12354 which exceptions may be thrown, but applies only to "all container
12355 types defined in this clause" and so excludes basic_string::swap
12356 because it is defined elsewhere.
12360 Eric Niebler points out that 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> paragraph 5 explicitly
12361 permits basic_string::swap to invalidates iterators, which is
12362 disallowed by 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> paragraph 10. Thus the standard would
12363 be contradictory if it were read or extended to read as having
12364 basic_string meet 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> paragraph 10 requirements.
12368 Yet several LWG members have expressed the belief that the original
12369 intent was that basic_string::swap should not throw exceptions as
12370 specified by 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> paragraph 10, and that the standard is
12371 unclear on this issue. The complexity of basic_string::swap is
12372 specified as "constant time", indicating the intent was to avoid
12373 copying (which could cause a bad_alloc or other exception). An
12374 important use of swap is to ensure that exceptions are not thrown in
12375 exception-safe code.
12379 Note: There remains long standing concern over whether or not it is
12380 possible to reasonably meet the 23.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.requirements"> [lib.container.requirements]</a> paragraph 10 swap
12381 requirements when allocators are unequal. The specification of
12382 basic_string::swap exception requirements is in no way intended to
12383 address, prejudice, or otherwise impact that concern.
12390 <p><b>Proposed resolution:</b></p>
12392 In 21.3.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::swap"> [lib.string::swap]</a>, add a throws clause:
12396 Throws: Shall not throw exceptions.
12399 <a name="404"><h3>404. May a replacement allocation function be declared inline?</h3></a><p><b>Section:</b> 17.4.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.replacement.functions"> [lib.replacement.functions]</a>, 18.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete"> [lib.new.delete]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 24 Apr 2003</p>
12401 The eight basic dynamic memory allocation functions (single-object
12402 and array versions of ::operator new and ::operator delete, in the
12403 ordinary and nothrow forms) are replaceable. A C++ program may
12404 provide an alternative definition for any of them, which will be used
12405 in preference to the implementation's definition.
12409 Three different parts of the standard mention requirements on
12410 replacement functions: 17.4.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.replacement.functions"> [lib.replacement.functions]</a>, 18.5.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.single"> [lib.new.delete.single]</a>
12411 and 18.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.array"> [lib.new.delete.array]</a>, and 3.7.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/basic.html#basic.stc.dynamic"> [basic.stc.dynamic]</a>.
12414 <p>None of these three places say whether a replacement function may
12415 be declared inline. 18.5.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.new.delete.single"> [lib.new.delete.single]</a> paragraph 2 specifies a
12416 signature for the replacement function, but that's not enough:
12417 the <tt>inline</tt> specifier is not part of a function's signature.
12418 One might also reason from 7.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/dcl.html#dcl.fct.spec"> [dcl.fct.spec]</a> paragraph 2, which
12419 requires that "an inline function shall be defined in every
12420 translation unit in which it is used," but this may not be quite
12421 specific enough either. We should either explicitly allow or
12422 explicitly forbid inline replacement memory allocation
12424 <p><b>Proposed resolution:</b></p>
12426 Add a new sentence to the end of 17.4.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.replacement.functions"> [lib.replacement.functions]</a> paragraph 3:
12427 "The program's definitions shall not be specified as <tt>inline</tt>.
12428 No diagnostic is required."
12431 <p><i>[Kona: added "no diagnostic is required"]</i></p>
12433 <p><b>Rationale:</b></p>
12435 The fact that <tt>inline</tt> isn't mentioned appears to have been
12436 nothing more than an oversight. Existing implementations do not
12437 permit inline functions as replacement memory allocation functions.
12438 Providing this functionality would be difficult in some cases, and is
12439 believed to be of limited value.
12442 <a name="405"><h3>405. qsort and POD</h3></a><p><b>Section:</b> 25.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.c.library"> [lib.alg.c.library]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Ray Lischner <b>Date:</b> 08 Apr 2003</p>
12444 Section 25.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.c.library"> [lib.alg.c.library]</a> describes bsearch and qsort, from the C
12445 standard library. Paragraph 4 does not list any restrictions on qsort,
12446 but it should limit the base parameter to point to POD. Presumably,
12447 qsort sorts the array by copying bytes, which requires POD.
12449 <p><b>Proposed resolution:</b></p>
12451 In 25.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.c.library"> [lib.alg.c.library]</a> paragraph 4, just after the declarations and
12452 before the nonnormative note, add these words: "both of which have the
12453 same behavior as the original declaration. The behavior is undefined
12454 unless the objects in the array pointed to by <i>base</i> are of POD
12458 <p><i>[Something along these lines is clearly necessary. Matt
12459 provided wording.]</i></p>
12461 <a name="406"><h3>406. vector::insert(s) exception safety</h3></a><p><b>Section:</b> 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 27 Apr 2003</p>
12463 There is a possible defect in the standard: the standard text was
12464 never intended to prevent arbitrary ForwardIterators, whose operations
12465 may throw exceptions, from being passed, and it also wasn't intended
12466 to require a temporary buffer in the case where ForwardIterators were
12467 passed (and I think most implementations don't use one). As is, the
12468 standard appears to impose requirements that aren't met by any
12469 existing implementation.
12471 <p><b>Proposed resolution:</b></p>
12472 <p>Replace 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a> paragraph 1 with:</p>
12474 1- Notes: Causes reallocation if the new size is greater than the
12475 old capacity. If no reallocation happens, all the iterators and
12476 references before the insertion point remain valid. If an exception
12477 is thrown other than by the copy constructor or assignment operator
12478 of T or by any InputIterator operation there are no effects.
12481 <p><i>[We probably need to say something similar for deque.]</i></p>
12484 <a name="407"><h3>407. Can singular iterators be destroyed?</h3></a><p><b>Section:</b> 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 3 June 2003</p>
12486 Clause 24.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.requirements"> [lib.iterator.requirements]</a>, paragraph 5, says that the only expression
12487 that is defined for a singular iterator is "an assignment of a
12488 non-singular value to an iterator that holds a singular value". This
12489 means that destroying a singular iterator (e.g. letting an automatic
12490 variable go out of scope) is technically undefined behavior. This
12491 seems overly strict, and probably unintentional.
12493 <p><b>Proposed resolution:</b></p>
12495 Change the sentence in question to "... the only exceptions are
12496 destroying an iterator that holds a singular value, or the assignment
12497 of a non-singular value to an iterator that holds a singular value."
12500 <a name="409"><h3>409. Closing an fstream should clear error state</h3></a><p><b>Section:</b> 27.8.1.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.members"> [lib.ifstream.members]</a>, 27.8.1.10 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ofstream.members"> [lib.ofstream.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Nathan Myers <b>Date:</b> 3 June 2003</p>
12502 A strict reading of 27.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstreams"> [lib.fstreams]</a> shows that opening or
12503 closing a basic_[io]fstream does not affect the error bits. This
12504 means, for example, that if you read through a file up to EOF, and
12505 then close the stream and reopen it at the beginning of the file,
12506 the EOF bit in the stream's error state is still set. This is
12510 The LWG considered this issue once before, as issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#22">22</a>,
12511 and put in a footnote to clarify that the strict reading was indeed
12512 correct. We did that because we believed the standard was
12513 unambiguous and consistent, and that we should not make architectural
12514 changes in a TC. Now that we're working on a new revision of the
12515 language, those considerations no longer apply.
12517 <p><b>Proposed resolution:</b></p>
12519 <p>Change 27.8.1.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.members"> [lib.ifstream.members]</a>, para. 3 from:</p>
12522 Calls rdbuf()->open(s,mode|in). If that function returns a null
12523 pointer, calls setstate(failbit) (which may throw ios_base::failure
12524 [Footnote: (lib.iostate.flags)].
12529 <blockquote>Calls rdbuf()->open(s,mode|in). If that function returns
12530 a null pointer, calls setstate(failbit) (which may throw
12531 ios_base::failure [Footnote: (lib.iostate.flags)), else calls clear().
12534 <p>Change 27.8.1.10 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ofstream.members"> [lib.ofstream.members]</a>, para. 3 from:</p>
12536 <blockquote>Calls rdbuf()->open(s,mode|out). If that function
12537 returns a null pointer, calls setstate(failbit) (which may throw
12538 ios_base::failure [Footnote: (lib.iostate.flags)).
12543 <blockquote>Calls rdbuf()->open(s,mode|out). If that function
12544 returns a null pointer, calls setstate(failbit) (which may throw
12545 ios_base::failure [Footnote: (lib.iostate.flags)), else calls clear().
12548 <p>Change 27.8.1.13 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstream.members"> [lib.fstream.members]</a>, para. 3 from:</p>
12550 <blockquote>Calls rdbuf()->open(s,mode), If that function returns a
12551 null pointer, calls setstate(failbit), (which may throw
12552 ios_base::failure). (lib.iostate.flags) )
12557 <blockquote>Calls rdbuf()->open(s,mode), If that function returns a
12558 null pointer, calls setstate(failbit), (which may throw
12559 ios_base::failure). (lib.iostate.flags) ), else calls clear().
12564 <p><i>[Kona: the LWG agrees this is a good idea. Post-Kona: Bill
12565 provided wording. He suggests having open, not close, clear the error
12568 <p><i>[Post-Sydney: Howard provided a new proposed resolution. The
12569 old one didn't make sense because it proposed to fix this at the
12570 level of basic_filebuf, which doesn't have access to the stream's
12571 error state. Howard's proposed resolution fixes this at the level
12572 of the three fstream class template instead.]</i></p>
12575 <a name="410"><h3>410. Missing semantics for stack and queue comparison operators</h3></a><p><b>Section:</b> 23.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.cons"> [lib.list.cons]</a>, 23.2.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.modifiers"> [lib.list.modifiers]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Hans Bos <b>Date:</b> 7 Jun 2003</p>
12577 Sections 23.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.cons"> [lib.list.cons]</a> and 23.2.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.modifiers"> [lib.list.modifiers]</a> list
12578 comparison operators (==, !=, <, <=, >, =>) for queue and
12579 stack. Only the semantics for queue::operator== (23.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.cons"> [lib.list.cons]</a> par2) and queue::operator< (23.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.cons"> [lib.list.cons]</a>
12582 <p><b>Proposed resolution:</b></p>
12584 <p>Add the following new paragraphs after 23.2.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.cons"> [lib.list.cons]</a>
12591 <p>Returns: <tt>x.c != y.c</tt></p>
12595 <p>Returns: <tt>x.c > y.c</tt></p>
12597 <pre> operator<=
12599 <p>Returns: <tt>x.c <= y.c</tt></p>
12601 <pre> operator>=
12603 <p>Returns: <tt>x.c >= y.c</tt></p>
12607 <p>Add the following paragraphs at the end of 23.2.3.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.list.modifiers"> [lib.list.modifiers]</a>:</p>
12613 <p>Returns: <tt>x.c == y.c</tt></p>
12617 <p>Returns: <tt>x.c < y.c</tt></p>
12621 <p>Returns: <tt>x.c != y.c</tt></p>
12625 <p>Returns: <tt>x.c > y.c</tt></p>
12627 <pre> operator<=
12629 <p>Returns: <tt>x.c <= y.c</tt></p>
12631 <pre> operator>=
12633 <p>Returns: <tt>x.c >= y.c</tt></p>
12638 <p><i>[Kona: Matt provided wording.]</i></p>
12640 <p><b>Rationale:</b></p>
12641 There isn't any real doubt about what these operators are
12642 supposed to do, but we ought to spell it out.
12644 <a name="411"><h3>411. Wrong names of set member functions</h3></a><p><b>Section:</b> 25.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.set.operations"> [lib.alg.set.operations]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Daniel Frey <b>Date:</b> 9 Jul 2003</p>
12646 25.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.set.operations"> [lib.alg.set.operations]</a> paragraph 1 reads:
12647 "The semantics of the set operations are generalized to multisets in a
12648 standard way by defining union() to contain the maximum number of
12649 occurrences of every element, intersection() to contain the minimum, and
12654 This is wrong. The name of the functions are set_union() and
12655 set_intersection(), not union() and intersection().
12657 <p><b>Proposed resolution:</b></p>
12658 <p>Change that sentence to use the correct names.</p>
12660 <a name="412"><h3>412. Typo in 27.4.4.3</h3></a><p><b>Section:</b> 27.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostate.flags"> [lib.iostate.flags]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 10 Jul 2003</p>
12662 The Effects clause in 27.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostate.flags"> [lib.iostate.flags]</a> paragraph 5 says that the
12663 function only throws if the respective bits are already set prior to
12664 the function call. That's obviously not the intent. The typo ought to
12665 be corrected and the text reworded as: "If (<i>state</i> &
12666 exceptions()) == 0, returns. ..."
12668 <p><b>Proposed resolution:</b></p>
12670 In 27.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostate.flags"> [lib.iostate.flags]</a> paragraph 5, replace "If (rdstate() &
12671 exceptions()) == 0" with "If ((state | (rdbuf() ? goodbit : badbit))
12672 & exceptions()) == 0".
12675 <p><i>[Kona: the original proposed resolution wasn't quite right. We
12676 really do mean rdstate(); the ambiguity is that the wording in the
12677 standard doesn't make it clear whether we mean rdstate() before
12678 setting the new state, or rdsate() after setting it. We intend the
12679 latter, of course. Post-Kona: Martin provided wording.]</i></p>
12682 <a name="413"><h3>413. Proposed resolution to LDR#64 still wrong</h3></a><p><b>Section:</b> 27.6.1.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream::extractors"> [lib.istream::extractors]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Bo Persson <b>Date:</b> 13 Jul 2003</p>
12684 The second sentence of the proposed resolution says:
12688 "If it inserted no characters because it caught an exception thrown
12689 while extracting characters from sb and ..."
12693 However, we are not extracting from sb, but extracting from the
12694 basic_istream (*this) and inserting into sb. I can't really tell if
12695 "extracting" or "sb" is a typo.
12699 Sydney: Definitely a real issue. We are, indeed, extracting characters
12700 from an istream and not from sb. The problem was there in the FDIS and
12701 wasn't fixed by issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#64">64</a>. Probably what was intended was
12702 to have *this instead of sb. We're talking about the exception flag
12703 state of a basic_istream object, and there's only one basic_istream
12704 object in this discussion, so that would be a consistent
12705 interpretation. (But we need to be careful: the exception policy of
12706 this member function must be consistent with that of other
12707 extractors.) PJP will provide wording.
12710 <p><b>Proposed resolution:</b></p>
12711 <p>Change the sentence from:</p>
12714 If it inserted no characters because it caught an exception thrown
12715 while extracting characters from sb and failbit is on in exceptions(),
12716 then the caught exception is rethrown.
12722 If it inserted no characters because it caught an exception thrown
12723 while extracting characters from *this and failbit is on in exceptions(),
12724 then the caught exception is rethrown.
12727 <a name="414"><h3>414. Which iterators are invalidated by v.erase()?</h3></a><p><b>Section:</b> 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 19 Aug 2003</p>
12729 Consider the following code fragment:
12732 <pre>int A[8] = { 1,3,5,7,9,8,4,2 };
12733 std::vector<int> v(A, A+8);
12735 std::vector<int>::iterator i1 = v.begin() + 3;
12736 std::vector<int>::iterator i2 = v.begin() + 4;
12742 Which iterators are invalidated by <tt>v.erase(i1)</tt>: i1, i2,
12747 On all existing implementations that I know of, the status of i1 and
12748 i2 is the same: both of them will be iterators that point to some
12749 elements of the vector (albeit not the same elements they did
12750 before). You won't get a crash if you use them. Depending on
12751 exactly what you mean by "invalidate", you might say that neither one
12752 has been invalidated because they still point to <i>something</i>,
12753 or you might say that both have been invalidated because in both
12754 cases the elements they point to have been changed out from under the
12759 The standard doesn't say either of those things. It says that erase
12760 invalidates all iterators and references "after the point of the
12761 erase". This doesn't include i1, since it's at the point of the
12762 erase instead of after it. I can't think of any sensible definition
12763 of invalidation by which one can say that i2 is invalidated but i1
12768 (This issue is important if you try to reason about iterator validity
12769 based only on the guarantees in the standard, rather than reasoning
12770 from typical implementation techniques. Strict debugging modes,
12771 which some programmers find useful, do not use typical implementation
12774 <p><b>Proposed resolution:</b></p>
12776 In 23.2.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.stack"> [lib.stack]</a> paragraph 3, change "Invalidates all the
12777 iterators and references after the point of the erase" to
12778 "Invalidates iterators and references at or after the point of the
12781 <p><b>Rationale:</b></p>
12782 <p>I believe this was essentially a typographical error, and that it
12783 was taken for granted that erasing an element invalidates iterators
12784 that point to it. The effects clause in question treats iterators
12785 and references in parallel, and it would seem counterintuitive to
12786 say that a reference to an erased value remains valid.</p>
12788 <a name="415"><h3>415. behavior of std::ws</h3></a><p><b>Section:</b> 27.6.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.manip"> [lib.istream.manip]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 18 Sep 2003</p>
12790 According to 27.6.1.4, the ws() manipulator is not required to construct
12791 the sentry object. The manipulator is also not a member function so the
12792 text in 27.6.1, p1 through 4 that describes the exception policy for
12793 istream member functions does not apply. That seems inconsistent with
12794 the rest of extractors and all the other input functions (i.e., ws will
12795 not cause a tied stream to be flushed before extraction, it doesn't check
12796 the stream's exceptions or catch exceptions thrown during input, and it
12797 doesn't affect the stream's gcount).
12799 <p><b>Proposed resolution:</b></p>
12801 Add to 27.6.1.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.manip"> [lib.istream.manip]</a>, immediately before the first sentence
12802 of paragraph 1, the following text:
12806 Behaves as an unformatted input function (as described in
12807 27.6.1.3, paragraph 1), except that it does not count the number
12808 of characters extracted and does not affect the value returned by
12809 subsequent calls to is.gcount(). After constructing a sentry
12813 <p><i>[Post-Kona: Martin provided wording]</i></p>
12816 <a name="420"><h3>420. is std::FILE a complete type?</h3></a><p><b>Section:</b> 27.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstreams"> [lib.fstreams]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 18 Sep 2003</p>
12818 7.19.1, p2, of C99 requires that the FILE type only be declared in
12819 <stdio.h>. None of the (implementation-defined) members of the
12820 struct is mentioned anywhere for obvious reasons.
12824 C++ says in 27.8.1, p2 that FILE is a type that's defined in <cstdio>. Is
12825 it really the intent that FILE be a complete type or is an implementation
12826 allowed to just declare it without providing a full definition?
12828 <p><b>Proposed resolution:</b></p>
12829 <p>In the first sentence of 27.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstreams"> [lib.fstreams]</a> paragraph 2, change
12830 "defined" to "declared".</p>
12831 <p><b>Rationale:</b></p>
12832 <p>We don't want to impose any restrictions beyond what the C standard
12833 already says. We don't want to make anything implementation defined,
12834 because that imposes new requirements in implementations.</p>
12836 <a name="425"><h3>425. return value of std::get_temporary_buffer</h3></a><p><b>Section:</b> 20.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.help"> [lib.meta.help]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 18 Sep 2003</p>
12838 The standard is not clear about the requirements on the value returned from
12839 a call to get_temporary_buffer(0). In particular, it fails to specify whether
12840 the call should return a distinct pointer each time it is called (like
12841 operator new), or whether the value is unspecified (as if returned by
12842 malloc). The standard also fails to mention what the required behavior
12843 is when the argument is less than 0.
12845 <p><b>Proposed resolution:</b></p>
12846 <p>Change 20.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-utilities.html#lib.meta.help"> [lib.meta.help]</a> paragraph 2 from "...or a pair of 0
12847 values if no storage can be obtained" to "...or a pair of 0 values if
12848 no storage can be obtained or if <i>n</i> <= 0."</p>
12849 <p><i>[Kona: Matt provided wording]</i></p>
12851 <a name="426"><h3>426. search_n(), fill_n(), and generate_n() with negative n</h3></a><p><b>Section:</b> 25.1.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.search"> [lib.alg.search]</a>, 25.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.fill"> [lib.alg.fill]</a>, 25.2.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.generate"> [lib.alg.generate]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 18 Sep 2003</p>
12853 The complexity requirements for these function templates are incorrect
12854 (or don't even make sense) for negative n:</p>
12856 <p>25.1.9, p7 (search_n):
12858 Complexity: At most (last1 - first1) * count applications
12859 of the corresponding predicate.</p>
12861 <p>25.2.5, p3 (fill_n):
12863 Complexity: Exactly last - first (or n) assignments.</p>
12866 <p>25.2.6, p3 (generate_n):
12868 Complexity: Exactly last - first (or n) assignments.</p>
12871 In addition, the Requirements or the Effects clauses for the latter two
12872 templates don't say anything about the behavior when n is negative.
12874 <p><b>Proposed resolution:</b></p>
12875 <p>Change 25.1.9, p7 to</p>
12878 Complexity: At most (last1 - first1) * count applications
12879 of the corresponding predicate if count is positive,
12883 <p>Change 25.2.5, p2 to</p>
12885 Effects: Assigns value through all the iterators in the range [first,
12886 last), or [first, first + n) if n is positive, none otherwise.
12889 <p>Change 25.2.5, p3 to:</p>
12891 Complexity: Exactly last - first (or n if n is positive,
12892 or 0 otherwise) assignments.
12897 to (notice the correction for the misspelled "through"):
12900 Effects: Invokes the function object genand assigns the return
12901 value of gen through all the iterators in the range [first, last),
12902 or [first, first + n) if n is positive, or [first, first)
12906 <p>Change 25.2.6, p3 to:</p>
12908 Complexity: Exactly last - first (or n if n is positive,
12909 or 0 otherwise) assignments.
12911 <p><b>Rationale:</b></p>
12912 <p>Informally, we want to say that whenever we see a negative number
12913 we treat it the same as if it were zero. We believe the above
12914 changes do that (although they may not be the minimal way of saying
12915 so). The LWG considered and rejected the alternative of saying that
12916 negative numbers are undefined behavior.</p>
12918 <a name="428"><h3>428. string::erase(iterator) validity</h3></a><p><b>Section:</b> 21.3.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::erase"> [lib.string::erase]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 18 Sep 2003</p>
12920 23.1.1, p3 along with Table 67 specify as a prerequisite for a.erase(q)
12921 that q must be a valid dereferenceable iterator into the sequence a.
12925 However, 21.3.5.5, p5 describing string::erase(p) only requires that
12926 p be a valid iterator.
12930 This may be interepreted as a relaxation of the general requirement,
12931 which is most likely not the intent.
12933 <p><b>Proposed resolution:</b></p>
12934 <p>Remove 21.3.5.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::erase"> [lib.string::erase]</a> paragraph 5.</p>
12935 <p><b>Rationale:</b></p>
12936 <p>The LWG considered two options: changing the string requirements to
12937 match the general container requirements, or just removing the
12938 erroneous string requirements altogether. The LWG chose the latter
12939 option, on the grounds that duplicating text always risks the
12940 possibility that it might be duplicated incorrectly.</p>
12942 <a name="432"><h3>432. stringbuf::overflow() makes only one write position available</h3></a><p><b>Section:</b> 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Christian W Brock <b>Date:</b> 24 Sep 2003</p>
12943 <p>27.7.1.3 par 8 says:</p>
12945 Notes: The function can make a write position available only if
12946 ( mode & ios_base::out) != 0. To make a write position
12947 available, the function reallocates (or initially allocates) an
12948 array object with a sufficient number of elements to hold the
12949 current array object (if any), plus one additional write position.
12950 If ( mode & ios_base::in) != 0, the function alters the read end
12951 pointer egptr() to point just past the new write position (as
12952 does the write end pointer epptr()).
12956 The sentences "plus one additional write position." and especially
12957 "(as does the write end pointer epptr())" COULD by interpreted
12958 (and is interpreted by at least my library vendor) as:
12962 post-condition: epptr() == pptr()+1
12966 This WOULD force sputc() to call the virtual overflow() each time.
12969 <p>The proposed change also affects Defect Report 169.</p>
12971 <p><b>Proposed resolution:</b></p>
12972 <p>27.7.1.1/2 Change:</p>
12975 2- Notes: The function allocates no array object.
12983 2- Postcondition: str() == "".
12992 -3- Effects: Constructs an object of class basic_stringbuf,
12993 initializing the base class with basic_streambuf()
12994 (lib.streambuf.cons), and initializing mode with which . Then copies
12995 the content of str into the basic_stringbuf underlying character
12996 sequence and initializes the input and output sequences according to
12997 which. If which & ios_base::out is true, initializes the output
12998 sequence with the underlying sequence. If which & ios_base::in is
12999 true, initializes the input sequence with the underlying sequence.
13007 -3- Effects: Constructs an object of class basic_stringbuf,
13008 initializing the base class with basic_streambuf()
13009 (lib.streambuf.cons), and initializing mode with which. Then copies
13010 the content of str into the basic_stringbuf underlying character
13011 sequence. If which & ios_base::out is true, initializes the output
13012 sequence such that pbase() points to the first underlying character,
13013 epptr() points one past the last underlying character, and if (which &
13014 ios_base::ate) is true, pptr() is set equal to
13015 epptr() else pptr() is set equal to pbase(). If which & ios_base::in
13016 is true, initializes the input sequence such that eback() and gptr()
13017 point to the first underlying character and egptr() points one past
13018 the last underlying character.
13022 <p>27.7.1.2/1 Change:</p>
13026 -1- Returns: A basic_string object whose content is equal to the
13027 basic_stringbuf underlying character sequence. If the buffer is only
13028 created in input mode, the underlying character sequence is equal to
13029 the input sequence; otherwise, it is equal to the output sequence. In
13030 case of an empty underlying character sequence, the function returns
13031 basic_string<charT,traits,Allocator>().
13039 -1- Returns: A basic_string object whose content is equal to the
13040 basic_stringbuf underlying character sequence. If the basic_stringbuf
13041 was created only in input mode, the resultant basic_string contains
13042 the character sequence in the range [eback(), egptr()). If the
13043 basic_stringbuf was created with (which & ios_base::out) being true
13044 then the resultant basic_string contains the character sequence in the
13045 range [pbase(), high_mark) where high_mark represents the position one
13046 past the highest initialized character in the buffer. Characters can
13047 be initialized either through writing to the stream, or by
13048 constructing the basic_stringbuf with a basic_string, or by calling
13049 the str(basic_string) member function. In the case of calling the
13050 str(basic_string) member function, all characters initialized prior to
13051 the call are now considered uninitialized (except for those
13052 characters re-initialized by the new basic_string). Otherwise the
13053 basic_stringbuf has been created in neither input nor output mode and
13054 a zero length basic_string is returned.
13064 -2- Effects: If the basic_stringbuf's underlying character sequence is
13065 not empty, deallocates it. Then copies the content of s into the
13066 basic_stringbuf underlying character sequence and initializes the
13067 input and output sequences according to the mode stored when creating
13068 the basic_stringbuf object. If (mode&ios_base::out) is true, then
13069 initializes the output sequence with the underlying sequence. If
13070 (mode&ios_base::in) is true, then initializes the input sequence with
13071 the underlying sequence.
13079 -2- Effects: Copies the content of s into the basic_stringbuf
13080 underlying character sequence. If mode & ios_base::out is true,
13081 initializes the output sequence such that pbase() points to the first
13082 underlying character, epptr() points one past the last underlying
13083 character, and if (mode & ios_base::ate) is true,
13084 pptr() is set equal to epptr() else pptr() is set equal to pbase(). If
13085 mode & ios_base::in is true, initializes the input sequence such that
13086 eback() and gptr() point to the first underlying character and egptr()
13087 points one past the last underlying character.
13091 <p>Remove 27.2.1.2/3. (Same rationale as issue 238: incorrect and unnecessary.)</p>
13093 <p>27.7.1.3/1 Change:</p>
13097 1- Returns: If the input sequence has a read position available,
13098 returns traits::to_int_type(*gptr()). Otherwise, returns
13107 1- Returns: If the input sequence has a read position available,
13108 returns traits::to_int_type(*gptr()). Otherwise, returns
13109 traits::eof(). Any character in the underlying buffer which has been
13110 initialized is considered to be part of the input sequence.
13114 <p>27.7.1.3/9 Change:</p>
13118 -9- Notes: The function can make a write position available only if (
13119 mode & ios_base::out) != 0. To make a write position available, the
13120 function reallocates (or initially allocates) an array object with a
13121 sufficient number of elements to hold the current array object (if
13122 any), plus one additional write position. If ( mode & ios_base::in) !=
13123 0, the function alters the read end pointer egptr() to point just past
13124 the new write position (as does the write end pointer epptr()).
13132 -9- The function can make a write position available only if ( mode &
13133 ios_base::out) != 0. To make a write position available, the function
13134 reallocates (or initially allocates) an array object with a sufficient
13135 number of elements to hold the current array object (if any), plus one
13136 additional write position. If ( mode & ios_base::in) != 0, the
13137 function alters the read end pointer egptr() to point just past the
13138 new write position.
13142 <p>27.7.1.3/12 Change:</p>
13146 -12- _ If (newoff + off) < 0, or (xend - xbeg) < (newoff + off), the
13147 positioning operation fails. Otherwise, the function assigns xbeg +
13148 newoff + off to the next pointer xnext .
13156 -12- _ If (newoff + off) < 0, or if (newoff + off) refers to an
13157 uninitialized character (as defined in 27.7.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.members"> [lib.stringbuf.members]</a>
13158 paragraph 1), the positioning operation fails. Otherwise, the function
13159 assigns xbeg + newoff + off to the next pointer xnext .
13163 <p><i>[post-Kona: Howard provided wording. At Kona the LWG agreed that
13164 something along these lines was a good idea, but the original
13165 proposed resolution didn't say enough about the effect of various
13166 member functions on the underlying character sequences.]</i></p>
13168 <p><b>Rationale:</b></p>
13169 <p>The current basic_stringbuf description is over-constrained in such
13170 a way as to prohibit vendors from making this the high-performance
13171 in-memory stream it was meant to be. The fundamental problem is that
13172 the pointers: eback(), gptr(), egptr(), pbase(), pptr(), epptr() are
13173 observable from a derived client, and the current description
13174 restricts the range [pbase(), epptr()) from being grown geometrically.
13175 This change allows, but does not require, geometric growth of this
13178 <p>Backwards compatibility issues: These changes will break code that
13179 derives from basic_stringbuf, observes epptr(), and depends upon
13180 [pbase(), epptr()) growing by one character on each call to overflow()
13181 (i.e. test suites). Otherwise there are no backwards compatibility
13184 <p>27.7.1.1/2: The non-normative note is non-binding, and if it were
13185 binding, would be over specification. The recommended change focuses
13186 on the important observable fact.</p>
13188 <p>27.7.1.1/3: This change does two things: 1. It describes exactly
13189 what must happen in terms of the sequences. The terms "input
13190 sequence" and "output sequence" are not well defined. 2. It
13191 introduces a common extension: open with app or ate mode. I concur
13192 with issue 238 that paragraph 4 is both wrong and unnecessary.</p>
13194 <p>27.7.1.2/1: This change is the crux of the efficiency issue. The
13195 resultant basic_string is not dependent upon epptr(), and thus
13196 implementors are free to grow the underlying buffer geometrically
13197 during overflow() *and* place epptr() at the end of that buffer.</p>
13199 <p>27.7.1.2/2: Made consistent with the proposed 27.7.1.1/3.</p>
13201 <p>27.7.1.3/1: Clarifies that characters written to the stream beyond
13202 the initially specified string are available for reading in an i/o
13203 basic_streambuf.</p>
13205 <p>27.7.1.3/9: Made normative by removing "Notes:", and removed the
13206 trailing parenthetical comment concerning epptr().</p>
13208 <p>27.7.1.3/12: Restricting the positioning to [xbeg, xend) is no
13209 longer allowable since [pbase(), epptr()) may now contain
13210 uninitialized characters. Positioning is only allowable over the
13211 initialized range.</p>
13213 <a name="434"><h3>434. bitset::to_string() hard to use</h3></a><p><b>Section:</b> 23.3.5.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.members"> [lib.bitset.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 15 Oct 2003</p>
13215 It has been pointed out a number of times that the bitset to_string() member
13216 function template is tedious to use since callers must explicitly specify the
13217 entire template argument list (3 arguments). At least two implementations
13218 provide a number of overloads of this template to make it easier to use.
13220 <p><b>Proposed resolution:</b></p>
13221 <p>In order to allow callers to specify no template arguments at all, just the
13222 first one (charT), or the first 2 (charT and traits), in addition to all
13223 three template arguments, add the following three overloads to both the
13224 interface (declarations only) of the class template bitset as well as to
13225 section 23.3.5.2, immediately after p34, the Returns clause of the existing
13226 to_string() member function template:</p>
13228 <pre> template <class charT, class traits>
13229 basic_string<charT, traits, allocator<charT> >
13230 to_string () const;
13232 -34.1- Returns: to_string<charT, traits, allocator<charT> >().
13234 template <class charT>
13235 basic_string<charT, char_traits<charT>, allocator<charT> >
13236 to_string () const;
13238 -34.2- Returns: to_string<charT, char_traits<charT>, allocator<charT> >().
13240 basic_string<char, char_traits<char>, allocator<char> >
13241 to_string () const;
13243 -34.3- Returns: to_string<char, char_traits<char>, allocator<char> >().
13246 <p><i>[Kona: the LWG agrees that this is an improvement over the
13247 status quo. Dietmar thought about an alternative using a proxy
13248 object but now believes that the proposed resolution above is the
13253 <a name="435"><h3>435. bug in DR 25</h3></a><p><b>Section:</b> 21.3.7.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string.io"> [lib.string.io]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 15 Oct 2003</p>
13256 It has been pointed out that the proposed resolution in DR 25 may not be
13257 quite up to snuff: <br>
13258 http://gcc.gnu.org/ml/libstdc++/2003-09/msg00147.html
13259 http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#25<br>
13263 It looks like Petur is right. The complete corrected text is copied below.
13264 I think we may have have been confused by the reference to 22.2.2.2.2 and
13265 the subsequent description of `n' which actually talks about the second
13266 argument to sputn(), not about the number of fill characters to pad with.
13270 So the question is: was the original text correct? If the intent was to
13271 follow classic iostreams then it most likely wasn't, since setting width()
13272 to less than the length of the string doesn't truncate it on output. This
13273 is also the behavior of most implementations (except for SGI's standard
13274 iostreams where the operator does truncate).
13276 <p><b>Proposed resolution:</b></p>
13277 <p>Change the text in 21.3.7.9, p4 from</p>
13279 If bool(k) is true, inserts characters as if by calling
13280 os.rdbuf()->sputn(str.data(), n), padding as described in stage 3
13281 of lib.facet.num.put.virtuals, where n is the larger of os.width()
13286 If bool(k) is true, determines padding as described in
13287 lib.facet.num.put.virtuals, and then inserts the resulting
13288 sequence of characters <tt>seq</tt> as if by calling
13289 <tt>os.rdbuf()->sputn(seq, n)</tt>, where <tt>n</tt> is the larger of
13290 <tt>os.width()</tt> and <tt>str.size()</tt>;
13293 <p><i>[Kona: it appears that neither the original wording, DR25, nor the
13294 proposed resolution, is quite what we want. We want to say that
13295 the string will be output, padded to os.width() if necessary. We
13296 don't want to duplicate the padding rules in clause 22, because
13297 they're complicated, but we need to be careful because they weren't
13298 quite written with quite this case in mind. We need to say what
13299 the character sequence is, and then defer to clause 22. Post-Kona:
13300 Benjamin provided wording.]</i></p>
13303 <a name="436"><h3>436. are cv-qualified facet types valid facets?</h3></a><p><b>Section:</b> 22.1.1.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.facet"> [lib.locale.facet]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 15 Oct 2003</p>
13305 Is "const std::ctype<char>" a valid template argument to has_facet, use_facet,
13306 and the locale template ctor? And if so, does it designate the same Facet as
13307 the non-const "std::ctype<char>?" What about "volatile std::ctype<char>?"
13308 Different implementations behave differently: some fail to compile, others
13309 accept such types but behave inconsistently.
13311 <p><b>Proposed resolution:</b></p>
13312 <p>Change 22.1.1.1.2, p1 to read:</p>
13314 <p>Template parameters in this clause which are required to be facets
13315 are those named Facet in declarations. A program that passes a type
13316 that is not a facet, or a type that refers to volatile-qualified
13317 facet, as an (explicit or deduced) template parameter to a locale
13318 function expecting a facet, is ill-formed. A const-qualified facet is
13319 a valid template argument to any locale function that expects a Facet
13320 template parameter.</p>
13322 <p><i>[Kona: changed the last sentence from a footnote to normative
13326 <a name="438"><h3>438. Ambiguity in the "do the right thing" clause</h3></a><p><b>Section:</b> 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 20 Oct 2003</p>
13328 <p>Section 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a>, paragraphs 9-11, fixed up the problem
13329 noticed with statements like:</p>
13330 <pre>vector<int> v(10, 1);
13333 <p>The intent of the above statement was to construct with:</p>
13334 <pre>vector(size_type, const value_type&);
13337 <p>but early implementations failed to compile as they bound to:</p>
13338 <pre>template <class InputIterator>
13339 vector(InputIterator f, InputIterator l);
13343 <p>Paragraphs 9-11 say that if InputIterator is an integral type, then the
13344 member template constructor will have the same effect as:</p>
13345 <pre>vector<static_cast<size_type>(f), static_cast<value_type>(l));
13347 <p>(and similarly for the other member template functions of sequences).</p>
13349 <p>There is also a note that describes one implementation technique:</p>
13351 One way that sequence implementors can satisfy this requirement is to
13352 specialize the member template for every integral type.
13355 <p>This might look something like:</p>
13357 <pre>template <class T>
13360 typedef unsigned size_type;
13362 explicit vector(size_type) {}
13363 vector(size_type, const T&) {}
13365 template <class I>
13371 template <class T>
13372 template <class I>
13373 vector<T>::vector(I, I) { ... }
13377 vector<int>::vector(int, int) { ... }
13381 vector<int>::vector(unsigned, unsigned) { ... }
13387 <p>Label this solution 'A'.</p>
13389 <p>The standard also says:</p>
13391 Less cumbersome implementation techniques also exist.
13394 A popular technique is to not specialize as above, but instead catch
13395 every call with the member template, detect the type of InputIterator,
13396 and then redirect to the correct logic. Something like:
13399 <pre>template <class T>
13400 template <class I>
13401 vector<T>::vector(I f, I l)
13403 choose_init(f, l, int2type<is_integral<I>::value>());
13406 template <class T>
13407 template <class I>
13408 vector<T>::choose_init(I f, I l, int2type<false>)
13410 // construct with iterators
13413 template <class T>
13414 template <class I>
13415 vector<T>::choose_init(I f, I l, int2type<true>)
13417 size_type sz = static_cast<size_type>(f);
13418 value_type v = static_cast<value_type>(l);
13419 // construct with sz,v
13424 <p>Label this solution 'B'.</p>
13426 <p>Both of these solutions solve the case the standard specifically
13428 <pre>vector<int> v(10, 1); // ok, vector size 10, initialized to 1
13432 However, (and here is the problem), the two solutions have different
13433 behavior in some cases where the value_type of the sequence is not an
13434 integral type. For example consider:
13436 <blockquote><pre> pair<char, char> p('a', 'b');
13437 vector<vector<pair<char, char> > > d('a', 'b');
13438 </pre></blockquote>
13440 The second line of this snippet is likely an error. Solution A catches
13441 the error and refuses to compile. The reason is that there is no
13442 specialization of the member template constructor that looks like:
13444 <pre>template <>
13446 vector<vector<pair<char, char> > >::vector(char, char) { ... }
13450 So the expression binds to the unspecialized member template
13451 constructor, and then fails (compile time) because char is not an
13456 Solution B compiles the above example though. 'a' is casted to an
13457 unsigned integral type and used to size the outer vector. 'b' is
13458 static casted to the inner vector using it's explicit constructor:
13461 <pre>explicit vector(size_type n);
13465 and so you end up with a static_cast<size_type>('a') by
13466 static_cast<size_type>('b') matrix.
13470 It is certainly possible that this is what the coder intended. But the
13471 explicit qualifier on the inner vector has been thwarted at any rate.
13475 The standard is not clear whether the expression:
13478 <pre> vector<vector<pair<char, char> > > d('a', 'b');
13482 (and similar expressions) are:
13486 <li> undefined behavior.</li>
13487 <li> illegal and must be rejected.</li>
13488 <li> legal and must be accepted.</li>
13491 <p>My preference is listed in the order presented.</p>
13493 <p>There are still other techniques for implementing the requirements of
13494 paragraphs 9-11, namely the "restricted template technique" (e.g.
13495 enable_if). This technique is the most compact and easy way of coding
13496 the requirements, and has the behavior of #2 (rejects the above
13501 Choosing 1 would allow all implementation techniques I'm aware of.
13502 Choosing 2 would allow only solution 'A' and the enable_if technique.
13503 Choosing 3 would allow only solution 'B'.
13507 Possible wording for a future standard if we wanted to actively reject
13508 the expression above would be to change "static_cast" in paragraphs
13509 9-11 to "implicit_cast" where that is defined by:
13513 <pre>template <class T, class U>
13515 T implicit_cast(const U& u)
13522 <p><b>Proposed resolution:</b></p>
13524 Replace 23.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.sequence.reqmts"> [lib.sequence.reqmts]</a> paragraphs 9 - 11 with:
13526 <p>For every sequence defined in this clause and in clause lib.strings:</p>
13530 <p>If the constructor</p>
13531 <pre> template <class InputIterator>
13532 X(InputIterator f, InputIterator l,
13533 const allocator_type& a = allocator_type())
13535 <p>is called with a type InputIterator that does not qualify as
13536 an input iterator, then the constructor will behave as if the
13537 overloaded constructor:</p>
13538 <pre> X(size_type, const value_type& = value_type(),
13539 const allocator_type& = allocator_type())
13541 <p>were called instead, with the arguments static_cast<size_type>(f), l and a, respectively.</p>
13545 <p>If the member functions of the forms:</p>
13546 <pre> template <class InputIterator> // such as insert()
13547 rt fx1(iterator p, InputIterator f, InputIterator l);
13549 template <class InputIterator> // such as append(), assign()
13550 rt fx2(InputIterator f, InputIterator l);
13552 template <class InputIterator> // such as replace()
13553 rt fx3(iterator i1, iterator i2, InputIterator f, InputIterator l);
13555 <p>are called with a type InputIterator that does not qualify as
13556 an input iterator, then these functions will behave as if the
13557 overloaded member functions:</p>
13558 <pre> rt fx1(iterator, size_type, const value_type&);
13560 rt fx2(size_type, const value_type&);
13562 rt fx3(iterator, iterator, size_type, const value_type&);
13564 <p>were called instead, with the same arguments.</p>
13568 <p>In the previous paragraph the alternative binding will fail if f
13569 is not implicitly convertible to X::size_type or if l is not implicitly
13570 convertible to X::value_type.</p>
13573 The extent to which an implementation determines that a type cannot be
13574 an input iterator is unspecified, except that as a minimum integral
13575 types shall not qualify as input iterators.
13581 Kona: agreed that the current standard requires <tt>v('a', 'b')</tt>
13582 to be accepted, and also agreed that this is surprising behavior. The
13583 LWG considered several options, including something like
13584 implicit_cast, which doesn't appear to be quite what we want. We
13585 considered Howards three options: allow acceptance or rejection,
13586 require rejection as a compile time error, and require acceptance. By
13587 straw poll (1-6-1), we chose to require a compile time error.
13588 Post-Kona: Howard provided wording.
13592 Sydney: The LWG agreed with this general direction, but there was some
13593 discomfort with the wording in the original proposed resolution.
13594 Howard submitted new wording, and we will review this again in
13598 <p><i>[Redmond: one very small change in wording: the first argument
13599 is cast to size_t. This fixes the problem of something like
13600 <tt>vector<vector<int> >(5, 5)</tt>, where int is not
13601 implicitly convertible to the value type.]</i></p>
13603 <p><b>Rationale:</b></p>
13604 <p>The proposed resolution fixes:</p>
13606 <pre> vector<int> v(10, 1);
13610 since as integral types 10 and 1 must be disqualified as input
13611 iterators and therefore the (size,value) constructor is called (as
13614 <p>The proposed resolution breaks:</p>
13616 <pre> vector<vector<T> > v(10, 1);
13620 because the integral type 1 is not *implicitly* convertible to
13621 vector<T>. The wording above requires a diagnostic.</p>
13624 The proposed resolution leaves the behavior of the following code
13630 operator int () const {return 10;}
13638 vector<B> v(A(), A());
13642 The implementation may or may not detect that A is not an input
13643 iterator and employee the (size,value) constructor. Note though that
13644 in the above example if the B(A) constructor is qualified explicit,
13645 then the implementation must reject the constructor as A is no longer
13646 implicitly convertible to B.
13649 <a name="441"><h3>441. Is fpos::state const?</h3></a><p><b>Section:</b> 27.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fpos"> [lib.fpos]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Vincent Leloup <b>Date:</b> 17 Nov 2003</p>
13651 In section 27.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fpos.members"> [lib.fpos.members]</a> fpos<stateT>::state() is declared
13652 non const, but in section 27.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fpos"> [lib.fpos]</a> it is declared const.
13654 <p><b>Proposed resolution:</b></p>
13656 In section 27.4.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fpos.members"> [lib.fpos.members]</a>, change the declaration of
13657 <tt>fpos<stateT>::state()</tt> to const.
13660 <a name="442"><h3>442. sentry::operator bool() inconsistent signature</h3></a><p><b>Section:</b> 27.6.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream::sentry"> [lib.ostream::sentry]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Vincent Leloup <b>Date:</b> 18 Nov 2003</p>
13662 In section 27.6.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream::sentry"> [lib.ostream::sentry]</a> paragraph 4, in description part
13663 basic_ostream<charT, traits>::sentry::operator bool() is declared
13664 as non const, but in section 27.6.2.3, in synopsis it is declared
13667 <p><b>Proposed resolution:</b></p>
13669 In section 27.6.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream::sentry"> [lib.ostream::sentry]</a> paragraph 4, change the declaration
13670 of <tt>sentry::operator bool()</tt> to const.
13673 <a name="443"><h3>443. filebuf::close() inconsistent use of EOF</h3></a><p><b>Section:</b> 27.8.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.members"> [lib.filebuf.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Vincent Leloup <b>Date:</b> 20 Nov 2003</p>
13675 In section 27.8.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.filebuf.members"> [lib.filebuf.members]</a> par6, in effects description of
13676 basic_filebuf<charT, traits>::close(), overflow(EOF) is used twice;
13677 should be overflow(traits::eof()).
13679 <p><b>Proposed resolution:</b></p>
13681 Change overflow(EOF) to overflow(traits::eof()).
13684 <a name="444"><h3>444. Bad use of casts in fstream</h3></a><p><b>Section:</b> 27.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstreams"> [lib.fstreams]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Vincent Leloup <b>Date:</b> 20 Nov 2003</p>
13686 27.8.1.7 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ifstream.members"> [lib.ifstream.members]</a> p1, 27.8.1.10 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ofstream.members"> [lib.ofstream.members]</a> p1, 27.8.1.13 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstream.members"> [lib.fstream.members]</a> p1 seems have same problem as exposed in LWG issue
13687 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#252">252</a>.
13689 <p><b>Proposed resolution:</b></p>
13691 <p><i>[Sydney: Genuine defect. 27.8.1.13 needs a cast to cast away
13692 constness. The other two places are stylistic: we could change the
13693 C-style casts to const_cast. Post-Sydney: Howard provided wording.
13696 <p>Change 27.8.1.7/1 from:</p>
13698 Returns: (basic_filebuf<charT,traits>*)&sb.
13703 Returns: const_cast<basic_filebuf<charT,traits>*>(&sb).
13706 <p>Change 27.8.1.10/1 from:</p>
13708 Returns: (basic_filebuf<charT,traits>*)&sb.
13713 Returns: const_cast<basic_filebuf<charT,traits>*>(&sb).
13716 <p>Change 27.8.1.13/1 from:</p>
13723 Returns: const_cast<basic_filebuf<charT,traits>*>(&sb).
13729 <a name="445"><h3>445. iterator_traits::reference unspecified for some iterator categories</h3></a><p><b>Section:</b> 24.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.traits"> [lib.iterator.traits]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 9 Dec 2003</p>
13731 The standard places no restrictions at all on the reference type
13732 of input, output, or forward iterators (for forward iterators it
13733 only specifies that *x must be value_type& and doesn't mention
13734 the reference type). Bidirectional iterators' reference type is
13735 restricted only by implication, since the base iterator's
13736 reference type is used as the return type of reverse_iterator's
13737 operator*, which must be T& in order to be a conforming forward
13742 Here's what I think we ought to be able to expect from an input
13743 or forward iterator's reference type R, where a is an iterator
13744 and V is its value_type
13749 *a is convertible to R
13753 R is convertible to V
13757 static_cast<V>(static_cast<R>(*a)) is equivalent to
13758 static_cast<V>(*a)
13762 <p>A mutable forward iterator ought to satisfy, for x of type V:</p>
13764 { R r = *a; r = x; } is equivalent to *a = x;
13768 I think these requirements capture existing container iterators
13769 (including vector<bool>'s), but render istream_iterator invalid;
13770 its reference type would have to be changed to a constant
13776 (Jeremy Siek) During the discussion in Sydney, it was felt that a
13777 simpler long term solution for this was needed. The solution proposed
13778 was to require <tt>reference</tt> to be the same type as <tt>*a</tt>
13779 and <tt>pointer</tt> to be the same type as <tt>a-></tt>. Most
13780 iterators in the Standard Library already meet this requirement. Some
13781 iterators are output iterators, and do not need to meet the
13782 requirement, and others are only specified through the general
13783 iterator requirements (which will change with this resolution). The
13784 sole case where there is an explicit definition of the reference type
13785 that will need to change is <tt>istreambuf_iterator</tt> which returns
13786 <tt>charT</tt> from <tt>operator*</tt> but has a reference type of
13787 <tt>charT&</tt>. We propose changing the reference type of
13788 <tt>istreambuf_iterator</tt> to <tt>charT</tt>.
13791 <p>The other option for resolving the issue with <tt>pointer</tt>,
13792 mentioned in the note below, is to remove <tt>pointer</tt>
13793 altogether. I prefer placing requirements on <tt>pointer</tt> to
13794 removing it for two reasons. First, <tt>pointer</tt> will become
13795 useful for implementing iterator adaptors and in particular,
13796 <tt>reverse_iterator</tt> will become more well defined. Second,
13797 removing <tt>pointer</tt> is a rather drastic and publicly-visible
13798 action to take.</p>
13800 <p>The proposed resolution technically enlarges the requirements for
13801 iterators, which means there are existing iterators (such as
13802 <tt>istreambuf_iterator</tt>, and potentially some programmer-defined
13803 iterators) that will no longer meet the requirements. Will this break
13804 existing code? The scenario in which it would is if an algorithm
13805 implementation (say in the Standard Library) is changed to rely on
13806 <tt>iterator_traits::reference</tt>, and then is used with one of the
13807 iterators that do not have an appropriately defined
13808 <tt>iterator_traits::reference</tt>.
13812 <p>The proposed resolution makes one other subtle change. Previously,
13813 it was required that output iterators have a <tt>difference_type</tt>
13814 and <tt>value_type</tt> of <tt>void</tt>, which means that a forward
13815 iterator could not be an output iterator. This is clearly a mistake,
13816 so I've changed the wording to say that those types may be
13820 <p><b>Proposed resolution:</b></p>
13822 <p>In 24.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.traits"> [lib.iterator.traits]</a>, after:</p>
13825 be defined as the iterator's difference type, value type and iterator
13826 category, respectively.
13832 In addition, the types
13833 <pre>iterator_traits<Iterator>::reference
13834 iterator_traits<Iterator>::pointer
13836 must be defined as the iterator's reference and pointer types, that
13837 is, the same type as the type of <tt>*a</tt> and <tt>a-></tt>,
13841 <p>In 24.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.iterator.traits"> [lib.iterator.traits]</a>, change:</p>
13844 In the case of an output iterator, the types
13845 <pre>iterator_traits<Iterator>::difference_type
13846 iterator_traits<Iterator>::value_type
13848 are both defined as <tt>void</tt>.
13853 In the case of an output iterator, the types
13854 <pre>iterator_traits<Iterator>::difference_type
13855 iterator_traits<Iterator>::value_type
13856 iterator_traits<Iterator>::reference
13857 iterator_traits<Iterator>::pointer
13859 may be defined as <tt>void</tt>.
13862 <p>In 24.5.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.istreambuf.iterator"> [lib.istreambuf.iterator]</a>, change:</p>
13864 <pre>typename traits::off_type, charT*, charT&>
13869 <pre>typename traits::off_type, charT*, charT>
13874 Redmond: there was concern in Sydney that this might not be the only place
13875 where things were underspecified and needed to be changed. Jeremy
13876 reviewed iterators in the standard and confirmed that nothing else
13877 needed to be changed.
13881 <a name="448"><h3>448. Random Access Iterators over abstract classes</h3></a><p><b>Section:</b> 24.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.random.access.iterators"> [lib.random.access.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 7 Jan 2004</p>
13883 Table 76, the random access iterator requirement table, says that the
13884 return type of a[n] must be "convertible to T". When an iterator's
13885 value_type T is an abstract class, nothing is convertible to T.
13886 Surely this isn't an intended restriction?
13888 <p><b>Proposed resolution:</b></p>
13890 Change the return type to "convertible to T const&".
13893 <a name="449"><h3>449. Library Issue 306 Goes Too Far</h3></a><p><b>Section:</b> 18.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.support.types"> [lib.support.types]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Pete Becker <b>Date:</b> 15 Jan 2004</p>
13894 <p>Original text:</p>
13896 The macro offsetof accepts a restricted set of type arguments in this
13897 International Standard. type shall be a POD structure or a POD union
13898 (clause 9). The result of applying the offsetof macro to a field that
13899 is a static data member or a function member is undefined."
13902 <p>Revised text:</p>
13904 "If type is not a POD structure or a POD union the results are undefined."
13908 Looks to me like the revised text should have replaced only the second
13909 sentence. It doesn't make sense standing alone.
13912 <p><b>Proposed resolution:</b></p>
13913 <p>Change 18.1, paragraph 5, to:</p>
13916 The macro offsetof accepts a restricted set of type arguments in this
13917 International Standard. If type is not a POD structure or a POD union
13918 the results are undefined. The result of applying the offsetof macro
13919 to a field that is a static data member or a function member is
13923 <a name="453"></a><h3><a name="453">453. basic_stringbuf::seekoff need not always fail for an empty stream</a></h3><p><b>Section:</b> 27.7.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.stringbuf.virtuals"> [lib.stringbuf.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Bill Plauger <b>Date:</b> 30 Jan 2004</p>
13924 <pre> pos_type basic_stringbuf::seekoff(off_type, ios_base::seekdir,
13925 ios_base::openmode);
13928 is obliged to fail if nothing has been inserted into the stream. This
13929 is unnecessary and undesirable. It should be permissible to seek to
13930 an effective offset of zero.</p>
13933 Sydney: Agreed that this is an annoying problem: seeking to zero should be
13934 legal. Bill will provide wording.
13937 <p><b>Proposed resolution:</b></p>
13938 <p>Change the sentence from:</p>
13940 For a sequence to be positioned, if its next pointer (either
13941 gptr() or pptr()) is a null pointer, the positioning operation
13948 For a sequence to be positioned, if its next pointer (either
13949 gptr() or pptr()) is a null pointer and the new offset newoff
13950 is nonzero, the positioning operation fails.
13953 <a name="455"><h3>455. cerr::tie() and wcerr::tie() are overspecified</h3></a><p><b>Section:</b> 27.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostream.objects"> [lib.iostream.objects]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Bill Plauger <b>Date:</b> 30 Jan 2004</p>
13955 Both cerr::tie() and wcerr::tie() are obliged to be null at program
13956 startup. This is overspecification and overkill. It is both traditional
13957 and useful to tie cerr to cout, to ensure that standard output is drained
13958 whenever an error message is written. This behavior should at least be
13959 permitted if not required. Same for wcerr::tie().
13961 <p><b>Proposed resolution:</b></p>
13963 <p>Add to the description of cerr:</p>
13965 After the object cerr is initialized, cerr.tie() returns &cout.
13966 Its state is otherwise the same as required for basic_ios<char>::init
13967 (lib.basic.ios.cons).
13970 <p>Add to the description of wcerr:</p>
13973 After the object wcerr is initialized, wcerr.tie() returns &wcout.
13974 Its state is otherwise the same as required for basic_ios<wchar_t>::init
13975 (lib.basic.ios.cons).
13978 <p><i>[Sydney: straw poll (3-1): we should <i>require</i>, not just
13979 permit, cout and cerr to be tied on startup. Pre-Redmond: Bill will
13980 provide wording.]</i></p>
13982 <a name="457"><h3>457. bitset constructor: incorrect number of initialized bits</h3></a><p><b>Section:</b> 23.3.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.cons"> [lib.bitset.cons]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Dag Henriksson <b>Date:</b> 30 Jan 2004</p>
13984 The constructor from unsigned long says it initializes "the first M
13985 bit positions to the corresponding bit values in val. M is the smaller
13986 of N and the value CHAR_BIT * sizeof(unsigned long)."
13990 Object-representation vs. value-representation strikes again. CHAR_BIT *
13991 sizeof (unsigned long) does not give us the number of bits an unsigned long
13992 uses to hold the value. Thus, the first M bit position above is not
13993 guaranteed to have any corresponding bit values in val.
13995 <p><b>Proposed resolution:</b></p>
13996 <p>In 23.3.5.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.bitset.cons"> [lib.bitset.cons]</a> paragraph 2, change "M is the smaller of
13997 N and the value CHAR_BIT * sizeof (unsigned long). (249)" to
13998 "<tt>M</tt> is the smaller of <tt>N</tt> and the number of bits in
13999 the value representation (section 3.9 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/basic.html#basic.types"> [basic.types]</a>) of <tt>unsigned
14003 <a name="460"><h3>460. Default modes missing from basic_fstream member specifications</h3></a><p><b>Section:</b> 27.8.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstreams"> [lib.fstreams]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Ben Hutchings <b>Date:</b> 1 Apr 2004</p>
14005 The second parameters of the non-default constructor and of the open
14006 member function for basic_fstream, named "mode", are optional
14007 according to the class declaration in 27.8.1.11 [lib.fstream]. The
14008 specifications of these members in 27.8.1.12 [lib.fstream.cons] and
14009 27.8.1.13 lib.fstream.members] disagree with this, though the
14010 constructor declaration has the "explicit" function-specifier implying
14011 that it is intended to be callable with one argument.
14013 <p><b>Proposed resolution:</b></p>
14014 <p>In 27.8.1.12 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstream.cons"> [lib.fstream.cons]</a>, change</p>
14015 <pre> explicit basic_fstream(const char* s, ios_base::openmode mode);
14018 <pre> explicit basic_fstream(const char* s,
14019 ios_base::openmode mode = ios_base::in|ios_base::out);
14021 <p>In 27.8.1.13 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.fstream.members"> [lib.fstream.members]</a>, change</p>
14022 <pre> void open(const char*s, ios_base::openmode mode);
14025 void open(const char*s,
14026 ios_base::openmode mode = ios_base::in|ios_base::out);
14028 <a name="461"><h3>461. time_get hard or impossible to implement</h3></a><p><b>Section:</b> 22.2.5.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.locale.time.get.virtuals"> [lib.locale.time.get.virtuals]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Bill Plauger <b>Date:</b> 23 Mar 2004</p>
14030 Template time_get currently contains difficult, if not impossible,
14031 requirements for do_date_order, do_get_time, and do_get_date. All require
14032 the implementation to scan a field generated by the %x or %X conversion
14033 specifier in strftime. Yes, do_date_order can always return no_order, but
14034 that doesn't help the other functions. The problem is that %x can be
14035 nearly anything, and it can vary widely with locales. It's horribly
14036 onerous to have to parse "third sunday after Michaelmas in the year of
14037 our Lord two thousand and three," but that's what we currently ask of
14038 do_get_date. More practically, it leads some people to think that if
14039 %x produces 10.2.04, we should know to look for dots as separators. Still
14044 Note that this is the <i>opposite</i> effect from the intent stated in the
14045 footnote earlier in this subclause:
14049 "In other words, user confirmation is required for reliable parsing of
14050 user-entered dates and times, but machine-generated formats can be
14051 parsed reliably. This allows parsers to be aggressive about interpreting
14052 user variations on standard formats."
14056 We should give both implementers and users an easier and more reliable
14057 alternative: provide a (short) list of alternative delimiters and say
14058 what the default date order is for no_order. For backward compatibility,
14059 and maximum latitude, we can permit an implementation to parse whatever
14060 %x or %X generates, but we shouldn't require it.
14062 <p><b>Proposed resolution:</b></p>
14064 <p><b>In the description:</b></p>
14065 <pre>iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
14066 ios_base::iostate& err, tm* t) const;
14070 2 Effects: Reads characters starting at suntil it has extracted those
14071 struct tm members, and remaining format characters, used by
14072 time_put<>::put to produce the format specified by 'X', or until it
14073 encounters an error or end of sequence.
14076 <p><b>change:</b> 'X'</p>
14078 <p><b>to:</b> "%H:%M:%S"</p>
14082 <pre>iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
14083 ios_base::iostate& err, tm* t) const;
14085 4 Effects: Reads characters starting at s until it has extracted those
14086 struct tm members, and remaining format characters, used by
14087 time_put<>::put to produce the format specified by 'x', or until it
14088 encounters an error.
14092 iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
14093 ios_base::iostate& err, tm* t) const;
14095 4 Effects: Reads characters starting at s until it has extracted those
14096 struct tm members, and remaining format characters, used by
14097 time_put<>::put to produce one of the following formats, or until it
14098 encounters an error. The format depends on the value returned by
14099 date_order() as follows:
14101 date_order() format
14103 no_order "%m/%d/%y"
14109 An implementation may also accept additional implementation-defined formats.
14112 <p><i>[Redmond: agreed that this is a real problem. The solution is
14113 probably to match C99's parsing rules. Bill provided wording.
14117 <a name="464"><h3>464. Suggestion for new member functions in standard containers</h3></a><p><b>Section:</b> 23.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.adaptors"> [lib.container.adaptors]</a>, 23.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map"> [lib.map]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Thorsten Ottosen <b>Date:</b> 12 May 2004</p>
14119 <p>To add slightly more convenience to vector<T> and map<Key,T> we should consider to add</p>
14121 <li> add vector<T>::data() member (const and non-const version)
14122 semantics: if( empty() ) return 0; else return buffer_;</li>
14123 <li> add map<Key,T>::at( const Key& k ) member (const and non-const version)
14124 <i>semantics</i>: iterator i = find( k ); if( i != end() ) return *i; else throw range_error();</li>
14130 <li>To obtain a pointer to the vector's buffer, one must use either
14131 operator[]() (which can give undefined behavior for empty vectors) or
14132 at() (which will then throw if the vector is empty). </li>
14133 <li>tr1::array<T,sz> already has a data() member</li>
14134 <li>e cannot use operator[]() when T is not DefaultDonstructible</li>
14135 <li>Neither when the map is const.</li>
14136 <li>when we want to make sure we don't add an element accidently</li>
14137 <li>when it should be considered an error if a key is not in the map</li>
14140 <p><b>Proposed resolution:</b></p>
14141 <p>In 23.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.adaptors"> [lib.container.adaptors]</a>, add the following to the <tt>vector</tt>
14142 synopsis after "element access" and before "modifiers":</p>
14143 <pre> // <i>[lib.vector.data] data access</i>
14145 const_pointer data() const;
14148 <p>Add a new subsection of 23.2.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.container.adaptors"> [lib.container.adaptors]</a>:</p>
14150 <p>23.2.4.x <tt>vector</tt> data access</p>
14151 <pre> pointer data();
14152 const_pointer data() const;
14154 <p><b>Returns:</b> A pointer such that [data(), data() + size()) is a valid
14155 range. For a non-empty vector, data() == &front().</p>
14156 <p><b>Complexity:</b> Constant time.</p>
14157 <p><b>Throws:</b> Nothing.</p>
14160 <p>In 23.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map"> [lib.map]</a>, add the following to the <tt>map</tt>
14161 synopsis immediately after the line for operator[]:</p>
14162 <pre> T& at(const key_type& x);
14163 const T& at(const key_type& x) const;
14166 <p>Add the following to 23.3.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.map.access"> [lib.map.access]</a>:</p>
14168 <pre> T& at(const key_type& x);
14169 const T& at(const key_type& x) const;
14172 <p><b>Returns:</b> A reference to the element whose key is equivalent
14173 to x, if such an element is present in the map.</p>
14174 <p><b>Throws:</b> <tt>out_of_range</tt> if no such element is present.</p>
14178 <p><b>Rationale:</b></p>
14179 <p>Neither of these additions provides any new functionality but the
14180 LWG agreed that they are convenient, especially for novices. The
14181 exception type chosen for <tt>at</tt>, <tt>std::out_of_range</tt>,
14182 was chosen to match <tt>vector::at</tt>.</p>
14184 <a name="465"><h3>465. Contents of <ciso646></h3></a><p><b>Section:</b> 17.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.headers"> [lib.headers]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Steve Clamage <b>Date:</b> 3 Jun 2004</p>
14185 <p>C header <iso646.h> defines macros for some operators, such as
14188 <p>Section 17.4.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.headers"> [lib.headers]</a> "Headers" says that except as noted in
14189 clauses 18 through 27, the <cname> C++ header contents are the same
14190 as the C header <name.h>. In particular, table 12 lists
14191 <ciso646> as a C++ header.</p>
14193 <p>I don't find any other mention of <ciso646>, or any mention of
14194 <iso646.h>, in clauses 17 thorough 27. That implies that the
14195 contents of <ciso646> are the same as C header <iso646.h>.</p>
14197 <p>Annex C (informative, not normative) in [diff.header.iso646.h] C.2.2.2
14198 "Header <iso646.h>" says that the alternative tokens are not
14199 defined as macros in <ciso646>, but does not mention the contents
14200 of <iso646.h>.</p>
14202 <p>I don't find any normative text to support C.2.2.2.</p>
14204 <p><b>Proposed resolution:</b></p>
14205 <p>Add to section 17.4.1.2 Headers [lib.headers] a new paragraph after
14206 paragraph 6 (the one about functions must be functions):</p>
14209 <p>Identifiers that are keywords or operators in C++ shall not be defined
14210 as macros in C++ standard library headers.
14211 [Footnote:In particular, including the standard header <iso646.h>
14212 or <ciso646> has no effect. </p>
14215 <p><i>[post-Redmond: Steve provided wording.]</i></p>
14218 <a name="467"><h3>467. char_traits::lt(), compare(), and memcmp()</h3></a><p><b>Section:</b> 21.1.3.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.char.traits.specializations.char"> [lib.char.traits.specializations.char]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 28 Jun 2004</p>
14221 Table 37 describes the requirements on Traits::compare() in terms of
14222 those on Traits::lt(). 21.1.3.1, p6 requires char_traits<char>::lt()
14223 to yield the same result as operator<(char, char).
14227 Most, if not all, implementations of char_traits<char>::compare()
14228 call memcmp() for efficiency. However, the C standard requires both
14229 memcmp() and strcmp() to interpret characters under comparison as
14230 unsigned, regardless of the signedness of char. As a result, all
14231 these char_traits implementations fail to meet the requirement
14232 imposed by Table 37 on compare() when char is signed.
14236 <p>Read email thread starting with c++std-lib-13499 for more. </p>
14237 <p><b>Proposed resolution:</b></p>
14240 <p>Change 21.1.3.1, p6 from</p>
14242 The two-argument members assign, eq, and lt are defined identically
14243 to the built-in operators =, ==, and < respectively.
14247 The two-argument member assign is defined identically to
14248 the built-in operator =. The two
14249 argument members eq and lt are defined identically to
14250 the built-in operators == and < for type unsigned char.
14253 <p><i>[Redmond: The LWG agreed with this general direction, but we
14254 also need to change <tt>eq</tt> to be consistent with this change.
14255 Post-Redmond: Martin provided wording.]</i></p>
14258 <a name="468"><h3>468. unexpected consequences of ios_base::operator void*()</h3></a><p><b>Section:</b> 27.4.4.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.iostate.flags"> [lib.iostate.flags]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 28 Jun 2004</p>
14260 <p>The program below is required to compile but when run it typically
14261 produces unexpected results due to the user-defined conversion from
14262 std::cout or any object derived from basic_ios to void*.
14265 <pre> #include <cassert>
14266 #include <iostream>
14270 assert (std::cin.tie () == std::cout);
14271 // calls std::cout.ios::operator void*()
14275 <p><b>Proposed resolution:</b></p>
14278 Replace std::basic_ios<charT, traits>::operator void*() with another
14279 conversion operator to some unspecified type that is guaranteed not
14280 to be convertible to any other type except for bool (a pointer-to-member
14281 might be one such suitable type). In addition, make it clear that the
14282 pointer type need not be a pointer to a complete type and when non-null,
14283 the value need not be valid.
14286 <p>Specifically, change in [lib.ios] the signature of</p>
14287 <pre> operator void*() const;
14290 <pre> operator unspecified-bool-type() const;
14292 <p>and change [lib.iostate.flags], p1 from</p>
14293 <pre> operator void*() const;
14296 <pre>operator unspecified-bool-type() const;
14298 -1- Returns: if fail() then a value that will evaluate false in a
14299 boolean context; otherwise a value that will evaluate true in a
14300 boolean context. The value type returned shall not be
14301 convertible to int.
14303 -2- [Note: This conversion can be used in contexts where a bool
14304 is expected (e.g., an if condition); however, implicit
14305 conversions (e.g., to int) that can occur with bool are not
14306 allowed, eliminating some sources of user error. One possible
14307 implementation choice for this type is pointer-to-member. - end
14311 <p><i>[Redmond: 5-4 straw poll in favor of doing this.]</i></p>
14312 <p><i>[Lillehammer: Doug provided revised wording for
14313 "unspecified-bool-type".]</i></p>
14316 <a name="469"><h3>469. vector<bool> ill-formed relational operators</h3></a><p><b>Section:</b> 23.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.vector"> [lib.vector]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 28 Jun 2004</p>
14319 The overloads of relational operators for vector<bool> specified
14320 in [lib.vector.bool] are redundant (they are semantically identical
14321 to those provided for the vector primary template) and may even be
14322 diagnosed as ill-formed (refer to Daveed Vandevoorde's explanation
14323 in c++std-lib-13647).
14326 <p><b>Proposed resolution:</b></p>
14328 Remove all overloads of overloads of relational operators for
14329 vector<bool> from [lib.vector.bool].
14332 <a name="474"><h3>474. confusing Footnote 297</h3></a><p><b>Section:</b> 27.6.2.5.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.ostream.inserters.character"> [lib.ostream.inserters.character]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 1 Jul 2004</p>
14335 I think Footnote 297 is confused. The paragraph it applies to seems
14336 quite clear in that widen() is only called if the object is not a char
14337 stream (i.e., not basic_ostream<char>), so it's irrelevant what the
14338 value of widen(c) is otherwise.
14340 <p><b>Proposed resolution:</b></p>
14342 I propose to strike the Footnote.
14345 <a name="475"><h3>475. May the function object passed to for_each modify the elements of the iterated sequence?</h3></a><p><b>Section:</b> 25.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.foreach"> [lib.alg.foreach]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Stephan T. Lavavej, Jaakko Jarvi <b>Date:</b> 9 Jul 2004</p>
14347 It is not clear whether the function object passed to for_each is allowed to
14348 modify the elements of the sequence being iterated over.
14352 for_each is classified without explanation in [lib.alg.nonmodifying], "25.1
14353 Non-modifying sequence operations". 'Non-modifying sequence operation' is
14358 25(5) says: "If an algorithm's Effects section says that a value pointed to
14359 by any iterator passed as an argument is modified, then that algorithm has
14360 an additional type requirement: The type of that argument shall satisfy the
14361 requirements of a mutable iterator (24.1)."
14364 <p>for_each's Effects section does not mention whether arguments can be
14368 "Effects: Applies f to the result of dereferencing every iterator in the
14369 range [first, last), starting from first and proceeding to last - 1."
14373 Every other algorithm in [lib.alg.nonmodifying] is "really" non-modifying in
14374 the sense that neither the algorithms themselves nor the function objects
14375 passed to the algorithms may modify the sequences or elements in any way.
14376 This DR affects only for_each.
14380 We suspect that for_each's classification in "non-modifying sequence
14381 operations" means that the algorithm itself does not inherently modify the
14382 sequence or the elements in the sequence, but that the function object
14383 passed to it may modify the elements it operates on.
14387 The original STL document by Stepanov and Lee explicitly prohibited the
14388 function object from modifying its argument.
14389 The "obvious" implementation of for_each found in several standard library
14390 implementations, however, does not impose this restriction.
14391 As a result, we suspect that the use of for_each with function objects that modify
14392 their arguments is wide-spread.
14393 If the restriction was reinstated, all such code would become non-conforming.
14394 Further, none of the other algorithms in the Standard
14395 could serve the purpose of for_each (transform does not guarantee the order in
14396 which its function object is called).
14400 We suggest that the standard be clarified to explicitly allow the function object
14401 passed to for_each modify its argument.</p>
14403 <p><b>Proposed resolution:</b></p>
14404 <p>Add a nonnormative note to the Effects in 25.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.foreach"> [lib.alg.foreach]</a>: If
14405 the type of 'first' satisfies the requirements of a mutable iterator,
14406 'f' may apply nonconstant functions through the dereferenced iterators
14410 <p><b>Rationale:</b></p>
14411 <p>The LWG believes that nothing in the standard prohibits function
14412 objects that modify the sequence elements. The problem is that
14413 for_each is in a secion entitled "nonmutating algorithms", and the
14414 title may be confusing. A nonnormative note should clarify that.</p>
14416 <a name="478"><h3>478. Should forward iterator requirements table have a line for r->m?</h3></a><p><b>Section:</b> 24.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iterators.html#lib.forward.iterators"> [lib.forward.iterators]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Dave Abrahams <b>Date:</b> 11 Jul 2004</p>
14418 The Forward Iterator requirements table contains the following:
14420 <pre> expression return type operational precondition
14422 ========== ================== =========== ==========================
14423 a->m U& if X is mutable, (*a).m pre: (*a).m is well-defined.
14424 otherwise const U&
14426 r->m U& (*r).m pre: (*r).m is well-defined.
14429 <p>The second line may be unnecessary. Paragraph 11 of
14430 [lib.iterator.requirements] says:
14434 In the following sections, a and b denote values of type const X, n
14435 denotes a value of the difference type Distance, u, tmp, and m
14436 denote identifiers, r denotes a value of X&, t denotes a value of
14437 value type T, o denotes a value of some type that is writable to
14438 the output iterator.
14442 Because operators can be overloaded on an iterator's const-ness, the
14443 current requirements allow iterators to make many of the operations
14444 specified using the identifiers a and b invalid for non-const
14447 <p>Related issue: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#477">477</a></p>
14448 <p><b>Proposed resolution:</b></p>
14450 <p>Remove the "r->m" line from the Forward Iterator requirements
14462 <p>in paragraph 11 of [lib.iterator.requirements].</p>
14465 <p><b>Rationale:</b></p>
14467 This is a defect because it constrains an lvalue to returning a modifiable lvalue.
14470 <a name="495"><h3>495. Clause 22 template parameter requirements</h3></a><p><b>Section:</b> 22 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-locales.html#lib.localization"> [lib.localization]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 10 Jan 2005</p>
14471 <p>It appears that there are no requirements specified for many of the
14472 template parameters in clause 22. It looks like this issue has never
14473 come up, except perhaps for Facet.</p>
14475 <p>Clause 22 isn't even listed in 17.3.2.1 [lib.type.descriptions],
14476 either, which is the wording that allows requirements on template
14477 parameters to be identified by name.</p>
14479 <p>So one issue is that 17.3.2.1 [lib.type.descriptions] Should be
14480 changed to cover clause 22. A better change, which will cover us in
14481 the future, would be to say that it applies to all the library
14482 clauses. Then if a template gets added to any library clause we are
14485 <p>charT, InputIterator, and other names with requirements defined
14486 elsewhere are fine, assuming the 17.3.2.1 [lib.type.descriptions] fix.
14487 But there are a few template arguments names which I don't think have
14488 requirements given elsewhere:</p>
14491 <li>internT and externT. The fix is to add wording saying that internT
14492 and externT must meet the same requirements as template arguments
14495 <li>stateT. I'm not sure about this one. There already is some wording,
14496 but it seems a bit vague.</li>
14498 <li>Intl. [lib.locale.moneypunct.byname] The fix for this one is to
14499 rename "Intl" to "International". The name is important because other
14500 text identifies the requirements for the name International but not
14503 <p><b>Proposed resolution:</b></p>
14504 <p>Change 17.3.2.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-intro.html#lib.type.descriptions"> [lib.type.descriptions]</a>, paragraph 1, from:</p>
14506 The Requirements subclauses may describe names that are used to
14507 specify constraints on template arguments.153) These names are used in
14508 clauses 20, 23, 25, and 26 to describe the types that may be supplied
14509 as arguments by a C++ program when instantiating template components
14514 The Requirements subclauses may describe names that are used to
14515 specify constraints on template arguments.153) These names are used in
14516 library clauses to describe the types that may be supplied as
14517 arguments by a C++ program when instantiating template components from
14521 <p>In the front matter of class 22, locales, add:</p>
14523 Template parameter types internT and externT shall meet the
14524 requirements of charT (described in 21 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.strings"> [lib.strings]</a>).
14526 <p><b>Rationale:</b></p>
14528 Again, a blanket clause isn't blanket enough. Also, we've got a
14529 couple of names that we don't have blanket requirement statements
14530 for. The only issue is what to do about stateT. This wording is
14531 thin, but probably adequate.</p>
14533 <a name="496"><h3>496. Illegal use of "T" in vector<bool></h3></a><p><b>Section:</b> 23.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.vector"> [lib.vector]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> richard@ex-parrot.com <b>Date:</b> 10 Feb 2005</p>
14535 In the synopsis of the std::vector<bool> specialisation in 23.2.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.vector"> [lib.vector]</a>,
14536 the non-template assign() function has the signature</p>
14538 <pre> void assign( size_type n, const T& t );
14541 <p>The type, T, is not defined in this context.</p>
14542 <p><b>Proposed resolution:</b></p>
14543 <p>Replace "T" with "value_type".</p>
14545 <a name="497"><h3>497. meaning of numeric_limits::traps for floating point types</h3></a><p><b>Section:</b> 18.2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-support.html#lib.numeric.limits.members"> [lib.numeric.limits.members]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 2 Mar 2005</p>
14547 <p>18.2.1.2, p59 says this much about the traps member of numeric_limits:</p>
14550 <p>static const bool traps;<br>
14551 -59- true if trapping is implemented for the type.204)
14553 Footnote 204: Required by LIA-1.
14557 <p>It's not clear what is meant by "is implemented" here.</p>
14560 In the context of floating point numbers it seems reasonable to expect
14561 to be able to use traps to determine whether a program can "safely" use
14562 infinity(), quiet_NaN(), etc., in arithmetic expressions, that is
14563 without causing a trap (i.e., on UNIX without having to worry about
14564 getting a signal). When traps is true, I would expect any of the
14565 operations in section 7 of IEEE 754 to cause a trap (and my program
14566 to get a SIGFPE). So, for example, on Alpha, I would expect traps
14567 to be true by default (unless I compiled my program with the -ieee
14568 option), false by default on most other popular architectures,
14569 including IA64, MIPS, PA-RISC, PPC, SPARC, and x86 which require
14570 traps to be explicitly enabled by the program.
14574 Another possible interpretation of p59 is that traps should be true
14575 on any implementation that supports traps regardless of whether they
14576 are enabled by default or not. I don't think such an interpretation
14577 makes the traps member very useful, even though that is how traps is
14578 implemented on several platforms. It is also the only way to implement
14579 traps on platforms that allow programs to enable and disable trapping
14582 <p><b>Proposed resolution:</b></p>
14583 <p>Change p59 to read:</p>
14584 <blockquote>True if, at program startup, there exists a value of the type that
14585 would cause an arithmetic operation using that value to trap.</blockquote>
14586 <p><b>Rationale:</b></p>
14588 Real issue, since trapping can be turned on and off. Unclear what a
14589 static query can say about a dynamic issue. The real advice we should
14590 give users is to use cfenv for these sorts of queries. But this new
14591 proposed resolution is at least consistent and slightly better than
14594 <a name="505"><h3>505. Result_type in random distribution requirements</h3></a><p><b>Section:</b> TR1 5.1.1 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.rand.req"> [tr.rand.req]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Walter Brown <b>Date:</b> 3 Jul 2005</p>
14596 Table 17: Random distribution requirements
14599 Row 1 requires that each random distribution provide a nested type "input_type";
14600 this type denotes the type of the values that the distribution consumes.
14603 Inspection of all distributions in [tr.rand.dist] reveals that each distribution
14604 provides a second typedef ("result_type") that denotes the type of the values the
14605 distribution produces when called.
14607 <p><b>Proposed resolution:</b></p>
14609 It seems to me that this is also a requirement
14610 for all distributions and should therefore be indicated as such via a new second
14611 row to this table 17:
14613 <table border="1" cellpadding="5">
14615 <td>X::result_type</td>
14618 <td>compile-time</td>
14623 Berlin: Voted to WP. N1932 adopts the proposed resolution: see Table 5 row 1.
14627 <a name="507"><h3>507. Missing requirement for variate_generator::operator()</h3></a><p><b>Section:</b> TR1 5.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.rand.var"> [tr.rand.var]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Walter Brown <b>Date:</b> 3 Jul 2005</p>
14629 Paragraph 11 of [tr.rand.var] equires that the member template
14631 <blockquote><pre>template<class T> result_type operator() (T value);
14632 </pre></blockquote>
14636 <blockquote><pre>distribution()(e, value)
14637 </pre></blockquote>
14639 However, not all distributions have an operator() with a corresponding signature.
14643 Berlin: As a working group we voted in favor of N1932 which makes this moot:
14644 variate_generator has been eliminated. Then in full committee we voted to give
14645 this issue WP status (mistakenly).
14648 <p><b>Proposed resolution:</b></p>
14650 We therefore recommend that we insert the following precondition before paragraph 11:
14653 Precondition: <tt>distribution().operator()(e,value)</tt> is well-formed.
14656 <a name="508"><h3>508. Bad parameters for ranlux64_base_01</h3></a><p><b>Section:</b> TR1 5.1.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.rand.predef"> [tr.rand.predef]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Walter Brown <b>Date:</b> 3 Jul 2005</p>
14658 The fifth of these engines with predefined parameters, ranlux64_base_01,
14659 appears to have an unintentional error for which there is a simple correction.
14660 The two pre-defined subtract_with_carry_01 engines are given as:
14662 <blockquote><pre>typedef subtract_with_carry_01<float, 24, 10, 24> ranlux_base_01;
14663 typedef subtract_with_carry_01<double, 48, 10, 24> ranlux64_base_01;
14664 </pre></blockquote>
14666 We demonstrate below that ranlux64_base_01 fails to meet the intent of the
14667 random number generation proposal, but that the simple correction to
14669 <blockquote><pre>typedef subtract_with_carry_01<double, 48, 5, 12> ranlux64_base_01;
14670 </pre></blockquote>
14672 does meet the intent of defining well-known good parameterizations.
14675 The ranlux64_base_01 engine as presented fails to meet the intent for
14676 predefined engines, stated in proposal N1398 (section E):
14679 In order to make good random numbers available to a large number of library
14680 users, this proposal not only defines generic random-number engines, but also
14681 provides a number of predefined well-known good parameterizations for those.
14684 The predefined ranlux_base_01 engine has been proven [1,2,3] to have a very
14685 long period and so meets this criterion. This property makes it suitable for
14686 use in the excellent discard_block engines defined subsequently. The proof
14687 of long period relies on the fact (proven in [1]) that 2**(w*r) - 2**(w*s)
14688 + 1 is prime (w, r, and s are template parameters to subtract_with_carry_01,
14689 as defined in [tr.rand.eng.sub1]).
14692 The ranlux64_base_01 engine as presented in [tr.rand.predef] uses w=48, r=24, s=10.
14693 For these numbers, the combination 2**(w*r)-2**(w*s)+1 is non-prime (though
14694 explicit factorization would be a challenge). In consequence, while it is
14695 certainly possible for some seeding states that this engine would have a very
14696 long period, it is not at all Òwell-knownÓ that this is the case. The intent
14697 in the N1398 proposal involved the base of the ranlux64 engine, which finds heavy
14698 use in the physics community. This is isomorphic to the predefined ranlux_base_01,
14699 but exploits the ability of double variables to hold (at least) 48 bits of mantissa,
14700 to deliver 48 random bits at a time rather than 24.
14702 <p><b>Proposed resolution:</b></p>
14704 To achieve this intended behavior, the correct template parameteriztion would be:
14706 <blockquote><pre>typedef subtract_with_carry_01<double, 48, 5, 12> ranlux64_base_01;
14707 </pre></blockquote>
14709 The sequence of mantissa bits delivered by this is isomorphic (treating each
14710 double as having the bits of two floats) to that delivered by ranlux_base_01.
14716 <li>F. James, Comput. Phys. Commun. 60(1990) 329</li>
14717 <li>G. Marsaglia and A. Zaman, Ann. Appl. Prob 1(1991) 462</li>
14718 <li>M. Luscher, Comput. Phys. Commun. 79(1994) 100-110</li>
14722 Berlin: Voted to WP. N1932 adopts the proposed resolution in 26.3.5,
14723 just above paragraph 5.
14727 <a name="519"><h3>519. Data() undocumented</h3></a><p><b>Section:</b> TR1 6.2.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.array.array"> [tr.array.array]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Pete Becker <b>Date:</b> 3 Jul 2005</p>
14729 <tt>array<>::data()</tt> is present in the class synopsis, but not documented.
14731 <p><b>Proposed resolution:</b></p>
14733 Add a new section, after 6.2.2.3:
14735 <blockquote><pre>T* data()
14736 const T* data() const;
14737 </pre></blockquote>
14739 <b>Returns:</b> <tt>elems</tt>.
14742 Change 6.2.2.4/2 to:
14745 In the case where <tt>N == 0</tt>, <tt>begin() == end()</tt>. The return value
14746 of <tt>data()</tt> is unspecified.
14749 <a name="520"><h3>520. Result_of and pointers to data members</h3></a><p><b>Section:</b> TR1 3.6 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.func.bind"> [tr.func.bind]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Pete Becker <b>Date:</b> 3 Jul 2005</p>
14751 In the original proposal for binders, the return type of bind() when
14752 called with a pointer to member data as it's callable object was
14753 defined to be mem_fn(ptr); when Peter Dimov and I unified the
14754 descriptions of the TR1 function objects we hoisted the descriptions
14755 of return types into the INVOKE pseudo-function and into result_of.
14756 Unfortunately, we left pointer to member data out of result_of, so
14757 bind doesn't have any specified behavior when called with a pointer
14760 <p><b>Proposed resolution:</b></p>
14762 Pete and Peter will provide wording.
14766 In 20.5.4 [lib.func.ret] ([tr.func.ret]) p3 add the following bullet after bullet 2:
14769 <li>If <tt>F</tt> is a member data pointer type <tt>R T::*</tt>, <tt>type</tt>
14770 shall be <tt><i>cv</i> R&</tt> when <tt>T1</tt> is <tt><i>cv</i> U1&</tt>,
14771 <tt>R</tt> otherwise.</li>
14775 Peter provided wording.
14778 <a name="521"><h3>521. Garbled requirements for argument_type in reference_wrapper</h3></a><p><b>Section:</b> TR1 2.1.2 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.util.refwrp.refwrp"> [tr.util.refwrp.refwrp]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Pete Becker <b>Date:</b> 3 Jul 2005</p>
14780 2.1.2/3, second bullet item currently says that reference_wrapper<T> is
14781 derived from unary_function<T, R> if T is:
14784 a pointer to member function type with cv-qualifier cv and no arguments;
14785 the type T1 is cv T* and R is the return type of the pointer to member function;
14788 The type of T1 can't be cv T*, 'cause that's a pointer to a pointer to member
14789 function. It should be a pointer to the class that T is a pointer to member of.
14793 a pointer to a member function R T0::f() cv (where cv represents the member
14794 function's cv-qualifiers); the type T1 is cv T0*
14797 Similarly, bullet item 2 in 2.1.2/4 should be:
14800 a pointer to a member function R T0::f(T2) cv (where cv represents the member
14801 function's cv-qualifiers); the type T1 is cv T0*
14803 <p><b>Proposed resolution:</b></p>
14806 Change bullet item 2 in 2.1.2/3:
14812 a pointer to member function <del>type with cv-qualifier <tt><i>cv</i></tt> and no arguments;
14813 the type <tt>T1</tt> is <tt><i>cv</i> T*</tt> and <tt>R</tt> is the return
14814 type of the pointer to member function</del> <ins><tt>R T0::f() <i>cv</i></tt>
14815 (where <tt><i>cv</i></tt> represents the member function's cv-qualifiers);
14816 the type <tt>T1</tt> is <tt><i>cv</i> T0*</tt></ins>
14822 Change bullet item 2 in 2.1.2/4:
14828 a pointer to member function <del>with cv-qualifier <tt><i>cv</i></tt> and taking one argument
14829 of type <tt>T2</tt>; the type <tt>T1</tt> is <tt><i>cv</i> T*</tt> and
14830 <tt>R</tt> is the return type of the pointer to member function</del>
14831 <ins><tt>R T0::f(T2) <i>cv</i></tt> (where <tt><i>cv</i></tt> represents the member
14832 function's cv-qualifiers); the type <tt>T1</tt> is <tt><i>cv</i> T0*</tt></ins>
14838 <a name="530"><h3>530. Must elements of a string be contiguous?</h3></a><p><b>Section:</b> 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Matt Austern <b>Date:</b> 15 Nov 2005</p>
14839 <p>Issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#69">69</a>, which was incorporated into C++03, mandated
14840 that the elements of a vector must be stored in contiguous memory.
14841 Should the same also apply to <tt>basic_string</tt>?</p>
14843 <p>We almost require contiguity already. Clause 23.3.4 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-containers.html#lib.multiset"> [lib.multiset]</a>
14844 defines <tt>operator[]</tt> as <tt>data()[pos]</tt>. What's missing
14845 is a similar guarantee if we access the string's elements via the
14846 iterator interface.</p>
14848 <p>Given the existence of <tt>data()</tt>, and the definition of
14849 <tt>operator[]</tt> and <tt>at</tt> in terms of <tt>data</tt>,
14850 I don't believe it's possible to write a useful and standard-
14851 conforming <tt>basic_string</tt> that isn't contiguous. I'm not
14852 aware of any non-contiguous implementation. We should just require
14855 <p><b>Proposed resolution:</b></p>
14856 <p>Add the following text to the end of 21.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.basic.string"> [lib.basic.string]</a>,
14860 <p>The characters in a string are stored contiguously, meaning that if
14861 <tt>s</tt> is a <tt>basic_string<charT, Allocator></tt>, then
14862 it obeys the identity
14863 <tt>&*(s.begin() + n) == &*s.begin() + n</tt>
14864 for all <tt>0 <= n < s.size()</tt>.
14868 <a name="533"><h3>533. typo in 2.2.3.10/1</h3></a><p><b>Section:</b> TR1 2.2.3.10 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.util.smartptr.getdeleter"> [tr.util.smartptr.getdeleter]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#DR">DR</a> <b>Submitter:</b> Paolo Carlini <b>Date:</b> 9 Nov 2005</p>
14870 I'm seeing something that looks like a typo. The Return of <tt>get_deleter</tt>
14874 If <tt>*this</tt> <i>owns</i> a deleter <tt>d</tt>...
14877 but <tt>get_deleter</tt> is a free function!
14879 <p><b>Proposed resolution:</b></p>
14881 Therefore, I think should be:
14884 If <tt><del>*this</del> <ins>p</ins></tt> <i>owns</i> a deleter <tt>d</tt>...
14887 <a name="535"><h3>535. std::string::swap specification poorly worded</h3></a><p><b>Section:</b> 21.3.5.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-strings.html#lib.string::swap"> [lib.string::swap]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Beman Dawes <b>Date:</b> 14 Dec 2005</p>
14889 std::string::swap currently says for effects and postcondition:
14894 <i>Effects:</i> Swaps the contents of the two strings.
14898 <i>Postcondition:</i> <tt>*this</tt> contains the characters that were in <tt><i>s</i></tt>,
14899 <tt><i>s</i></tt> contains the characters that were in <tt>*this</tt>.
14904 Specifying both Effects and Postcondition seems redundant, and the postcondition
14905 needs to be made stronger. Users would be unhappy if the characters were not in
14906 the same order after the swap.
14908 <p><b>Proposed resolution:</b></p>
14911 <del><i>Effects:</i> Swaps the contents of the two strings.</del>
14915 <i>Postcondition:</i> <tt>*this</tt> contains the <ins>same sequence of</ins>
14916 characters that <del>were</del> <ins>was</ins> in <tt><i>s</i></tt>,
14917 <tt><i>s</i></tt> contains the <ins>same sequence of</ins> characters that
14918 <del>were</del> <ins>was</ins> in <tt>*this</tt>.
14922 <a name="537"><h3>537. Typos in the signatures in 27.6.1.3/42-43 and 27.6.2.4</h3></a><p><b>Section:</b> 27.6.1.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-iostreams.html#lib.istream.unformatted"> [lib.istream.unformatted]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Paolo Carlini <b>Date:</b> 12 Feb 2006</p>
14924 In the most recent working draft, I'm still seeing:
14927 <blockquote><pre>seekg(off_type& off, ios_base::seekdir dir)
14928 </pre></blockquote>
14934 <blockquote><pre>seekp(pos_type& pos)
14936 seekp(off_type& off, ios_base::seekdir dir)
14937 </pre></blockquote>
14940 that is, by reference off and pos arguments.
14942 <p><b>Proposed resolution:</b></p>
14944 After 27.6.1.3p42 change:
14947 <blockquote><pre>basic_istream<charT,traits>& seekg(off_type<del>&</del> <i>off</i>, ios_base::seekdir <i>dir</i>);
14948 </pre></blockquote>
14951 After 27.6.2.4p1 change:
14954 <blockquote><pre>basic_ostream<charT,traits>& seekp(pos_type<del>&</del> <i>pos</i>);
14955 </pre></blockquote>
14958 After 27.6.2.4p3 change:
14961 <blockquote><pre>basic_ostream<charT,traits>& seekp(off_type<del>&</del> <i>off</i>, ios_base::seekdir <i>dir</i>);
14962 </pre></blockquote>
14964 <a name="538"></a><h3><a name="538">538. 241 again: Does unique_copy() require CopyConstructible and Assignable?</a></h3><p><b>Section:</b> 25.2.8 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lib-algorithms.html#lib.alg.unique"> [lib.alg.unique]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Howard Hinnant <b>Date:</b> 9 Feb 2006</p>
14966 I believe I botched the resolution of
14967 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#241">
14968 241 "Does unique_copy() require CopyConstructible and Assignable?"</a> which now
14973 This talks about <tt>unique_copy</tt> requirements and currently reads:
14977 -5- <i>Requires:</i> The ranges <tt>[<i>first</i>, <i>last</i>)</tt> and
14978 <tt>[<i>result</i>, <i>result</i>+(<i>last</i>-<i>first</i>))</tt>
14979 shall not overlap. The expression <tt>*<i>result</i> = *<i>first</i></tt> shall
14980 be valid. If neither <tt>InputIterator</tt> nor <tt>OutputIterator</tt> meets the
14981 requirements of forward iterator then the value type of <tt>InputIterator</tt>
14982 must be CopyConstructible (20.1.3). Otherwise CopyConstructible is not required.
14986 The problem (which Paolo discovered) is that when the iterators are at their
14987 most restrictive (<tt>InputIterator</tt>, <tt>OutputIterator</tt>), then we want
14988 <tt>InputIterator::value_type</tt> to be both <tt>CopyConstructible</tt> and
14989 <tt>CopyAssignable</tt> (for the most efficient implementation). However this
14990 proposed resolution only makes it clear that it is <tt>CopyConstructible</tt>,
14991 and that one can assign from <tt>*<i>first</i></tt> to <tt>*<i>result</i></tt>.
14992 This latter requirement does not necessarily imply that you can:
14995 <blockquote><pre>*<i>first</i> = *<i>first</i>;
14996 </pre></blockquote>
14997 <p><b>Proposed resolution:</b></p>
14999 -5- <i>Requires:</i> The ranges <tt>[<i>first</i>, <i>last</i>)</tt> and
15000 <tt>[<i>result</i>, <i>result</i>+(<i>last</i>-<i>first</i>))</tt>
15001 shall not overlap. The expression <tt>*<i>result</i> = *<i>first</i></tt>
15003 be valid. If neither <tt>InputIterator</tt> nor <tt>OutputIterator</tt> meets the
15004 requirements of forward iterator then the <del>value type</del>
15005 <ins><tt>value_type</tt></ins> of <tt>InputIterator</tt>
15006 must be CopyConstructible (20.1.3) <ins>and Assignable</ins>.
15007 Otherwise CopyConstructible is not required.
15010 <a name="540"><h3>540. shared_ptr<void>::operator*()</h3></a><p><b>Section:</b> TR1 2.2.3.5 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.util.smartptr.shared.obs"> [tr.util.smartptr.shared.obs]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 15 Oct 2005</p>
15012 I'm trying to reconcile the note in tr.util.smartptr.shared.obs, p6
15013 that talks about the operator*() member function of shared_ptr:
15017 Notes: When T is void, attempting to instantiate this member function
15018 renders the program ill-formed. [Note: Instantiating shared_ptr<void>
15019 does not necessarily result in instantiating this member function.
15024 with the requirement in temp.inst, p1:
15028 The implicit instantiation of a class template specialization causes
15029 the implicit instantiation of the declarations, but not of the
15034 I assume that what the note is really trying to say is that
15035 "instantiating shared_ptr<void> *must not* result in instantiating
15036 this member function." That is, that this function must not be
15037 declared a member of shared_ptr<void>. Is my interpretation
15040 <p><b>Proposed resolution:</b></p>
15046 -6- <del><i>Notes:</i></del> When <tt>T</tt> is <tt>void</tt>, <del>attempting to instantiate
15047 this member function renders the program ill-formed. [<i>Note:</i>
15048 Instantiating <tt>shared_ptr<void></tt> does not necessarily result in
15049 instantiating this member function. <i>--end note</i>]</del> <ins>it is
15050 unspecified whether this member function is declared or not, and if so, what its
15051 return type is, except that the declaration (although not necessarily the
15052 definition) of the function shall be well-formed.</ins>
15056 <a name="541"><h3>541. shared_ptr template assignment and void</h3></a><p><b>Section:</b> TR1 2.2.3 <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/tr1.html#tr.util.smartptr.shared"> [tr.util.smartptr.shared]</a> <b>Status:</b> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#WP">WP</a> <b>Submitter:</b> Martin Sebor <b>Date:</b> 16 Oct 2005</p>
15058 Is the void specialization of the template assignment operator taking
15059 a shared_ptr<void> as an argument supposed be well-formed?
15062 I.e., is this snippet well-formed:
15064 <blockquote><pre>shared_ptr<void> p;
15065 p.operator=<void>(p);
15066 </pre></blockquote>
15069 Gcc complains about auto_ptr<void>::operator*() returning a reference
15070 to void. I suspect it's because shared_ptr has two template assignment
15071 operators, one of which takes auto_ptr, and the auto_ptr template gets
15072 implicitly instantiated in the process of overload resolution.
15076 The only way I see around it is to do the same trick with auto_ptr<void>
15077 operator*() as with the same operator in shared_ptr<void>.
15081 PS Strangely enough, the EDG front end doesn't mind the code, even
15082 though in a small test case (below) I can reproduce the error with
15086 <blockquote><pre>template <class T>
15087 struct A { T& operator*() { return *(T*)0; } };
15089 template <class T>
15091 void operator= (const B&) { }
15092 template <class U>
15093 void operator= (const B<U>&) { }
15094 template <class U>
15095 void operator= (const A<U>&) { }
15101 b.operator=<void>(b);
15103 </pre></blockquote>
15104 <p><b>Proposed resolution:</b></p>
15106 In [lib.memory] change:
15108 <blockquote><pre>template<class X> class auto_ptr;
15109 <ins>template<> class auto_ptr<void>;</ins>
15110 </pre></blockquote>
15113 In [lib.auto.ptr]/2 add the following before the last closing brace:
15116 <blockquote><pre>template<> class auto_ptr<void>
15119 typedef void element_type;
15121 </pre></blockquote>
15123 <p>----- End of document -----</p>