summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/expression/evaluator.hpp14
-rw-r--r--src/buildtool/storage/garbage_collector.cpp5
-rw-r--r--src/other_tools/just_mr/launch.cpp4
-rw-r--r--src/utils/cpp/atomic.hpp13
-rw-r--r--src/utils/cpp/type_safe_arithmetic.hpp2
5 files changed, 23 insertions, 15 deletions
diff --git a/src/buildtool/build_engine/expression/evaluator.hpp b/src/buildtool/build_engine/expression/evaluator.hpp
index 726df568..ba9bd2ef 100644
--- a/src/buildtool/build_engine/expression/evaluator.hpp
+++ b/src/buildtool/build_engine/expression/evaluator.hpp
@@ -44,18 +44,20 @@ class Evaluator {
class EvaluationError : public std::exception {
public:
- explicit EvaluationError(std::string const& msg,
+ explicit EvaluationError(std::string msg,
bool while_eval = false,
bool user_context = false,
std::vector<ExpressionPtr> involved_objetcs =
std::vector<ExpressionPtr>{}) noexcept
- : msg_{(while_eval ? ""
- : (user_context ? "UserError: "
- : "EvaluationError: ")) +
- msg},
+ : msg_{std::move(msg)},
while_eval_{while_eval},
user_context_{user_context},
- involved_objects_{std::move(std::move(involved_objetcs))} {}
+ involved_objects_{std::move(std::move(involved_objetcs))} {
+ if (not while_eval_) {
+ msg_ = (user_context_ ? "UserError: " : "EvaluationError: ") +
+ msg_;
+ }
+ }
[[nodiscard]] auto what() const noexcept -> char const* final {
return msg_.c_str();
}
diff --git a/src/buildtool/storage/garbage_collector.cpp b/src/buildtool/storage/garbage_collector.cpp
index 817e5240..6f41dcd8 100644
--- a/src/buildtool/storage/garbage_collector.cpp
+++ b/src/buildtool/storage/garbage_collector.cpp
@@ -89,7 +89,8 @@ auto GarbageCollector::TriggerGarbageCollection(
for (auto const& entry :
std::filesystem::directory_iterator(storage_config.CacheRoot())) {
- if (entry.path().filename().string().find(remove_me_prefix) == 0) {
+ if (entry.path().filename().string().starts_with(
+ remove_me_prefix)) {
to_remove.emplace_back(entry.path());
}
}
@@ -120,7 +121,7 @@ auto GarbageCollector::TriggerGarbageCollection(
std::vector<std::filesystem::path> left_over{};
for (auto const& entry :
std::filesystem::directory_iterator(storage_config.CacheRoot())) {
- if (entry.path().filename().string().find(kRemoveMe) == 0) {
+ if (entry.path().filename().string().starts_with(kRemoveMe)) {
left_over.emplace_back(entry.path());
}
}
diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp
index ccebd966..16429864 100644
--- a/src/other_tools/just_mr/launch.cpp
+++ b/src/other_tools/just_mr/launch.cpp
@@ -138,13 +138,13 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
if (log_args.log_limit and *log_args.log_limit != kDefaultLogLevel) {
cmd.emplace_back("--log-limit");
cmd.emplace_back(
- std::to_string(static_cast<std::underlying_type<LogLevel>::type>(
+ std::to_string(static_cast<std::underlying_type_t<LogLevel>>(
*log_args.log_limit)));
}
if (log_args.restrict_stderr_log_limit) {
cmd.emplace_back("--restrict-stderr-log-limit");
cmd.emplace_back(
- std::to_string(static_cast<std::underlying_type<LogLevel>::type>(
+ std::to_string(static_cast<std::underlying_type_t<LogLevel>>(
*log_args.restrict_stderr_log_limit)));
}
if (log_args.plain_log) {
diff --git a/src/utils/cpp/atomic.hpp b/src/utils/cpp/atomic.hpp
index 4ef7e40c..b610a350 100644
--- a/src/utils/cpp/atomic.hpp
+++ b/src/utils/cpp/atomic.hpp
@@ -18,6 +18,7 @@
#include <atomic>
#include <condition_variable>
#include <shared_mutex>
+#include <type_traits>
#include <utility> // std::move
// Atomic wrapper with notify/wait capabilities.
@@ -51,22 +52,26 @@ class atomic {
return value_.load(order);
}
- template <class U = T, class = std::enable_if_t<std::is_integral_v<U>>>
+ template <class U = T>
+ requires(std::is_integral_v<U>)
auto operator++() -> T {
std::shared_lock lock(mutex_);
return ++value_;
}
- template <class U = T, class = std::enable_if_t<std::is_integral_v<U>>>
+ template <class U = T>
+ requires(std::is_integral_v<U>)
[[nodiscard]] auto operator++(int) -> T {
std::shared_lock lock(mutex_);
return value_++;
}
- template <class U = T, class = std::enable_if_t<std::is_integral_v<U>>>
+ template <class U = T>
+ requires(std::is_integral_v<U>)
auto operator--() -> T {
std::shared_lock lock(mutex_);
return --value_;
}
- template <class U = T, class = std::enable_if_t<std::is_integral_v<U>>>
+ template <class U = T>
+ requires(std::is_integral_v<U>)
[[nodiscard]] auto operator--(int) -> T {
std::shared_lock lock(mutex_);
return value_--;
diff --git a/src/utils/cpp/type_safe_arithmetic.hpp b/src/utils/cpp/type_safe_arithmetic.hpp
index be2ca405..690e9a86 100644
--- a/src/utils/cpp/type_safe_arithmetic.hpp
+++ b/src/utils/cpp/type_safe_arithmetic.hpp
@@ -30,7 +30,7 @@ template <typename T,
T MAX_VALUE = std::numeric_limits<T>::max(),
T SMALLEST_VALUE = std::numeric_limits<T>::min()>
struct type_safe_arithmetic_tag {
- static_assert(std::is_arithmetic<T>::value,
+ static_assert(std::is_arithmetic_v<T>,
"T must be an arithmetic type (integer or floating-point)");
using value_t = T;