@@ -148,6 +148,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
~allocator() _GLIBCXX_NOTHROW { }
+ friend bool
+ operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
+ { return true; }
+
+ friend bool
+ operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW
+ { return false; }
+
// Inherit everything else.
};
@@ -157,24 +165,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_NOTHROW
{ return true; }
- template<typename _Tp>
- inline bool
- operator==(const allocator<_Tp>&, const allocator<_Tp>&)
- _GLIBCXX_NOTHROW
- { return true; }
-
template<typename _T1, typename _T2>
inline bool
operator!=(const allocator<_T1>&, const allocator<_T2>&)
_GLIBCXX_NOTHROW
{ return false; }
- template<typename _Tp>
- inline bool
- operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
- _GLIBCXX_NOTHROW
- { return false; }
-
// Invalid allocator<cv T> partial specializations.
// allocator_traits::rebind_alloc can be used to form a valid allocator type.
template<typename _Tp>
@@ -174,16 +174,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
max_size() const throw()
{ return _Traits::max_size(_M_allocator) - _M_extra; }
- friend bool
- operator==(const debug_allocator& __lhs, const debug_allocator& __rhs)
- { return __lhs._M_allocator == __rhs._M_allocator; }
- };
+ template<typename _Alloc2>
+ friend bool
+ operator==(const debug_allocator& __lhs,
+ const debug_allocator<_Alloc2>& __rhs) _GLIBCXX_NOTHROW
+ { return __lhs._M_allocator == debug_allocator(__rhs)._M_allocator; }
- template<typename _Alloc>
- inline bool
- operator!=(const debug_allocator<_Alloc>& __lhs,
- const debug_allocator<_Alloc>& __rhs)
- { return !(__lhs == __rhs); }
+ template<typename _Alloc2>
+ friend bool
+ operator!=(const debug_allocator& __lhs,
+ const debug_allocator<_Alloc2>& __rhs) _GLIBCXX_NOTHROW
+ { return !(__lhs == __rhs); }
+ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
@@ -166,17 +166,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
- };
- template<typename _Tp>
- inline bool
- operator==(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&)
- { return true; }
-
- template<typename _Tp>
- inline bool
- operator!=(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&)
- { return false; }
+ template<typename _Up>
+ friend bool
+ operator==(const malloc_allocator&, const malloc_allocator<_Up>&)
+ _GLIBCXX_NOTHROW
+ { return true; }
+
+ template<typename _Up>
+ friend bool
+ operator!=(const malloc_allocator&, const malloc_allocator<_Up>&)
+ _GLIBCXX_NOTHROW
+ { return false; }
+ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
@@ -157,18 +157,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
destroy(pointer __p) { __p->~_Tp(); }
#endif
+
+ template<typename _Up>
+ friend bool
+ operator==(const new_allocator&, const new_allocator<_Up>&)
+ _GLIBCXX_NOTHROW
+ { return true; }
+
+ template<typename _Up>
+ friend bool
+ operator!=(const new_allocator&, const new_allocator<_Up>&)
+ _GLIBCXX_NOTHROW
+ { return false; }
};
- template<typename _Tp>
- inline bool
- operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
- { return true; }
-
- template<typename _Tp>
- inline bool
- operator!=(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
- { return false; }
-
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
new file mode 100644
@@ -0,0 +1,31 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+#include <ext/debug_allocator.h>
+
+__gnu_cxx::debug_allocator< std::allocator<int> > i;
+__gnu_cxx::debug_allocator< std::allocator<float> > f;
+
+bool b1 = i == i;
+bool b2 = f == f;
+bool b3 = i == f;
+
+bool n1 = i != i;
+bool n2 = f != f;
+bool n3 = i != f;
new file mode 100644
@@ -0,0 +1,31 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+#include <ext/extptr_allocator.h>
+
+__gnu_cxx::_ExtPtr_allocator<int> i;
+__gnu_cxx::_ExtPtr_allocator<float> f;
+
+bool b1 = i == i;
+bool b2 = f == f;
+bool b3 = i == f;
+
+bool n1 = i != i;
+bool n2 = f != f;
+bool n3 = i != f;
new file mode 100644
@@ -0,0 +1,31 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+#include <ext/malloc_allocator.h>
+
+__gnu_cxx::malloc_allocator<int> i;
+__gnu_cxx::malloc_allocator<float> f;
+
+bool b1 = i == i;
+bool b2 = f == f;
+bool b3 = i == f;
+
+bool n1 = i != i;
+bool n2 = f != f;
+bool n3 = i != f;
new file mode 100644
@@ -0,0 +1,31 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+#include <ext/new_allocator.h>
+
+__gnu_cxx::new_allocator<int> i;
+__gnu_cxx::new_allocator<float> f;
+
+bool b1 = i == i;
+bool b2 = f == f;
+bool b3 = i == f;
+
+bool n1 = i != i;
+bool n2 = f != f;
+bool n3 = i != f;