wrapper class for STL stream: forward operator<< calls
问题 I'm currently writing a wrapper for STL stream to synchronize write calls from multiple threads. I have the following (simplified) code: class Synchronize { private: std::stringstream ss; public: void write(std::string& str) { // locking ... ss << str; // unlocking ... }; // other stuff .. }; Synchronize& operator<<(Synchronize& o, std::string& str) { o.write(str); return o; } Synchronize& operator<<(Synchronize* o, std::string& str) { o->write(str); return *o; } Its now possible to call the