---
name: "__gnu_debug::_Safe_unordered_container"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_debug::_Safe_unordered_container"
---

# \_\_gnu\_debug::\_Safe\_unordered\_container(3)

Base class for constructing a safe unordered container type that tracks iterators that reference it.

## NAME

\_\_gnu\_debug::\_Safe\_unordered\_container\< \_Container \> - Base class for constructing a *safe* unordered container type that tracks iterators that reference it.

## SYNOPSIS

\#include \<safe\_unordered\_container.h\>

Inherits **\_\_gnu\_debug::\_Safe\_unordered\_container\_base**.

Inherited by **\_\_gnu\_debug::\_Safe\_container\< unordered\_map, \_Alloc, \_\_gnu\_debug::\_Safe\_unordered\_container \>**, **\_\_gnu\_debug::\_Safe\_container\< unordered\_multimap, \_Alloc, \_\_gnu\_debug::\_Safe\_unordered\_container \>**, **\_\_gnu\_debug::\_Safe\_container\< unordered\_set, \_Alloc, \_\_gnu\_debug::\_Safe\_unordered\_container \>**, and **\_\_gnu\_debug::\_Safe\_container\< unordered\_multiset, \_Alloc, \_\_gnu\_debug::\_Safe\_unordered\_container \>**.

### Public Attributes

**\_Safe\_iterator\_base** \* **\_M\_const\_iterators**\
 The list of constant iterators that reference this container.  **\_Safe\_iterator\_base** \* **\_M\_const\_local\_iterators**\
 The list of constant local iterators that reference this container.  **\_Safe\_iterator\_base** \* **\_M\_iterators**\
 The list of mutable iterators that reference this container.  **\_Safe\_iterator\_base** \* **\_M\_local\_iterators**\
 The list of mutable local iterators that reference this container.  unsigned int **\_M\_version**\
 The container version number. This number may never be 0.

### Protected Member Functions

void **\_M\_detach\_all** () const\
 void **\_M\_detach\_singular** () const\
 \_\_gnu\_cxx::\_\_mutex & **\_M\_get\_mutex** () const noexcept\
 template\<typename \_VictimIt\> void **\_M\_invalidate** (\_VictimIt \_\_victim)\
 template\<typename \_VictimIt\> void **\_M\_invalidate** (\_VictimIt \_\_victim, const **\_\_gnu\_cxx::\_\_scoped\_lock** &\_\_lock)\
 constexpr void **\_M\_invalidate\_all** () const\
 void **\_M\_invalidate\_all** ()\
 template\<typename \_Predicate\> void **\_M\_invalidate\_all\_if** (\_Predicate \_\_pred)\
 void **\_M\_revalidate\_singular** () const\
 void **\_M\_swap** (const **\_Safe\_sequence\_base** &\_\_x) const noexcept\
 void **\_M\_swap** (const \_Safe\_unordered\_container\_base &\_\_x) const noexcept\

## Detailed Description

### template\<typename \_Container\>

class \_\_gnu\_debug::\_Safe\_unordered\_container\< \_Container \>"Base class for constructing a *safe* unordered container type that tracks iterators that reference it.

The class template \_Safe\_unordered\_container simplifies the construction of *safe* unordered containers that track the iterators that reference the container, so that the iterators are notified of changes in the container that may affect their operation, e.g., if the container invalidates its iterators or is destructed. This class template may only be used by deriving from it and passing the name of the derived class as its template parameter via the curiously recurring template pattern. The derived class must have iterator and const\_iterator types that are instantiations of class template \_Safe\_iterator for this container and local\_iterator and const\_local\_iterator types that are instantiations of class template \_Safe\_local\_iterator for this container. Iterators will then be tracked automatically.

## Member Function Documentation

### void \_\_gnu\_debug::\_Safe\_unordered\_container\_base::\_M\_detach\_all () const \[protected\], \[inherited\]

Detach all iterators, leaving them singular.

Referenced by **~\_Safe\_unordered\_container\_base()**.

### void \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_detach\_singular () const \[protected\], \[inherited\]

Detach all singular iterators.

**Postcondition**

for all iterators i attached to this sequence, i-\>\_M\_version == \_M\_version.

### \_\_gnu\_cxx::\_\_mutex & \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_get\_mutex () const \[protected\], \[noexcept\], \[inherited\]

For use in \_Safe\_sequence.

Referenced by **\_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_from\_if()**.

### void \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_invalidate\_all () const \[inline\], \[constexpr\], \[protected\], \[inherited\]

Invalidates all iterators.

References **\_M\_invalidate\_all()**, and **\_M\_version**.

Referenced by **\_M\_invalidate\_all()**.

### void \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_revalidate\_singular () const \[protected\], \[inherited\]

Revalidates all attached singular iterators. This method may be used to validate iterators that were invalidated before (but for some reason, such as an exception, need to become valid again).

### void \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_swap (const \_Safe\_sequence\_base & \_\_x) const \[protected\], \[noexcept\], \[inherited\]

Swap this sequence with the given sequence. This operation also swaps ownership of the iterators, so that when the operation is complete all iterators that originally referenced one container now reference the other container.

### void \_\_gnu\_debug::\_Safe\_unordered\_container\_base::\_M\_swap (const \_Safe\_unordered\_container\_base & \_\_x) const \[protected\], \[noexcept\], \[inherited\]

Swap this container with the given container. This operation also swaps ownership of the iterators, so that when the operation is complete all iterators that originally referenced one container now reference the other container.

## Member Data Documentation

### \_Safe\_iterator\_base\* \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_const\_iterators \[mutable\], \[inherited\]

The list of constant iterators that reference this container.

Referenced by **\_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_from\_if()**.

### \_Safe\_iterator\_base\* \_\_gnu\_debug::\_Safe\_unordered\_container\_base::\_M\_const\_local\_iterators \[mutable\], \[inherited\]

The list of constant local iterators that reference this container.

### \_Safe\_iterator\_base\* \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_iterators \[mutable\], \[inherited\]

The list of mutable iterators that reference this container.

Referenced by **\_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_from\_if()**.

### \_Safe\_iterator\_base\* \_\_gnu\_debug::\_Safe\_unordered\_container\_base::\_M\_local\_iterators \[mutable\], \[inherited\]

The list of mutable local iterators that reference this container.

### unsigned int \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_version \[mutable\], \[inherited\]

The container version number. This number may never be 0.

Referenced by **\_M\_invalidate\_all()**, **\_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_from\_if()**, **\_\_gnu\_debug::\_Safe\_iterator\< \_Base\_iterator, map \>::operator=()**, **\_\_gnu\_debug::\_Safe\_iterator\< \_Base\_iterator, map \>::operator=()**, **\_\_gnu\_debug::\_Safe\_local\_iterator\< \_OtherIterator, \_UContainer \>::operator=()**, and **\_\_gnu\_debug::\_Safe\_local\_iterator\< \_OtherIterator, \_UContainer \>::operator=()**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
