While I was making myself familliar with C++14 specification, I have read that, if a class has no explicitly declared Copy Constructor, Copy Assignment Operator, Move Constructor nor Move Assignment Operator, default implementations should be generated by the compiler.
Consider this empty class for thread safe files:
class ThreadSafeFile
{
std::mutex m_mutex;
std::string m_FileName;
std::ofstream m_File;
};
When I try to move assign it like this:
ThreadSafeFile file;
ThreadSafeFile file2 = std::move(file);
I am getting this compilation error:
function "ThreadSafeFile::ThreadSafeFile(const ThreadSafeFile &)" (declared implicitly) cannot be referenced -- it is a deleted function
Why is that so?