STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
safe_sequence.h
Go to the documentation of this file.
1 // Safe sequence implementation -*- C++ -*-
2 
3 // Copyright (C) 2003-2013 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.
10 
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.
15 
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.
19 
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/>.
24 
29 #ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H
30 #define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1
31 
32 #include <debug/debug.h>
33 #include <debug/macros.h>
34 #include <debug/functions.h>
35 #include <debug/safe_base.h>
36 
37 namespace __gnu_debug
38 {
39  template<typename _Iterator, typename _Sequence>
40  class _Safe_iterator;
41 
46  template<typename _Type>
48  {
49  _Type __value;
50 
51  public:
52  explicit _Not_equal_to(const _Type& __v) : __value(__v) { }
53 
54  bool
55  operator()(const _Type& __x) const
56  { return __value != __x; }
57  };
58 
61  template <typename _Type>
62  class _Equal_to
63  {
64  _Type __value;
65 
66  public:
67  explicit _Equal_to(const _Type& __v) : __value(__v) { }
68 
69  bool
70  operator()(const _Type& __x) const
71  { return __value == __x; }
72  };
73 
76  template<typename _Iterator>
78  {
79  typedef typename std::iterator_traits<_Iterator>::difference_type
81 
82  _Iterator _M_base;
84 
85  public:
86  _After_nth_from(const difference_type& __n, const _Iterator& __base)
87  : _M_base(__base), _M_n(__n) { }
88 
89  bool
90  operator()(const _Iterator& __x) const
91  { return __x - _M_base >= _M_n; }
92  };
93 
110  template<typename _Sequence>
111  class _Safe_sequence : public _Safe_sequence_base
112  {
113  public:
118  template<typename _Predicate>
119  void
120  _M_invalidate_if(_Predicate __pred);
121 
126  template<typename _Predicate>
127  void
128  _M_transfer_from_if(_Safe_sequence& __from, _Predicate __pred);
129  };
130 } // namespace __gnu_debug
131 
132 #include <debug/safe_sequence.tcc>
133 
134 #endif
_Iterator _M_base
Definition: safe_sequence.h:82
bool operator()(const _Type &__x) const
Definition: safe_sequence.h:55
_Type __value
Definition: safe_sequence.h:64
Definition: safe_sequence.h:62
Definition: safe_sequence.h:47
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Definition: functions.h:446
Definition: safe_sequence.h:77
void _M_invalidate_if(_Predicate __pred)
Definition: safe_sequence.tcc:38
std::iterator_traits< _Iterator >::difference_type difference_type
Definition: safe_sequence.h:80
bool operator()(const _Iterator &__x) const
Definition: safe_sequence.h:90
_Equal_to(const _Type &__v)
Definition: safe_sequence.h:67
difference_type _M_n
Definition: safe_sequence.h:83
_Not_equal_to(const _Type &__v)
Definition: safe_sequence.h:52
void _M_transfer_from_if(_Safe_sequence &__from, _Predicate __pred)
Definition: safe_sequence.tcc:69
_After_nth_from(const difference_type &__n, const _Iterator &__base)
Definition: safe_sequence.h:86
bool operator()(const _Type &__x) const
Definition: safe_sequence.h:70
_Type __value
Definition: safe_sequence.h:49