Article View: comp.std.c++
Article #2513Re: IOManipulators with two arguments?
From: Bernd Eggink
Date: Thu, 09 Nov 1995 11:10
Date: Thu, 09 Nov 1995 11:10
55 lines
2456 bytes
2456 bytes
Dr. Richard Botting (dick@silicon.csci.csusb.edu) wrote: > According to the 2nd addition of Horstmann's "Mastering C++", > cout << setiosflags(ios::fixed, ios::floatfield); > is OK, but I found that it would not compile because the libraries > on our Gnu C++ n.m.0 do not have a two argument form of the > iomanipulator setiosflags. This must be a typo. It should read cout.setf(ios::fixed, ios::floatfield); AFAIK, the library does not provide manipulators with two arguments. You can, of course, easily write your own. > In the draft standard/working papers (HTML version) I searched > for all occurences of setisoflags and failed to > find anything but a one argument form: > smanip setiosflags (ios_base::fmtflags mask); > Similarly for resetiosflags. > I presume that this is deliberate and that there is a > way of expressing the older pair of arguments in terms > of a single argument. > Am I right? > And if so... how does one do the euqivalent of > cout.setf(ios:: F, ios::G); > by using > cout<<setiosflags( X ); You can build manipulators with 2 parameters in different ways. I prefer the manipulator to be a classname, so that M(x,y) is a temporary object. If you don't want to do that, you may write cout << resetiosflags(ios::floatfield) << setiosflags(ios::fixed); although that is somewhat clumsy. Bernd -- +----------------------------------+ | Bernd Eggink | | Rechenzentrum Uni Hamburg | | admin@rzaix13.rrz.uni-hamburg.de | +----------------------------------+ --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<47slkd$p5@rzsun02.rrz.uni-hamburg.de>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<47or96$kct@news.csus.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 09 Nov 95 11:10:19 GMT Approved: fjh@cs.mu.oz.au Return-Path: <daemon@migs.UCAR.EDU> From: admin@rzaix13.uni-hamburg.de (Bernd Eggink) Newsgroups: comp.std.c++ Subject: Re: IOManipulators with two arguments? X-Original-Date: 9 Nov 1995 10:37:01 GMT Organization: University of Hamburg -- Germany Message-ID: <47slkd$p5@rzsun02.rrz.uni-hamburg.de> References: <47or96$kct@news.csus.edu> X-Newsreader: TIN [version 1.2 PL2] X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMKHh0uEDnX0m9pzZAQGACwF/ery9gogrE4NeyI/vKCWl8BrcDSmVIsZo RlF1+5PDbPLkccAeu+UW+l7t/dfJQ8WJ =Pyur