AlexLordThorsen
AlexLordThorsen

Reputation: 8498

c++ persisten iomanipulation

So I have some code which looks like this

debug_file << left << setw(10) << timestamp << left 
<< setw(10) << activity_type << left << setw(10) << key << setw(10) 
<< left << event_data1 << setw(10) << left << event_data2 << setw(10) 
<< left << event_data2 << endl;

i would like to be able to write

// all output to debug_file defaults to left justify unless specified
// all output to debug_file defaults to setw(10)
debug_file << timestamp << activity_type << key << event_data1 << event_data2 
<< event_data3 << endl;

first of all, I'm not quite sure what this behaviour is called. Second, I don't know where in iomanip to look in order to do it. Now that I'm writing this I came up with the idea of making function which takes any input type and just does << left << setw(10) << input, but I'm still interested in if there's a pre-built solution.

Upvotes: 0

Views: 93

Answers (1)

Alok Save
Alok Save

Reputation: 206546

You can use the inbuilt function:

setiosflags()

Upvotes: 2

Related Questions