From 645896335d675ef045eedc9e652ae1766dbfec09 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 24 Feb 2022 16:07:09 +0300 Subject: [PATCH] code: Convert is_same+result_of assertions into invocable concepts Signed-off-by: Pavel Emelyanov --- cql3/prepared_statements_cache.hh | 3 +-- mutation_partition.cc | 2 +- mutation_partition.hh | 1 + utils/loading_cache.hh | 7 +++---- utils/logalloc.cc | 4 +--- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cql3/prepared_statements_cache.hh b/cql3/prepared_statements_cache.hh index f112ba4ed7..d477ba48b8 100644 --- a/cql3/prepared_statements_cache.hh +++ b/cql3/prepared_statements_cache.hh @@ -141,9 +141,8 @@ public: } template + requires std::is_invocable_r_v> void remove_if(Pred&& pred) { - static_assert(std::is_same)>>::value, "Bad Pred signature"); - _cache.remove_if([&pred] (const prepared_cache_entry& e) { return pred(e->statement); }); diff --git a/mutation_partition.cc b/mutation_partition.cc index 1e95473689..29dc38aca6 100644 --- a/mutation_partition.cc +++ b/mutation_partition.cc @@ -1239,12 +1239,12 @@ size_t mutation_partition::external_memory_usage(const schema& s) const { } template +requires std::is_invocable_r_v void mutation_partition::trim_rows(const schema& s, const std::vector& row_ranges, Func&& func) { check_schema(s); - static_assert(std::is_same>::value, "Bad func signature"); stop_iteration stop = stop_iteration::no; auto last = reversal_traits::begin(_rows); diff --git a/mutation_partition.hh b/mutation_partition.hh index 7b27cf0cd7..f0a2ffcb0e 100644 --- a/mutation_partition.hh +++ b/mutation_partition.hh @@ -1243,6 +1243,7 @@ private: // If reversed is true, func will be called on entries in reverse order. In that case row_ranges // must be already in reverse order. template + requires std::is_invocable_r_v void trim_rows(const schema& s, const std::vector& row_ranges, Func&& func); diff --git a/utils/loading_cache.hh b/utils/loading_cache.hh index 9f4396c052..467353de24 100644 --- a/utils/loading_cache.hh +++ b/utils/loading_cache.hh @@ -216,11 +216,11 @@ private: public: template + requires std::is_invocable_r_v, Func, const key_type&> loading_cache(size_t max_size, lowres_clock::duration expiry, lowres_clock::duration refresh, logging::logger& logger, Func&& load) : loading_cache(max_size, expiry, refresh, logger) { static_assert(ReloadEnabled == loading_cache_reload_enabled::yes, "This constructor should only be invoked when ReloadEnabled == loading_cache_reload_enabled::yes"); - static_assert(std::is_same, std::result_of_t>::value, "Bad Func signature"); _load = std::forward(load); @@ -254,8 +254,8 @@ public: } template + requires std::is_invocable_r_v, LoadFunc, const key_type&> future get_ptr(const Key& k, LoadFunc&& load) { - static_assert(std::is_same, std::result_of_t>::value, "Bad LoadFunc signature"); // We shouldn't be here if caching is disabled assert(caching_enabled()); @@ -332,9 +332,8 @@ public: } template + requires std::is_invocable_r_v void remove_if(Pred&& pred) { - static_assert(std::is_same>::value, "Bad Pred signature"); - auto cond_pred = [this, &pred] (const ts_value_lru_entry& v) { return pred(v.timestamped_value().value()); }; diff --git a/utils/logalloc.cc b/utils/logalloc.cc index 5ce24c8456..47d7ec5655 100644 --- a/utils/logalloc.cc +++ b/utils/logalloc.cc @@ -1309,11 +1309,9 @@ private: } template + requires std::is_invocable_r_v void for_each_live(segment* seg, Func&& func) { // scylla-gdb.py:scylla_lsa_segment is coupled with this implementation. - - static_assert(std::is_same>::value, "bad Func signature"); - auto pos = align_up_for_asan(seg->at(0)); while (pos < seg->at(segment::size)) { auto old_pos = pos;