Skip to content

Commit

Permalink
Use std::any_of with lamda
Browse files Browse the repository at this point in the history
  • Loading branch information
iomaganaris committed Sep 12, 2023
1 parent ab5fd9f commit 2718f2c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/codegen/codegen_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1890,15 +1890,11 @@ void CodegenCppVisitor::print_vector_elements(const std::vector<T>& elements,
template <typename T>
bool has_parameter_of_name(const T& node, const std::string& name) {
auto parameters = node->get_parameters();
struct ParameterHasName {
const std::string paramater_name;
explicit ParameterHasName(const std::string& name)
: paramater_name(name) {}
bool operator()(const decltype(*parameters.begin()) arg) const {
return arg->get_node_name() == paramater_name;
}
};
return std::any_of(parameters.begin(), parameters.end(), ParameterHasName(name));
return std::any_of(parameters.begin(),
parameters.end(),
[&name](const decltype(*parameters.begin()) arg) {
return arg->get_node_name() == name;
});
}


Expand Down

0 comments on commit 2718f2c

Please sign in to comment.