https://bugs.llvm.org/show_bug.cgi?id=48611
Bug ID: 48611
Summary: user-defined template operator < not used
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Hi,
in the following code the user-defined operator< for enum E1 is used, but the
user-defined template operator< for enum E2 is not used - the built-in
operator< is used instead for E2. Even though the standard states that a user
user-defined relational operator candidate hides the built-in operator during
overload resolution (https://eel.is/c++draft/over.built#1)
NB: when I change "operator <" to "operator &" (with appropriate return types)
then the user-defined overload is used in both cases.
I searched the standard, if there is a specialization for relational operators
during overload resolution, but I couldn't find one.
Tobias
-----------------------------------------------------------------
#include <iostream>
enum E1 {
e1_a
};
inline bool operator<(E1, E1) {
return true;
}
enum E2 {
e2_a
};
template<class E>
inline bool operator<(E, E) {
return true;
}
int main()
{
if (E1::e1_a < E1::e1_a) {
std::cout << "user-defined operator used for E1\n";
} else {
std::cout << "builtin operator used for E1\n";
}
if (E2::e2_a < E2::e2_a) {
std::cout << "user-defined operator used for E2\n";
} else {
std::cout << "builtin operator used for E2\n";
}
}
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs