I am trying to make a struct
, in which one of the members is of std::stringstream
type. I am using C++11, and according to http://www.cplusplus.com/reference/sstream/stringstream/operator=/ I can do it.
Here is my code:
struct logline_t
{
stringstream logString; /*!< String line to be saved to a file (and printed to cout). */
ElogLevel logLevel; /*!< The \ref ElogLevel of this line. */
timeval currentTime; /*!< time stamp of current log line */
logline_t& operator =(const logline_t& a)
{
logString = a.logString;
logLevel = a.logLevel;
currentTime = a.currentTime;
return *this;
}
};
It doesn't compile, as I am getting this error:
error: use of deleted function ‘std::basic_stringstream<char>& std::basic_stringstream<char>::operator=(const std::basic_stringstream<char>&)’
I don't understand why it doesn't work. I have tried logString = move(a.logString);
as well. Same result. I would appreciate all help.
Edit: Here is my code, I have applied the changes suggested by most of the users and in my code they do not compile. I am still getting an error at the very beginning of the struct
.
Line 40: ../src/CLogger.h:40:9: error: use of deleted function ‘std::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)’
Line 86: ../src/CLogger.cpp:86:41: error: use of deleted function ‘CLogger::logline_t::logline_t(const CLogger::logline_t&)’
Line 91: ../src/CLogger.cpp:91:9: error: use of deleted function ‘CLogger::logline_t::logline_t(const CLogger::logline_t&)’
If any other information is needed i will provide it.