I'm currently writing a wrapper for an std::stringstream and i want to forward all the operator<< calls through my class to the std::stringstream. This works just fine now
(thanks to this question: wrapper class for STL stream: forward operator<< calls), but there is still one issue with it.
Let's say I have the following code:
class StreamWrapper {
private:
    std::stringstream buffer;
public:
    template<typename T>
    void write(T &t);
    template<typename T>
    friend StreamWrapper& operator<<(StreamWrapper& o, T const& t);
    // other stuff ...
};
template<typename T>
StreamWrapper& operator<<(StreamWrapper& o, T const& t) {
    o.write(t);
    return o;
}
template<typename T>
void StreamWrapper::write(T& t) {
    // other stuff ...
    buffer << t;
    // other stuff ...
}
If I now do this:
StreamWrapper wrapper;
wrapper << "text" << 15 << "stuff";
This works just fine. But if I want to use the stream modifiers like std::endl, which is a function according to http://www.cplusplus.com/reference/ios/endl, I simply doesn't compile.
StreamWrapper wrapper;
wrapper << "text" << 15 << "stuff" << std::endl;
Why? How can I forward the stream modifiers too?
 
     
     
    