From 00e10ea721796f660b3479eb6f862125c255dc88 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 14 Apr 2022 00:02:42 +0200 Subject: Add move constructor. --- src/file.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/file.cc') diff --git a/src/file.cc b/src/file.cc index 9ee91fe7..74db8396 100644 --- a/src/file.cc +++ b/src/file.cc @@ -58,6 +58,26 @@ File::File(boost::filesystem::path path, std::string mode) } +File::File(File&& other) + : _path(other._path) + , _file(other._file) +{ + other._file = nullptr; +} + + +File& +File::operator=(File&& other) +{ + if (*this != other) { + close(); + _file = other._file; + other._file = nullptr; + } + return *this; +} + + void File::close() { -- cgit v1.2.3