From: Joel Rosdahl Date: Sun, 6 Oct 2019 19:43:39 +0000 (+0200) Subject: Make File movable and noncopyable X-Git-Tag: v4.0~755 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1cb1990643f6e1dd3693705a6be465bb36e9e1a2;p=thirdparty%2Fccache.git Make File movable and noncopyable --- diff --git a/src/File.hpp b/src/File.hpp index 0e639db43..d36dbdcb6 100644 --- a/src/File.hpp +++ b/src/File.hpp @@ -16,10 +16,12 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +#include "NonCopyable.hpp" + #include #include -class File +class File : public NonCopyable { public: File(const std::string& path, const char* mode) @@ -27,6 +29,19 @@ public: open(path, mode); } + File(File&& other) : m_file(other.m_file) + { + other.m_file = nullptr; + } + + File& + operator=(File&& other) + { + m_file = other.m_file; + other.m_file = nullptr; + return *this; + } + void open(const std::string& path, const char* mode) {