I have been reading up on C++11's new move semantics, and what itsn't clear to me is if using a custom constructor prevents the compiler from automatically adding move semantics to your class. I don't understand if the rule of 5 also includes simple classes like the one below.
I have the following class:
class CodeFile
{
private:
std::vector<Function> functions;
//std::vector<std::wstring, unsigned long> variables;
std::vector<std::wstring> lines;
std::vector<unsigned char> constants;
public:
std::wstring directory;
std::wstring fileName;
void setFilePath(std::wstring filePath);
bool addFunction(Function function);
void Run();
void Finalize();
CodeFile(std::wstring filePath);
};
With the last line being the constructor. Does defining this constructor prevent the compiler from optimizing the class by adding move constructors?
Should I declare the class as following instead?
class CodeFile
{
private:
std::vector<Function> functions;
//std::vector<std::wstring, unsigned long> variables;
std::vector<std::wstring> lines;
std::vector<unsigned char> constants;
public:
std::wstring directory;
std::wstring fileName;
void setFilePath(std::wstring filePath);
bool addFunction(Function function);
void Run();
void Finalize();
static CodeFile fromFile(std::wstring filePath);
};