---
name: "__gnu_debug::_Safe_unordered_container"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_debug::_Safe_unordered_container/3cxx"
---

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

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**.

### Public Member Functions

void **\_M\_invalidate\_all** ()\
 template\<typename \_Predicate \> void **\_M\_invalidate\_if** (\_Predicate \_\_pred)\
 template\<typename \_Predicate \> void **\_M\_invalidate\_local\_if** (\_Predicate \_\_pred)\

### 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** ()\
 void **\_M\_detach\_singular** ()\
 \_\_gnu\_cxx::\_\_mutex & **\_M\_get\_mutex** ()  throw ()\
 void **\_M\_invalidate\_all** () const\
 void **\_M\_invalidate\_locals** ()\
 void **\_M\_revalidate\_singular** ()\
 void **\_M\_swap** (**\_Safe\_sequence\_base** &\_\_x) noexcept\
 void **\_M\_swap** (**\_Safe\_unordered\_container\_base** &\_\_x) noexcept\

### Static Protected Member Functions

template\<typename \_ExtractKey , typename \_Source \> static \_UContMergeGuard\< \_Source, \_UContInvalidatePred\< \_ExtractKey, \_Source \> \> **\_S\_uc\_guard** (\_ExtractKey, \_Source &\_\_src)\
 template\<typename \_ExtractKey , typename \_Source \> static \_UContMergeGuard\< \_Source, \_UMContInvalidatePred\< \_ExtractKey, \_Source \> \> **\_S\_umc\_guard** (\_ExtractKey, \_Source &\_\_src)\

## 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 ()` [protected]`, ` [inherited]`

Detach all iterators, leaving them singular.

### void \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_detach\_singular ()` [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 ()` [protected]`, ` [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]`, ` [protected]`, ` [inherited]`

Invalidates all iterators.

References **\_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_version**.

### template\<typename \_Container \> template\<typename \_Predicate \> void \_\_gnu\_debug::\_Safe\_unordered\_container\< \_Container \>::\_M\_invalidate\_if (\_Predicate \_\_pred)

Invalidates all iterators `x` that reference this container, are not singular, and for which `__pred(x)` returns `true`. `__pred` will be invoked with the normal iterators nested in the safe ones.

### template\<typename \_Container \> template\<typename \_Predicate \> void \_\_gnu\_debug::\_Safe\_unordered\_container\< \_Container \>::\_M\_invalidate\_local\_if (\_Predicate \_\_pred)

Invalidates all local iterators `x` that reference this container, are not singular, and for which `__pred(x)` returns `true`. `__pred` will be invoked with the normal local iterators nested in the safe ones.

### void \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_revalidate\_singular ()` [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 (\_Safe\_sequence\_base & \_\_x)` [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 (\_Safe\_unordered\_container\_base & \_\_x)` [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` [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` [inherited]`

The list of constant local iterators that reference this container.

### \_Safe\_iterator\_base\* \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_iterators` [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` [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 **\_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_invalidate\_all()**, and **\_\_gnu\_debug::\_Safe\_local\_iterator\< \_Iterator, \_Sequence \>::operator=()**.

## Author

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