From bc39ecc0385dd7e0cb9e1df84628e4c6dde34ab5 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 27 Aug 2024 11:14:38 +0200 Subject: Reformat code to comply with clang-format 18 ... while keeping our .clang-format file. --- src/utils/archive/archive_ops.cpp | 8 ++--- src/utils/cpp/atomic.hpp | 4 +-- src/utils/cpp/concepts.hpp | 59 +++++++++++++++++----------------- src/utils/cpp/hash_combine.hpp | 4 +-- src/utils/cpp/json.hpp | 4 +-- src/utils/cpp/type_safe_arithmetic.hpp | 16 ++++----- 6 files changed, 48 insertions(+), 47 deletions(-) (limited to 'src/utils') diff --git a/src/utils/archive/archive_ops.cpp b/src/utils/archive/archive_ops.cpp index 59b1d8a0..8e70c814 100644 --- a/src/utils/archive/archive_ops.cpp +++ b/src/utils/archive/archive_ops.cpp @@ -95,8 +95,8 @@ auto enable_read_filter(archive* ar, ArchiveType type) -> bool { } // namespace #endif // BOOTSTRAP_BUILD_TOOL -auto ArchiveOps::WriteEntry(archive_entry* entry, archive* aw) - -> std::optional { +auto ArchiveOps::WriteEntry(archive_entry* entry, + archive* aw) -> std::optional { #ifndef BOOTSTRAP_BUILD_TOOL std::filesystem::path entry_path{archive_entry_sourcepath(entry)}; // only write to archive if entry is file @@ -115,8 +115,8 @@ auto ArchiveOps::WriteEntry(archive_entry* entry, archive* aw) return std::nullopt; } -auto ArchiveOps::CopyData(archive* ar, archive* aw) - -> std::optional { +auto ArchiveOps::CopyData(archive* ar, + archive* aw) -> std::optional { #ifndef BOOTSTRAP_BUILD_TOOL int r{}; const void* buff{nullptr}; diff --git a/src/utils/cpp/atomic.hpp b/src/utils/cpp/atomic.hpp index 13dc8ca9..4ef7e40c 100644 --- a/src/utils/cpp/atomic.hpp +++ b/src/utils/cpp/atomic.hpp @@ -102,8 +102,8 @@ class atomic_shared_ptr { atomic_shared_ptr(atomic_shared_ptr&& other) = delete; ~atomic_shared_ptr() = default; - auto operator=(atomic_shared_ptr const& other) - -> atomic_shared_ptr& = delete; + auto operator=(atomic_shared_ptr const& other) -> atomic_shared_ptr& = + delete; auto operator=(atomic_shared_ptr&& other) -> atomic_shared_ptr& = delete; auto operator=(ptr_t desired) -> ptr_t { // NOLINT std::shared_lock lock(mutex_); diff --git a/src/utils/cpp/concepts.hpp b/src/utils/cpp/concepts.hpp index 548fb960..90946762 100644 --- a/src/utils/cpp/concepts.hpp +++ b/src/utils/cpp/concepts.hpp @@ -22,71 +22,72 @@ // TODO(modernize): remove this once std::derived_from is shipped with libcxx template -concept derived_from = std::is_base_of_v&& +concept derived_from = + std::is_base_of_v && std::is_convertible_v; // TODO(modernize): remove this once std::same_as is shipped with libcxx template -concept same_as = std::is_same_vand std::is_same_v; +concept same_as = std::is_same_v and std::is_same_v; template -concept ContainsString = requires { - typename T::value_type; -} -and std::is_same_v; +concept ContainsString = requires { typename T::value_type; } and + std::is_same_v; template concept HasSize = requires(T const c) { - { c.size() } - ->same_as; // TODO(modernize): replace by std::same_as + { + c.size() + } -> same_as; // TODO(modernize): replace by std::same_as }; template concept HasToString = requires(T const t) { - { t.ToString() } - ->same_as; // TODO(modernize): replace by std::same_as + { + t.ToString() + } -> same_as; // TODO(modernize): replace by std::same_as }; template concept InputIterableContainer = requires(T const c) { - { c.begin() } - ->same_as; // TODO(modernize): replace by - // std::input_iterator - { c.end() } - ->same_as; // TODO(modernize): replace by - // std::input_iterator + { + c.begin() + } -> same_as; // TODO(modernize): replace by + // std::input_iterator + { + c.end() + } -> same_as; // TODO(modernize): replace by + // std::input_iterator }; template -concept OutputIterableContainer = InputIterableContainerand requires(T c) { - { std::inserter(c, c.begin()) } - ->same_as>; // TODO(modernize): replace by - // std::output_iterator +concept OutputIterableContainer = InputIterableContainer and requires(T c) { + { + std::inserter(c, c.begin()) + } -> same_as>; // TODO(modernize): replace by + // std::output_iterator }; template concept InputIterableStringContainer = - InputIterableContainerand ContainsString; + InputIterableContainer and ContainsString; // TODO(modernize): remove this once we require clang version >= 14.0.0 template concept ClockHasFromSys = requires(std::chrono::time_point const tp) { - T::from_sys(tp); -}; + T::from_sys(tp); + }; // TODO(modernize): remove this once we require clang version >= 14.0.0 template -concept ClockHasFromTime = requires(std::time_t const t) { - T::from_time_t(t); -}; +concept ClockHasFromTime = requires(std::time_t const t) { T::from_time_t(t); }; template concept StrMapConstForwardIterator = requires(T const c) { { - std::remove_reference_t { (*c).first } - } - ->same_as; + std::remove_reference_t{(*c).first} + } -> same_as; }; #endif // INCLUDED_SRC_UTILS_CPP_CONCEPTS_HPP diff --git a/src/utils/cpp/hash_combine.hpp b/src/utils/cpp/hash_combine.hpp index a09c9985..78fed417 100644 --- a/src/utils/cpp/hash_combine.hpp +++ b/src/utils/cpp/hash_combine.hpp @@ -22,8 +22,8 @@ // Taken from Boost, as hash_combine did not yet make it to STL. // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0814r0.pdf template -inline auto hash_combine(gsl::not_null const& seed, T const& v) - -> void { +inline auto hash_combine(gsl::not_null const& seed, + T const& v) -> void { *seed ^= std::hash{}(v) + 0x9e3779b9 + (*seed << 6) + (*seed >> 2); // NOLINT } diff --git a/src/utils/cpp/json.hpp b/src/utils/cpp/json.hpp index 64c208a7..1fe4df3f 100644 --- a/src/utils/cpp/json.hpp +++ b/src/utils/cpp/json.hpp @@ -33,8 +33,8 @@ auto ExtractValueAs( nlohmann::json const& j, std::string const& key, std::function&& logger = - [](std::string const& /*unused*/) -> void {}) noexcept - -> std::optional { + [](std::string const& /*unused*/) -> void { + }) noexcept -> std::optional { try { auto it = j.find(key); if (it == j.end()) { diff --git a/src/utils/cpp/type_safe_arithmetic.hpp b/src/utils/cpp/type_safe_arithmetic.hpp index 373f76fc..be2ca405 100644 --- a/src/utils/cpp/type_safe_arithmetic.hpp +++ b/src/utils/cpp/type_safe_arithmetic.hpp @@ -70,10 +70,10 @@ class type_safe_arithmetic { type_safe_arithmetic(type_safe_arithmetic const&) = default; type_safe_arithmetic(type_safe_arithmetic&&) noexcept = default; - auto operator=(type_safe_arithmetic const&) - -> type_safe_arithmetic& = default; - auto operator=(type_safe_arithmetic&&) noexcept - -> type_safe_arithmetic& = default; + auto operator=(type_safe_arithmetic const&) -> type_safe_arithmetic& = + default; + auto operator=(type_safe_arithmetic&&) noexcept -> type_safe_arithmetic& = + default; ~type_safe_arithmetic() = default; auto operator=(value_t value) -> type_safe_arithmetic& { @@ -138,8 +138,8 @@ class type_safe_arithmetic { // } template -auto operator+=(type_safe_arithmetic& lhs, type_safe_arithmetic rhs) - -> type_safe_arithmetic& { +auto operator+=(type_safe_arithmetic& lhs, + type_safe_arithmetic rhs) -> type_safe_arithmetic& { lhs.set(lhs.get() + rhs.get()); return lhs; } @@ -189,8 +189,8 @@ auto operator+=(type_safe_arithmetic& lhs, type_safe_arithmetic rhs) // } template -auto operator++(type_safe_arithmetic& a, int) - -> type_safe_arithmetic { +auto operator++(type_safe_arithmetic& a, + int) -> type_safe_arithmetic { auto r = a; a += type_safe_arithmetic{1}; return r; -- cgit v1.2.3