summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/archive/archive_ops.cpp8
-rw-r--r--src/utils/cpp/atomic.hpp4
-rw-r--r--src/utils/cpp/concepts.hpp59
-rw-r--r--src/utils/cpp/hash_combine.hpp4
-rw-r--r--src/utils/cpp/json.hpp4
-rw-r--r--src/utils/cpp/type_safe_arithmetic.hpp16
6 files changed, 48 insertions, 47 deletions
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<std::string> {
+auto ArchiveOps::WriteEntry(archive_entry* entry,
+ archive* aw) -> std::optional<std::string> {
#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<std::string> {
+auto ArchiveOps::CopyData(archive* ar,
+ archive* aw) -> std::optional<std::string> {
#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 <class T, class U>
-concept derived_from = std::is_base_of_v<U, T>&&
+concept derived_from =
+ std::is_base_of_v<U, T> &&
std::is_convertible_v<const volatile T*, const volatile U*>;
// TODO(modernize): remove this once std::same_as is shipped with libcxx
template <class T, class U>
-concept same_as = std::is_same_v<T, U>and std::is_same_v<U, T>;
+concept same_as = std::is_same_v<T, U> and std::is_same_v<U, T>;
template <class T>
-concept ContainsString = requires {
- typename T::value_type;
-}
-and std::is_same_v<typename T::value_type, std::string>;
+concept ContainsString = requires { typename T::value_type; } and
+ std::is_same_v<typename T::value_type, std::string>;
template <class T>
concept HasSize = requires(T const c) {
- { c.size() }
- ->same_as<std::size_t>; // TODO(modernize): replace by std::same_as
+ {
+ c.size()
+ } -> same_as<std::size_t>; // TODO(modernize): replace by std::same_as
};
template <typename T>
concept HasToString = requires(T const t) {
- { t.ToString() }
- ->same_as<std::string>; // TODO(modernize): replace by std::same_as
+ {
+ t.ToString()
+ } -> same_as<std::string>; // TODO(modernize): replace by std::same_as
};
template <class T>
concept InputIterableContainer = requires(T const c) {
- { c.begin() }
- ->same_as<typename T::const_iterator>; // TODO(modernize): replace by
- // std::input_iterator
- { c.end() }
- ->same_as<typename T::const_iterator>; // TODO(modernize): replace by
- // std::input_iterator
+ {
+ c.begin()
+ } -> same_as<typename T::const_iterator>; // TODO(modernize): replace by
+ // std::input_iterator
+ {
+ c.end()
+ } -> same_as<typename T::const_iterator>; // TODO(modernize): replace by
+ // std::input_iterator
};
template <class T>
-concept OutputIterableContainer = InputIterableContainer<T>and requires(T c) {
- { std::inserter(c, c.begin()) }
- ->same_as<std::insert_iterator<T>>; // TODO(modernize): replace by
- // std::output_iterator
+concept OutputIterableContainer = InputIterableContainer<T> and requires(T c) {
+ {
+ std::inserter(c, c.begin())
+ } -> same_as<std::insert_iterator<T>>; // TODO(modernize): replace by
+ // std::output_iterator
};
template <class T>
concept InputIterableStringContainer =
- InputIterableContainer<T>and ContainsString<T>;
+ InputIterableContainer<T> and ContainsString<T>;
// TODO(modernize): remove this once we require clang version >= 14.0.0
template <typename T>
concept ClockHasFromSys =
requires(std::chrono::time_point<std::chrono::system_clock> const tp) {
- T::from_sys(tp);
-};
+ T::from_sys(tp);
+ };
// TODO(modernize): remove this once we require clang version >= 14.0.0
template <typename T>
-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 <typename T>
concept StrMapConstForwardIterator = requires(T const c) {
{
- std::remove_reference_t<decltype((*c).first)> { (*c).first }
- }
- ->same_as<std::string const>;
+ std::remove_reference_t<decltype((*c).first)>{(*c).first}
+ } -> same_as<std::string const>;
};
#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 <class T>
-inline auto hash_combine(gsl::not_null<std::size_t*> const& seed, T const& v)
- -> void {
+inline auto hash_combine(gsl::not_null<std::size_t*> const& seed,
+ T const& v) -> void {
*seed ^=
std::hash<T>{}(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<void(std::string const& error)>&& logger =
- [](std::string const& /*unused*/) -> void {}) noexcept
- -> std::optional<ValueT> {
+ [](std::string const& /*unused*/) -> void {
+ }) noexcept -> std::optional<ValueT> {
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 <typename TAG>
-auto operator+=(type_safe_arithmetic<TAG>& lhs, type_safe_arithmetic<TAG> rhs)
- -> type_safe_arithmetic<TAG>& {
+auto operator+=(type_safe_arithmetic<TAG>& lhs,
+ type_safe_arithmetic<TAG> rhs) -> type_safe_arithmetic<TAG>& {
lhs.set(lhs.get() + rhs.get());
return lhs;
}
@@ -189,8 +189,8 @@ auto operator+=(type_safe_arithmetic<TAG>& lhs, type_safe_arithmetic<TAG> rhs)
// }
template <typename TAG>
-auto operator++(type_safe_arithmetic<TAG>& a, int)
- -> type_safe_arithmetic<TAG> {
+auto operator++(type_safe_arithmetic<TAG>& a,
+ int) -> type_safe_arithmetic<TAG> {
auto r = a;
a += type_safe_arithmetic<TAG>{1};
return r;