Open AdamBucior opened 3 years ago
I think it might be possible to default equality for pair
, but not for tuple
which permits different types to be compared.
I think it might be possible to default equality for
pair
, but not fortuple
which permits different types to be compared.
pair
's comparisons can't be generally defaulted since it allows reference members and "A defaulted <=>
or ==
operator function for class C
is defined as deleted if any non-static data member of C
is of reference type or C
has variant members." ([class.compare.default]/2).
That said, I've been thinking about implementing "has no fields of reference type" partial specializations for pair
and tuple
in ABI broken world so their special member functions could be defaulted. Such a partial specialization of pair
could also default its comparisons if those comparisons were specified as members or hidden friends rather than vanilla non-members.
With C++20 it's possible to default comparison operators. With
has_unique_object_representations
and an intrinsic to detect if type is trivially equality comparable (it hasdefault
edoperator==
and all of it's members are trivially equality comparable) we could greatly increase number of cases whenequal
usesmemcmp
.It would be great if we could
default
operator==
for types liketuple
andpair
, but I don't know if we can do that.