Код: Выделить всё
template
struct Wrapper {
T value;
constexpr auto operator==(const T other) const {
return value == other;
}
};
template
void fun() {
static_assert(W != 0); // This line fails on Clang
}
int main() {
fun();
}
Код: Выделить всё
:11:21: error: return type 'auto' of selected 'operator==' function for rewritten '!=' comparison is not 'bool'
11 | static_assert(W != 0); // This line fails on Clang
| ~ ^ ~
:15:5: note: in instantiation of function template specialization 'fun' requested here
15 | fun();
| ^
:4:20: note: declared here
4 | constexpr auto operator==(const T other) const {
| ^
< hr />
Однако, что интересно, когда я меняю определение fun() на следующее:
Код: Выделить всё
template
void fun() {
void(W == 0); // Adding this line makes the error go away
static_assert(W != 0);
}
Альтернативно, если я изменю определение класса Wrapper, чтобы не использовать параметр шаблона, он снова успешно компилируется обоими компиляторами.
Я думаю, это может быть Clang/ Ошибка LLVM, но я не уверен, так ли это на самом деле.
Подробнее здесь: https://stackoverflow.com/questions/783 ... uto-return