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