projects
/
libdcp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
915991a
)
Add move constructor.
author
Carl Hetherington
<cth@carlh.net>
Wed, 13 Apr 2022 22:02:42 +0000
(
00:02
+0200)
committer
Carl Hetherington
<cth@carlh.net>
Thu, 5 May 2022 19:46:30 +0000
(21:46 +0200)
src/file.cc
patch
|
blob
|
history
src/file.h
patch
|
blob
|
history
diff --git
a/src/file.cc
b/src/file.cc
index 9ee91fe709aa03c36503d6c03eb1c6834b89f624..74db83965e1fa8d89043ef6135f4cd13eb791cf1 100644
(file)
--- 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()
{
diff --git
a/src/file.h
b/src/file.h
index bedceada7140254719d1953a923355a7b3b8f80c..26d0704a6ae42af53fa1f7dd24be75b898f9b09e 100644
(file)
--- a/
src/file.h
+++ b/
src/file.h
@@
-52,6
+52,10
@@
public:
* @param mode mode flags, as for fopen(3)
*/
File(boost::filesystem::path, std::string mode);
+
+ File(File&& other);
+ File& operator=(File&& other);
+
~File();
File(File const&) = delete;