Skip to content

Commit

Permalink
Allow binary operator templates
Browse files Browse the repository at this point in the history
  • Loading branch information
i-garrison authored and jonahgraham committed Apr 4, 2023
1 parent 385b915 commit 3fdea6e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4221,6 +4221,22 @@ public void testThreeWayComparisonSimpleCase() throws Exception {
helper.assertVariableValue("greater10", 1);
}

// template<typename T1, typename T2>
// constexpr int operator |(T1 t1, T2 t2) {
// return t1 + t2;
// }
//
// enum X {
// V1 = 17,
// V2 = 25,
// };
//
// constexpr auto value = V1 | V2;
public void testBinaryOperatorOverloadTemplate() throws Exception {
BindingAssertionHelper helper = getAssertionHelper(CPP);
helper.assertVariableValue("value", 42);
}

// typedef int I;
// typedef int I;
// typedef I I;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4099,9 +4099,10 @@ static LookupData findOverloadedNonmemberOperator(IType methodLookupType, Overlo
ICPPFunctionType ft = func.getType();
IType[] pts = ft.getParameterTypes();
if ((enum1 != null && pts.length > 0
&& enum1.isSameType(getUltimateTypeUptoPointers(pts[0])))
|| (enum2 != null && pts.length > 1
&& enum2.isSameType(getUltimateTypeUptoPointers(pts[1])))) {
&& (CPPTemplates.isDependentType(pts[0])
|| enum1.isSameType(getUltimateTypeUptoPointers(pts[0]))))
|| (enum2 != null && pts.length > 1 && (CPPTemplates.isDependentType(pts[1])
|| enum2.isSameType(getUltimateTypeUptoPointers(pts[1]))))) {
items[j++] = object;
}
}
Expand Down

0 comments on commit 3fdea6e

Please sign in to comment.