@@ -1730,20 +1730,24 @@ class cppfront
1730
1730
}
1731
1731
1732
1732
1733
+ auto has_template_parameter_named (declaration_node const & decl, token const & id)
1734
+ -> bool
1735
+ {
1736
+ if (auto & params = decl.template_parameters ) {
1737
+ return std::any_of (params->parameters .begin (), params->parameters .end (), [&](auto & param) {
1738
+ assert (param->has_name ());
1739
+ return *param->name () == id;
1740
+ });
1741
+ }
1742
+ return false ;
1743
+ }
1744
+
1733
1745
auto is_template_parameter (token const & lookup_id)
1734
1746
-> bool
1735
1747
{
1736
1748
// If any parent declaration
1737
1749
return std::any_of (current_declarations.begin () + 1 , current_declarations.end (), [&](auto & decl) {
1738
- // has a template parameter
1739
- if (auto & params = decl->template_parameters ) {
1740
- return std::any_of (params->parameters .begin (), params->parameters .end (), [&](auto & param) {
1741
- // of equal name.
1742
- assert (param->has_name ());
1743
- return *param->name () == lookup_id;
1744
- });
1745
- }
1746
- return false ;
1750
+ return has_template_parameter_named (*decl, lookup_id);
1747
1751
});
1748
1752
}
1749
1753
@@ -3928,22 +3932,11 @@ class cppfront
3928
3932
-> bool
3929
3933
{
3930
3934
assert ( current_declarations.back () );
3931
- auto has_template_parameter = [&](declaration_node const * decl, token const * id) {
3932
- // If `decl` has a template parameter
3933
- if (auto & params = decl->template_parameters ) {
3934
- return std::any_of (params->parameters .begin (), params->parameters .end (), [&](auto & param) {
3935
- assert (param->has_name ());
3936
- // of equal name.
3937
- return *param->name () == *id;
3938
- });
3939
- }
3940
- return false ;
3941
- };
3942
- return has_template_parameter (current_declarations.back (), &lookup_id)
3935
+ return has_template_parameter_named (*current_declarations.back (), lookup_id)
3943
3936
|| (
3944
3937
current_declarations.back ()->parent_is_type ()
3945
3938
&& current_declarations.back ()->has_name (" operator=" )
3946
- && has_template_parameter ( current_declarations.back ()->get_parent (), & lookup_id)
3939
+ && has_template_parameter_named (* current_declarations.back ()->get_parent (), lookup_id)
3947
3940
);
3948
3941
}
3949
3942
0 commit comments