https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117921

            Bug ID: 117921
           Summary: containers do not use ADL swap for Compare, Pred or
                    Hash types
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

"Any Compare, Pred, or Hash types belonging to a and b shall meet the
Cpp17Swappable requirements and shall be exchanged by calling swap as described
in 16.4.4.3. [...] the allocators of a and b shall also be exchanged by calling
swap
as described in 16.4.4.3."

But our hash containers get this wrong:

      void
      _M_swap(_Hash_code_base& __x)
      { std::swap(__ebo_hash::_M_get(), __x.__ebo_hash::_M_get()); }

      void
      _M_swap(_Hashtable_base& __x)
      {
        __hash_code_base::_M_swap(__x);
        std::swap(_EqualEBO::_M_get(), __x._EqualEBO::_M_get());
      }

The RB tree gets it wrong too:

      std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare);

They're correct for the allocators, as they use std::__alloc_on_swap.

Reply via email to