https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113386
Bug ID: 113386
Summary: std::pair comparison operators should be transparent,
but are not in libstdc++
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: janschultke at googlemail dot com
Target Milestone: ---
## Code to reproduce
#include <utility>
bool equals(const std::pair<int, int>& a, const std::pair<const int, const
int>& b) {
return a == b;
}
## Explanation
Clang with -stdlib=libc++ compiles this, as does MSVC. Bug #90203 was
incorrectly closed.
std::pair comparison operators should be transparent, see
https://eel.is/c++draft/pairs.spec The standard requires the signature:
> template<class T1, class T2, class U1, class U2>
> constexpr bool operator==(const pair<T1, T2>& x, const pair<U1, U2>& y);
libstdc++ incorrectly implements this with only two template parameters:
> template<typename _T1, typename _T2>
> inline _GLIBCXX_CONSTEXPR bool
> operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
> { return __x.first == __y.first && __x.second == __y.second; }