---
name: "__gnu_debug__Safe_sequence"
section: "3"
platform: "linux"
package: "libstdc++6-4.2-doc"
version: "4.2.4-6"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/__gnu_debug__Safe_sequence"
---

# \_\_gnu\_debug\_\_Safe\_sequence(3)

## NAME

\_\_gnu\_debug::\_Safe\_sequence -

## SYNOPSIS

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

Inherited by \_\_gnu\_cxx::\_\_debug::hash\_map\< \_Value, \_Tp, \_HashFcn, \_EqualKey, \_Alloc \>, \_\_gnu\_cxx::\_\_debug::hash\_multimap\< \_Value, \_Tp, \_HashFcn, \_EqualKey, \_Alloc \>, \_\_gnu\_cxx::\_\_debug::hash\_multiset\< \_Value, \_HashFcn, \_EqualKey, \_Alloc \>, \_\_gnu\_cxx::\_\_debug::hash\_set\< \_Value, \_HashFcn, \_EqualKey, \_Alloc \>, \_\_gnu\_debug::basic\_string\< \_CharT, \_Traits, \_Allocator \>, std::\_\_debug::deque\< \_Tp, \_Allocator \>, std::\_\_debug::list\< \_Tp, \_Allocator \>, std::\_\_debug::map\< \_Key, \_Tp, \_Compare, \_Allocator \>, std::\_\_debug::multimap\< \_Key, \_Tp, \_Compare, \_Allocator \>, std::\_\_debug::multiset\< \_Key, \_Compare, \_Allocator \>, std::\_\_debug::set\< \_Key, \_Compare, \_Allocator \>, and std::\_\_debug::vector\< \_Tp, \_Allocator \>.

## Detailed Description

### template\<typename \_Sequence\> class \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>

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 102 of file safe\_sequence.h.

### Public Member Functions

void **\_M\_invalidate\_all** () const \
 template\<typename \_Predicate\> void **\_M\_invalidate\_if** (\_Predicate \_\_pred)\
 template\<typename \_Iterator\> void **\_M\_transfer\_iter** (const **\_Safe\_iterator**\< \_Iterator, \_Sequence \> &\_\_x)\

### Public Attributes

**\_Safe\_iterator\_base** \* **\_M\_const\_iterators**\
 **\_Safe\_iterator\_base** \* **\_M\_iterators**\
 unsigned int **\_M\_version**\

### Protected Member Functions

void **\_M\_detach\_all** ()\
 void **\_M\_detach\_singular** ()\
 \_\_gnu\_cxx::\_\_mutex & **\_M\_get\_mutex** ()\
 void **\_M\_revalidate\_singular** ()\
 void **\_M\_swap** (**\_Safe\_sequence\_base** &\_\_x)\

## Member Function Documentation

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

Detach all iterators, leaving them singular.

Referenced by \_\_gnu\_debug::\_Safe\_sequence\_base::~\_Safe\_sequence\_base().

### 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\_invalidate\_if(), and \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_iter().

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

Invalidates all iterators.

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

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

### template\<typename \_Sequence\> template\<typename \_Predicate\> void \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_invalidate\_if (\_Predicate \_\_pred)` [inline]`

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 126 of file safe\_sequence.h.

References \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_const\_iterators, \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_get\_mutex(), and \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_iterators.

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

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

### template\<typename \_Sequence\> template\<typename \_Iterator\> void \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_iter (const \_Safe\_iterator\< \_Iterator, \_Sequence \> & \_\_x)` [inline]`

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

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

References \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_const\_iterators, \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_get\_mutex(), \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_iterators, \_\_gnu\_debug::\_Safe\_iterator\_base::\_M\_sequence, and \_\_gnu\_debug::\_Safe\_iterator\< \_Iterator, \_Sequence \>::base().

## Member Data Documentation

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

The list of constant iterators that reference this container.

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

Referenced by \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_invalidate\_if(), \_\_gnu\_debug::\_Safe\_iterator\< \_Iterator, \_Sequence \>::\_M\_invalidate\_single(), and \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_iter().

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

The list of mutable iterators that reference this container.

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

Referenced by \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_invalidate\_if(), \_\_gnu\_debug::\_Safe\_iterator\< \_Iterator, \_Sequence \>::\_M\_invalidate\_single(), and \_\_gnu\_debug::\_Safe\_sequence\< \_Sequence \>::\_M\_transfer\_iter().

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

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

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

Referenced by \_\_gnu\_debug::\_Safe\_sequence\_base::\_M\_invalidate\_all().

## Author

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