Skip to content

Commit e106810

Browse files
cast arg type from ints to doubles and resolve operators (#142)
If operator resolution fails with the given argument types, we cast ints to doubles and try again.
1 parent 3deac30 commit e106810

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clingwrapper/src/clingwrapper.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class ApplicationStarter {
246246
// load frequently used headers
247247
const char* code =
248248
"#include <algorithm>\n"
249+
"#include <numeric>\n"
249250
"#include <complex>\n"
250251
"#include <iostream>\n"
251252
"#include <string.h>\n" // for strcpy
@@ -1736,6 +1737,20 @@ Cppyy::TCppMethod_t Cppyy::GetGlobalOperator(
17361737
if (cppmeth)
17371738
return cppmeth;
17381739
}
1740+
{
1741+
// we are trying to do a madeup IntegralToFloating implicit cast emulating clang
1742+
bool flag = false;
1743+
if (rc_type == "int") {
1744+
rc_type = "double";
1745+
flag = true;
1746+
}
1747+
if (lc_type == "int") {
1748+
lc_type = "double";
1749+
flag = true;
1750+
}
1751+
if (flag)
1752+
return GetGlobalOperator(scope, lc_type, rc_type, opname);
1753+
}
17391754
return nullptr;
17401755
}
17411756

0 commit comments

Comments
 (0)