Skip to content

Commit 075b328

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 752117e commit 075b328

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
@@ -1461,23 +1461,6 @@ bool Cppyy::IsTemplatedMethod(TCppMethod_t method)
14611461
return Cpp::IsTemplatedFunction(method);
14621462
}
14631463

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

1511-
Cppyy::TCppMethod_t cppmeth = nullptr;
1494+
Cppyy::TCppMethod_t cppmeth = Cpp::BestOverloadFunctionMatch(
1495+
unresolved_candidate_methods, templ_params, arg_types);
15121496

1513-
if (unresolved_candidate_methods.size() == 1 && !templ_params.empty())
1497+
if (!cppmeth && unresolved_candidate_methods.size() == 1 &&
1498+
!templ_params.empty())
15141499
cppmeth =
15151500
Cpp::InstantiateTemplate(unresolved_candidate_methods[0],
15161501
templ_params.data(), templ_params.size());
15171502

1518-
if (!cppmeth)
1519-
cppmeth = Cpp::BestOverloadFunctionMatch(unresolved_candidate_methods,
1520-
templ_params, arg_types);
1521-
15221503
return cppmeth;
15231504

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

0 commit comments

Comments
 (0)