<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - user-defined template operator < not used"
href="https://bugs.llvm.org/show_bug.cgi?id=48611">48611</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>user-defined template operator < not used
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tobias.loew@steag.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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 (<a href="https://eel.is/c++draft/over.built#1">https://eel.is/c++draft/over.built#1</a>)
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";
}
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>