473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

manipulator persistence in streams


Something I've noticed has me annoyed.

consider this
ostream o;

o << scientific << setw(15) << setprecision(5) << right <<
a << b << c << endl;

on some platforms a, b, and c are all formatted according to the field
widths specified and other times (a) is the only variable that maintains
the requested justification and field width.

I can understand something like
o << scientific << setw(15) << setprecision(5) << right << a;
o << b << c << endl;

throwing out the field information but I'm not seeing any consistency
across applications.

Aren't manipulators suppose to be persistent until overridden, especially
in one statement as in my first example?
Jul 28 '06 #1
2 2050
noone wrote:
Something I've noticed has me annoyed.

consider this
ostream o;

o << scientific << setw(15) << setprecision(5) << right <<
a << b << c << endl;

on some platforms a, b, and c are all formatted according to the field
widths specified and other times (a) is the only variable that
maintains the requested justification and field width.

I can understand something like
o << scientific << setw(15) << setprecision(5) << right << a;
o << b << c << endl;

throwing out the field information but I'm not seeing any consistency
across applications.

Aren't manipulators suppose to be persistent until overridden,
especially in one statement as in my first example?
I couldn't find any wording in the Standard to support this, but in
Josuttis' "The C++ Standard Library" he mentions that manipulators
with values (like setw or setprecision) only affect the next output
operation. The other type (right, scientific) are flag type manips
and they should stick, IIUIC.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 28 '06 #2
On Thu, 27 Jul 2006 22:54:36 -0400, Victor Bazarov wrote:
>>
Aren't manipulators suppose to be persistent until overridden,
especially in one statement as in my first example?

I couldn't find any wording in the Standard to support this, but in
Josuttis' "The C++ Standard Library" he mentions that manipulators
with values (like setw or setprecision) only affect the next output
operation. The other type (right, scientific) are flag type manips
and they should stick, IIUIC.
I guess that would explain the difference but I swear that I've seen
setw() and the like survive multiple statements in my foggy memory...must
have been bugs in the GNU implementations I used. Wouldn't be the first
time.

thanks!
Jul 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paolo Losi | last post by:
Hi all, I'm pretty new to the python language so please excuse me if this is FAQ... I'm very glad to be part of the list! :-) I'm looking into a way to implement a generic workflow framework...
8
by: Boris | last post by:
Is it possible to manipulate the std::ostream to prepend a string when performing output, e.g. // manipute std::cout to prepend "prefix " std::cout << "hallo" << std::endl; // results in...
0
by: Steven T. Hatton | last post by:
I tried to create my own manipulator that would both set the width of the subsequent output field, and cast an unsigned char to unsigned in. I came up with the following rather ugly hack. Notice...
8
by: stoptv | last post by:
Hello group, this is my dilemma: ------------------------------------------------------------------------ #include <iostream> using namespace std; // a regular manipulator ostream & hello(...
6
by: jack | last post by:
I have a class which overloads the insertion operator '<<' for every type that ostream handles. I do this so that I can use my class a direct replacement for cout and cerr where the insertion...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
5
by: ax | last post by:
my book says it is ok define ostream& operator<<(ostream& (*p)(ostream )) { return (*p)( *this); } ostream& endl(ostream& o) {o.put('\n'); o.flush();} but seems compiler says it is...
2
Colloid Snake
by: Colloid Snake | last post by:
Hello, I was attempting to configure log4cpp to monitor some logs on my *nix box, and when I run 'make' I get this error message: # make g++ -DHAVE_CONFIG_H -I. -I. -I../include...
9
by: barcaroller | last post by:
When I use an iostream manipulator in a cout statement, it seems to affect all subsequent cout statements. cout << x << endl; // dec by default cout << hex << x << endl; // hex cout <<...
0
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.