1
0
Fork 0

added move constructor

This commit is contained in:
Frank Celler 2013-12-19 16:27:02 +01:00
parent a82ef8b1ea
commit b0a43ea575
2 changed files with 25 additions and 7 deletions

View File

@ -136,21 +136,34 @@ LoggerStream::LoggerStream (LoggerData::Info const& info) :
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief copy constructor /// @brief move or copy constructor
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
LoggerStream::LoggerStream (LoggerStream const& copy) : #if defined(_MSC_VER)
_stream(new stringstream(copy._stream->str())), _info(copy._info) {
LoggerStream::LoggerStream (LoggerStream&& copy) :
_stream(copy._stream), _info(copy._info) {
copy._stream = 0;
} }
#else
LoggerStream::LoggerStream (LoggerStream const& copy) :
_stream(copy._stream), _info(copy._info) {
}
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief destructs a logger stream /// @brief destructs a logger stream
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
LoggerStream::~LoggerStream () { LoggerStream::~LoggerStream () {
if (_stream != 0) {
computeInfo(_info); computeInfo(_info);
Logger::output(static_cast<stringstream*> (_stream)->str(), _info); Logger::output(static_cast<stringstream*> (_stream)->str(), _info);
delete _stream;
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -51,6 +51,7 @@ namespace triagens {
class LoggerStream { class LoggerStream {
LoggerStream& operator= (LoggerStream const&); LoggerStream& operator= (LoggerStream const&);
LoggerStream (LoggerStream const&);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @} /// @}
@ -80,10 +81,14 @@ namespace triagens {
LoggerStream (LoggerData::Info const&); LoggerStream (LoggerData::Info const&);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief copy constructor /// @brief move or copy constructor
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#if defined(_MSC_VER)
LoggerStream (LoggerStream&&);
#else
LoggerStream (LoggerStream const&); LoggerStream (LoggerStream const&);
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief destructs a logger stream /// @brief destructs a logger stream