summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-02-23 18:50:24 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2024-03-07 16:06:10 +0100
commitbbeef185dc79a335c983fdd3b503ae10e590458e (patch)
tree7c39b78388c7255e282b1dbdc6fb9328fd2c3ac5 /src/utils
parent6597438e4644087529d88c0979b3cef20cabc44d (diff)
downloadjustbuild-bbeef185dc79a335c983fdd3b503ae10e590458e.tar.gz
TmpDir: Getter should return const ref
... and prohibit moves and move assignments.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/cpp/tmp_dir.cpp2
-rw-r--r--src/utils/cpp/tmp_dir.hpp12
2 files changed, 8 insertions, 6 deletions
diff --git a/src/utils/cpp/tmp_dir.cpp b/src/utils/cpp/tmp_dir.cpp
index b0cc4905..987bcbcf 100644
--- a/src/utils/cpp/tmp_dir.cpp
+++ b/src/utils/cpp/tmp_dir.cpp
@@ -53,7 +53,7 @@ auto TmpDir::Create(std::filesystem::path const& prefix,
}
}
-auto TmpDir::GetPath() const noexcept -> std::filesystem::path {
+auto TmpDir::GetPath() const& noexcept -> std::filesystem::path const& {
return tmp_dir_;
}
diff --git a/src/utils/cpp/tmp_dir.hpp b/src/utils/cpp/tmp_dir.hpp
index b0dd5e5e..3801e7a0 100644
--- a/src/utils/cpp/tmp_dir.hpp
+++ b/src/utils/cpp/tmp_dir.hpp
@@ -33,13 +33,15 @@ class TmpDir {
/// \brief Destroy the TmpDir object. It tries to remove the tmp folder.
~TmpDir() noexcept;
- // no copies, only moves
+ // no copies, no moves
TmpDir(TmpDir const&) = delete;
- TmpDir(TmpDir&& other) noexcept = default;
+ TmpDir(TmpDir&& other) noexcept = delete;
auto operator=(TmpDir const&) = delete;
- auto operator=(TmpDir&& other) noexcept -> TmpDir& = default;
+ auto operator=(TmpDir&& other) noexcept -> TmpDir& = delete;
- [[nodiscard]] auto GetPath() const noexcept -> std::filesystem::path;
+ [[nodiscard]] auto GetPath() const& noexcept
+ -> std::filesystem::path const&;
+ [[nodiscard]] auto GetPath() && = delete;
/// \brief Creates a completely unique directory in a given prefix path.
[[nodiscard]] static auto Create(
@@ -51,4 +53,4 @@ class TmpDir {
std::filesystem::path tmp_dir_{};
};
-#endif // INCLUDED_SRC_OTHER_TOOLS_TMP_DIR_HPP \ No newline at end of file
+#endif // INCLUDED_SRC_OTHER_TOOLS_TMP_DIR_HPP