Greetings!
I’d like to make small program what reverses part of a stream between markers using stream effectors and/or manipulators For example:
From this:
cout << “something” << revstream::start << “asdf” << 3.14 << revstream::end << “something”;
To this:
something41.3fdsasomething
I’d like it to work not just on the standard cout and I’d like to embed them several times.
I’m new in c++ and my main problems are:
– I can’t create a new stream to store what is inside the markers
– How to reverse the temp stream?
I tried so many things and I stuck here:
class revstream {
public:
static ostream& start(ostream &os) {
//do the reversing
return ???;
}
static ostream& end(ostream &os) {
return reversedstream;
}
};
You can do this, but it’s ugly as butt:
Your ostream manipulator has to return a reference to
ostream, so you have to allocate withinrevstream::start.