stringstream temporary ostream return problem
问题 I'm creating a logger with the following sections: // #define LOG(x) // for release mode #define LOG(x) log(x) log(const string& str); log(const ostream& str); With the idea to do: LOG("Test"); LOG(string("Testing") + " 123"); stringstream s; LOG(s << "Testing" << 1 << "two" << 3); This all works as intended, but when I do: LOG(stringstream() << "Testing" << 1 << "two" << 3); It does not work: void log(const ostream& os) { std::streambuf* buf = os.rdbuf(); if( buf && typeid(*buf) == typeid