libstdc++
|
00001 // Safe container implementation -*- C++ -*- 00002 00003 // Copyright (C) 2011 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file debug/safe_unordered_container.h 00026 * This file is a GNU debug extension to the Standard C++ Library. 00027 */ 00028 00029 #ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 00030 #define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 1 00031 00032 #include <debug/debug.h> 00033 #include <debug/macros.h> 00034 #include <debug/functions.h> 00035 #include <debug/safe_unordered_base.h> 00036 00037 namespace __gnu_debug 00038 { 00039 /** 00040 * @brief Base class for constructing a @a safe unordered container type 00041 * that tracks iterators that reference it. 00042 * 00043 * The class template %_Safe_unordered_container simplifies the 00044 * construction of @a safe unordered containers that track the iterators 00045 * that reference the container, so that the iterators are notified of 00046 * changes in the container that may affect their operation, e.g., if 00047 * the container invalidates its iterators or is destructed. This class 00048 * template may only be used by deriving from it and passing the name 00049 * of the derived class as its template parameter via the curiously 00050 * recurring template pattern. The derived class must have @c 00051 * iterator and @c const_iterator types that are instantiations of 00052 * class template _Safe_iterator for this container and @c local_iterator 00053 * and @c const_local_iterator types that are instantiations of class 00054 * template _Safe_local_iterator for this container. Iterators will 00055 * then be tracked automatically. 00056 */ 00057 template<typename _Container> 00058 class _Safe_unordered_container : public _Safe_unordered_container_base 00059 { 00060 public: 00061 /** Invalidates all iterators @c x that reference this container, 00062 are not singular, and for which @c __pred(x) returns @c 00063 true. @c __pred will be invoked with the normal iterators nested 00064 in the safe ones. */ 00065 template<typename _Predicate> 00066 void 00067 _M_invalidate_if(_Predicate __pred); 00068 00069 /** Invalidates all local iterators @c x that reference this container, 00070 are not singular, and for which @c __pred(x) returns @c 00071 true. @c __pred will be invoked with the normal ilocal iterators 00072 nested in the safe ones. */ 00073 template<typename _Predicate> 00074 void 00075 _M_invalidate_local_if(_Predicate __pred); 00076 }; 00077 } // namespace __gnu_debug 00078 00079 #include <debug/safe_unordered_container.tcc> 00080 00081 #endif