I have an instance of a class which implements a writing interface such as this one:
struct Writer {
    virtual size_t write(const char* buffer, size_t size, size_t offset) = 0;
};
I also have a function that takes the std::ostream& as an argument and writes to it. Like so:
void foo(std::ostream& os) {
    os << "hello world"; // Say, I don't control this code
}
What is the simplest way to make foo write into my instance of the Writer interface?
Bonus points for a Reader interface and std::istream.
EDIT:
Maybe I should also mention, I must assume that foo writes a huge amount of data to the std::ostream, thus a solution where foo first writes into std::stringstream which I then write into the Writer won't work.
 
    