manipulators Questions

6

Solved

I am refactoring some legacy code which is using printf with longs strings (without any actual formatting) to print out plain text table headers which looks notionally like this: | Table | Column ...
Syringomyelia asked 13/2, 2013 at 19:2

7

Solved

I want to define a class MyStream so that: MyStream myStream; myStream << 1 << 2 << 3 << std::endl << 5 << 6 << std::endl << 7 << 8 << s...
Inharmonious asked 6/2, 2010 at 10:17

5

I've got a line of code that sets the fill value to a '-' character in my output, but need to reset the setfill flag to its default whitespace character. How do I do that? cout << setw...
Donegal asked 3/10, 2009 at 12:33

4

Solved

Let's suppose I want to write my own manipulator for input and output. cin >> mymanip >> str; or cout << mymanip << str; What I want that mymanip does is toggle case ...
Adamis asked 27/11, 2016 at 22:14

3

Solved

I'm trying to use C++11 features to make custom stream manipulators easier to create. I can use lambda functions as manipulators, but not std::function<ostream&(ostream&)>. Here's th...
Scriptural asked 22/10, 2012 at 0:35

2

Solved

I'm having some trouble trying to implement a custom stream class to generate nicely indented code in an output file. I've searched online extensively but there doesn't seem to be a consensus on th...
Henkel asked 12/12, 2012 at 15:10

4

Solved

I'm trying to write a stream manipulator with arguments. I have class with 3 int's CDate(Year, Month, Day). So I need to make manipulator date_format(const char*). e.g. : CDate a(2006, 5, 15); co...
Cyclopean asked 29/3, 2015 at 23:36

2

Solved

Should extracting from a stream using the std::ws manipulator ever raise the fail bit? In the following code, a Clang-compiled (within Xcode 4.5.1) program fails the final assertion. Evidently s &g...
Josefina asked 16/11, 2012 at 19:56

1

Solved

I want to figure out how to pass a manipulator like std::endl to a function and then use the passed-in manipulator in the function. I can declare the function like this: void f(std::ostream&(*...
Egocentrism asked 8/4, 2014 at 5:0

2

Solved

The print function in Python automatically separates its arguments with a customisable separator. Is there any way to emulate this behavior in C++ by using stream manipulators? That is, the follow...
Murmurous asked 3/4, 2014 at 14:8

3

I was trying out the noskipws manipulator in C++ and I wrote following code. #include <iostream> #include <sstream> #include <string> using namespace std; int main() { string ...
Tamworth asked 16/2, 2014 at 10:13

2

This is a exercise for school, so please provide just hints and no complete examples ;-) I have my own manipulator: template<typename T, typename Tr=char_traits<T> > ios_base& tog...
Dickie asked 30/12, 2013 at 15:40

1

Solved

As I understand, the extraction operator skips the whitespace in the beginning and stops upon encountering a whitespace or end of stream. noskipws can be used to stop ignoring the leading whitespac...
Sideburns asked 8/6, 2012 at 10:3

2

In Stroustrup's C++ book, there is an example of a custom manipulator taking an argument (pls see the attached code). I am confused about how the struct is created. In particular, it looks like the...
Buschi asked 28/10, 2011 at 21:37

2

Solved

All, Why does the following code fail to compile for 'std::endl', but it's fine for all of the other inserted types? #include <sstream> // ostringstream /// @brief A class that does stream...
Pushy asked 18/5, 2011 at 22:44

2

Solved

PSPS: (a Pre-scripted Post-script) It has just come to mind that a more prescient question would have included the notion of: Is this non-display of "0x"(showbase) for zero-value integers a standar...
Epicarp asked 17/7, 2010 at 23:27

3

Solved

The little test program below prints out: And SS Number IS =3039 I would like the number to print out with padded left zeros such that the total length is 8. So: And SS Number IS =00003039 (noti...
Venipuncture asked 2/3, 2010 at 19:30

4

Solved

I am trying to write a simple audit class that takes input via operator << and writes the audit after receiving a custom manipulator like this: class CAudit { public: //needs to be template...
Blakey asked 25/8, 2009 at 14:15
1

© 2022 - 2024 — McMap. All rights reserved.