1*e4b17023SJohn Marino // Safe container implementation -*- C++ -*- 2*e4b17023SJohn Marino 3*e4b17023SJohn Marino // Copyright (C) 2011 Free Software Foundation, Inc. 4*e4b17023SJohn Marino // 5*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library. This library is free 6*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the 7*e4b17023SJohn Marino // terms of the GNU General Public License as published by the 8*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option) 9*e4b17023SJohn Marino // any later version. 10*e4b17023SJohn Marino 11*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful, 12*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of 13*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*e4b17023SJohn Marino // GNU General Public License for more details. 15*e4b17023SJohn Marino 16*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional 17*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version 18*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation. 19*e4b17023SJohn Marino 20*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and 21*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program; 22*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>. 24*e4b17023SJohn Marino 25*e4b17023SJohn Marino /** @file debug/safe_unordered_container.h 26*e4b17023SJohn Marino * This file is a GNU debug extension to the Standard C++ Library. 27*e4b17023SJohn Marino */ 28*e4b17023SJohn Marino 29*e4b17023SJohn Marino #ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 30*e4b17023SJohn Marino #define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 1 31*e4b17023SJohn Marino 32*e4b17023SJohn Marino #include <debug/debug.h> 33*e4b17023SJohn Marino #include <debug/macros.h> 34*e4b17023SJohn Marino #include <debug/functions.h> 35*e4b17023SJohn Marino #include <debug/safe_unordered_base.h> 36*e4b17023SJohn Marino 37*e4b17023SJohn Marino namespace __gnu_debug 38*e4b17023SJohn Marino { 39*e4b17023SJohn Marino /** 40*e4b17023SJohn Marino * @brief Base class for constructing a @a safe unordered container type 41*e4b17023SJohn Marino * that tracks iterators that reference it. 42*e4b17023SJohn Marino * 43*e4b17023SJohn Marino * The class template %_Safe_unordered_container simplifies the 44*e4b17023SJohn Marino * construction of @a safe unordered containers that track the iterators 45*e4b17023SJohn Marino * that reference the container, so that the iterators are notified of 46*e4b17023SJohn Marino * changes in the container that may affect their operation, e.g., if 47*e4b17023SJohn Marino * the container invalidates its iterators or is destructed. This class 48*e4b17023SJohn Marino * template may only be used by deriving from it and passing the name 49*e4b17023SJohn Marino * of the derived class as its template parameter via the curiously 50*e4b17023SJohn Marino * recurring template pattern. The derived class must have @c 51*e4b17023SJohn Marino * iterator and @c const_iterator types that are instantiations of 52*e4b17023SJohn Marino * class template _Safe_iterator for this container and @c local_iterator 53*e4b17023SJohn Marino * and @c const_local_iterator types that are instantiations of class 54*e4b17023SJohn Marino * template _Safe_local_iterator for this container. Iterators will 55*e4b17023SJohn Marino * then be tracked automatically. 56*e4b17023SJohn Marino */ 57*e4b17023SJohn Marino template<typename _Container> 58*e4b17023SJohn Marino class _Safe_unordered_container : public _Safe_unordered_container_base 59*e4b17023SJohn Marino { 60*e4b17023SJohn Marino public: 61*e4b17023SJohn Marino /** Invalidates all iterators @c x that reference this container, 62*e4b17023SJohn Marino are not singular, and for which @c __pred(x) returns @c 63*e4b17023SJohn Marino true. @c __pred will be invoked with the normal iterators nested 64*e4b17023SJohn Marino in the safe ones. */ 65*e4b17023SJohn Marino template<typename _Predicate> 66*e4b17023SJohn Marino void 67*e4b17023SJohn Marino _M_invalidate_if(_Predicate __pred); 68*e4b17023SJohn Marino 69*e4b17023SJohn Marino /** Invalidates all local iterators @c x that reference this container, 70*e4b17023SJohn Marino are not singular, and for which @c __pred(x) returns @c 71*e4b17023SJohn Marino true. @c __pred will be invoked with the normal ilocal iterators 72*e4b17023SJohn Marino nested in the safe ones. */ 73*e4b17023SJohn Marino template<typename _Predicate> 74*e4b17023SJohn Marino void 75*e4b17023SJohn Marino _M_invalidate_local_if(_Predicate __pred); 76*e4b17023SJohn Marino }; 77*e4b17023SJohn Marino } // namespace __gnu_debug 78*e4b17023SJohn Marino 79*e4b17023SJohn Marino #include <debug/safe_unordered_container.tcc> 80*e4b17023SJohn Marino 81*e4b17023SJohn Marino #endif 82