]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Make File movable and noncopyable
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 6 Oct 2019 19:43:39 +0000 (21:43 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 7 Oct 2019 07:37:59 +0000 (09:37 +0200)
src/File.hpp

index 0e639db43ee3e51496183af25162792eb262967f..d36dbdcb691423e5ef59ff267b8cf2ea875cbc7a 100644 (file)
 // 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 <cstdio>
 #include <string>
 
-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)
   {