---
name: "__gnu_debug::Safe_sequence"
section: "3"
platform: "linux"
package: "libstdc++6-doc"
version: "3.4.6-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_debug::Safe_sequence"
---

# \_\_gnu\_debug::Safe\_sequence(3)

Base class for constructing a 'safe' sequence type that tracks iterators that reference it.

## NAME

\_\_gnu\_debug::Safe\_sequence - Base class for constructing a 'safe' sequence type that tracks iterators that reference it.

## SYNOPSIS

`#include <safe_sequence.h>`

Inherits **\_\_gnu\_debug::Safe\_sequence\_base**.

Inherited by **\_\_gnu\_debug::basic\_string\< CharT, Traits, Allocator \>**, **\_\_gnu\_debug\_def::deque\< Type, Allocator \>**, **\_\_gnu\_debug\_def::hash\_map\< Value, Type, HashFcn, EqualKey, Alloc \>**, **\_\_gnu\_debug\_def::hash\_multimap\< Value, Type, HashFcn, EqualKey, Alloc \>**, **\_\_gnu\_debug\_def::hash\_multiset\< Value, HashFcn, EqualKey, Alloc \>**, **\_\_gnu\_debug\_def::hash\_set\< Value, HashFcn, EqualKey, Alloc \>**, **\_\_gnu\_debug\_def::list\< Type, Allocator \>**, **\_\_gnu\_debug\_def::map\< Key, Type, Compare, Allocator \>**, **\_\_gnu\_debug\_def::multimap\< Key, Type, Compare, Allocator \>**, **\_\_gnu\_debug\_def::multiset\< Key, Compare, Allocator \>**, **\_\_gnu\_debug\_def::set\< Key, Compare, Allocator \>**, and **\_\_gnu\_debug\_def::vector\< Type, Allocator \>**.

### Public Member Functions

template\<typename Predicate\> void **M\_invalidate\_if** (Predicate pred)\
 template\<typename Iterator\> void **M\_transfer\_iter** (const **Safe\_iterator**\< Iterator, Sequence \> &x)\
 void **M\_invalidate\_all** () const\

### Public Attributes

**Safe\_iterator\_base** \* **M\_iterators**\
 *The list of mutable iterators that reference this container.*  **Safe\_iterator\_base** \* **M\_const\_iterators**\
 *The list of constant 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** ()\
 void **M\_revalidate\_singular** ()\
 void **M\_swap** (**Safe\_sequence\_base** &x)\

## Detailed Description

### template\<typename Sequence\> class \_\_gnu\_debug::Safe\_sequence\< Sequence \>

Base class for constructing a 'safe' sequence type that tracks iterators that reference it.

The class template Safe\_sequence simplifies the construction of 'safe' sequences that track the iterators that reference the sequence, so that the iterators are notified of changes in the sequence 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  types that are instantiations of class template **Safe\_iterator** for this sequence. Iterators will then be tracked automatically.

Definition at line 96 of file safe\_sequence.h.

## Member Function Documentation

### template\<typename Sequence\> template\<typename Predicate\> void \_\_gnu\_debug::Safe\_sequence\< Sequence \>::M\_invalidate\_if (Predicate pred)

Invalidates all iterators `x` that reference this sequence, are not singular, and for which `pred(x)` returns `true`. The user of this routine should be careful not to make copies of the iterators passed to `pred`, as the copies may interfere with the invalidation.

Definition at line 120 of file safe\_sequence.h.

### template\<typename Sequence\> template\<typename Iterator\> void \_\_gnu\_debug::Safe\_sequence\< Sequence \>::M\_transfer\_iter (const Safe\_iterator\< Iterator, Sequence \> & x)

Transfers all iterators that reference this memory location to this sequence from whatever sequence they are attached to.

Definition at line 152 of file safe\_sequence.h.

### void \_\_gnu\_debug::Safe\_sequence\_base::M\_detach\_all ()` [protected, inherited]`

Detach all iterators, leaving them singular.

Definition at line 114 of file debug.cc.

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

Definition at line 133 of file debug.cc.

### 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 reasion, such as an exception, need to become valid again).

Definition at line 154 of file debug.cc.

### void \_\_gnu\_debug::Safe\_sequence\_base::M\_swap (Safe\_sequence\_base & x)` [protected, 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.

Definition at line 172 of file debug.cc.

References \_\_gnu\_debug::swap().

### void \_\_gnu\_debug::Safe\_sequence\_base::M\_invalidate\_all () const` [inline, inherited]`

Invalidates all iterators.

Definition at line 202 of file safe\_base.h.

## Member Data Documentation

### Safe\_iterator\_base\* \_\_gnu\_debug::Safe\_sequence\_base::M\_iterators` [inherited]`

The list of mutable iterators that reference this container.

Definition at line 153 of file safe\_base.h.

### Safe\_iterator\_base\* \_\_gnu\_debug::Safe\_sequence\_base::M\_const\_iterators` [inherited]`

The list of constant iterators that reference this container.

Definition at line 156 of file safe\_base.h.

### unsigned int \_\_gnu\_debug::Safe\_sequence\_base::M\_version` [mutable, inherited]`

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

Definition at line 159 of file safe\_base.h.

## Author

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