libstdc++: __gnu_debug::_Safe_sequence< _Sequence > Class Template Reference

libstdc++

__gnu_debug::_Safe_sequence< _Sequence > Class Template Reference

`#include <safe_sequence.h>`

Inheritance diagram for __gnu_debug::_Safe_sequence< _Sequence >:
[legend]

## Public Member Functions
template<typename _Predicate>
constexpr void | _M_invalidate_if (_Predicate __pred) const
template<typename _Predicate>
void | _M_transfer_from_if (const _Safe_sequence &__from, _Predicate __pred) const

## Public Attributes
_Safe_iterator_base * | _M_const_iterators
_Safe_iterator_base * | _M_iterators
unsigned int | _M_version

## Protected Member Functions
void | _M_detach_all () const
void | _M_detach_singular () const
__gnu_cxx::__mutex & | _M_get_mutex () const noexcept
constexpr void | _M_invalidate_all () const
void | _M_revalidate_singular () const
void | _M_swap (const _Safe_sequence_base &__x) const noexcept

## 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 `const_iterator` types that are instantiations of class template _Safe_iterator for this sequence. Iterators will then be tracked automatically.

Definition at line 111 of file safe_sequence.h.

## Member Function Documentation

## ◆ _M_detach_all()

void __gnu_debug::_Safe_sequence_base::_M_detach_all | ( |  | ) | const
| protectedinherited

Detach all iterators, leaving them singular.

Referenced by ~_Safe_sequence_base().

## ◆ _M_detach_singular()

void __gnu_debug::_Safe_sequence_base::_M_detach_singular | ( |  | ) | const
| protectedinherited

Detach all singular iterators.

Postcondition
  for all iterators i attached to this sequence, i->_M_version == _M_version.

## ◆ _M_get_mutex()

__gnu_cxx::__mutex & __gnu_debug::_Safe_sequence_base::_M_get_mutex | ( |  | ) | const
| protectednoexceptinherited

For use in _Safe_sequence.

Referenced by __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_from_if().

## ◆ _M_invalidate_all()

void __gnu_debug::_Safe_sequence_base::_M_invalidate_all | ( |  | ) | const
| inlineconstexprprotectedinherited

Invalidates all iterators.

Definition at line 314 of file safe_base.h.

References _M_invalidate_all(), and _M_version.

Referenced by _M_invalidate_all().

## ◆ _M_invalidate_if()

template<typename _Sequence>
template<typename _Predicate>

void __gnu_debug::_Safe_sequence< _Sequence >::_M_invalidate_if | ( | _Predicate | __pred | ) | const
| inlineconstexpr

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

Definition at line 124 of file safe_sequence.h.

## ◆ _M_revalidate_singular()

void __gnu_debug::_Safe_sequence_base::_M_revalidate_singular | ( |  | ) | const
| protectedinherited

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

## ◆ _M_swap()

void __gnu_debug::_Safe_sequence_base::_M_swap | ( | const _Safe_sequence_base & | __x | ) | const
| protectednoexceptinherited

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.

## ◆ _M_transfer_from_if()

template<typename _Sequence>
template<typename _Predicate>

void __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_from_if | ( | const _Safe_sequence< _Sequence > & | __from,
|  | _Predicate | __pred ) const

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

Definition at line 68 of file safe_sequence.tcc.

References std::__addressof(), __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_next, __gnu_debug::_Safe_iterator_base::_M_prior, __gnu_debug::_Safe_iterator_base::_M_sequence, __gnu_debug::_Safe_iterator_base::_M_version, and __gnu_debug::_Safe_sequence_base::_M_version.

## Member Data Documentation

## ◆ _M_const_iterators

_Safe_iterator_base* __gnu_debug::_Safe_sequence_base::_M_const_iterators
| mutableinherited

The list of constant iterators that reference this container.

Definition at line 227 of file safe_base.h.

Referenced by __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_from_if().

## ◆ _M_iterators

_Safe_iterator_base* __gnu_debug::_Safe_sequence_base::_M_iterators
| mutableinherited

The list of mutable iterators that reference this container.

Definition at line 224 of file safe_base.h.

Referenced by __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_from_if().

## ◆ _M_version

unsigned int __gnu_debug::_Safe_sequence_base::_M_version
| mutableinherited

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

Definition at line 230 of file safe_base.h.

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=().

The documentation for this class was generated from the following files:

- formatter.h
- safe_sequence.h
- safe_sequence.tcc