29#ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H
30#define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 1
57 template<
typename _Container>
63 {
return *
static_cast<_Container*
>(
this); }
67 _M_invalidate_locals()
69 auto __local_end = _M_cont()._M_base().cend(0);
71 [__local_end](__decltype(__local_end) __it)
72 {
return __it != __local_end; });
75#if __cplusplus > 201402L
76 template<
typename _ExtractKey,
typename _Source>
77 struct _UContInvalidatePred
79 template<
typename _Iterator>
81 operator()(_Iterator __it)
const
82 {
return _M_source.count(_ExtractKey{}(*__it)) == 0; }
84 const _Source& _M_source;
87 template<
typename _ExtractKey,
typename _Source>
88 struct _UMContInvalidatePred
90 template<
typename _Iterator>
92 operator()(_Iterator __it)
const
95 _M_source._M_base().equal_range(_ExtractKey{}(*__it));
96 for (
auto __rit = __rng.first;
97 __rit != __rng.second; ++__rit)
106 const _Source& _M_source;
109 template<
typename _Source,
typename _Inval
idatePred>
110 struct _UContMergeGuard
112 _UContMergeGuard(_Source& __src) noexcept
113 : _M_source(__src), _M_size(__src.size()), _M_pred { __src }
116 _UContMergeGuard(
const _UContMergeGuard&) =
delete;
120 const std::size_t __size = _M_source.size();
121 if (__size == _M_size)
127 _M_source._M_invalidate_all();
130 _M_source._M_invalidate_if(_M_pred);
131 _M_source._M_invalidate_local_if(_M_pred);
136 _M_source._M_invalidate_all();
141 const std::size_t _M_size;
142 _InvalidatePred _M_pred;
145 template<
typename _ExtractKey,
typename _Source>
146 static _UContMergeGuard<_Source,
147 _UContInvalidatePred<_ExtractKey, _Source>>
148 _S_uc_guard(_ExtractKey, _Source& __src)
150 typedef _UContInvalidatePred<_ExtractKey, _Source> _InvalidatePred;
151 return _UContMergeGuard<_Source, _InvalidatePred>(__src);
154 template<
typename _ExtractKey,
typename _Source>
155 static _UContMergeGuard<_Source,
156 _UMContInvalidatePred<_ExtractKey, _Source>>
157 _S_umc_guard(_ExtractKey, _Source& __src)
159 typedef _UMContInvalidatePred<_ExtractKey, _Source> _InvalidatePred;
160 return _UContMergeGuard<_Source, _InvalidatePred>(__src);
168 auto __end = _M_cont()._M_base().cend();
170 {
return __it != __end; });
171 _M_invalidate_locals();
178 template<
typename _Predicate>
186 template<
typename _Predicate>
GNU debug classes for public use.
Base class that supports tracking of local iterators that reference an unordered container.
Base class for constructing a safe unordered container type that tracks iterators that reference it.
void _M_invalidate_local_if(_Predicate __pred)
void _M_invalidate_if(_Predicate __pred)