Merge pull request #4611 from lioncash/fileutil

IOFile: Minor changes
This commit is contained in:
JosJuice 2017-01-05 09:17:03 +01:00 committed by GitHub
commit 41101be545
2 changed files with 8 additions and 11 deletions

View File

@ -908,18 +908,18 @@ IOFile::~IOFile()
Close();
}
IOFile::IOFile(IOFile&& other) : m_file(nullptr), m_good(true)
IOFile::IOFile(IOFile&& other) noexcept : m_file(nullptr), m_good(true)
{
Swap(other);
}
IOFile& IOFile::operator=(IOFile&& other)
IOFile& IOFile::operator=(IOFile&& other) noexcept
{
Swap(other);
return *this;
}
void IOFile::Swap(IOFile& other)
void IOFile::Swap(IOFile& other) noexcept
{
std::swap(m_file, other.m_file);
std::swap(m_good, other.m_good);

View File

@ -168,10 +168,10 @@ public:
~IOFile();
IOFile(IOFile&& other);
IOFile& operator=(IOFile&& other);
IOFile(IOFile&& other) noexcept;
IOFile& operator=(IOFile&& other) noexcept;
void Swap(IOFile& other);
void Swap(IOFile& other) noexcept;
bool Open(const std::string& filename, const char openmode[]);
bool Close();
@ -211,7 +211,7 @@ public:
bool IsOpen() const { return nullptr != m_file; }
// m_good is set to false when a read, write or other function fails
bool IsGood() const { return m_good; }
operator void*() { return m_good ? m_file : nullptr; }
explicit operator bool() const { return IsGood(); }
std::FILE* ReleaseHandle();
std::FILE* GetHandle() { return m_file; }
@ -230,12 +230,9 @@ public:
std::clearerr(m_file);
}
private:
std::FILE* m_file;
bool m_good;
private:
IOFile(IOFile&);
IOFile& operator=(IOFile& other);
};
} // namespace