I have an if constexpr checking that a type is equality-comparable with itself. I use std::is_invocable_v<std::equal_to<>, T, T>.
However, when T is a vector of incomparable structs, the snippet falsely returns True. Is there a deep reason for it or is it a compiler bug?
Minimal example follows.
#include <type_traits>
#include <iostream>
#include <vector>
class TNonComparable{};
int main()
{
std::cout << std::is_invocable_v<std::equal_to<>, TNonComparable, TNonComparable> << "\n";
// 0
std::cout << std::is_invocable_v<
std::equal_to<>,
std::vector<TNonComparable>,
std::vector<TNonComparable>
> << "\n";
// 1
std::vector<TNonComparable> vec;
// vec == vec;
// (expected) compilation error
}
I checked the output at Godbolt's, it is the same for all recent versions of g++ and clang.