From d762bfa1953933dfac0a29a74523c25719396b8c Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Sat, 15 Apr 2023 16:28:33 +0200 Subject: imports: Switch to Microsoft GSL implementation ... with two minor code base changes compared to previous use of gsl-lite: - dag.hpp: ActionNode::Ptr and ArtifactNode::Ptr are not wrapped in gsl::not_null<> anymore, due to lack of support for wrapping std::unique_ptr<>. More specifically, the move constructor is missing, rendering it impossible to use std::vector<>::emplace_back(). - utils/cpp/gsl.hpp: New header file added to implement the macros ExpectsAudit() and EnsureAudit(), asserts running only in debug builds, which were available in gsl-lite but are missing in MS GSL. --- src/buildtool/file_system/git_tree.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/buildtool/file_system/git_tree.hpp') diff --git a/src/buildtool/file_system/git_tree.hpp b/src/buildtool/file_system/git_tree.hpp index ac409e69..5007b106 100644 --- a/src/buildtool/file_system/git_tree.hpp +++ b/src/buildtool/file_system/git_tree.hpp @@ -19,7 +19,7 @@ #include #include -#include "gsl-lite/gsl-lite.hpp" +#include "gsl/gsl" #include "src/buildtool/file_system/git_repo.hpp" #include "src/buildtool/file_system/object_type.hpp" #include "src/buildtool/multithreading/atomic_value.hpp" @@ -69,14 +69,12 @@ class GitTree { entries_t entries_; std::string raw_id_; - GitTree(gsl::not_null cas, + GitTree(gsl::not_null const& cas, entries_t&& entries, std::string raw_id) noexcept - : cas_{std::move(cas)}, - entries_{std::move(entries)}, - raw_id_{std::move(raw_id)} {} + : cas_{cas}, entries_{std::move(entries)}, raw_id_{std::move(raw_id)} {} - [[nodiscard]] static auto FromEntries(gsl::not_null cas, + [[nodiscard]] static auto FromEntries(gsl::not_null const& cas, GitRepo::tree_entries_t&& entries, std::string raw_id) noexcept -> std::optional { @@ -93,16 +91,16 @@ class GitTree { } } } - return GitTree(std::move(cas), std::move(e), std::move(raw_id)); + return GitTree(cas, std::move(e), std::move(raw_id)); } }; class GitTreeEntry { public: - GitTreeEntry(gsl::not_null cas, + GitTreeEntry(gsl::not_null const& cas, std::string raw_id, ObjectType type) noexcept - : cas_{std::move(cas)}, raw_id_{std::move(raw_id)}, type_{type} {} + : cas_{cas}, raw_id_{std::move(raw_id)}, type_{type} {} [[nodiscard]] auto IsBlob() const noexcept { return IsFileObject(type_); } [[nodiscard]] auto IsTree() const noexcept { return IsTreeObject(type_); } -- cgit v1.2.3