Skip to content

Commit 5052f82

Browse files
committed
Improve handling of GetMethodTemplate to fall back on Instantiate
Rather than try Instantiate if the set is single, we use BestOverloadMatch by default
1 parent e821921 commit 5052f82

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

clingwrapper/src/clingwrapper.cxx

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,23 +1463,6 @@ bool Cppyy::IsTemplatedMethod(TCppMethod_t method)
14631463
return Cpp::IsTemplatedFunction(method);
14641464
}
14651465

1466-
// // helpers for Cppyy::GetMethodTemplate()
1467-
// static std::map<TDictionary::DeclId_t, CallWrapper*> gMethodTemplates;
1468-
//
1469-
// static inline
1470-
// void remove_space(std::string& n) {
1471-
// std::string::iterator pos = std::remove_if(n.begin(), n.end(), isspace);
1472-
// n.erase(pos, n.end());
1473-
// }
1474-
//
1475-
// static inline
1476-
// bool template_compare(std::string n1, std::string n2) {
1477-
// if (n1.back() == '>') n1 = n1.substr(0, n1.size()-1);
1478-
// remove_space(n1);
1479-
// remove_space(n2);
1480-
// return n2.compare(0, n1.size(), n1) == 0;
1481-
// }
1482-
//
14831466
Cppyy::TCppMethod_t Cppyy::GetMethodTemplate(
14841467
TCppScope_t scope, const std::string& name, const std::string& proto)
14851468
{
@@ -1510,17 +1493,15 @@ Cppyy::TCppMethod_t Cppyy::GetMethodTemplate(
15101493
Cppyy::AppendTypesSlow(proto, arg_types);
15111494
Cppyy::AppendTypesSlow(explicit_params, templ_params);
15121495

1513-
Cppyy::TCppMethod_t cppmeth = nullptr;
1496+
Cppyy::TCppMethod_t cppmeth = Cpp::BestOverloadFunctionMatch(
1497+
unresolved_candidate_methods, templ_params, arg_types);
15141498

1515-
if (unresolved_candidate_methods.size() == 1 && !templ_params.empty())
1499+
if (!cppmeth && unresolved_candidate_methods.size() == 1 &&
1500+
!templ_params.empty())
15161501
cppmeth =
15171502
Cpp::InstantiateTemplate(unresolved_candidate_methods[0],
15181503
templ_params.data(), templ_params.size());
15191504

1520-
if (!cppmeth)
1521-
cppmeth = Cpp::BestOverloadFunctionMatch(unresolved_candidate_methods,
1522-
templ_params, arg_types);
1523-
15241505
return cppmeth;
15251506

15261507
// if it fails, use Sema to propogate info about why it failed (DeductionInfo)

0 commit comments

Comments
 (0)