diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp index 43c6d78ce..9b465962c 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp @@ -91,4 +91,10 @@ using IntSVector = std::vector; template concept is_in_list_c = (std::same_as, Ts> || ...); +// functor to include all +struct IncludeAll { + constexpr bool operator()(Idx /*ignored*/) const { return true; } +}; +constexpr IncludeAll include_all{}; + } // namespace power_grid_model diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp index a512fc834..9113e1844 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp @@ -1014,8 +1014,6 @@ class MainModelImpl, ComponentLis return math_param_increment; } - static constexpr auto include_all = [](Idx) { return true; }; - /** This is a heavily templated member function because it operates on many different variables of many *different types, but the essence is ever the same: filling one member (vector) of the calculation calc_input *struct (soa) with the right calculation symmetric or asymmetric calculation parameters, in the same order as @@ -1068,7 +1066,7 @@ class MainModelImpl, ComponentLis */ template (CalcStructOut::*comp_vect), class ComponentIn, - std::invocable PredicateIn = decltype(include_all)> + std::invocable PredicateIn = IncludeAll> requires std::convertible_to, bool> static void prepare_input(MainModelState const& state, std::vector const& components, std::vector& calc_input, PredicateIn include = include_all) { @@ -1087,7 +1085,7 @@ class MainModelImpl, ComponentLis template (CalcStructOut::*comp_vect), class ComponentIn, - std::invocable PredicateIn = decltype(include_all)> + std::invocable PredicateIn = IncludeAll> requires std::convertible_to, bool> static void prepare_input(MainModelState const& state, std::vector const& components, std::vector& calc_input, diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp index 5968ebfcb..96f49d225 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp @@ -429,8 +429,6 @@ class Topology { } } - static constexpr auto include_all = [](Idx) { return true; }; - // proxy class to find the coupled object in math model in the coupling process to a single type object // given a particular component index struct SingleTypeObjectFinder { @@ -481,7 +479,7 @@ class Topology { // The coupling element should be pre-allocated in coupling // Only connect the component if include(component_i) returns true template + typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = IncludeAll> requires std::invocable, MathModelTopology&> && grouped_idx_vector_type< std::remove_reference_t>>