gccxml_gem 0.9-x86-darwin-9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/Rakefile +75 -0
  2. data/bin/gccxml +0 -0
  3. data/bin/gccxml_cc1plus +0 -0
  4. data/gccxml.rb +44 -0
  5. data/share/doc/gccxml-0.9/Copyright.txt +55 -0
  6. data/share/doc/gccxml-0.9/gccxml.html +168 -0
  7. data/share/doc/gccxml-0.9/gccxml.txt +293 -0
  8. data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
  9. data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
  10. data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
  11. data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
  12. data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
  13. data/share/gccxml-0.9/GCC/2.95/complex +38 -0
  14. data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
  15. data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
  16. data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
  17. data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
  18. data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
  19. data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
  20. data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
  21. data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
  22. data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
  23. data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
  24. data/share/gccxml-0.9/GCC/2.95/deque +19 -0
  25. data/share/gccxml-0.9/GCC/2.95/exception +20 -0
  26. data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
  27. data/share/gccxml-0.9/GCC/2.95/functional +64 -0
  28. data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
  29. data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
  30. data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
  31. data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
  32. data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
  33. data/share/gccxml-0.9/GCC/2.95/list +19 -0
  34. data/share/gccxml-0.9/GCC/2.95/map +20 -0
  35. data/share/gccxml-0.9/GCC/2.95/memory +21 -0
  36. data/share/gccxml-0.9/GCC/2.95/new +13 -0
  37. data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
  38. data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
  39. data/share/gccxml-0.9/GCC/2.95/queue +20 -0
  40. data/share/gccxml-0.9/GCC/2.95/set +20 -0
  41. data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
  42. data/share/gccxml-0.9/GCC/2.95/stack +19 -0
  43. data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
  44. data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
  45. data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
  46. data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
  47. data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
  48. data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
  49. data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
  50. data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
  51. data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
  52. data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
  53. data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
  54. data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
  55. data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
  56. data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
  57. data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
  58. data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
  59. data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
  60. data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
  61. data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
  62. data/share/gccxml-0.9/GCC/2.95/string +26 -0
  63. data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
  64. data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
  65. data/share/gccxml-0.9/GCC/2.95/utility +25 -0
  66. data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
  67. data/share/gccxml-0.9/GCC/2.95/vector +19 -0
  68. data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
  69. data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
  70. data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
  71. data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
  72. data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
  73. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
  74. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
  75. data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
  76. data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
  77. data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
  78. data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
  79. data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
  80. data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
  81. data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
  82. data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
  83. data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
  84. data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
  85. data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
  86. data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
  87. data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
  88. data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
  89. data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
  90. data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
  91. data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
  92. data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
  93. data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
  94. data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
  95. data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
  96. data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
  97. data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
  98. data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
  99. data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
  100. data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
  101. data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +618 -0
  102. data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
  103. data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
  104. data/share/gccxml-0.9/GCC/find_flags +105 -0
  105. data/share/gccxml-0.9/Intel/find_flags +56 -0
  106. data/share/gccxml-0.9/Intel/pthread.h +16 -0
  107. data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
  108. data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
  109. data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
  110. data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
  111. data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
  112. data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
  113. data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
  114. data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
  115. data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
  116. data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
  117. data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
  118. data/share/gccxml-0.9/MIPSpro/find_flags +137 -0
  119. data/share/gccxml-0.9/Sun/5.8/adaptation.patch +168 -0
  120. data/share/gccxml-0.9/Sun/README +8 -0
  121. data/share/gccxml-0.9/Sun/adapt_headers.sh +24 -0
  122. data/share/gccxml-0.9/Sun/find_flags +69 -0
  123. data/share/gccxml-0.9/gccxml_config +2 -0
  124. data/share/gccxml-0.9/gccxml_find_flags +93 -0
  125. data/share/man/man1/gccxml.1 +246 -0
  126. metadata +204 -0
@@ -0,0 +1,1167 @@
1
+ // List implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2005 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 2, 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
+ // You should have received a copy of the GNU General Public License along
17
+ // with this library; see the file COPYING. If not, write to the Free
18
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19
+ // USA.
20
+
21
+ // As a special exception, you may use this file as part of a free software
22
+ // library without restriction. Specifically, if other files instantiate
23
+ // templates or use macros or inline functions from this file, or you compile
24
+ // this file and link it with other files to produce an executable, this
25
+ // file does not by itself cause the resulting executable to be covered by
26
+ // the GNU General Public License. This exception does not however
27
+ // invalidate any other reasons why the executable file might be covered by
28
+ // the GNU General Public License.
29
+
30
+ /*
31
+ *
32
+ * Copyright (c) 1994
33
+ * Hewlett-Packard Company
34
+ *
35
+ * Permission to use, copy, modify, distribute and sell this software
36
+ * and its documentation for any purpose is hereby granted without fee,
37
+ * provided that the above copyright notice appear in all copies and
38
+ * that both that copyright notice and this permission notice appear
39
+ * in supporting documentation. Hewlett-Packard Company makes no
40
+ * representations about the suitability of this software for any
41
+ * purpose. It is provided "as is" without express or implied warranty.
42
+ *
43
+ *
44
+ * Copyright (c) 1996,1997
45
+ * Silicon Graphics Computer Systems, Inc.
46
+ *
47
+ * Permission to use, copy, modify, distribute and sell this software
48
+ * and its documentation for any purpose is hereby granted without fee,
49
+ * provided that the above copyright notice appear in all copies and
50
+ * that both that copyright notice and this permission notice appear
51
+ * in supporting documentation. Silicon Graphics makes no
52
+ * representations about the suitability of this software for any
53
+ * purpose. It is provided "as is" without express or implied warranty.
54
+ */
55
+
56
+ /** @file stl_list.h
57
+ * This is an internal header file, included by other library headers.
58
+ * You should not attempt to use it directly.
59
+ */
60
+
61
+ #ifndef __GLIBCPP_INTERNAL_LIST_H
62
+ #define __GLIBCPP_INTERNAL_LIST_H
63
+
64
+ #include <bits/concept_check.h>
65
+
66
+ namespace std
67
+ {
68
+ // Supporting structures are split into common and templated types; the
69
+ // latter publicly inherits from the former in an effort to reduce code
70
+ // duplication. This results in some "needless" static_cast'ing later on,
71
+ // but it's all safe downcasting.
72
+
73
+ /// @if maint Common part of a node in the %list. @endif
74
+ struct _List_node_base
75
+ {
76
+ _List_node_base* _M_next; ///< Self-explanatory
77
+ _List_node_base* _M_prev; ///< Self-explanatory
78
+ };
79
+
80
+ /// @if maint An actual node in the %list. @endif
81
+ template<typename _Tp>
82
+ struct _List_node : public _List_node_base
83
+ {
84
+ _Tp _M_data; ///< User's data.
85
+ };
86
+
87
+
88
+ /**
89
+ * @if maint
90
+ * @brief Common part of a list::iterator.
91
+ *
92
+ * A simple type to walk a doubly-linked list. All operations here should
93
+ * be self-explanatory after taking any decent introductory data structures
94
+ * course.
95
+ * @endif
96
+ */
97
+ struct _List_iterator_base
98
+ {
99
+ typedef size_t size_type;
100
+ typedef ptrdiff_t difference_type;
101
+ typedef bidirectional_iterator_tag iterator_category;
102
+
103
+ /// The only member points to the %list element.
104
+ _List_node_base* _M_node;
105
+
106
+ _List_iterator_base(_List_node_base* __x)
107
+ : _M_node(__x)
108
+ { }
109
+
110
+ _List_iterator_base()
111
+ : _M_node()
112
+ { }
113
+
114
+ /// Walk the %list forward.
115
+ void
116
+ _M_incr()
117
+ { _M_node = _M_node->_M_next; }
118
+
119
+ /// Walk the %list backward.
120
+ void
121
+ _M_decr()
122
+ { _M_node = _M_node->_M_prev; }
123
+
124
+ bool
125
+ operator==(const _List_iterator_base& __x) const
126
+ { return _M_node == __x._M_node; }
127
+
128
+ bool
129
+ operator!=(const _List_iterator_base& __x) const
130
+ { return _M_node != __x._M_node; }
131
+ };
132
+
133
+ /**
134
+ * @brief A list::iterator.
135
+ *
136
+ * In addition to being used externally, a list holds one of these
137
+ * internally, pointing to the sequence of data.
138
+ *
139
+ * @if maint
140
+ * All the functions are op overloads.
141
+ * @endif
142
+ */
143
+ template<typename _Tp, typename _Ref, typename _Ptr>
144
+ struct _List_iterator : public _List_iterator_base
145
+ {
146
+ typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
147
+ typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
148
+ typedef _List_iterator<_Tp,_Ref,_Ptr> _Self;
149
+
150
+ typedef _Tp value_type;
151
+ typedef _Ptr pointer;
152
+ typedef _Ref reference;
153
+ typedef _List_node<_Tp> _Node;
154
+
155
+ _List_iterator(_Node* __x)
156
+ : _List_iterator_base(__x)
157
+ { }
158
+
159
+ _List_iterator()
160
+ : _List_iterator_base()
161
+ { }
162
+
163
+ _List_iterator(const iterator& __x)
164
+ : _List_iterator_base(__x._M_node)
165
+ { }
166
+
167
+ reference
168
+ operator*() const
169
+ { return static_cast<_Node*>(_M_node)->_M_data; }
170
+ // Must downcast from List_node_base to _List_node to get to _M_data.
171
+
172
+ pointer
173
+ operator->() const
174
+ { return &(operator*()); }
175
+
176
+ _Self&
177
+ operator++()
178
+ {
179
+ this->_M_incr();
180
+ return *this;
181
+ }
182
+
183
+ _Self
184
+ operator++(int)
185
+ {
186
+ _Self __tmp = *this;
187
+ this->_M_incr();
188
+ return __tmp;
189
+ }
190
+
191
+ _Self&
192
+ operator--()
193
+ {
194
+ this->_M_decr();
195
+ return *this;
196
+ }
197
+
198
+ _Self
199
+ operator--(int)
200
+ {
201
+ _Self __tmp = *this;
202
+ this->_M_decr();
203
+ return __tmp;
204
+ }
205
+ };
206
+
207
+
208
+ /// @if maint Primary default version. @endif
209
+ /**
210
+ * @if maint
211
+ * See bits/stl_deque.h's _Deque_alloc_base for an explanation.
212
+ * @endif
213
+ */
214
+ template<typename _Tp, typename _Allocator, bool _IsStatic>
215
+ class _List_alloc_base
216
+ {
217
+ public:
218
+ typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
219
+ allocator_type;
220
+
221
+ allocator_type
222
+ get_allocator() const { return _M_node_allocator; }
223
+
224
+ _List_alloc_base(const allocator_type& __a)
225
+ : _M_node_allocator(__a)
226
+ { }
227
+
228
+ protected:
229
+ _List_node<_Tp>*
230
+ _M_get_node()
231
+ { return _M_node_allocator.allocate(1); }
232
+
233
+ void
234
+ _M_put_node(_List_node<_Tp>* __p)
235
+ { _M_node_allocator.deallocate(__p, 1); }
236
+
237
+ // NOTA BENE
238
+ // The stored instance is not actually of "allocator_type"'s type. Instead
239
+ // we rebind the type to Allocator<List_node<Tp>>, which according to
240
+ // [20.1.5]/4 should probably be the same. List_node<Tp> is not the same
241
+ // size as Tp (it's two pointers larger), and specializations on Tp may go
242
+ // unused because List_node<Tp> is being bound instead.
243
+ //
244
+ // We put this to the test in get_allocator above; if the two types are
245
+ // actually different, there had better be a conversion between them.
246
+ //
247
+ // None of the predefined allocators shipped with the library (as of 3.1)
248
+ // use this instantiation anyhow; they're all instanceless.
249
+ typename _Alloc_traits<_List_node<_Tp>, _Allocator>::allocator_type
250
+ _M_node_allocator;
251
+
252
+ _List_node<_Tp>* _M_node;
253
+ };
254
+
255
+ /// @if maint Specialization for instanceless allocators. @endif
256
+ template<typename _Tp, typename _Allocator>
257
+ class _List_alloc_base<_Tp, _Allocator, true>
258
+ {
259
+ public:
260
+ typedef typename _Alloc_traits<_Tp, _Allocator>::allocator_type
261
+ allocator_type;
262
+
263
+ allocator_type
264
+ get_allocator() const { return allocator_type(); }
265
+
266
+ _List_alloc_base(const allocator_type&)
267
+ { }
268
+
269
+ protected:
270
+ // See comment in primary template class about why this is safe for the
271
+ // standard predefined classes.
272
+ typedef typename _Alloc_traits<_List_node<_Tp>, _Allocator>::_Alloc_type
273
+ _Alloc_type;
274
+
275
+ _List_node<_Tp>*
276
+ _M_get_node()
277
+ { return _Alloc_type::allocate(1); }
278
+
279
+ void
280
+ _M_put_node(_List_node<_Tp>* __p)
281
+ { _Alloc_type::deallocate(__p, 1); }
282
+
283
+ _List_node<_Tp>* _M_node;
284
+ };
285
+
286
+
287
+ /**
288
+ * @if maint
289
+ * See bits/stl_deque.h's _Deque_base for an explanation.
290
+ * @endif
291
+ */
292
+ template <typename _Tp, typename _Alloc>
293
+ class _List_base
294
+ : public _List_alloc_base<_Tp, _Alloc,
295
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
296
+ {
297
+ public:
298
+ typedef _List_alloc_base<_Tp, _Alloc,
299
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
300
+ _Base;
301
+ typedef typename _Base::allocator_type allocator_type;
302
+
303
+ _List_base(const allocator_type& __a)
304
+ : _Base(__a)
305
+ {
306
+ this->_M_node = this->_M_get_node();
307
+ this->_M_node->_M_next = this->_M_node;
308
+ this->_M_node->_M_prev = this->_M_node;
309
+ }
310
+
311
+ // This is what actually destroys the list.
312
+ ~_List_base()
313
+ {
314
+ __clear();
315
+ this->_M_put_node(this->_M_node);
316
+ }
317
+
318
+ void
319
+ __clear();
320
+ };
321
+
322
+
323
+ /**
324
+ * @brief A standard container with linear time access to elements, and
325
+ * fixed time insertion/deletion at any point in the sequence.
326
+ *
327
+ * @ingroup Containers
328
+ * @ingroup Sequences
329
+ *
330
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
331
+ * <a href="tables.html#66">reversible container</a>, and a
332
+ * <a href="tables.html#67">sequence</a>, including the
333
+ * <a href="tables.html#68">optional sequence requirements</a> with the
334
+ * %exception of @c at and @c operator[].
335
+ *
336
+ * This is a @e doubly @e linked %list. Traversal up and down the %list
337
+ * requires linear time, but adding and removing elements (or @e nodes) is
338
+ * done in constant time, regardless of where the change takes place.
339
+ * Unlike std::vector and std::deque, random-access iterators are not
340
+ * provided, so subscripting ( @c [] ) access is not allowed. For algorithms
341
+ * which only need sequential access, this lack makes no difference.
342
+ *
343
+ * Also unlike the other standard containers, std::list provides specialized
344
+ * algorithms %unique to linked lists, such as splicing, sorting, and
345
+ * in-place reversal.
346
+ *
347
+ * @if maint
348
+ * A couple points on memory allocation for list<Tp>:
349
+ *
350
+ * First, we never actually allocate a Tp, we allocate List_node<Tp>'s
351
+ * and trust [20.1.5]/4 to DTRT. This is to ensure that after elements from
352
+ * %list<X,Alloc1> are spliced into %list<X,Alloc2>, destroying the memory of
353
+ * the second %list is a valid operation, i.e., Alloc1 giveth and Alloc2
354
+ * taketh away.
355
+ *
356
+ * Second, a %list conceptually represented as
357
+ * @code
358
+ * A <---> B <---> C <---> D
359
+ * @endcode
360
+ * is actually circular; a link exists between A and D. The %list class
361
+ * holds (as its only data member) a private list::iterator pointing to
362
+ * @e D, not to @e A! To get to the head of the %list, we start at the tail
363
+ * and move forward by one. When this member iterator's next/previous
364
+ * pointers refer to itself, the %list is %empty.
365
+ * @endif
366
+ */
367
+ template<typename _Tp, typename _Alloc = allocator<_Tp> >
368
+ class list : protected _List_base<_Tp, _Alloc>
369
+ {
370
+ // concept requirements
371
+ __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
372
+
373
+ typedef _List_base<_Tp, _Alloc> _Base;
374
+
375
+ public:
376
+ typedef _Tp value_type;
377
+ typedef value_type* pointer;
378
+ typedef const value_type* const_pointer;
379
+ typedef _List_iterator<_Tp,_Tp&,_Tp*> iterator;
380
+ typedef _List_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
381
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
382
+ typedef std::reverse_iterator<iterator> reverse_iterator;
383
+ typedef value_type& reference;
384
+ typedef const value_type& const_reference;
385
+ typedef size_t size_type;
386
+ typedef ptrdiff_t difference_type;
387
+ typedef typename _Base::allocator_type allocator_type;
388
+
389
+ protected:
390
+ // Note that pointers-to-_Node's can be ctor-converted to iterator types.
391
+ typedef _List_node<_Tp> _Node;
392
+
393
+ /** @if maint
394
+ * One data member plus two memory-handling functions. If the _Alloc
395
+ * type requires separate instances, then one of those will also be
396
+ * included, accumulated from the topmost parent.
397
+ * @endif
398
+ */
399
+ using _Base::_M_node;
400
+ using _Base::_M_put_node;
401
+ using _Base::_M_get_node;
402
+
403
+ /**
404
+ * @if maint
405
+ * @param x An instance of user data.
406
+ *
407
+ * Allocates space for a new node and constructs a copy of @a x in it.
408
+ * @endif
409
+ */
410
+ _Node*
411
+ _M_create_node(const value_type& __x)
412
+ {
413
+ _Node* __p = _M_get_node();
414
+ try {
415
+ _Construct(&__p->_M_data, __x);
416
+ }
417
+ catch(...)
418
+ {
419
+ _M_put_node(__p);
420
+ __throw_exception_again;
421
+ }
422
+ return __p;
423
+ }
424
+
425
+ /**
426
+ * @if maint
427
+ * Allocates space for a new node and default-constructs a new instance
428
+ * of @c value_type in it.
429
+ * @endif
430
+ */
431
+ _Node*
432
+ _M_create_node()
433
+ {
434
+ _Node* __p = _M_get_node();
435
+ try {
436
+ _Construct(&__p->_M_data);
437
+ }
438
+ catch(...)
439
+ {
440
+ _M_put_node(__p);
441
+ __throw_exception_again;
442
+ }
443
+ return __p;
444
+ }
445
+
446
+ public:
447
+ // [23.2.2.1] construct/copy/destroy
448
+ // (assign() and get_allocator() are also listed in this section)
449
+ /**
450
+ * @brief Default constructor creates no elements.
451
+ */
452
+ explicit
453
+ list(const allocator_type& __a = allocator_type())
454
+ : _Base(__a) { }
455
+
456
+ /**
457
+ * @brief Create a %list with copies of an exemplar element.
458
+ * @param n The number of elements to initially create.
459
+ * @param value An element to copy.
460
+ *
461
+ * This constructor fills the %list with @a n copies of @a value.
462
+ */
463
+ list(size_type __n, const value_type& __value,
464
+ const allocator_type& __a = allocator_type())
465
+ : _Base(__a)
466
+ { this->insert(begin(), __n, __value); }
467
+
468
+ /**
469
+ * @brief Create a %list with default elements.
470
+ * @param n The number of elements to initially create.
471
+ *
472
+ * This constructor fills the %list with @a n copies of a
473
+ * default-constructed element.
474
+ */
475
+ explicit
476
+ list(size_type __n)
477
+ : _Base(allocator_type())
478
+ { this->insert(begin(), __n, value_type()); }
479
+
480
+ /**
481
+ * @brief %List copy constructor.
482
+ * @param x A %list of identical element and allocator types.
483
+ *
484
+ * The newly-created %list uses a copy of the allocation object used
485
+ * by @a x.
486
+ */
487
+ list(const list& __x)
488
+ : _Base(__x.get_allocator())
489
+ { this->insert(begin(), __x.begin(), __x.end()); }
490
+
491
+ /**
492
+ * @brief Builds a %list from a range.
493
+ * @param first An input iterator.
494
+ * @param last An input iterator.
495
+ *
496
+ * Create a %list consisting of copies of the elements from [first,last).
497
+ * This is linear in N (where N is distance(first,last)).
498
+ *
499
+ * @if maint
500
+ * We don't need any dispatching tricks here, because insert does all of
501
+ * that anyway.
502
+ * @endif
503
+ */
504
+ template<typename _InputIterator>
505
+ list(_InputIterator __first, _InputIterator __last,
506
+ const allocator_type& __a = allocator_type())
507
+ : _Base(__a)
508
+ { this->insert(begin(), __first, __last); }
509
+
510
+ /**
511
+ * The dtor only erases the elements, and note that if the elements
512
+ * themselves are pointers, the pointed-to memory is not touched in any
513
+ * way. Managing the pointer is the user's responsibilty.
514
+ */
515
+ ~list() { }
516
+
517
+ /**
518
+ * @brief %List assignment operator.
519
+ * @param x A %list of identical element and allocator types.
520
+ *
521
+ * All the elements of @a x are copied, but unlike the copy constructor,
522
+ * the allocator object is not copied.
523
+ */
524
+ list&
525
+ operator=(const list& __x);
526
+
527
+ /**
528
+ * @brief Assigns a given value to a %list.
529
+ * @param n Number of elements to be assigned.
530
+ * @param val Value to be assigned.
531
+ *
532
+ * This function fills a %list with @a n copies of the given value.
533
+ * Note that the assignment completely changes the %list and that the
534
+ * resulting %list's size is the same as the number of elements assigned.
535
+ * Old data may be lost.
536
+ */
537
+ void
538
+ assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); }
539
+
540
+ /**
541
+ * @brief Assigns a range to a %list.
542
+ * @param first An input iterator.
543
+ * @param last An input iterator.
544
+ *
545
+ * This function fills a %list with copies of the elements in the
546
+ * range [first,last).
547
+ *
548
+ * Note that the assignment completely changes the %list and that the
549
+ * resulting %list's size is the same as the number of elements assigned.
550
+ * Old data may be lost.
551
+ */
552
+ template<typename _InputIterator>
553
+ void
554
+ assign(_InputIterator __first, _InputIterator __last)
555
+ {
556
+ // Check whether it's an integral type. If so, it's not an iterator.
557
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
558
+ _M_assign_dispatch(__first, __last, _Integral());
559
+ }
560
+
561
+ /// Get a copy of the memory allocation object.
562
+ allocator_type
563
+ get_allocator() const { return _Base::get_allocator(); }
564
+
565
+ // iterators
566
+ /**
567
+ * Returns a read/write iterator that points to the first element in the
568
+ * %list. Iteration is done in ordinary element order.
569
+ */
570
+ iterator
571
+ begin() { return static_cast<_Node*>(_M_node->_M_next); }
572
+
573
+ /**
574
+ * Returns a read-only (constant) iterator that points to the first element
575
+ * in the %list. Iteration is done in ordinary element order.
576
+ */
577
+ const_iterator
578
+ begin() const { return static_cast<_Node*>(_M_node->_M_next); }
579
+
580
+ /**
581
+ * Returns a read/write iterator that points one past the last element in
582
+ * the %list. Iteration is done in ordinary element order.
583
+ */
584
+ iterator
585
+ end() { return _M_node; }
586
+
587
+ /**
588
+ * Returns a read-only (constant) iterator that points one past the last
589
+ * element in the %list. Iteration is done in ordinary element order.
590
+ */
591
+ const_iterator
592
+ end() const { return _M_node; }
593
+
594
+ /**
595
+ * Returns a read/write reverse iterator that points to the last element in
596
+ * the %list. Iteration is done in reverse element order.
597
+ */
598
+ reverse_iterator
599
+ rbegin() { return reverse_iterator(end()); }
600
+
601
+ /**
602
+ * Returns a read-only (constant) reverse iterator that points to the last
603
+ * element in the %list. Iteration is done in reverse element order.
604
+ */
605
+ const_reverse_iterator
606
+ rbegin() const { return const_reverse_iterator(end()); }
607
+
608
+ /**
609
+ * Returns a read/write reverse iterator that points to one before the
610
+ * first element in the %list. Iteration is done in reverse element
611
+ * order.
612
+ */
613
+ reverse_iterator
614
+ rend() { return reverse_iterator(begin()); }
615
+
616
+ /**
617
+ * Returns a read-only (constant) reverse iterator that points to one
618
+ * before the first element in the %list. Iteration is done in reverse
619
+ * element order.
620
+ */
621
+ const_reverse_iterator
622
+ rend() const
623
+ { return const_reverse_iterator(begin()); }
624
+
625
+ // [23.2.2.2] capacity
626
+ /**
627
+ * Returns true if the %list is empty. (Thus begin() would equal end().)
628
+ */
629
+ bool
630
+ empty() const { return _M_node->_M_next == _M_node; }
631
+
632
+ /** Returns the number of elements in the %list. */
633
+ size_type
634
+ size() const { return distance(begin(), end()); }
635
+
636
+ /** Returns the size() of the largest possible %list. */
637
+ size_type
638
+ max_size() const { return size_type(-1); }
639
+
640
+ /**
641
+ * @brief Resizes the %list to the specified number of elements.
642
+ * @param new_size Number of elements the %list should contain.
643
+ * @param x Data with which new elements should be populated.
644
+ *
645
+ * This function will %resize the %list to the specified number of
646
+ * elements. If the number is smaller than the %list's current size the
647
+ * %list is truncated, otherwise the %list is extended and new elements
648
+ * are populated with given data.
649
+ */
650
+ void
651
+ resize(size_type __new_size, const value_type& __x);
652
+
653
+ /**
654
+ * @brief Resizes the %list to the specified number of elements.
655
+ * @param new_size Number of elements the %list should contain.
656
+ *
657
+ * This function will resize the %list to the specified number of
658
+ * elements. If the number is smaller than the %list's current size the
659
+ * %list is truncated, otherwise the %list is extended and new elements
660
+ * are default-constructed.
661
+ */
662
+ void
663
+ resize(size_type __new_size) { this->resize(__new_size, value_type()); }
664
+
665
+ // element access
666
+ /**
667
+ * Returns a read/write reference to the data at the first element of the
668
+ * %list.
669
+ */
670
+ reference
671
+ front() { return *begin(); }
672
+
673
+ /**
674
+ * Returns a read-only (constant) reference to the data at the first
675
+ * element of the %list.
676
+ */
677
+ const_reference
678
+ front() const { return *begin(); }
679
+
680
+ /**
681
+ * Returns a read/write reference to the data at the last element of the
682
+ * %list.
683
+ */
684
+ reference
685
+ back() { return *(--end()); }
686
+
687
+ /**
688
+ * Returns a read-only (constant) reference to the data at the last
689
+ * element of the %list.
690
+ */
691
+ const_reference
692
+ back() const { return *(--end()); }
693
+
694
+ // [23.2.2.3] modifiers
695
+ /**
696
+ * @brief Add data to the front of the %list.
697
+ * @param x Data to be added.
698
+ *
699
+ * This is a typical stack operation. The function creates an element at
700
+ * the front of the %list and assigns the given data to it. Due to the
701
+ * nature of a %list this operation can be done in constant time, and
702
+ * does not invalidate iterators and references.
703
+ */
704
+ void
705
+ push_front(const value_type& __x) { this->insert(begin(), __x); }
706
+
707
+ #ifdef _GLIBCPP_DEPRECATED
708
+ /**
709
+ * @brief Add data to the front of the %list.
710
+ *
711
+ * This is a typical stack operation. The function creates a
712
+ * default-constructed element at the front of the %list. Due to the
713
+ * nature of a %list this operation can be done in constant time. You
714
+ * should consider using push_front(value_type()) instead.
715
+ *
716
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
717
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
718
+ * c++config.h.
719
+ */
720
+ void
721
+ push_front() { this->insert(begin(), value_type()); }
722
+ #endif
723
+
724
+ /**
725
+ * @brief Removes first element.
726
+ *
727
+ * This is a typical stack operation. It shrinks the %list by one.
728
+ * Due to the nature of a %list this operation can be done in constant
729
+ * time, and only invalidates iterators/references to the element being
730
+ * removed.
731
+ *
732
+ * Note that no data is returned, and if the first element's data is
733
+ * needed, it should be retrieved before pop_front() is called.
734
+ */
735
+ void
736
+ pop_front() { this->erase(begin()); }
737
+
738
+ /**
739
+ * @brief Add data to the end of the %list.
740
+ * @param x Data to be added.
741
+ *
742
+ * This is a typical stack operation. The function creates an element at
743
+ * the end of the %list and assigns the given data to it. Due to the
744
+ * nature of a %list this operation can be done in constant time, and
745
+ * does not invalidate iterators and references.
746
+ */
747
+ void
748
+ push_back(const value_type& __x) { this->insert(end(), __x); }
749
+
750
+ #ifdef _GLIBCPP_DEPRECATED
751
+ /**
752
+ * @brief Add data to the end of the %list.
753
+ *
754
+ * This is a typical stack operation. The function creates a
755
+ * default-constructed element at the end of the %list. Due to the nature
756
+ * of a %list this operation can be done in constant time. You should
757
+ * consider using push_back(value_type()) instead.
758
+ *
759
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
760
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
761
+ * c++config.h.
762
+ */
763
+ void
764
+ push_back() { this->insert(end(), value_type()); }
765
+ #endif
766
+
767
+ /**
768
+ * @brief Removes last element.
769
+ *
770
+ * This is a typical stack operation. It shrinks the %list by one.
771
+ * Due to the nature of a %list this operation can be done in constant
772
+ * time, and only invalidates iterators/references to the element being
773
+ * removed.
774
+ *
775
+ * Note that no data is returned, and if the last element's data is
776
+ * needed, it should be retrieved before pop_back() is called.
777
+ */
778
+ void
779
+ pop_back()
780
+ {
781
+ iterator __tmp = end();
782
+ this->erase(--__tmp);
783
+ }
784
+
785
+ /**
786
+ * @brief Inserts given value into %list before specified iterator.
787
+ * @param position An iterator into the %list.
788
+ * @param x Data to be inserted.
789
+ * @return An iterator that points to the inserted data.
790
+ *
791
+ * This function will insert a copy of the given value before the specified
792
+ * location.
793
+ * Due to the nature of a %list this operation can be done in constant
794
+ * time, and does not invalidate iterators and references.
795
+ */
796
+ iterator
797
+ insert(iterator __position, const value_type& __x);
798
+
799
+ #ifdef _GLIBCPP_DEPRECATED
800
+ /**
801
+ * @brief Inserts an element into the %list.
802
+ * @param position An iterator into the %list.
803
+ * @return An iterator that points to the inserted element.
804
+ *
805
+ * This function will insert a default-constructed element before the
806
+ * specified location. You should consider using
807
+ * insert(position,value_type()) instead.
808
+ * Due to the nature of a %list this operation can be done in constant
809
+ * time, and does not invalidate iterators and references.
810
+ *
811
+ * @note This was deprecated in 3.2 and will be removed in 3.4. You must
812
+ * define @c _GLIBCPP_DEPRECATED to make this visible in 3.2; see
813
+ * c++config.h.
814
+ */
815
+ iterator
816
+ insert(iterator __position) { return insert(__position, value_type()); }
817
+ #endif
818
+
819
+ /**
820
+ * @brief Inserts a number of copies of given data into the %list.
821
+ * @param position An iterator into the %list.
822
+ * @param n Number of elements to be inserted.
823
+ * @param x Data to be inserted.
824
+ *
825
+ * This function will insert a specified number of copies of the given data
826
+ * before the location specified by @a position.
827
+ *
828
+ * Due to the nature of a %list this operation can be done in constant
829
+ * time, and does not invalidate iterators and references.
830
+ */
831
+ void
832
+ insert(iterator __pos, size_type __n, const value_type& __x)
833
+ { _M_fill_insert(__pos, __n, __x); }
834
+
835
+ /**
836
+ * @brief Inserts a range into the %list.
837
+ * @param pos An iterator into the %list.
838
+ * @param first An input iterator.
839
+ * @param last An input iterator.
840
+ *
841
+ * This function will insert copies of the data in the range [first,last)
842
+ * into the %list before the location specified by @a pos.
843
+ *
844
+ * Due to the nature of a %list this operation can be done in constant
845
+ * time, and does not invalidate iterators and references.
846
+ */
847
+ template<typename _InputIterator>
848
+ void
849
+ insert(iterator __pos, _InputIterator __first, _InputIterator __last)
850
+ {
851
+ // Check whether it's an integral type. If so, it's not an iterator.
852
+ typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
853
+ _M_insert_dispatch(__pos, __first, __last, _Integral());
854
+ }
855
+
856
+ /**
857
+ * @brief Remove element at given position.
858
+ * @param position Iterator pointing to element to be erased.
859
+ * @return An iterator pointing to the next element (or end()).
860
+ *
861
+ * This function will erase the element at the given position and thus
862
+ * shorten the %list by one.
863
+ *
864
+ * Due to the nature of a %list this operation can be done in constant
865
+ * time, and only invalidates iterators/references to the element being
866
+ * removed.
867
+ * The user is also cautioned that
868
+ * this function only erases the element, and that if the element is itself
869
+ * a pointer, the pointed-to memory is not touched in any way. Managing
870
+ * the pointer is the user's responsibilty.
871
+ */
872
+ iterator
873
+ erase(iterator __position);
874
+
875
+ /**
876
+ * @brief Remove a range of elements.
877
+ * @param first Iterator pointing to the first element to be erased.
878
+ * @param last Iterator pointing to one past the last element to be
879
+ * erased.
880
+ * @return An iterator pointing to the element pointed to by @a last
881
+ * prior to erasing (or end()).
882
+ *
883
+ * This function will erase the elements in the range [first,last) and
884
+ * shorten the %list accordingly.
885
+ *
886
+ * Due to the nature of a %list this operation can be done in constant
887
+ * time, and only invalidates iterators/references to the element being
888
+ * removed.
889
+ * The user is also cautioned that
890
+ * this function only erases the elements, and that if the elements
891
+ * themselves are pointers, the pointed-to memory is not touched in any
892
+ * way. Managing the pointer is the user's responsibilty.
893
+ */
894
+ iterator
895
+ erase(iterator __first, iterator __last)
896
+ {
897
+ while (__first != __last)
898
+ erase(__first++);
899
+ return __last;
900
+ }
901
+
902
+ /**
903
+ * @brief Swaps data with another %list.
904
+ * @param x A %list of the same element and allocator types.
905
+ *
906
+ * This exchanges the elements between two lists in constant time.
907
+ * (It is only swapping a single pointer, so it should be quite fast.)
908
+ * Note that the global std::swap() function is specialized such that
909
+ * std::swap(l1,l2) will feed to this function.
910
+ */
911
+ void
912
+ swap(list& __x) { std::swap(_M_node, __x._M_node); }
913
+
914
+ /**
915
+ * Erases all the elements. Note that this function only erases the
916
+ * elements, and that if the elements themselves are pointers, the
917
+ * pointed-to memory is not touched in any way. Managing the pointer is
918
+ * the user's responsibilty.
919
+ */
920
+ void
921
+ clear() { _Base::__clear(); }
922
+
923
+ // [23.2.2.4] list operations
924
+ /**
925
+ * @doctodo
926
+ */
927
+ void
928
+ splice(iterator __position, list& __x)
929
+ {
930
+ if (!__x.empty())
931
+ this->_M_transfer(__position, __x.begin(), __x.end());
932
+ }
933
+
934
+ /**
935
+ * @doctodo
936
+ */
937
+ void
938
+ splice(iterator __position, list&, iterator __i)
939
+ {
940
+ iterator __j = __i;
941
+ ++__j;
942
+ if (__position == __i || __position == __j) return;
943
+ this->_M_transfer(__position, __i, __j);
944
+ }
945
+
946
+ /**
947
+ * @doctodo
948
+ */
949
+ void
950
+ splice(iterator __position, list&, iterator __first, iterator __last)
951
+ {
952
+ if (__first != __last)
953
+ this->_M_transfer(__position, __first, __last);
954
+ }
955
+
956
+ /**
957
+ * @doctodo
958
+ */
959
+ void
960
+ remove(const _Tp& __value);
961
+
962
+ /**
963
+ * @doctodo
964
+ */
965
+ template<typename _Predicate>
966
+ void
967
+ remove_if(_Predicate);
968
+
969
+ /**
970
+ * @doctodo
971
+ */
972
+ void
973
+ unique();
974
+
975
+ /**
976
+ * @doctodo
977
+ */
978
+ template<typename _BinaryPredicate>
979
+ void
980
+ unique(_BinaryPredicate);
981
+
982
+ /**
983
+ * @doctodo
984
+ */
985
+ void
986
+ merge(list& __x);
987
+
988
+ /**
989
+ * @doctodo
990
+ */
991
+ template<typename _StrictWeakOrdering>
992
+ void
993
+ merge(list&, _StrictWeakOrdering);
994
+
995
+ /**
996
+ * @doctodo
997
+ */
998
+ void
999
+ reverse() { __List_base_reverse(this->_M_node); }
1000
+
1001
+ /**
1002
+ * @doctodo
1003
+ */
1004
+ void
1005
+ sort();
1006
+
1007
+ /**
1008
+ * @doctodo
1009
+ */
1010
+ template<typename _StrictWeakOrdering>
1011
+ void
1012
+ sort(_StrictWeakOrdering);
1013
+
1014
+ protected:
1015
+ // Internal assign functions follow.
1016
+
1017
+ // called by the range assign to implement [23.1.1]/9
1018
+ template<typename _Integer>
1019
+ void
1020
+ _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1021
+ {
1022
+ _M_fill_assign(static_cast<size_type>(__n),
1023
+ static_cast<value_type>(__val));
1024
+ }
1025
+
1026
+ // called by the range assign to implement [23.1.1]/9
1027
+ template<typename _InputIter>
1028
+ void
1029
+ _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type);
1030
+
1031
+ // Called by assign(n,t), and the range assign when it turns out to be the
1032
+ // same thing.
1033
+ void
1034
+ _M_fill_assign(size_type __n, const value_type& __val);
1035
+
1036
+
1037
+ // Internal insert functions follow.
1038
+
1039
+ // called by the range insert to implement [23.1.1]/9
1040
+ template<typename _Integer>
1041
+ void
1042
+ _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1043
+ __true_type)
1044
+ {
1045
+ _M_fill_insert(__pos, static_cast<size_type>(__n),
1046
+ static_cast<value_type>(__x));
1047
+ }
1048
+
1049
+ // called by the range insert to implement [23.1.1]/9
1050
+ template<typename _InputIterator>
1051
+ void
1052
+ _M_insert_dispatch(iterator __pos,
1053
+ _InputIterator __first, _InputIterator __last,
1054
+ __false_type)
1055
+ {
1056
+ for ( ; __first != __last; ++__first)
1057
+ insert(__pos, *__first);
1058
+ }
1059
+
1060
+ // Called by insert(p,n,x), and the range insert when it turns out to be
1061
+ // the same thing.
1062
+ void
1063
+ _M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
1064
+ {
1065
+ for ( ; __n > 0; --__n)
1066
+ insert(__pos, __x);
1067
+ }
1068
+
1069
+
1070
+ // Moves the elements from [first,last) before position.
1071
+ void
1072
+ _M_transfer(iterator __position, iterator __first, iterator __last)
1073
+ {
1074
+ if (__position != __last) {
1075
+ // Remove [first, last) from its old position.
1076
+ __last._M_node->_M_prev->_M_next = __position._M_node;
1077
+ __first._M_node->_M_prev->_M_next = __last._M_node;
1078
+ __position._M_node->_M_prev->_M_next = __first._M_node;
1079
+
1080
+ // Splice [first, last) into its new position.
1081
+ _List_node_base* __tmp = __position._M_node->_M_prev;
1082
+ __position._M_node->_M_prev = __last._M_node->_M_prev;
1083
+ __last._M_node->_M_prev = __first._M_node->_M_prev;
1084
+ __first._M_node->_M_prev = __tmp;
1085
+ }
1086
+ }
1087
+ };
1088
+
1089
+
1090
+ /**
1091
+ * @brief List equality comparison.
1092
+ * @param x A %list.
1093
+ * @param y A %list of the same type as @a x.
1094
+ * @return True iff the size and elements of the lists are equal.
1095
+ *
1096
+ * This is an equivalence relation. It is linear in the size of the
1097
+ * lists. Lists are considered equivalent if their sizes are equal,
1098
+ * and if corresponding elements compare equal.
1099
+ */
1100
+ template<typename _Tp, typename _Alloc>
1101
+ inline bool
1102
+ operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
1103
+ {
1104
+ typedef typename list<_Tp,_Alloc>::const_iterator const_iterator;
1105
+ const_iterator __end1 = __x.end();
1106
+ const_iterator __end2 = __y.end();
1107
+
1108
+ const_iterator __i1 = __x.begin();
1109
+ const_iterator __i2 = __y.begin();
1110
+ while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
1111
+ ++__i1;
1112
+ ++__i2;
1113
+ }
1114
+ return __i1 == __end1 && __i2 == __end2;
1115
+ }
1116
+
1117
+ /**
1118
+ * @brief List ordering relation.
1119
+ * @param x A %list.
1120
+ * @param y A %list of the same type as @a x.
1121
+ * @return True iff @a x is lexographically less than @a y.
1122
+ *
1123
+ * This is a total ordering relation. It is linear in the size of the
1124
+ * lists. The elements must be comparable with @c <.
1125
+ *
1126
+ * See std::lexographical_compare() for how the determination is made.
1127
+ */
1128
+ template<typename _Tp, typename _Alloc>
1129
+ inline bool
1130
+ operator<(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
1131
+ {
1132
+ return lexicographical_compare(__x.begin(), __x.end(),
1133
+ __y.begin(), __y.end());
1134
+ }
1135
+
1136
+ /// Based on operator==
1137
+ template<typename _Tp, typename _Alloc>
1138
+ inline bool
1139
+ operator!=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
1140
+ { return !(__x == __y); }
1141
+
1142
+ /// Based on operator<
1143
+ template<typename _Tp, typename _Alloc>
1144
+ inline bool
1145
+ operator>(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
1146
+ { return __y < __x; }
1147
+
1148
+ /// Based on operator<
1149
+ template<typename _Tp, typename _Alloc>
1150
+ inline bool
1151
+ operator<=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
1152
+ { return !(__y < __x); }
1153
+
1154
+ /// Based on operator<
1155
+ template<typename _Tp, typename _Alloc>
1156
+ inline bool
1157
+ operator>=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
1158
+ { return !(__x < __y); }
1159
+
1160
+ /// See std::list::swap().
1161
+ template<typename _Tp, typename _Alloc>
1162
+ inline void
1163
+ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
1164
+ { __x.swap(__y); }
1165
+ } // namespace std
1166
+
1167
+ #endif /* __GLIBCPP_INTERNAL_LIST_H */