Make ext allocators support heterogeneous equality comparison
commit5d56b42ba9fb4ec3fb5f3708ffba7a47fd0e9e8f
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Oct 2018 11:32:29 +0000 (11 11:32 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Oct 2018 11:32:29 +0000 (11 11:32 +0000)
treeb1c73116191a1c6dd4176e76678744adf18f30cb
parentcebe6e17b35cbd43eecb0e666b775042bd33a825
Make ext allocators support heterogeneous equality comparison

The Allocator requirements include the ability to compare different
specializations of the same allocator class template. This did not work
for __gnu_cxx::new_allocator and other extension allocators.  This patch
replaces the equality operators for those allocators with inline friends
that support heterogeneous comparisons.  (I'm not changing all ext
allocators because some are bit-rotted already).

Additionally, the equality operators for comparing two std::allocator
objects of the same type are now defined as inline friends. Those
overloads don't need to be declared at namespace scope, because they
aren't specified in the standard (but they're needed in this
implementation to avoid ambiguities caused by the extra overloads
defined for the base allocator type).

* include/bits/allocator.h
(operator==(const allocator<_Tp>&, const allocator<_Tp>))
(operator!=(const allocator<_Tp>&, const allocator<_Tp>)): Replace
with inline friends.
* include/ext/debug_allocator.h (operator==, operator!=): Replace
with inline friend functions that compare to rebound allocators.
* include/ext/malloc_allocator.h (operator==, operator!=): Likewise.
* include/ext/new_allocator.h (operator==, operator!=): Likewise.
* testsuite/ext/debug_allocator/eq.cc: New test.
* testsuite/ext/ext_pointer/alloc_eq.cc: New test.
* testsuite/ext/malloc_allocator/eq.cc: New test.
* testsuite/ext/new_allocator/eq.cc: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265036 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/ext/debug_allocator.h
libstdc++-v3/include/ext/malloc_allocator.h
libstdc++-v3/include/ext/new_allocator.h
libstdc++-v3/testsuite/ext/debug_allocator/eq.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/ext_pointer/alloc_eq.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/malloc_allocator/eq.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/new_allocator/eq.cc [new file with mode: 0644]