C++ streams operator << and manipulators / formatters
- by Ayman
First, most of my recent work was Java. So even though I "know" C++, I do not want to write Java in C++.
And C++ templates are one thing I will really miss when going back to Java.
Now that this out of the way, if I want to do create a new stream formatter, say pic, that will have a single std::string parameter in it's constructor.
I would like the user to be able to write something like:
cout << pic("Date is 20../../..") << "100317" << endl;
The output should be
Date is 2010/03/17
How do I write the pic class? when the compiler sees the cout what are the underlying steps the compiler does?