I don’t know why this is a mistake, but I'm just trying to add something akin to endl so that I can throw what is in the ostringstream for our debugger. I have the following:
class debug_stream_info
{
public:
debug_stream_info(int errorLine, char *errorFile, int level)
:m_errorLine(errorLine), m_errorFile(errorFile), m_logLevel(level)
{
}
friend std::basic_ostringstream<char>& operator<<(std::basic_ostringstream<char>& os, debug_stream_info& debug_info);
private:
int m_errorLine;
std::string m_errorFile;
int m_logLevel;
};
std::basic_ostringstream<char>& operator<<(std::basic_ostringstream<char>& os, debug_stream_info& debug_info)
{
os.str("");
os.seekp(0);
return os;
}
int main(int argc, char** argv)
{
std::ostringstream myout;
myout << "hey there" << " and some more " << "Numbers!!: " << 435 << 54.2 << " that good for numbers" << debug_stream_info(__LINE__, __FILE__, LOG_LEVEL);
return 0;
}
The error I get: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'debug_stream_info' (or there is no acceptable conversion)for the main line. This is on VS2008.
I include sstream, iostream, etc., and I have the correct namespaces. I have no other errors. I even tried replacing all the entries basic_ostreamwith simple ostringstream, and there was no difference (I will have a version w_charlater, but I wanted the simple case to work first). I made the object on the line above, and then passed the fully constructed object on the line, and the error was exactly the same. I changed the signature of the second argument to and from constwithout change.
, ?
: , , , std:: ostream, , std::ostringstream ( std::basic_ostringstream), . , ostream , os.str(), Ostream, .