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: unassignedclangb...@nondot.org
Reporter: da...@doublewise.net
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs