Skip to content

Commit

Permalink
fix other lambda issues
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Xiang <[email protected]>
  • Loading branch information
TonyXiang8787 committed Jan 21, 2025
1 parent 96f1626 commit 8540595
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,10 @@ using IntSVector = std::vector<IntS>;
template <class T, class... Ts>
concept is_in_list_c = (std::same_as<std::remove_const_t<T>, Ts> || ...);

// functor to include all
struct IncludeAll {
constexpr bool operator()(Idx /*ignored*/) const { return true; }
};
constexpr IncludeAll include_all{};

} // namespace power_grid_model
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,6 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, 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
Expand Down Expand Up @@ -1068,7 +1066,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
*/
template <calculation_input_type CalcStructOut, typename CalcParamOut,
std::vector<CalcParamOut>(CalcStructOut::*comp_vect), class ComponentIn,
std::invocable<Idx> PredicateIn = decltype(include_all)>
std::invocable<Idx> PredicateIn = IncludeAll>
requires std::convertible_to<std::invoke_result_t<PredicateIn, Idx>, bool>
static void prepare_input(MainModelState const& state, std::vector<Idx2D> const& components,
std::vector<CalcStructOut>& calc_input, PredicateIn include = include_all) {
Expand All @@ -1087,7 +1085,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis

template <calculation_input_type CalcStructOut, typename CalcParamOut,
std::vector<CalcParamOut>(CalcStructOut::*comp_vect), class ComponentIn,
std::invocable<Idx> PredicateIn = decltype(include_all)>
std::invocable<Idx> PredicateIn = IncludeAll>
requires std::convertible_to<std::invoke_result_t<PredicateIn, Idx>, bool>
static void prepare_input(MainModelState const& state, std::vector<Idx2D> const& components,
std::vector<CalcStructOut>& calc_input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 <Idx (MathModelTopology::*n_obj_fn)() const, typename GetMathTopoComponent,
typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = decltype(include_all)>
typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = IncludeAll>
requires std::invocable<std::remove_cvref_t<GetMathTopoComponent>, MathModelTopology&> &&
grouped_idx_vector_type<
std::remove_reference_t<std::invoke_result_t<GetMathTopoComponent, MathModelTopology&>>>
Expand Down

0 comments on commit 8540595

Please sign in to comment.