From 97e411bc968ebe8aa0115423cae5cc435eeb3f1d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 11 Mar 2023 17:22:57 +0800 Subject: [PATCH] sstables: sstable_directory: add type constraints add type constraits for `sstable_directory::parallel_for_each_restricted()`, to enforce the constraints on the function so it should be invocable with the argument of specified type. this helps to prevent the problems of passing function which accepts `pair` or `tuple`. Signed-off-by: Kefu Chai --- sstables/sstable_directory.cc | 2 ++ sstables/sstable_directory.hh | 1 + 2 files changed, 3 insertions(+) diff --git a/sstables/sstable_directory.cc b/sstables/sstable_directory.cc index 574fa08f34..7cd6f5f420 100644 --- a/sstables/sstable_directory.cc +++ b/sstables/sstable_directory.cc @@ -6,6 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +#include #include #include #include @@ -361,6 +362,7 @@ sstable_directory::do_for_each_sstable(std::function(sstables::shared_s } template +requires std::is_invocable_r_v, Func, typename std::decay_t::value_type&> future<> sstable_directory::parallel_for_each_restricted(Container&& C, Func&& func) { return do_with(std::move(C), std::move(func), [this] (Container& c, Func& func) mutable { diff --git a/sstables/sstable_directory.hh b/sstables/sstable_directory.hh index eed7af55bf..9985e96e05 100644 --- a/sstables/sstable_directory.hh +++ b/sstables/sstable_directory.hh @@ -133,6 +133,7 @@ private: void validate(sstables::shared_sstable sst, process_flags flags) const; template + requires std::is_invocable_r_v, Func, typename std::decay_t::value_type&> future<> parallel_for_each_restricted(Container&& C, Func&& func); future<> load_foreign_sstables(sstable_info_vector info_vec);