From 3f41feb6e022a30cfce39ec40c7ffda46d75193d Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 26 May 2023 15:06:49 +0200 Subject: style: Use designated initializers This feature has been introduced with C++20. --- src/buildtool/common/artifact.hpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/buildtool/common/artifact.hpp') diff --git a/src/buildtool/common/artifact.hpp b/src/buildtool/common/artifact.hpp index eb5be3a3..3a593f5b 100644 --- a/src/buildtool/common/artifact.hpp +++ b/src/buildtool/common/artifact.hpp @@ -82,8 +82,9 @@ class Artifact { std::size_t size = std::stoul(size_str); auto const& object_type = FromChar(*type.c_str()); return ObjectInfo{ - ArtifactDigest{id, size, IsTreeObject(object_type)}, - object_type}; + .digest = + ArtifactDigest{id, size, IsTreeObject(object_type)}, + .type = object_type}; } catch (std::out_of_range const& e) { Logger::Log(LogLevel::Debug, "size raised out_of_range exception."); @@ -100,10 +101,11 @@ class Artifact { j["size"].is_number() and j["type"].is_string()) { auto const& object_type = FromChar(*(j["type"].get().c_str())); - return ObjectInfo{ArtifactDigest{j["id"].get(), - j["size"].get(), - IsTreeObject(object_type)}, - object_type}; + return ObjectInfo{ + .digest = ArtifactDigest{j["id"].get(), + j["size"].get(), + IsTreeObject(object_type)}, + .type = object_type}; } return std::nullopt; } @@ -159,8 +161,9 @@ class Artifact { void SetObjectInfo(ObjectInfo const& object_info, bool fail_info) const noexcept { if (fail_info) { - object_info_ = - ObjectInfo{object_info.digest, object_info.type, true}; + object_info_ = ObjectInfo{.digest = object_info.digest, + .type = object_info.type, + .failed = true}; } else { object_info_ = object_info; @@ -170,7 +173,8 @@ class Artifact { void SetObjectInfo(ArtifactDigest const& digest, ObjectType type, bool failed) const noexcept { - object_info_ = ObjectInfo{digest, type, failed}; + object_info_ = + ObjectInfo{.digest = digest, .type = type, .failed = failed}; } [[nodiscard]] static auto CreateLocalArtifact( -- cgit v1.2.3