Make DeletingFile movable.
PiperOrigin-RevId: 592332785
This commit is contained in:
parent
5ee24d1662
commit
7c3a5296ab
|
@ -17,10 +17,25 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "absl/log/absl_log.h"
|
||||
|
||||
namespace mediapipe {
|
||||
|
||||
DeletingFile::DeletingFile(DeletingFile&& other)
|
||||
: path_(std::move(other.path_)),
|
||||
delete_on_destruction_(other.delete_on_destruction_) {
|
||||
other.delete_on_destruction_ = false;
|
||||
}
|
||||
|
||||
DeletingFile& DeletingFile::operator=(DeletingFile&& other) {
|
||||
path_ = std::move(other.path_);
|
||||
delete_on_destruction_ = other.delete_on_destruction_;
|
||||
other.delete_on_destruction_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeletingFile::DeletingFile(const std::string& path, bool delete_on_destruction)
|
||||
: path_(path), delete_on_destruction_(delete_on_destruction) {}
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ class DeletingFile {
|
|||
DeletingFile(const DeletingFile&) = delete;
|
||||
DeletingFile& operator=(const DeletingFile&) = delete;
|
||||
|
||||
// DeletingFile is movable. The moved-from object remains in valid but
|
||||
// unspecified state and will not perform any operations on destruction.
|
||||
DeletingFile(DeletingFile&& other);
|
||||
DeletingFile& operator=(DeletingFile&& other);
|
||||
|
||||
// Provide the path to the file and whether the file should be deleted
|
||||
// when this object is destroyed.
|
||||
DeletingFile(const std::string& path, bool delete_on_destruction);
|
||||
|
|
Loading…
Reference in New Issue
Block a user