This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
request suggestions/proofread for DR
- To: stdc++ <libstdc++ at sourceware dot cygnus dot com>
- Subject: request suggestions/proofread for DR
- From: brent verner <brent at rcfile dot org>
- Date: Wed, 12 Jul 2000 02:51:02 -0400
Hi,
After dealing with the num_get::do_get thingy, and studying the 14882,
I believe a DR is due (maybe in me :). Below is a draft of the DR I
plan on submitting. I would appreciate it if the membership of this
list would give me a sanity check, as well as any suggestions.
Thank you.
Brent
i=====================================================================
// Defect Report: 22.2.2.1.2 num_get virtual functions
//
// please consider the following:
#include <iostream>
#include <sstream>
void
loopy()
{
std::istringstream iss(" 1 2 3 4 5 ");
// or even
//std::istringstream iss(" ");
int num;
int i=0;
while ( iss >> num ){
std::cout << num << std::endl;
}
return;
}
/*
iss will have ios_base::eofbit before ios_base::failbit,
causing an infinite loop.
contrast that with the following which does not loop
endlessly.
*/
void
dogood()
{
std::istringstream iss(" one two three four five ");
std::string num;
int i=0;
while ( iss >> num ){
std::cout << num << std::endl;
}
return;
}
int
main()
{
dogood();
loopy();
return 0;
}
/*
to cause
basic_istream<charT,traits>& operator>>(int& n);
to behave more like
basic_istream<charT,traits>& operator>>
(basic_streambuf<char_type,traits>* sb);
I propose the following addition to clarify this situation.
Location:
22.2.2.1.2 num_get virtual functions
11 Stage 3: The result of stage 2 processing can be one of
Addition:
Stage 2 was unable to successfully accumulate and convert
any chars to type val. ios_base::failbit is assigned to err.
*/
--
Damon Brent Verner o _ _ _
Cracker Jack? Surprise Certified _o /\_ _ \\o (_)\__/o (_)
brent@rcfile.org _< \_ _>(_) (_)/<_ \_| \ _|/' \/
brent@linux1.org (_)>(_) (_) (_) (_) (_)' _\o_