[llvm-bugs] [Bug 44721] New: Defaulted comparison operator with built-in type as member in same namespace as comparison operator template rejected
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 30 14:24:24 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44721
Bug ID: 44721
Summary: Defaulted comparison operator with built-in type as
member in same namespace as comparison operator
template rejected
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: david at doublewise.net
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
The following well-formed code:
```
namespace n {
template<typename T>
bool operator==(T const &, T const &) {
return true;
}
struct s {
friend bool operator==(s const &, s const &) = default;
int x;
};
}
```
is rejected by clang with the following message:
```
main.cpp:4:6: error: overloaded 'operator==' must have at least one parameter
of class or enumeration type
bool operator==(T const &, T const &) {
^
main.cpp:9:14: note: in instantiation of function template specialization
'n::operator==<int>' requested here
friend bool operator==(s const &, s const &) = default;
^
1 error generated.
```
A similar error occurs for `operator<=>`. This occurs only when the comparison
operator is defaulted. Manually writing out the equivalent definition is fine.
(In the real code, the generic `operator==` is constrained with a concept that
would not match any built-in type)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200130/42abf9b7/attachment.html>
More information about the llvm-bugs
mailing list