disallow move/copy of `ScopedFile` (#4723)

This commit is contained in:
Oliver Stöneberg 2023-03-02 20:44:29 +01:00 committed by GitHub
parent cfba046408
commit b53bb36798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -81,6 +81,12 @@ public:
{
return mFullPath;
}
ScopedFile(const ScopedFile&) = delete;
ScopedFile(ScopedFile&&) = delete;
ScopedFile& operator=(const ScopedFile&) = delete;
ScopedFile& operator=(ScopedFile&&) = delete;
private:
const std::string mName;
const std::string mPath;

View File

@ -26,6 +26,7 @@
#include <algorithm>
#include <cstddef>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
@ -56,10 +57,10 @@ private:
settings.jobs = jobs;
settings.showtime = showtime;
ProcessExecutor executor(filemap, settings, *this);
std::vector<ScopedFile> scopedfiles;
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
scopedfiles.reserve(filemap.size());
for (std::map<std::string, std::size_t>::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i)
scopedfiles.emplace_back(i->first, data);
scopedfiles.emplace_back(new ScopedFile(i->first, data));
ASSERT_EQUALS(result, executor.check());
}

View File

@ -226,10 +226,10 @@ private:
EXPECT_EQ("", settings.nomsg.addSuppressionLine(suppression));
}
ThreadExecutor executor(files, settings, *this);
std::vector<ScopedFile> scopedfiles;
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
scopedfiles.reserve(files.size());
for (std::map<std::string, std::size_t>::const_iterator i = files.cbegin(); i != files.cend(); ++i)
scopedfiles.emplace_back(i->first, code);
scopedfiles.emplace_back(new ScopedFile(i->first, code));
const unsigned int exitCode = executor.check();
@ -254,10 +254,10 @@ private:
EXPECT_EQ("", settings.nomsg.addSuppressionLine(suppression));
}
ProcessExecutor executor(files, settings, *this);
std::vector<ScopedFile> scopedfiles;
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
scopedfiles.reserve(files.size());
for (std::map<std::string, std::size_t>::const_iterator i = files.cbegin(); i != files.cend(); ++i)
scopedfiles.emplace_back(i->first, code);
scopedfiles.emplace_back(new ScopedFile(i->first, code));
const unsigned int exitCode = executor.check();

View File

@ -26,6 +26,7 @@
#include <algorithm>
#include <cstddef>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
@ -56,10 +57,10 @@ private:
settings.jobs = jobs;
settings.showtime = showtime;
ThreadExecutor executor(filemap, settings, *this);
std::vector<ScopedFile> scopedfiles;
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
scopedfiles.reserve(filemap.size());
for (std::map<std::string, std::size_t>::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i)
scopedfiles.emplace_back(i->first, data);
scopedfiles.emplace_back(new ScopedFile(i->first, data));
ASSERT_EQUALS(result, executor.check());
}