Article View: gnu.g++.lib.bug
Article #62ostream << hex problem in library, not compiler
From: Jason Merrill
Date: Sun, 12 Apr 1992 05:22
Date: Sun, 12 Apr 1992 05:22
79 lines
3071 bytes
3071 bytes
In an earlier posting, I complained of the errors
Arraychar.c:121: type conversion required for type `ostream'
Arraychar.c:126: type conversion required for type `ostream'
caused by the code
void THIS::printOn(ostream& strm) const
{
strm.fill('0');
strm.width(2);
strm << hex;
for (register unsigned i=0; i<sz; i++) {
if (i > 0) strm << " ";
strm << "0x" << ((unsigned int)(unsigned char)v[i]);
}
strm << dec;
}
and said that the problem was that g++ was not converting ostream& to ios&
correctly. Looking at the library more closely, I realize that the problem
is not this, but rather that there is no insertor defined for type
ios& (*)(ios&). Diffs to iostream.h:
*** /gnu/libg++/libg++/iostream/iostream.h Wed Feb 26 12:29:47 1992
--- g++-include/iostream.h Sat Apr 11 22:16:20 1992
***************
*** 27,32
class istream; class ostream;
typedef istream& (*__imanip)(istream&);
typedef ostream& (*__omanip)(ostream&);
extern istream& ws(istream& ins);
extern ostream& flush(ostream& outs);
--- 27,33 -----
class istream; class ostream;
typedef istream& (*__imanip)(istream&);
typedef ostream& (*__omanip)(ostream&);
+ typedef ios& (*__iosmanip)(ios&);
extern istream& ws(istream& ins);
extern ostream& flush(ostream& outs);
***************
*** 77,82
extern ostream& operator<<(ostream&, float n);
extern ostream& operator<<(ostream&, double n);
inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
extern ostream& operator<<(ostream&, streambuf*);
class istream : public ios
--- 78,85 -----
extern ostream& operator<<(ostream&, float n);
extern ostream& operator<<(ostream&, double n);
inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
+ inline ostream& operator<<(ostream& os, __iosmanip func)
+ { (*func)(os); return os; }
extern ostream& operator<<(ostream&, streambuf*);
class istream : public ios
***************
*** 154,159
extern istream& operator>>(istream&, float&);
extern istream& operator>>(istream&, double&);
inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
class iostream : public ios {
_G_size_t _gcount;
--- 157,164 -----
extern istream& operator>>(istream&, float&);
extern istream& operator>>(istream&, double&);
inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
+ inline istream& operator>>(istream& is, __iosmanip func)
+ { (*func)(is); return is; }
class iostream : public ios {
_G_size_t _gcount;
Technical Details
Message-ID:
<1992Apr12.052255.14221@muddcs.claremont.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!jarthur.claremont.edu!jasonShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!jarthur.claremont.edu!jason From: jason@jarthur.claremont.edu (Jason Merrill) Subject: ostream << hex problem in library, not compiler Message-ID: <1992Apr12.052255.14221@muddcs.claremont.edu> Sender: gnulists@ai.mit.edu Organization: Harvey Mudd College Distribution: gnu Date: Sun, 12 Apr 1992 05:22:55 GMT Approved: bug-lib-g++@prep.ai.mit.edu Lines: 80