Is it possible to create ostream object, which outputs to multiple destinations?
- by fiktor
In 0-th approximation I have a class
class MyClass{
public:
...
std::ostream & getOStream(){return f;}
private:
ofstream f;
...
};
Which is used sometimes in the following way:
MyClass myclass;
myclass.getOStream()<<some<<information<<printed<<here;
But now I want to change the class MyClass, so that information will be printed both to f and to std::out, i.e. I want the above line to be equivalent to
myclass.f<<some<<information<<printed<<here;
std::cout<<some<<information<<printed<<here;
I don't know any good way to do that. Do you? Is there any standard solution (for example in stl or in boost)?
P.S.
I tried to search on this, but it seems that I don't know good keywords. Words multiple, output, ostream, C++, boost seem to be too general.