code: Convert is_same+result_of assertions into invocable concepts

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2022-02-24 16:07:09 +03:00
parent 063da81ab7
commit 645896335d
5 changed files with 7 additions and 10 deletions

View File

@@ -141,9 +141,8 @@ public:
}
template <typename Pred>
requires std::is_invocable_r_v<bool, Pred, ::shared_ptr<cql_statement>>
void remove_if(Pred&& pred) {
static_assert(std::is_same<bool, std::result_of_t<Pred(::shared_ptr<cql_statement>)>>::value, "Bad Pred signature");
_cache.remove_if([&pred] (const prepared_cache_entry& e) {
return pred(e->statement);
});

View File

@@ -1239,12 +1239,12 @@ size_t mutation_partition::external_memory_usage(const schema& s) const {
}
template<bool reversed, typename Func>
requires std::is_invocable_r_v<stop_iteration, Func, rows_entry&>
void mutation_partition::trim_rows(const schema& s,
const std::vector<query::clustering_range>& row_ranges,
Func&& func)
{
check_schema(s);
static_assert(std::is_same<stop_iteration, std::result_of_t<Func(rows_entry&)>>::value, "Bad func signature");
stop_iteration stop = stop_iteration::no;
auto last = reversal_traits<reversed>::begin(_rows);

View File

@@ -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<bool reversed, typename Func>
requires std::is_invocable_r_v<stop_iteration, Func, rows_entry&>
void trim_rows(const schema& s,
const std::vector<query::clustering_range>& row_ranges,
Func&& func);

View File

@@ -216,11 +216,11 @@ private:
public:
template<typename Func>
requires std::is_invocable_r_v<future<value_type>, 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<future<value_type>, std::result_of_t<Func(const key_type&)>>::value, "Bad Func signature");
_load = std::forward<Func>(load);
@@ -254,8 +254,8 @@ public:
}
template <typename LoadFunc>
requires std::is_invocable_r_v<future<value_type>, LoadFunc, const key_type&>
future<value_ptr> get_ptr(const Key& k, LoadFunc&& load) {
static_assert(std::is_same<future<value_type>, std::result_of_t<LoadFunc(const key_type&)>>::value, "Bad LoadFunc signature");
// We shouldn't be here if caching is disabled
assert(caching_enabled());
@@ -332,9 +332,8 @@ public:
}
template <typename Pred>
requires std::is_invocable_r_v<bool, Pred, const value_type&>
void remove_if(Pred&& pred) {
static_assert(std::is_same<bool, std::result_of_t<Pred(const value_type&)>>::value, "Bad Pred signature");
auto cond_pred = [this, &pred] (const ts_value_lru_entry& v) {
return pred(v.timestamped_value().value());
};

View File

@@ -1309,11 +1309,9 @@ private:
}
template<typename Func>
requires std::is_invocable_r_v<void, Func, const object_descriptor*, void*, size_t>
void for_each_live(segment* seg, Func&& func) {
// scylla-gdb.py:scylla_lsa_segment is coupled with this implementation.
static_assert(std::is_same<void, std::result_of_t<Func(const object_descriptor*, void*, size_t)>>::value, "bad Func signature");
auto pos = align_up_for_asan(seg->at<const char>(0));
while (pos < seg->at<const char>(segment::size)) {
auto old_pos = pos;