paredeyes commited on
Commit
57e71e9
·
verified ·
1 Parent(s): 35c2896

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +7 -0
  2. ffmpeg/bin/avutil-59.dll +3 -0
  3. mingw/bin/dlltool.exe +3 -0
  4. mingw/bin/gprof.exe +3 -0
  5. mingw/bin/ld.bfd.exe +3 -0
  6. mingw/bin/ld.exe +3 -0
  7. mingw/bin/objcopy.exe +3 -0
  8. mingw/bin/objdump.exe +3 -0
  9. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/locale_classes.h +817 -0
  10. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/localefwd.h +188 -0
  11. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_iterator_base_types.h +172 -0
  12. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_list.h +1463 -0
  13. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_map.h +827 -0
  14. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_move.h +92 -0
  15. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_multimap.h +757 -0
  16. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_multiset.h +654 -0
  17. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_numeric.h +341 -0
  18. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_pair.h +264 -0
  19. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_queue.h +584 -0
  20. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_raw_storage_iter.h +111 -0
  21. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_relops.h +136 -0
  22. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_set.h +665 -0
  23. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_stack.h +302 -0
  24. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_tempbuf.h +211 -0
  25. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_tree.h +1466 -0
  26. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_uninitialized.h +436 -0
  27. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_vector.h +1174 -0
  28. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stream_iterator.h +216 -0
  29. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/streambuf.tcc +179 -0
  30. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/streambuf_iterator.h +397 -0
  31. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stringfwd.h +70 -0
  32. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_after.h +554 -0
  33. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_array.h +704 -0
  34. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_array.tcc +246 -0
  35. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_before.h +735 -0
  36. mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/vector.tcc +656 -0
  37. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/bitset +328 -0
  38. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/debug.h +159 -0
  39. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/deque +484 -0
  40. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/formatter.h +397 -0
  41. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/functions.h +388 -0
  42. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/list +640 -0
  43. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/macros.h +251 -0
  44. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/map +42 -0
  45. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/map.h +398 -0
  46. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/multimap.h +386 -0
  47. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/multiset.h +382 -0
  48. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/safe_association.h +210 -0
  49. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/safe_base.h +225 -0
  50. mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/safe_iterator.h +648 -0
.gitattributes CHANGED
@@ -65,3 +65,10 @@ cmake/bin/cpack.exe filter=lfs diff=lfs merge=lfs -text
65
  cmake/bin/cmake.exe filter=lfs diff=lfs merge=lfs -text
66
  mingw/bin/as.exe filter=lfs diff=lfs merge=lfs -text
67
  ffmpeg/bin/ffplay.exe filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
65
  cmake/bin/cmake.exe filter=lfs diff=lfs merge=lfs -text
66
  mingw/bin/as.exe filter=lfs diff=lfs merge=lfs -text
67
  ffmpeg/bin/ffplay.exe filter=lfs diff=lfs merge=lfs -text
68
+ mingw/bin/dlltool.exe filter=lfs diff=lfs merge=lfs -text
69
+ mingw/bin/ld.exe filter=lfs diff=lfs merge=lfs -text
70
+ ffmpeg/bin/avutil-59.dll filter=lfs diff=lfs merge=lfs -text
71
+ mingw/bin/objdump.exe filter=lfs diff=lfs merge=lfs -text
72
+ mingw/bin/objcopy.exe filter=lfs diff=lfs merge=lfs -text
73
+ mingw/bin/ld.bfd.exe filter=lfs diff=lfs merge=lfs -text
74
+ mingw/bin/gprof.exe filter=lfs diff=lfs merge=lfs -text
ffmpeg/bin/avutil-59.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b050cd184509d22930a5d1b6271f0946910c00a3fa3501bf1e5cbc70efc17a25
3
+ size 2827776
mingw/bin/dlltool.exe ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1bd1f89d0210f2b86651828ef5a57e96dbacad40570c47b467dcd94995416a1f
3
+ size 1024526
mingw/bin/gprof.exe ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b46756dbd490fdc9ab2a1cb135abada52e862899e7d1781b6f0bd0b76f2694c
3
+ size 1024014
mingw/bin/ld.bfd.exe ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea56b98c634216a145010b57353dc1c14126e34ff83c074ee51b5b3171f20394
3
+ size 1291278
mingw/bin/ld.exe ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea56b98c634216a145010b57353dc1c14126e34ff83c074ee51b5b3171f20394
3
+ size 1291278
mingw/bin/objcopy.exe ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a52a7cc95582bf0a324d4302c027e7917e438eb3b25f2a420a0a74ae9a90349
3
+ size 1160718
mingw/bin/objdump.exe ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef8606b46ccdafff45f4f06d39f8283c215f2597b67558527f9d1e02a5479555
3
+ size 1756174
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/locale_classes.h ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Locale support -*- C++ -*-
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4
+ // 2006, 2007, 2008
5
+ // Free Software Foundation, Inc.
6
+ //
7
+ // This file is part of the GNU ISO C++ Library. This library is free
8
+ // software; you can redistribute it and/or modify it under the
9
+ // terms of the GNU General Public License as published by the
10
+ // Free Software Foundation; either version 2, or (at your option)
11
+ // any later version.
12
+
13
+ // This library is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License along
19
+ // with this library; see the file COPYING. If not, write to the Free
20
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21
+ // USA.
22
+
23
+ // As a special exception, you may use this file as part of a free software
24
+ // library without restriction. Specifically, if other files instantiate
25
+ // templates or use macros or inline functions from this file, or you compile
26
+ // this file and link it with other files to produce an executable, this
27
+ // file does not by itself cause the resulting executable to be covered by
28
+ // the GNU General Public License. This exception does not however
29
+ // invalidate any other reasons why the executable file might be covered by
30
+ // the GNU General Public License.
31
+
32
+ /** @file locale_classes.h
33
+ * This is an internal header file, included by other library headers.
34
+ * You should not attempt to use it directly.
35
+ */
36
+
37
+ //
38
+ // ISO C++ 14882: 22.1 Locales
39
+ //
40
+
41
+ #ifndef _LOCALE_CLASSES_H
42
+ #define _LOCALE_CLASSES_H 1
43
+
44
+ #pragma GCC system_header
45
+
46
+ #include <bits/localefwd.h>
47
+ #include <string>
48
+ #include <ext/atomicity.h>
49
+
50
+ _GLIBCXX_BEGIN_NAMESPACE(std)
51
+
52
+ // 22.1.1 Class locale
53
+ /**
54
+ * @brief Container class for localization functionality.
55
+ *
56
+ * The locale class is first a class wrapper for C library locales. It is
57
+ * also an extensible container for user-defined localization. A locale is
58
+ * a collection of facets that implement various localization features such
59
+ * as money, time, and number printing.
60
+ *
61
+ * Constructing C++ locales does not change the C library locale.
62
+ *
63
+ * This library supports efficient construction and copying of locales
64
+ * through a reference counting implementation of the locale class.
65
+ */
66
+ class locale
67
+ {
68
+ public:
69
+ // Types:
70
+ /// Definition of locale::category.
71
+ typedef int category;
72
+
73
+ // Forward decls and friends:
74
+ class facet;
75
+ class id;
76
+ class _Impl;
77
+
78
+ friend class facet;
79
+ friend class _Impl;
80
+
81
+ template<typename _Facet>
82
+ friend bool
83
+ has_facet(const locale&) throw();
84
+
85
+ template<typename _Facet>
86
+ friend const _Facet&
87
+ use_facet(const locale&);
88
+
89
+ template<typename _Cache>
90
+ friend struct __use_cache;
91
+
92
+ //@{
93
+ /**
94
+ * @brief Category values.
95
+ *
96
+ * The standard category values are none, ctype, numeric, collate, time,
97
+ * monetary, and messages. They form a bitmask that supports union and
98
+ * intersection. The category all is the union of these values.
99
+ *
100
+ * NB: Order must match _S_facet_categories definition in locale.cc
101
+ */
102
+ static const category none = 0;
103
+ static const category ctype = 1L << 0;
104
+ static const category numeric = 1L << 1;
105
+ static const category collate = 1L << 2;
106
+ static const category time = 1L << 3;
107
+ static const category monetary = 1L << 4;
108
+ static const category messages = 1L << 5;
109
+ static const category all = (ctype | numeric | collate |
110
+ time | monetary | messages);
111
+ //@}
112
+
113
+ // Construct/copy/destroy:
114
+
115
+ /**
116
+ * @brief Default constructor.
117
+ *
118
+ * Constructs a copy of the global locale. If no locale has been
119
+ * explicitly set, this is the "C" locale.
120
+ */
121
+ locale() throw();
122
+
123
+ /**
124
+ * @brief Copy constructor.
125
+ *
126
+ * Constructs a copy of @a other.
127
+ *
128
+ * @param other The locale to copy.
129
+ */
130
+ locale(const locale& __other) throw();
131
+
132
+ /**
133
+ * @brief Named locale constructor.
134
+ *
135
+ * Constructs a copy of the named C library locale.
136
+ *
137
+ * @param s Name of the locale to construct.
138
+ * @throw std::runtime_error if s is null or an undefined locale.
139
+ */
140
+ explicit
141
+ locale(const char* __s);
142
+
143
+ /**
144
+ * @brief Construct locale with facets from another locale.
145
+ *
146
+ * Constructs a copy of the locale @a base. The facets specified by @a
147
+ * cat are replaced with those from the locale named by @a s. If base is
148
+ * named, this locale instance will also be named.
149
+ *
150
+ * @param base The locale to copy.
151
+ * @param s Name of the locale to use facets from.
152
+ * @param cat Set of categories defining the facets to use from s.
153
+ * @throw std::runtime_error if s is null or an undefined locale.
154
+ */
155
+ locale(const locale& __base, const char* __s, category __cat);
156
+
157
+ /**
158
+ * @brief Construct locale with facets from another locale.
159
+ *
160
+ * Constructs a copy of the locale @a base. The facets specified by @a
161
+ * cat are replaced with those from the locale @a add. If @a base and @a
162
+ * add are named, this locale instance will also be named.
163
+ *
164
+ * @param base The locale to copy.
165
+ * @param add The locale to use facets from.
166
+ * @param cat Set of categories defining the facets to use from add.
167
+ */
168
+ locale(const locale& __base, const locale& __add, category __cat);
169
+
170
+ /**
171
+ * @brief Construct locale with another facet.
172
+ *
173
+ * Constructs a copy of the locale @a other. The facet @f is added to
174
+ * @other, replacing an existing facet of type Facet if there is one. If
175
+ * @f is null, this locale is a copy of @a other.
176
+ *
177
+ * @param other The locale to copy.
178
+ * @param f The facet to add in.
179
+ */
180
+ template<typename _Facet>
181
+ locale(const locale& __other, _Facet* __f);
182
+
183
+ /// Locale destructor.
184
+ ~locale() throw();
185
+
186
+ /**
187
+ * @brief Assignment operator.
188
+ *
189
+ * Set this locale to be a copy of @a other.
190
+ *
191
+ * @param other The locale to copy.
192
+ * @return A reference to this locale.
193
+ */
194
+ const locale&
195
+ operator=(const locale& __other) throw();
196
+
197
+ /**
198
+ * @brief Construct locale with another facet.
199
+ *
200
+ * Constructs and returns a new copy of this locale. Adds or replaces an
201
+ * existing facet of type Facet from the locale @a other into the new
202
+ * locale.
203
+ *
204
+ * @param Facet The facet type to copy from other
205
+ * @param other The locale to copy from.
206
+ * @return Newly constructed locale.
207
+ * @throw std::runtime_error if other has no facet of type Facet.
208
+ */
209
+ template<typename _Facet>
210
+ locale
211
+ combine(const locale& __other) const;
212
+
213
+ // Locale operations:
214
+ /**
215
+ * @brief Return locale name.
216
+ * @return Locale name or "*" if unnamed.
217
+ */
218
+ string
219
+ name() const;
220
+
221
+ /**
222
+ * @brief Locale equality.
223
+ *
224
+ * @param other The locale to compare against.
225
+ * @return True if other and this refer to the same locale instance, are
226
+ * copies, or have the same name. False otherwise.
227
+ */
228
+ bool
229
+ operator==(const locale& __other) const throw ();
230
+
231
+ /**
232
+ * @brief Locale inequality.
233
+ *
234
+ * @param other The locale to compare against.
235
+ * @return ! (*this == other)
236
+ */
237
+ bool
238
+ operator!=(const locale& __other) const throw ()
239
+ { return !(this->operator==(__other)); }
240
+
241
+ /**
242
+ * @brief Compare two strings according to collate.
243
+ *
244
+ * Template operator to compare two strings using the compare function of
245
+ * the collate facet in this locale. One use is to provide the locale to
246
+ * the sort function. For example, a vector v of strings could be sorted
247
+ * according to locale loc by doing:
248
+ * @code
249
+ * std::sort(v.begin(), v.end(), loc);
250
+ * @endcode
251
+ *
252
+ * @param s1 First string to compare.
253
+ * @param s2 Second string to compare.
254
+ * @return True if collate<Char> facet compares s1 < s2, else false.
255
+ */
256
+ template<typename _Char, typename _Traits, typename _Alloc>
257
+ bool
258
+ operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
259
+ const basic_string<_Char, _Traits, _Alloc>& __s2) const;
260
+
261
+ // Global locale objects:
262
+ /**
263
+ * @brief Set global locale
264
+ *
265
+ * This function sets the global locale to the argument and returns a
266
+ * copy of the previous global locale. If the argument has a name, it
267
+ * will also call std::setlocale(LC_ALL, loc.name()).
268
+ *
269
+ * @param locale The new locale to make global.
270
+ * @return Copy of the old global locale.
271
+ */
272
+ static locale
273
+ global(const locale&);
274
+
275
+ /**
276
+ * @brief Return reference to the "C" locale.
277
+ */
278
+ static const locale&
279
+ classic();
280
+
281
+ private:
282
+ // The (shared) implementation
283
+ _Impl* _M_impl;
284
+
285
+ // The "C" reference locale
286
+ static _Impl* _S_classic;
287
+
288
+ // Current global locale
289
+ static _Impl* _S_global;
290
+
291
+ // Names of underlying locale categories.
292
+ // NB: locale::global() has to know how to modify all the
293
+ // underlying categories, not just the ones required by the C++
294
+ // standard.
295
+ static const char* const* const _S_categories;
296
+
297
+ // Number of standard categories. For C++, these categories are
298
+ // collate, ctype, monetary, numeric, time, and messages. These
299
+ // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
300
+ // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
301
+ // 1003.1-2001) specifies LC_MESSAGES.
302
+ // In addition to the standard categories, the underlying
303
+ // operating system is allowed to define extra LC_*
304
+ // macros. For GNU systems, the following are also valid:
305
+ // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
306
+ // and LC_IDENTIFICATION.
307
+ enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
308
+
309
+ #ifdef __GTHREADS
310
+ static __gthread_once_t _S_once;
311
+ #endif
312
+
313
+ explicit
314
+ locale(_Impl*) throw();
315
+
316
+ static void
317
+ _S_initialize();
318
+
319
+ static void
320
+ _S_initialize_once();
321
+
322
+ static category
323
+ _S_normalize_category(category);
324
+
325
+ void
326
+ _M_coalesce(const locale& __base, const locale& __add, category __cat);
327
+ };
328
+
329
+
330
+ // 22.1.1.1.2 Class locale::facet
331
+ /**
332
+ * @brief Localization functionality base class.
333
+ *
334
+ * The facet class is the base class for a localization feature, such as
335
+ * money, time, and number printing. It provides common support for facets
336
+ * and reference management.
337
+ *
338
+ * Facets may not be copied or assigned.
339
+ */
340
+ class locale::facet
341
+ {
342
+ private:
343
+ friend class locale;
344
+ friend class locale::_Impl;
345
+
346
+ mutable _Atomic_word _M_refcount;
347
+
348
+ // Contains data from the underlying "C" library for the classic locale.
349
+ static __c_locale _S_c_locale;
350
+
351
+ // String literal for the name of the classic locale.
352
+ static const char _S_c_name[2];
353
+
354
+ #ifdef __GTHREADS
355
+ static __gthread_once_t _S_once;
356
+ #endif
357
+
358
+ static void
359
+ _S_initialize_once();
360
+
361
+ protected:
362
+ /**
363
+ * @brief Facet constructor.
364
+ *
365
+ * This is the constructor provided by the standard. If refs is 0, the
366
+ * facet is destroyed when the last referencing locale is destroyed.
367
+ * Otherwise the facet will never be destroyed.
368
+ *
369
+ * @param refs The initial value for reference count.
370
+ */
371
+ explicit
372
+ facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
373
+ { }
374
+
375
+ /// Facet destructor.
376
+ virtual
377
+ ~facet();
378
+
379
+ static void
380
+ _S_create_c_locale(__c_locale& __cloc, const char* __s,
381
+ __c_locale __old = 0);
382
+
383
+ static __c_locale
384
+ _S_clone_c_locale(__c_locale& __cloc);
385
+
386
+ static void
387
+ _S_destroy_c_locale(__c_locale& __cloc);
388
+
389
+ // Returns data from the underlying "C" library data for the
390
+ // classic locale.
391
+ static __c_locale
392
+ _S_get_c_locale();
393
+
394
+ static const char*
395
+ _S_get_c_name();
396
+
397
+ private:
398
+ void
399
+ _M_add_reference() const throw()
400
+ { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
401
+
402
+ void
403
+ _M_remove_reference() const throw()
404
+ {
405
+ if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
406
+ {
407
+ try
408
+ { delete this; }
409
+ catch(...)
410
+ { }
411
+ }
412
+ }
413
+
414
+ facet(const facet&); // Not defined.
415
+
416
+ facet&
417
+ operator=(const facet&); // Not defined.
418
+ };
419
+
420
+
421
+ // 22.1.1.1.3 Class locale::id
422
+ /**
423
+ * @brief Facet ID class.
424
+ *
425
+ * The ID class provides facets with an index used to identify them.
426
+ * Every facet class must define a public static member locale::id, or be
427
+ * derived from a facet that provides this member, otherwise the facet
428
+ * cannot be used in a locale. The locale::id ensures that each class
429
+ * type gets a unique identifier.
430
+ */
431
+ class locale::id
432
+ {
433
+ private:
434
+ friend class locale;
435
+ friend class locale::_Impl;
436
+
437
+ template<typename _Facet>
438
+ friend const _Facet&
439
+ use_facet(const locale&);
440
+
441
+ template<typename _Facet>
442
+ friend bool
443
+ has_facet(const locale&) throw ();
444
+
445
+ // NB: There is no accessor for _M_index because it may be used
446
+ // before the constructor is run; the effect of calling a member
447
+ // function (even an inline) would be undefined.
448
+ mutable size_t _M_index;
449
+
450
+ // Last id number assigned.
451
+ static _Atomic_word _S_refcount;
452
+
453
+ void
454
+ operator=(const id&); // Not defined.
455
+
456
+ id(const id&); // Not defined.
457
+
458
+ public:
459
+ // NB: This class is always a static data member, and thus can be
460
+ // counted on to be zero-initialized.
461
+ /// Constructor.
462
+ id() { }
463
+
464
+ size_t
465
+ _M_id() const;
466
+ };
467
+
468
+
469
+ // Implementation object for locale.
470
+ class locale::_Impl
471
+ {
472
+ public:
473
+ // Friends.
474
+ friend class locale;
475
+ friend class locale::facet;
476
+
477
+ template<typename _Facet>
478
+ friend bool
479
+ has_facet(const locale&) throw();
480
+
481
+ template<typename _Facet>
482
+ friend const _Facet&
483
+ use_facet(const locale&);
484
+
485
+ template<typename _Cache>
486
+ friend struct __use_cache;
487
+
488
+ private:
489
+ // Data Members.
490
+ _Atomic_word _M_refcount;
491
+ const facet** _M_facets;
492
+ size_t _M_facets_size;
493
+ const facet** _M_caches;
494
+ char** _M_names;
495
+ static const locale::id* const _S_id_ctype[];
496
+ static const locale::id* const _S_id_numeric[];
497
+ static const locale::id* const _S_id_collate[];
498
+ static const locale::id* const _S_id_time[];
499
+ static const locale::id* const _S_id_monetary[];
500
+ static const locale::id* const _S_id_messages[];
501
+ static const locale::id* const* const _S_facet_categories[];
502
+
503
+ void
504
+ _M_add_reference() throw()
505
+ { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
506
+
507
+ void
508
+ _M_remove_reference() throw()
509
+ {
510
+ if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
511
+ {
512
+ try
513
+ { delete this; }
514
+ catch(...)
515
+ { }
516
+ }
517
+ }
518
+
519
+ _Impl(const _Impl&, size_t);
520
+ _Impl(const char*, size_t);
521
+ _Impl(size_t) throw();
522
+
523
+ ~_Impl() throw();
524
+
525
+ _Impl(const _Impl&); // Not defined.
526
+
527
+ void
528
+ operator=(const _Impl&); // Not defined.
529
+
530
+ bool
531
+ _M_check_same_name()
532
+ {
533
+ bool __ret = true;
534
+ if (_M_names[1])
535
+ // We must actually compare all the _M_names: can be all equal!
536
+ for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
537
+ __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
538
+ return __ret;
539
+ }
540
+
541
+ void
542
+ _M_replace_categories(const _Impl*, category);
543
+
544
+ void
545
+ _M_replace_category(const _Impl*, const locale::id* const*);
546
+
547
+ void
548
+ _M_replace_facet(const _Impl*, const locale::id*);
549
+
550
+ void
551
+ _M_install_facet(const locale::id*, const facet*);
552
+
553
+ template<typename _Facet>
554
+ void
555
+ _M_init_facet(_Facet* __facet)
556
+ { _M_install_facet(&_Facet::id, __facet); }
557
+
558
+ void
559
+ _M_install_cache(const facet*, size_t);
560
+ };
561
+
562
+
563
+ /**
564
+ * @brief Test for the presence of a facet.
565
+ *
566
+ * has_facet tests the locale argument for the presence of the facet type
567
+ * provided as the template parameter. Facets derived from the facet
568
+ * parameter will also return true.
569
+ *
570
+ * @param Facet The facet type to test the presence of.
571
+ * @param locale The locale to test.
572
+ * @return true if locale contains a facet of type Facet, else false.
573
+ */
574
+ template<typename _Facet>
575
+ bool
576
+ has_facet(const locale& __loc) throw();
577
+
578
+ /**
579
+ * @brief Return a facet.
580
+ *
581
+ * use_facet looks for and returns a reference to a facet of type Facet
582
+ * where Facet is the template parameter. If has_facet(locale) is true,
583
+ * there is a suitable facet to return. It throws std::bad_cast if the
584
+ * locale doesn't contain a facet of type Facet.
585
+ *
586
+ * @param Facet The facet type to access.
587
+ * @param locale The locale to use.
588
+ * @return Reference to facet of type Facet.
589
+ * @throw std::bad_cast if locale doesn't contain a facet of type Facet.
590
+ */
591
+ template<typename _Facet>
592
+ const _Facet&
593
+ use_facet(const locale& __loc);
594
+
595
+
596
+ /**
597
+ * @brief Facet for localized string comparison.
598
+ *
599
+ * This facet encapsulates the code to compare strings in a localized
600
+ * manner.
601
+ *
602
+ * The collate template uses protected virtual functions to provide
603
+ * the actual results. The public accessors forward the call to
604
+ * the virtual functions. These virtual functions are hooks for
605
+ * developers to implement the behavior they require from the
606
+ * collate facet.
607
+ */
608
+ template<typename _CharT>
609
+ class collate : public locale::facet
610
+ {
611
+ public:
612
+ // Types:
613
+ //@{
614
+ /// Public typedefs
615
+ typedef _CharT char_type;
616
+ typedef basic_string<_CharT> string_type;
617
+ //@}
618
+
619
+ protected:
620
+ // Underlying "C" library locale information saved from
621
+ // initialization, needed by collate_byname as well.
622
+ __c_locale _M_c_locale_collate;
623
+
624
+ public:
625
+ /// Numpunct facet id.
626
+ static locale::id id;
627
+
628
+ /**
629
+ * @brief Constructor performs initialization.
630
+ *
631
+ * This is the constructor provided by the standard.
632
+ *
633
+ * @param refs Passed to the base facet class.
634
+ */
635
+ explicit
636
+ collate(size_t __refs = 0)
637
+ : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
638
+ { }
639
+
640
+ /**
641
+ * @brief Internal constructor. Not for general use.
642
+ *
643
+ * This is a constructor for use by the library itself to set up new
644
+ * locales.
645
+ *
646
+ * @param cloc The "C" locale.
647
+ * @param refs Passed to the base facet class.
648
+ */
649
+ explicit
650
+ collate(__c_locale __cloc, size_t __refs = 0)
651
+ : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
652
+ { }
653
+
654
+ /**
655
+ * @brief Compare two strings.
656
+ *
657
+ * This function compares two strings and returns the result by calling
658
+ * collate::do_compare().
659
+ *
660
+ * @param lo1 Start of string 1.
661
+ * @param hi1 End of string 1.
662
+ * @param lo2 Start of string 2.
663
+ * @param hi2 End of string 2.
664
+ * @return 1 if string1 > string2, -1 if string1 < string2, else 0.
665
+ */
666
+ int
667
+ compare(const _CharT* __lo1, const _CharT* __hi1,
668
+ const _CharT* __lo2, const _CharT* __hi2) const
669
+ { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
670
+
671
+ /**
672
+ * @brief Transform string to comparable form.
673
+ *
674
+ * This function is a wrapper for strxfrm functionality. It takes the
675
+ * input string and returns a modified string that can be directly
676
+ * compared to other transformed strings. In the "C" locale, this
677
+ * function just returns a copy of the input string. In some other
678
+ * locales, it may replace two chars with one, change a char for
679
+ * another, etc. It does so by returning collate::do_transform().
680
+ *
681
+ * @param lo Start of string.
682
+ * @param hi End of string.
683
+ * @return Transformed string_type.
684
+ */
685
+ string_type
686
+ transform(const _CharT* __lo, const _CharT* __hi) const
687
+ { return this->do_transform(__lo, __hi); }
688
+
689
+ /**
690
+ * @brief Return hash of a string.
691
+ *
692
+ * This function computes and returns a hash on the input string. It
693
+ * does so by returning collate::do_hash().
694
+ *
695
+ * @param lo Start of string.
696
+ * @param hi End of string.
697
+ * @return Hash value.
698
+ */
699
+ long
700
+ hash(const _CharT* __lo, const _CharT* __hi) const
701
+ { return this->do_hash(__lo, __hi); }
702
+
703
+ // Used to abstract out _CharT bits in virtual member functions, below.
704
+ int
705
+ _M_compare(const _CharT*, const _CharT*) const;
706
+
707
+ size_t
708
+ _M_transform(_CharT*, const _CharT*, size_t) const;
709
+
710
+ protected:
711
+ /// Destructor.
712
+ virtual
713
+ ~collate()
714
+ { _S_destroy_c_locale(_M_c_locale_collate); }
715
+
716
+ /**
717
+ * @brief Compare two strings.
718
+ *
719
+ * This function is a hook for derived classes to change the value
720
+ * returned. @see compare().
721
+ *
722
+ * @param lo1 Start of string 1.
723
+ * @param hi1 End of string 1.
724
+ * @param lo2 Start of string 2.
725
+ * @param hi2 End of string 2.
726
+ * @return 1 if string1 > string2, -1 if string1 < string2, else 0.
727
+ */
728
+ virtual int
729
+ do_compare(const _CharT* __lo1, const _CharT* __hi1,
730
+ const _CharT* __lo2, const _CharT* __hi2) const;
731
+
732
+ /**
733
+ * @brief Transform string to comparable form.
734
+ *
735
+ * This function is a hook for derived classes to change the value
736
+ * returned.
737
+ *
738
+ * @param lo1 Start of string 1.
739
+ * @param hi1 End of string 1.
740
+ * @param lo2 Start of string 2.
741
+ * @param hi2 End of string 2.
742
+ * @return 1 if string1 > string2, -1 if string1 < string2, else 0.
743
+ */
744
+ virtual string_type
745
+ do_transform(const _CharT* __lo, const _CharT* __hi) const;
746
+
747
+ /**
748
+ * @brief Return hash of a string.
749
+ *
750
+ * This function computes and returns a hash on the input string. This
751
+ * function is a hook for derived classes to change the value returned.
752
+ *
753
+ * @param lo Start of string.
754
+ * @param hi End of string.
755
+ * @return Hash value.
756
+ */
757
+ virtual long
758
+ do_hash(const _CharT* __lo, const _CharT* __hi) const;
759
+ };
760
+
761
+ template<typename _CharT>
762
+ locale::id collate<_CharT>::id;
763
+
764
+ // Specializations.
765
+ template<>
766
+ int
767
+ collate<char>::_M_compare(const char*, const char*) const;
768
+
769
+ template<>
770
+ size_t
771
+ collate<char>::_M_transform(char*, const char*, size_t) const;
772
+
773
+ #ifdef _GLIBCXX_USE_WCHAR_T
774
+ template<>
775
+ int
776
+ collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
777
+
778
+ template<>
779
+ size_t
780
+ collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
781
+ #endif
782
+
783
+ /// class collate_byname [22.2.4.2].
784
+ template<typename _CharT>
785
+ class collate_byname : public collate<_CharT>
786
+ {
787
+ public:
788
+ //@{
789
+ /// Public typedefs
790
+ typedef _CharT char_type;
791
+ typedef basic_string<_CharT> string_type;
792
+ //@}
793
+
794
+ explicit
795
+ collate_byname(const char* __s, size_t __refs = 0)
796
+ : collate<_CharT>(__refs)
797
+ {
798
+ if (__builtin_strcmp(__s, "C") != 0
799
+ && __builtin_strcmp(__s, "POSIX") != 0)
800
+ {
801
+ this->_S_destroy_c_locale(this->_M_c_locale_collate);
802
+ this->_S_create_c_locale(this->_M_c_locale_collate, __s);
803
+ }
804
+ }
805
+
806
+ protected:
807
+ virtual
808
+ ~collate_byname() { }
809
+ };
810
+
811
+ _GLIBCXX_END_NAMESPACE
812
+
813
+ #ifndef _GLIBCXX_EXPORT_TEMPLATE
814
+ # include <bits/locale_classes.tcc>
815
+ #endif
816
+
817
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/localefwd.h ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Locale support -*- C++ -*-
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4
+ // 2006, 2007
5
+ // Free Software Foundation, Inc.
6
+ //
7
+ // This file is part of the GNU ISO C++ Library. This library is free
8
+ // software; you can redistribute it and/or modify it under the
9
+ // terms of the GNU General Public License as published by the
10
+ // Free Software Foundation; either version 2, or (at your option)
11
+ // any later version.
12
+
13
+ // This library is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License along
19
+ // with this library; see the file COPYING. If not, write to the Free
20
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21
+ // USA.
22
+
23
+ // As a special exception, you may use this file as part of a free software
24
+ // library without restriction. Specifically, if other files instantiate
25
+ // templates or use macros or inline functions from this file, or you compile
26
+ // this file and link it with other files to produce an executable, this
27
+ // file does not by itself cause the resulting executable to be covered by
28
+ // the GNU General Public License. This exception does not however
29
+ // invalidate any other reasons why the executable file might be covered by
30
+ // the GNU General Public License.
31
+
32
+ /** @file localefwd.h
33
+ * This is an internal header file, included by other library headers.
34
+ * You should not attempt to use it directly.
35
+ */
36
+
37
+ //
38
+ // ISO C++ 14882: 22.1 Locales
39
+ //
40
+
41
+ #ifndef _LOCALE_FWD_H
42
+ #define _LOCALE_FWD_H 1
43
+
44
+ #pragma GCC system_header
45
+
46
+ #include <bits/c++config.h>
47
+ #include <bits/c++locale.h> // Defines __c_locale, config-specific include
48
+ #include <iosfwd> // For ostreambuf_iterator, istreambuf_iterator
49
+ #include <cctype>
50
+
51
+ _GLIBCXX_BEGIN_NAMESPACE(std)
52
+
53
+ // 22.1.1 Locale
54
+ class locale;
55
+
56
+ template<typename _Facet>
57
+ bool
58
+ has_facet(const locale&) throw();
59
+
60
+ template<typename _Facet>
61
+ const _Facet&
62
+ use_facet(const locale&);
63
+
64
+ // 22.1.3 Convenience interfaces
65
+ template<typename _CharT>
66
+ bool
67
+ isspace(_CharT, const locale&);
68
+
69
+ template<typename _CharT>
70
+ bool
71
+ isprint(_CharT, const locale&);
72
+
73
+ template<typename _CharT>
74
+ bool
75
+ iscntrl(_CharT, const locale&);
76
+
77
+ template<typename _CharT>
78
+ bool
79
+ isupper(_CharT, const locale&);
80
+
81
+ template<typename _CharT>
82
+ bool
83
+ islower(_CharT, const locale&);
84
+
85
+ template<typename _CharT>
86
+ bool
87
+ isalpha(_CharT, const locale&);
88
+
89
+ template<typename _CharT>
90
+ bool
91
+ isdigit(_CharT, const locale&);
92
+
93
+ template<typename _CharT>
94
+ bool
95
+ ispunct(_CharT, const locale&);
96
+
97
+ template<typename _CharT>
98
+ bool
99
+ isxdigit(_CharT, const locale&);
100
+
101
+ template<typename _CharT>
102
+ bool
103
+ isalnum(_CharT, const locale&);
104
+
105
+ template<typename _CharT>
106
+ bool
107
+ isgraph(_CharT, const locale&);
108
+
109
+ template<typename _CharT>
110
+ _CharT
111
+ toupper(_CharT, const locale&);
112
+
113
+ template<typename _CharT>
114
+ _CharT
115
+ tolower(_CharT, const locale&);
116
+
117
+ // 22.2.1 and 22.2.1.3 ctype
118
+ class ctype_base;
119
+ template<typename _CharT>
120
+ class ctype;
121
+ template<> class ctype<char>;
122
+ #ifdef _GLIBCXX_USE_WCHAR_T
123
+ template<> class ctype<wchar_t>;
124
+ #endif
125
+ template<typename _CharT>
126
+ class ctype_byname;
127
+ // NB: Specialized for char and wchar_t in locale_facets.h.
128
+
129
+ class codecvt_base;
130
+ template<typename _InternT, typename _ExternT, typename _StateT>
131
+ class codecvt;
132
+ template<> class codecvt<char, char, mbstate_t>;
133
+ #ifdef _GLIBCXX_USE_WCHAR_T
134
+ template<> class codecvt<wchar_t, char, mbstate_t>;
135
+ #endif
136
+ template<typename _InternT, typename _ExternT, typename _StateT>
137
+ class codecvt_byname;
138
+
139
+ // 22.2.2 and 22.2.3 numeric
140
+ _GLIBCXX_BEGIN_LDBL_NAMESPACE
141
+ template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
142
+ class num_get;
143
+ template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
144
+ class num_put;
145
+ _GLIBCXX_END_LDBL_NAMESPACE
146
+ template<typename _CharT> class numpunct;
147
+ template<typename _CharT> class numpunct_byname;
148
+
149
+ // 22.2.4 collation
150
+ template<typename _CharT>
151
+ class collate;
152
+ template<typename _CharT> class
153
+ collate_byname;
154
+
155
+ // 22.2.5 date and time
156
+ class time_base;
157
+ template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
158
+ class time_get;
159
+ template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
160
+ class time_get_byname;
161
+ template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
162
+ class time_put;
163
+ template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
164
+ class time_put_byname;
165
+
166
+ // 22.2.6 money
167
+ class money_base;
168
+ _GLIBCXX_BEGIN_LDBL_NAMESPACE
169
+ template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
170
+ class money_get;
171
+ template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
172
+ class money_put;
173
+ _GLIBCXX_END_LDBL_NAMESPACE
174
+ template<typename _CharT, bool _Intl = false>
175
+ class moneypunct;
176
+ template<typename _CharT, bool _Intl = false>
177
+ class moneypunct_byname;
178
+
179
+ // 22.2.7 message retrieval
180
+ class messages_base;
181
+ template<typename _CharT>
182
+ class messages;
183
+ template<typename _CharT>
184
+ class messages_byname;
185
+
186
+ _GLIBCXX_END_NAMESPACE
187
+
188
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_iterator_base_types.h ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Types used in iterator implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996-1998
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_iterator_base_types.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ *
61
+ * This file contains all of the general iterator-related utility types,
62
+ * such as iterator_traits and struct iterator.
63
+ */
64
+
65
+ #ifndef _STL_ITERATOR_BASE_TYPES_H
66
+ #define _STL_ITERATOR_BASE_TYPES_H 1
67
+
68
+ #pragma GCC system_header
69
+
70
+ #include <bits/c++config.h>
71
+ #include <cstddef>
72
+
73
+ _GLIBCXX_BEGIN_NAMESPACE(std)
74
+
75
+ //@{
76
+ /**
77
+ * @defgroup iterator_tags Iterator Tags
78
+ * These are empty types, used to distinguish different iterators. The
79
+ * distinction is not made by what they contain, but simply by what they
80
+ * are. Different underlying algorithms can then be used based on the
81
+ * different operations supported by different iterator types.
82
+ */
83
+ /// Marking input iterators.
84
+ struct input_iterator_tag {};
85
+ /// Marking output iterators.
86
+ struct output_iterator_tag {};
87
+ /// Forward iterators support a superset of input iterator operations.
88
+ struct forward_iterator_tag : public input_iterator_tag {};
89
+ /// Bidirectional iterators support a superset of forward iterator
90
+ /// operations.
91
+ struct bidirectional_iterator_tag : public forward_iterator_tag {};
92
+ /// Random-access iterators support a superset of bidirectional iterator
93
+ /// operations.
94
+ struct random_access_iterator_tag : public bidirectional_iterator_tag {};
95
+ //@}
96
+
97
+
98
+ /**
99
+ * @brief Common %iterator class.
100
+ *
101
+ * This class does nothing but define nested typedefs. %Iterator classes
102
+ * can inherit from this class to save some work. The typedefs are then
103
+ * used in specializations and overloading.
104
+ *
105
+ * In particular, there are no default implementations of requirements
106
+ * such as @c operator++ and the like. (How could there be?)
107
+ */
108
+ template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
109
+ typename _Pointer = _Tp*, typename _Reference = _Tp&>
110
+ struct iterator
111
+ {
112
+ /// One of the @link iterator_tags tag types@endlink.
113
+ typedef _Category iterator_category;
114
+ /// The type "pointed to" by the iterator.
115
+ typedef _Tp value_type;
116
+ /// Distance between iterators is represented as this type.
117
+ typedef _Distance difference_type;
118
+ /// This type represents a pointer-to-value_type.
119
+ typedef _Pointer pointer;
120
+ /// This type represents a reference-to-value_type.
121
+ typedef _Reference reference;
122
+ };
123
+
124
+ /**
125
+ * This class does nothing but define nested typedefs. The general
126
+ * version simply "forwards" the nested typedefs from the Iterator
127
+ * argument. Specialized versions for pointers and pointers-to-const
128
+ * provide tighter, more correct semantics.
129
+ */
130
+ template<typename _Iterator>
131
+ struct iterator_traits
132
+ {
133
+ typedef typename _Iterator::iterator_category iterator_category;
134
+ typedef typename _Iterator::value_type value_type;
135
+ typedef typename _Iterator::difference_type difference_type;
136
+ typedef typename _Iterator::pointer pointer;
137
+ typedef typename _Iterator::reference reference;
138
+ };
139
+
140
+ template<typename _Tp>
141
+ struct iterator_traits<_Tp*>
142
+ {
143
+ typedef random_access_iterator_tag iterator_category;
144
+ typedef _Tp value_type;
145
+ typedef ptrdiff_t difference_type;
146
+ typedef _Tp* pointer;
147
+ typedef _Tp& reference;
148
+ };
149
+
150
+ template<typename _Tp>
151
+ struct iterator_traits<const _Tp*>
152
+ {
153
+ typedef random_access_iterator_tag iterator_category;
154
+ typedef _Tp value_type;
155
+ typedef ptrdiff_t difference_type;
156
+ typedef const _Tp* pointer;
157
+ typedef const _Tp& reference;
158
+ };
159
+
160
+ /**
161
+ * This function is not a part of the C++ standard but is syntactic
162
+ * sugar for internal library use only.
163
+ */
164
+ template<typename _Iter>
165
+ inline typename iterator_traits<_Iter>::iterator_category
166
+ __iterator_category(const _Iter&)
167
+ { return typename iterator_traits<_Iter>::iterator_category(); }
168
+
169
+ _GLIBCXX_END_NAMESPACE
170
+
171
+ #endif /* _STL_ITERATOR_BASE_TYPES_H */
172
+
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_list.h ADDED
@@ -0,0 +1,1463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // List implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_list.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_LIST_H
63
+ #define _STL_LIST_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+
67
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
68
+
69
+ // Supporting structures are split into common and templated types; the
70
+ // latter publicly inherits from the former in an effort to reduce code
71
+ // duplication. This results in some "needless" static_cast'ing later on,
72
+ // but it's all safe downcasting.
73
+
74
+ /// Common part of a node in the %list.
75
+ struct _List_node_base
76
+ {
77
+ _List_node_base* _M_next;
78
+ _List_node_base* _M_prev;
79
+
80
+ static void
81
+ swap(_List_node_base& __x, _List_node_base& __y);
82
+
83
+ void
84
+ transfer(_List_node_base * const __first,
85
+ _List_node_base * const __last);
86
+
87
+ void
88
+ reverse();
89
+
90
+ void
91
+ hook(_List_node_base * const __position);
92
+
93
+ void
94
+ unhook();
95
+ };
96
+
97
+ /// An actual node in the %list.
98
+ template<typename _Tp>
99
+ struct _List_node : public _List_node_base
100
+ {
101
+ ///< User's data.
102
+ _Tp _M_data;
103
+ };
104
+
105
+ /**
106
+ * @brief A list::iterator.
107
+ *
108
+ * All the functions are op overloads.
109
+ */
110
+ template<typename _Tp>
111
+ struct _List_iterator
112
+ {
113
+ typedef _List_iterator<_Tp> _Self;
114
+ typedef _List_node<_Tp> _Node;
115
+
116
+ typedef ptrdiff_t difference_type;
117
+ typedef std::bidirectional_iterator_tag iterator_category;
118
+ typedef _Tp value_type;
119
+ typedef _Tp* pointer;
120
+ typedef _Tp& reference;
121
+
122
+ _List_iterator()
123
+ : _M_node() { }
124
+
125
+ explicit
126
+ _List_iterator(_List_node_base* __x)
127
+ : _M_node(__x) { }
128
+
129
+ // Must downcast from List_node_base to _List_node to get to _M_data.
130
+ reference
131
+ operator*() const
132
+ { return static_cast<_Node*>(_M_node)->_M_data; }
133
+
134
+ pointer
135
+ operator->() const
136
+ { return &static_cast<_Node*>(_M_node)->_M_data; }
137
+
138
+ _Self&
139
+ operator++()
140
+ {
141
+ _M_node = _M_node->_M_next;
142
+ return *this;
143
+ }
144
+
145
+ _Self
146
+ operator++(int)
147
+ {
148
+ _Self __tmp = *this;
149
+ _M_node = _M_node->_M_next;
150
+ return __tmp;
151
+ }
152
+
153
+ _Self&
154
+ operator--()
155
+ {
156
+ _M_node = _M_node->_M_prev;
157
+ return *this;
158
+ }
159
+
160
+ _Self
161
+ operator--(int)
162
+ {
163
+ _Self __tmp = *this;
164
+ _M_node = _M_node->_M_prev;
165
+ return __tmp;
166
+ }
167
+
168
+ bool
169
+ operator==(const _Self& __x) const
170
+ { return _M_node == __x._M_node; }
171
+
172
+ bool
173
+ operator!=(const _Self& __x) const
174
+ { return _M_node != __x._M_node; }
175
+
176
+ // The only member points to the %list element.
177
+ _List_node_base* _M_node;
178
+ };
179
+
180
+ /**
181
+ * @brief A list::const_iterator.
182
+ *
183
+ * All the functions are op overloads.
184
+ */
185
+ template<typename _Tp>
186
+ struct _List_const_iterator
187
+ {
188
+ typedef _List_const_iterator<_Tp> _Self;
189
+ typedef const _List_node<_Tp> _Node;
190
+ typedef _List_iterator<_Tp> iterator;
191
+
192
+ typedef ptrdiff_t difference_type;
193
+ typedef std::bidirectional_iterator_tag iterator_category;
194
+ typedef _Tp value_type;
195
+ typedef const _Tp* pointer;
196
+ typedef const _Tp& reference;
197
+
198
+ _List_const_iterator()
199
+ : _M_node() { }
200
+
201
+ explicit
202
+ _List_const_iterator(const _List_node_base* __x)
203
+ : _M_node(__x) { }
204
+
205
+ _List_const_iterator(const iterator& __x)
206
+ : _M_node(__x._M_node) { }
207
+
208
+ // Must downcast from List_node_base to _List_node to get to
209
+ // _M_data.
210
+ reference
211
+ operator*() const
212
+ { return static_cast<_Node*>(_M_node)->_M_data; }
213
+
214
+ pointer
215
+ operator->() const
216
+ { return &static_cast<_Node*>(_M_node)->_M_data; }
217
+
218
+ _Self&
219
+ operator++()
220
+ {
221
+ _M_node = _M_node->_M_next;
222
+ return *this;
223
+ }
224
+
225
+ _Self
226
+ operator++(int)
227
+ {
228
+ _Self __tmp = *this;
229
+ _M_node = _M_node->_M_next;
230
+ return __tmp;
231
+ }
232
+
233
+ _Self&
234
+ operator--()
235
+ {
236
+ _M_node = _M_node->_M_prev;
237
+ return *this;
238
+ }
239
+
240
+ _Self
241
+ operator--(int)
242
+ {
243
+ _Self __tmp = *this;
244
+ _M_node = _M_node->_M_prev;
245
+ return __tmp;
246
+ }
247
+
248
+ bool
249
+ operator==(const _Self& __x) const
250
+ { return _M_node == __x._M_node; }
251
+
252
+ bool
253
+ operator!=(const _Self& __x) const
254
+ { return _M_node != __x._M_node; }
255
+
256
+ // The only member points to the %list element.
257
+ const _List_node_base* _M_node;
258
+ };
259
+
260
+ template<typename _Val>
261
+ inline bool
262
+ operator==(const _List_iterator<_Val>& __x,
263
+ const _List_const_iterator<_Val>& __y)
264
+ { return __x._M_node == __y._M_node; }
265
+
266
+ template<typename _Val>
267
+ inline bool
268
+ operator!=(const _List_iterator<_Val>& __x,
269
+ const _List_const_iterator<_Val>& __y)
270
+ { return __x._M_node != __y._M_node; }
271
+
272
+
273
+ /// See bits/stl_deque.h's _Deque_base for an explanation.
274
+ template<typename _Tp, typename _Alloc>
275
+ class _List_base
276
+ {
277
+ protected:
278
+ // NOTA BENE
279
+ // The stored instance is not actually of "allocator_type"'s
280
+ // type. Instead we rebind the type to
281
+ // Allocator<List_node<Tp>>, which according to [20.1.5]/4
282
+ // should probably be the same. List_node<Tp> is not the same
283
+ // size as Tp (it's two pointers larger), and specializations on
284
+ // Tp may go unused because List_node<Tp> is being bound
285
+ // instead.
286
+ //
287
+ // We put this to the test in the constructors and in
288
+ // get_allocator, where we use conversions between
289
+ // allocator_type and _Node_alloc_type. The conversion is
290
+ // required by table 32 in [20.1.5].
291
+ typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
292
+ _Node_alloc_type;
293
+
294
+ typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
295
+
296
+ struct _List_impl
297
+ : public _Node_alloc_type
298
+ {
299
+ _List_node_base _M_node;
300
+
301
+ _List_impl()
302
+ : _Node_alloc_type(), _M_node()
303
+ { }
304
+
305
+ _List_impl(const _Node_alloc_type& __a)
306
+ : _Node_alloc_type(__a), _M_node()
307
+ { }
308
+ };
309
+
310
+ _List_impl _M_impl;
311
+
312
+ _List_node<_Tp>*
313
+ _M_get_node()
314
+ { return _M_impl._Node_alloc_type::allocate(1); }
315
+
316
+ void
317
+ _M_put_node(_List_node<_Tp>* __p)
318
+ { _M_impl._Node_alloc_type::deallocate(__p, 1); }
319
+
320
+ public:
321
+ typedef _Alloc allocator_type;
322
+
323
+ _Node_alloc_type&
324
+ _M_get_Node_allocator()
325
+ { return *static_cast<_Node_alloc_type*>(&this->_M_impl); }
326
+
327
+ const _Node_alloc_type&
328
+ _M_get_Node_allocator() const
329
+ { return *static_cast<const _Node_alloc_type*>(&this->_M_impl); }
330
+
331
+ _Tp_alloc_type
332
+ _M_get_Tp_allocator() const
333
+ { return _Tp_alloc_type(_M_get_Node_allocator()); }
334
+
335
+ allocator_type
336
+ get_allocator() const
337
+ { return allocator_type(_M_get_Node_allocator()); }
338
+
339
+ _List_base()
340
+ : _M_impl()
341
+ { _M_init(); }
342
+
343
+ _List_base(const allocator_type& __a)
344
+ : _M_impl(__a)
345
+ { _M_init(); }
346
+
347
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
348
+ _List_base(_List_base&& __x)
349
+ : _M_impl(__x._M_get_Node_allocator())
350
+ {
351
+ _M_init();
352
+ _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node);
353
+ }
354
+ #endif
355
+
356
+ // This is what actually destroys the list.
357
+ ~_List_base()
358
+ { _M_clear(); }
359
+
360
+ void
361
+ _M_clear();
362
+
363
+ void
364
+ _M_init()
365
+ {
366
+ this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
367
+ this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
368
+ }
369
+ };
370
+
371
+ /**
372
+ * @brief A standard container with linear time access to elements,
373
+ * and fixed time insertion/deletion at any point in the sequence.
374
+ *
375
+ * @ingroup Containers
376
+ * @ingroup Sequences
377
+ *
378
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
379
+ * <a href="tables.html#66">reversible container</a>, and a
380
+ * <a href="tables.html#67">sequence</a>, including the
381
+ * <a href="tables.html#68">optional sequence requirements</a> with the
382
+ * %exception of @c at and @c operator[].
383
+ *
384
+ * This is a @e doubly @e linked %list. Traversal up and down the
385
+ * %list requires linear time, but adding and removing elements (or
386
+ * @e nodes) is done in constant time, regardless of where the
387
+ * change takes place. Unlike std::vector and std::deque,
388
+ * random-access iterators are not provided, so subscripting ( @c
389
+ * [] ) access is not allowed. For algorithms which only need
390
+ * sequential access, this lack makes no difference.
391
+ *
392
+ * Also unlike the other standard containers, std::list provides
393
+ * specialized algorithms %unique to linked lists, such as
394
+ * splicing, sorting, and in-place reversal.
395
+ *
396
+ * A couple points on memory allocation for list<Tp>:
397
+ *
398
+ * First, we never actually allocate a Tp, we allocate
399
+ * List_node<Tp>'s and trust [20.1.5]/4 to DTRT. This is to ensure
400
+ * that after elements from %list<X,Alloc1> are spliced into
401
+ * %list<X,Alloc2>, destroying the memory of the second %list is a
402
+ * valid operation, i.e., Alloc1 giveth and Alloc2 taketh away.
403
+ *
404
+ * Second, a %list conceptually represented as
405
+ * @code
406
+ * A <---> B <---> C <---> D
407
+ * @endcode
408
+ * is actually circular; a link exists between A and D. The %list
409
+ * class holds (as its only data member) a private list::iterator
410
+ * pointing to @e D, not to @e A! To get to the head of the %list,
411
+ * we start at the tail and move forward by one. When this member
412
+ * iterator's next/previous pointers refer to itself, the %list is
413
+ * %empty.
414
+ */
415
+ template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
416
+ class list : protected _List_base<_Tp, _Alloc>
417
+ {
418
+ // concept requirements
419
+ typedef typename _Alloc::value_type _Alloc_value_type;
420
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
421
+ __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
422
+
423
+ typedef _List_base<_Tp, _Alloc> _Base;
424
+ typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
425
+
426
+ public:
427
+ typedef _Tp value_type;
428
+ typedef typename _Tp_alloc_type::pointer pointer;
429
+ typedef typename _Tp_alloc_type::const_pointer const_pointer;
430
+ typedef typename _Tp_alloc_type::reference reference;
431
+ typedef typename _Tp_alloc_type::const_reference const_reference;
432
+ typedef _List_iterator<_Tp> iterator;
433
+ typedef _List_const_iterator<_Tp> const_iterator;
434
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
435
+ typedef std::reverse_iterator<iterator> reverse_iterator;
436
+ typedef size_t size_type;
437
+ typedef ptrdiff_t difference_type;
438
+ typedef _Alloc allocator_type;
439
+
440
+ protected:
441
+ // Note that pointers-to-_Node's can be ctor-converted to
442
+ // iterator types.
443
+ typedef _List_node<_Tp> _Node;
444
+
445
+ using _Base::_M_impl;
446
+ using _Base::_M_put_node;
447
+ using _Base::_M_get_node;
448
+ using _Base::_M_get_Tp_allocator;
449
+ using _Base::_M_get_Node_allocator;
450
+
451
+ /**
452
+ * @param x An instance of user data.
453
+ *
454
+ * Allocates space for a new node and constructs a copy of @a x in it.
455
+ */
456
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
457
+ _Node*
458
+ _M_create_node(const value_type& __x)
459
+ {
460
+ _Node* __p = this->_M_get_node();
461
+ try
462
+ {
463
+ _M_get_Tp_allocator().construct(&__p->_M_data, __x);
464
+ }
465
+ catch(...)
466
+ {
467
+ _M_put_node(__p);
468
+ __throw_exception_again;
469
+ }
470
+ return __p;
471
+ }
472
+ #else
473
+ template<typename... _Args>
474
+ _Node*
475
+ _M_create_node(_Args&&... __args)
476
+ {
477
+ _Node* __p = this->_M_get_node();
478
+ try
479
+ {
480
+ _M_get_Tp_allocator().construct(&__p->_M_data,
481
+ std::forward<_Args>(__args)...);
482
+ }
483
+ catch(...)
484
+ {
485
+ _M_put_node(__p);
486
+ __throw_exception_again;
487
+ }
488
+ return __p;
489
+ }
490
+ #endif
491
+
492
+ public:
493
+ // [23.2.2.1] construct/copy/destroy
494
+ // (assign() and get_allocator() are also listed in this section)
495
+ /**
496
+ * @brief Default constructor creates no elements.
497
+ */
498
+ list()
499
+ : _Base() { }
500
+
501
+ /**
502
+ * @brief Creates a %list with no elements.
503
+ * @param a An allocator object.
504
+ */
505
+ explicit
506
+ list(const allocator_type& __a)
507
+ : _Base(__a) { }
508
+
509
+ /**
510
+ * @brief Creates a %list with copies of an exemplar element.
511
+ * @param n The number of elements to initially create.
512
+ * @param value An element to copy.
513
+ * @param a An allocator object.
514
+ *
515
+ * This constructor fills the %list with @a n copies of @a value.
516
+ */
517
+ explicit
518
+ list(size_type __n, const value_type& __value = value_type(),
519
+ const allocator_type& __a = allocator_type())
520
+ : _Base(__a)
521
+ { _M_fill_initialize(__n, __value); }
522
+
523
+ /**
524
+ * @brief %List copy constructor.
525
+ * @param x A %list of identical element and allocator types.
526
+ *
527
+ * The newly-created %list uses a copy of the allocation object used
528
+ * by @a x.
529
+ */
530
+ list(const list& __x)
531
+ : _Base(__x._M_get_Node_allocator())
532
+ { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
533
+
534
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
535
+ /**
536
+ * @brief %List move constructor.
537
+ * @param x A %list of identical element and allocator types.
538
+ *
539
+ * The newly-created %list contains the exact contents of @a x.
540
+ * The contents of @a x are a valid, but unspecified %list.
541
+ */
542
+ list(list&& __x)
543
+ : _Base(std::forward<_Base>(__x)) { }
544
+ #endif
545
+
546
+ /**
547
+ * @brief Builds a %list from a range.
548
+ * @param first An input iterator.
549
+ * @param last An input iterator.
550
+ * @param a An allocator object.
551
+ *
552
+ * Create a %list consisting of copies of the elements from
553
+ * [@a first,@a last). This is linear in N (where N is
554
+ * distance(@a first,@a last)).
555
+ */
556
+ template<typename _InputIterator>
557
+ list(_InputIterator __first, _InputIterator __last,
558
+ const allocator_type& __a = allocator_type())
559
+ : _Base(__a)
560
+ {
561
+ // Check whether it's an integral type. If so, it's not an iterator.
562
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
563
+ _M_initialize_dispatch(__first, __last, _Integral());
564
+ }
565
+
566
+ /**
567
+ * No explicit dtor needed as the _Base dtor takes care of
568
+ * things. The _Base dtor only erases the elements, and note
569
+ * that if the elements themselves are pointers, the pointed-to
570
+ * memory is not touched in any way. Managing the pointer is
571
+ * the user's responsibility.
572
+ */
573
+
574
+ /**
575
+ * @brief %List assignment operator.
576
+ * @param x A %list of identical element and allocator types.
577
+ *
578
+ * All the elements of @a x are copied, but unlike the copy
579
+ * constructor, the allocator object is not copied.
580
+ */
581
+ list&
582
+ operator=(const list& __x);
583
+
584
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
585
+ /**
586
+ * @brief %List move assignment operator.
587
+ * @param x A %list of identical element and allocator types.
588
+ *
589
+ * The contents of @a x are moved into this %list (without copying).
590
+ * @a x is a valid, but unspecified %list
591
+ */
592
+ list&
593
+ operator=(list&& __x)
594
+ {
595
+ // NB: DR 675.
596
+ this->clear();
597
+ this->swap(__x);
598
+ return *this;
599
+ }
600
+ #endif
601
+
602
+ /**
603
+ * @brief Assigns a given value to a %list.
604
+ * @param n Number of elements to be assigned.
605
+ * @param val Value to be assigned.
606
+ *
607
+ * This function fills a %list with @a n copies of the given
608
+ * value. Note that the assignment completely changes the %list
609
+ * and that the resulting %list's size is the same as the number
610
+ * of elements assigned. Old data may be lost.
611
+ */
612
+ void
613
+ assign(size_type __n, const value_type& __val)
614
+ { _M_fill_assign(__n, __val); }
615
+
616
+ /**
617
+ * @brief Assigns a range to a %list.
618
+ * @param first An input iterator.
619
+ * @param last An input iterator.
620
+ *
621
+ * This function fills a %list with copies of the elements in the
622
+ * range [@a first,@a last).
623
+ *
624
+ * Note that the assignment completely changes the %list and
625
+ * that the resulting %list's size is the same as the number of
626
+ * elements assigned. Old data may be lost.
627
+ */
628
+ template<typename _InputIterator>
629
+ void
630
+ assign(_InputIterator __first, _InputIterator __last)
631
+ {
632
+ // Check whether it's an integral type. If so, it's not an iterator.
633
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
634
+ _M_assign_dispatch(__first, __last, _Integral());
635
+ }
636
+
637
+ /// Get a copy of the memory allocation object.
638
+ allocator_type
639
+ get_allocator() const
640
+ { return _Base::get_allocator(); }
641
+
642
+ // iterators
643
+ /**
644
+ * Returns a read/write iterator that points to the first element in the
645
+ * %list. Iteration is done in ordinary element order.
646
+ */
647
+ iterator
648
+ begin()
649
+ { return iterator(this->_M_impl._M_node._M_next); }
650
+
651
+ /**
652
+ * Returns a read-only (constant) iterator that points to the
653
+ * first element in the %list. Iteration is done in ordinary
654
+ * element order.
655
+ */
656
+ const_iterator
657
+ begin() const
658
+ { return const_iterator(this->_M_impl._M_node._M_next); }
659
+
660
+ /**
661
+ * Returns a read/write iterator that points one past the last
662
+ * element in the %list. Iteration is done in ordinary element
663
+ * order.
664
+ */
665
+ iterator
666
+ end()
667
+ { return iterator(&this->_M_impl._M_node); }
668
+
669
+ /**
670
+ * Returns a read-only (constant) iterator that points one past
671
+ * the last element in the %list. Iteration is done in ordinary
672
+ * element order.
673
+ */
674
+ const_iterator
675
+ end() const
676
+ { return const_iterator(&this->_M_impl._M_node); }
677
+
678
+ /**
679
+ * Returns a read/write reverse iterator that points to the last
680
+ * element in the %list. Iteration is done in reverse element
681
+ * order.
682
+ */
683
+ reverse_iterator
684
+ rbegin()
685
+ { return reverse_iterator(end()); }
686
+
687
+ /**
688
+ * Returns a read-only (constant) reverse iterator that points to
689
+ * the last element in the %list. Iteration is done in reverse
690
+ * element order.
691
+ */
692
+ const_reverse_iterator
693
+ rbegin() const
694
+ { return const_reverse_iterator(end()); }
695
+
696
+ /**
697
+ * Returns a read/write reverse iterator that points to one
698
+ * before the first element in the %list. Iteration is done in
699
+ * reverse element order.
700
+ */
701
+ reverse_iterator
702
+ rend()
703
+ { return reverse_iterator(begin()); }
704
+
705
+ /**
706
+ * Returns a read-only (constant) reverse iterator that points to one
707
+ * before the first element in the %list. Iteration is done in reverse
708
+ * element order.
709
+ */
710
+ const_reverse_iterator
711
+ rend() const
712
+ { return const_reverse_iterator(begin()); }
713
+
714
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
715
+ /**
716
+ * Returns a read-only (constant) iterator that points to the
717
+ * first element in the %list. Iteration is done in ordinary
718
+ * element order.
719
+ */
720
+ const_iterator
721
+ cbegin() const
722
+ { return const_iterator(this->_M_impl._M_node._M_next); }
723
+
724
+ /**
725
+ * Returns a read-only (constant) iterator that points one past
726
+ * the last element in the %list. Iteration is done in ordinary
727
+ * element order.
728
+ */
729
+ const_iterator
730
+ cend() const
731
+ { return const_iterator(&this->_M_impl._M_node); }
732
+
733
+ /**
734
+ * Returns a read-only (constant) reverse iterator that points to
735
+ * the last element in the %list. Iteration is done in reverse
736
+ * element order.
737
+ */
738
+ const_reverse_iterator
739
+ crbegin() const
740
+ { return const_reverse_iterator(end()); }
741
+
742
+ /**
743
+ * Returns a read-only (constant) reverse iterator that points to one
744
+ * before the first element in the %list. Iteration is done in reverse
745
+ * element order.
746
+ */
747
+ const_reverse_iterator
748
+ crend() const
749
+ { return const_reverse_iterator(begin()); }
750
+ #endif
751
+
752
+ // [23.2.2.2] capacity
753
+ /**
754
+ * Returns true if the %list is empty. (Thus begin() would equal
755
+ * end().)
756
+ */
757
+ bool
758
+ empty() const
759
+ { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
760
+
761
+ /** Returns the number of elements in the %list. */
762
+ size_type
763
+ size() const
764
+ { return std::distance(begin(), end()); }
765
+
766
+ /** Returns the size() of the largest possible %list. */
767
+ size_type
768
+ max_size() const
769
+ { return _M_get_Tp_allocator().max_size(); }
770
+
771
+ /**
772
+ * @brief Resizes the %list to the specified number of elements.
773
+ * @param new_size Number of elements the %list should contain.
774
+ * @param x Data with which new elements should be populated.
775
+ *
776
+ * This function will %resize the %list to the specified number
777
+ * of elements. If the number is smaller than the %list's
778
+ * current size the %list is truncated, otherwise the %list is
779
+ * extended and new elements are populated with given data.
780
+ */
781
+ void
782
+ resize(size_type __new_size, value_type __x = value_type());
783
+
784
+ // element access
785
+ /**
786
+ * Returns a read/write reference to the data at the first
787
+ * element of the %list.
788
+ */
789
+ reference
790
+ front()
791
+ { return *begin(); }
792
+
793
+ /**
794
+ * Returns a read-only (constant) reference to the data at the first
795
+ * element of the %list.
796
+ */
797
+ const_reference
798
+ front() const
799
+ { return *begin(); }
800
+
801
+ /**
802
+ * Returns a read/write reference to the data at the last element
803
+ * of the %list.
804
+ */
805
+ reference
806
+ back()
807
+ {
808
+ iterator __tmp = end();
809
+ --__tmp;
810
+ return *__tmp;
811
+ }
812
+
813
+ /**
814
+ * Returns a read-only (constant) reference to the data at the last
815
+ * element of the %list.
816
+ */
817
+ const_reference
818
+ back() const
819
+ {
820
+ const_iterator __tmp = end();
821
+ --__tmp;
822
+ return *__tmp;
823
+ }
824
+
825
+ // [23.2.2.3] modifiers
826
+ /**
827
+ * @brief Add data to the front of the %list.
828
+ * @param x Data to be added.
829
+ *
830
+ * This is a typical stack operation. The function creates an
831
+ * element at the front of the %list and assigns the given data
832
+ * to it. Due to the nature of a %list this operation can be
833
+ * done in constant time, and does not invalidate iterators and
834
+ * references.
835
+ */
836
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
837
+ void
838
+ push_front(const value_type& __x)
839
+ { this->_M_insert(begin(), __x); }
840
+ #else
841
+ template<typename... _Args>
842
+ void
843
+ push_front(_Args&&... __args)
844
+ { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
845
+ #endif
846
+
847
+ /**
848
+ * @brief Removes first element.
849
+ *
850
+ * This is a typical stack operation. It shrinks the %list by
851
+ * one. Due to the nature of a %list this operation can be done
852
+ * in constant time, and only invalidates iterators/references to
853
+ * the element being removed.
854
+ *
855
+ * Note that no data is returned, and if the first element's data
856
+ * is needed, it should be retrieved before pop_front() is
857
+ * called.
858
+ */
859
+ void
860
+ pop_front()
861
+ { this->_M_erase(begin()); }
862
+
863
+ /**
864
+ * @brief Add data to the end of the %list.
865
+ * @param x Data to be added.
866
+ *
867
+ * This is a typical stack operation. The function creates an
868
+ * element at the end of the %list and assigns the given data to
869
+ * it. Due to the nature of a %list this operation can be done
870
+ * in constant time, and does not invalidate iterators and
871
+ * references.
872
+ */
873
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
874
+ void
875
+ push_back(const value_type& __x)
876
+ { this->_M_insert(end(), __x); }
877
+ #else
878
+ template<typename... _Args>
879
+ void
880
+ push_back(_Args&&... __args)
881
+ { this->_M_insert(end(), std::forward<_Args>(__args)...); }
882
+ #endif
883
+
884
+ /**
885
+ * @brief Removes last element.
886
+ *
887
+ * This is a typical stack operation. It shrinks the %list by
888
+ * one. Due to the nature of a %list this operation can be done
889
+ * in constant time, and only invalidates iterators/references to
890
+ * the element being removed.
891
+ *
892
+ * Note that no data is returned, and if the last element's data
893
+ * is needed, it should be retrieved before pop_back() is called.
894
+ */
895
+ void
896
+ pop_back()
897
+ { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
898
+
899
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
900
+ /**
901
+ * @brief Constructs object in %list before specified iterator.
902
+ * @param position A const_iterator into the %list.
903
+ * @param args Arguments.
904
+ * @return An iterator that points to the inserted data.
905
+ *
906
+ * This function will insert an object of type T constructed
907
+ * with T(std::forward<Args>(args)...) before the specified
908
+ * location. Due to the nature of a %list this operation can
909
+ * be done in constant time, and does not invalidate iterators
910
+ * and references.
911
+ */
912
+ template<typename... _Args>
913
+ iterator
914
+ emplace(iterator __position, _Args&&... __args);
915
+ #endif
916
+
917
+ /**
918
+ * @brief Inserts given value into %list before specified iterator.
919
+ * @param position An iterator into the %list.
920
+ * @param x Data to be inserted.
921
+ * @return An iterator that points to the inserted data.
922
+ *
923
+ * This function will insert a copy of the given value before
924
+ * the specified location. Due to the nature of a %list this
925
+ * operation can be done in constant time, and does not
926
+ * invalidate iterators and references.
927
+ */
928
+ iterator
929
+ insert(iterator __position, const value_type& __x);
930
+
931
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
932
+ /**
933
+ * @brief Inserts given rvalue into %list before specified iterator.
934
+ * @param position An iterator into the %list.
935
+ * @param x Data to be inserted.
936
+ * @return An iterator that points to the inserted data.
937
+ *
938
+ * This function will insert a copy of the given rvalue before
939
+ * the specified location. Due to the nature of a %list this
940
+ * operation can be done in constant time, and does not
941
+ * invalidate iterators and references.
942
+ */
943
+ iterator
944
+ insert(iterator __position, value_type&& __x)
945
+ { return emplace(__position, std::move(__x)); }
946
+ #endif
947
+
948
+ /**
949
+ * @brief Inserts a number of copies of given data into the %list.
950
+ * @param position An iterator into the %list.
951
+ * @param n Number of elements to be inserted.
952
+ * @param x Data to be inserted.
953
+ *
954
+ * This function will insert a specified number of copies of the
955
+ * given data before the location specified by @a position.
956
+ *
957
+ * This operation is linear in the number of elements inserted and
958
+ * does not invalidate iterators and references.
959
+ */
960
+ void
961
+ insert(iterator __position, size_type __n, const value_type& __x)
962
+ {
963
+ list __tmp(__n, __x, _M_get_Node_allocator());
964
+ splice(__position, __tmp);
965
+ }
966
+
967
+ /**
968
+ * @brief Inserts a range into the %list.
969
+ * @param position An iterator into the %list.
970
+ * @param first An input iterator.
971
+ * @param last An input iterator.
972
+ *
973
+ * This function will insert copies of the data in the range [@a
974
+ * first,@a last) into the %list before the location specified by
975
+ * @a position.
976
+ *
977
+ * This operation is linear in the number of elements inserted and
978
+ * does not invalidate iterators and references.
979
+ */
980
+ template<typename _InputIterator>
981
+ void
982
+ insert(iterator __position, _InputIterator __first,
983
+ _InputIterator __last)
984
+ {
985
+ list __tmp(__first, __last, _M_get_Node_allocator());
986
+ splice(__position, __tmp);
987
+ }
988
+
989
+ /**
990
+ * @brief Remove element at given position.
991
+ * @param position Iterator pointing to element to be erased.
992
+ * @return An iterator pointing to the next element (or end()).
993
+ *
994
+ * This function will erase the element at the given position and thus
995
+ * shorten the %list by one.
996
+ *
997
+ * Due to the nature of a %list this operation can be done in
998
+ * constant time, and only invalidates iterators/references to
999
+ * the element being removed. The user is also cautioned that
1000
+ * this function only erases the element, and that if the element
1001
+ * is itself a pointer, the pointed-to memory is not touched in
1002
+ * any way. Managing the pointer is the user's responsibility.
1003
+ */
1004
+ iterator
1005
+ erase(iterator __position);
1006
+
1007
+ /**
1008
+ * @brief Remove a range of elements.
1009
+ * @param first Iterator pointing to the first element to be erased.
1010
+ * @param last Iterator pointing to one past the last element to be
1011
+ * erased.
1012
+ * @return An iterator pointing to the element pointed to by @a last
1013
+ * prior to erasing (or end()).
1014
+ *
1015
+ * This function will erase the elements in the range @a
1016
+ * [first,last) and shorten the %list accordingly.
1017
+ *
1018
+ * This operation is linear time in the size of the range and only
1019
+ * invalidates iterators/references to the element being removed.
1020
+ * The user is also cautioned that this function only erases the
1021
+ * elements, and that if the elements themselves are pointers, the
1022
+ * pointed-to memory is not touched in any way. Managing the pointer
1023
+ * is the user's responsibility.
1024
+ */
1025
+ iterator
1026
+ erase(iterator __first, iterator __last)
1027
+ {
1028
+ while (__first != __last)
1029
+ __first = erase(__first);
1030
+ return __last;
1031
+ }
1032
+
1033
+ /**
1034
+ * @brief Swaps data with another %list.
1035
+ * @param x A %list of the same element and allocator types.
1036
+ *
1037
+ * This exchanges the elements between two lists in constant
1038
+ * time. Note that the global std::swap() function is
1039
+ * specialized such that std::swap(l1,l2) will feed to this
1040
+ * function.
1041
+ */
1042
+ void
1043
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1044
+ swap(list&& __x)
1045
+ #else
1046
+ swap(list& __x)
1047
+ #endif
1048
+ {
1049
+ _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node);
1050
+
1051
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
1052
+ // 431. Swapping containers with unequal allocators.
1053
+ std::__alloc_swap<typename _Base::_Node_alloc_type>::
1054
+ _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
1055
+ }
1056
+
1057
+ /**
1058
+ * Erases all the elements. Note that this function only erases
1059
+ * the elements, and that if the elements themselves are
1060
+ * pointers, the pointed-to memory is not touched in any way.
1061
+ * Managing the pointer is the user's responsibility.
1062
+ */
1063
+ void
1064
+ clear()
1065
+ {
1066
+ _Base::_M_clear();
1067
+ _Base::_M_init();
1068
+ }
1069
+
1070
+ // [23.2.2.4] list operations
1071
+ /**
1072
+ * @brief Insert contents of another %list.
1073
+ * @param position Iterator referencing the element to insert before.
1074
+ * @param x Source list.
1075
+ *
1076
+ * The elements of @a x are inserted in constant time in front of
1077
+ * the element referenced by @a position. @a x becomes an empty
1078
+ * list.
1079
+ *
1080
+ * Requires this != @a x.
1081
+ */
1082
+ void
1083
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1084
+ splice(iterator __position, list&& __x)
1085
+ #else
1086
+ splice(iterator __position, list& __x)
1087
+ #endif
1088
+ {
1089
+ if (!__x.empty())
1090
+ {
1091
+ _M_check_equal_allocators(__x);
1092
+
1093
+ this->_M_transfer(__position, __x.begin(), __x.end());
1094
+ }
1095
+ }
1096
+
1097
+ /**
1098
+ * @brief Insert element from another %list.
1099
+ * @param position Iterator referencing the element to insert before.
1100
+ * @param x Source list.
1101
+ * @param i Iterator referencing the element to move.
1102
+ *
1103
+ * Removes the element in list @a x referenced by @a i and
1104
+ * inserts it into the current list before @a position.
1105
+ */
1106
+ void
1107
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1108
+ splice(iterator __position, list&& __x, iterator __i)
1109
+ #else
1110
+ splice(iterator __position, list& __x, iterator __i)
1111
+ #endif
1112
+ {
1113
+ iterator __j = __i;
1114
+ ++__j;
1115
+ if (__position == __i || __position == __j)
1116
+ return;
1117
+
1118
+ if (this != &__x)
1119
+ _M_check_equal_allocators(__x);
1120
+
1121
+ this->_M_transfer(__position, __i, __j);
1122
+ }
1123
+
1124
+ /**
1125
+ * @brief Insert range from another %list.
1126
+ * @param position Iterator referencing the element to insert before.
1127
+ * @param x Source list.
1128
+ * @param first Iterator referencing the start of range in x.
1129
+ * @param last Iterator referencing the end of range in x.
1130
+ *
1131
+ * Removes elements in the range [first,last) and inserts them
1132
+ * before @a position in constant time.
1133
+ *
1134
+ * Undefined if @a position is in [first,last).
1135
+ */
1136
+ void
1137
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1138
+ splice(iterator __position, list&& __x, iterator __first,
1139
+ iterator __last)
1140
+ #else
1141
+ splice(iterator __position, list& __x, iterator __first,
1142
+ iterator __last)
1143
+ #endif
1144
+ {
1145
+ if (__first != __last)
1146
+ {
1147
+ if (this != &__x)
1148
+ _M_check_equal_allocators(__x);
1149
+
1150
+ this->_M_transfer(__position, __first, __last);
1151
+ }
1152
+ }
1153
+
1154
+ /**
1155
+ * @brief Remove all elements equal to value.
1156
+ * @param value The value to remove.
1157
+ *
1158
+ * Removes every element in the list equal to @a value.
1159
+ * Remaining elements stay in list order. Note that this
1160
+ * function only erases the elements, and that if the elements
1161
+ * themselves are pointers, the pointed-to memory is not
1162
+ * touched in any way. Managing the pointer is the user's
1163
+ * responsibility.
1164
+ */
1165
+ void
1166
+ remove(const _Tp& __value);
1167
+
1168
+ /**
1169
+ * @brief Remove all elements satisfying a predicate.
1170
+ * @param Predicate Unary predicate function or object.
1171
+ *
1172
+ * Removes every element in the list for which the predicate
1173
+ * returns true. Remaining elements stay in list order. Note
1174
+ * that this function only erases the elements, and that if the
1175
+ * elements themselves are pointers, the pointed-to memory is
1176
+ * not touched in any way. Managing the pointer is the user's
1177
+ * responsibility.
1178
+ */
1179
+ template<typename _Predicate>
1180
+ void
1181
+ remove_if(_Predicate);
1182
+
1183
+ /**
1184
+ * @brief Remove consecutive duplicate elements.
1185
+ *
1186
+ * For each consecutive set of elements with the same value,
1187
+ * remove all but the first one. Remaining elements stay in
1188
+ * list order. Note that this function only erases the
1189
+ * elements, and that if the elements themselves are pointers,
1190
+ * the pointed-to memory is not touched in any way. Managing
1191
+ * the pointer is the user's responsibility.
1192
+ */
1193
+ void
1194
+ unique();
1195
+
1196
+ /**
1197
+ * @brief Remove consecutive elements satisfying a predicate.
1198
+ * @param BinaryPredicate Binary predicate function or object.
1199
+ *
1200
+ * For each consecutive set of elements [first,last) that
1201
+ * satisfy predicate(first,i) where i is an iterator in
1202
+ * [first,last), remove all but the first one. Remaining
1203
+ * elements stay in list order. Note that this function only
1204
+ * erases the elements, and that if the elements themselves are
1205
+ * pointers, the pointed-to memory is not touched in any way.
1206
+ * Managing the pointer is the user's responsibility.
1207
+ */
1208
+ template<typename _BinaryPredicate>
1209
+ void
1210
+ unique(_BinaryPredicate);
1211
+
1212
+ /**
1213
+ * @brief Merge sorted lists.
1214
+ * @param x Sorted list to merge.
1215
+ *
1216
+ * Assumes that both @a x and this list are sorted according to
1217
+ * operator<(). Merges elements of @a x into this list in
1218
+ * sorted order, leaving @a x empty when complete. Elements in
1219
+ * this list precede elements in @a x that are equal.
1220
+ */
1221
+ void
1222
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1223
+ merge(list&& __x);
1224
+ #else
1225
+ merge(list& __x);
1226
+ #endif
1227
+
1228
+ /**
1229
+ * @brief Merge sorted lists according to comparison function.
1230
+ * @param x Sorted list to merge.
1231
+ * @param StrictWeakOrdering Comparison function defining
1232
+ * sort order.
1233
+ *
1234
+ * Assumes that both @a x and this list are sorted according to
1235
+ * StrictWeakOrdering. Merges elements of @a x into this list
1236
+ * in sorted order, leaving @a x empty when complete. Elements
1237
+ * in this list precede elements in @a x that are equivalent
1238
+ * according to StrictWeakOrdering().
1239
+ */
1240
+ template<typename _StrictWeakOrdering>
1241
+ void
1242
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1243
+ merge(list&&, _StrictWeakOrdering);
1244
+ #else
1245
+ merge(list&, _StrictWeakOrdering);
1246
+ #endif
1247
+
1248
+ /**
1249
+ * @brief Reverse the elements in list.
1250
+ *
1251
+ * Reverse the order of elements in the list in linear time.
1252
+ */
1253
+ void
1254
+ reverse()
1255
+ { this->_M_impl._M_node.reverse(); }
1256
+
1257
+ /**
1258
+ * @brief Sort the elements.
1259
+ *
1260
+ * Sorts the elements of this list in NlogN time. Equivalent
1261
+ * elements remain in list order.
1262
+ */
1263
+ void
1264
+ sort();
1265
+
1266
+ /**
1267
+ * @brief Sort the elements according to comparison function.
1268
+ *
1269
+ * Sorts the elements of this list in NlogN time. Equivalent
1270
+ * elements remain in list order.
1271
+ */
1272
+ template<typename _StrictWeakOrdering>
1273
+ void
1274
+ sort(_StrictWeakOrdering);
1275
+
1276
+ protected:
1277
+ // Internal constructor functions follow.
1278
+
1279
+ // Called by the range constructor to implement [23.1.1]/9
1280
+
1281
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
1282
+ // 438. Ambiguity in the "do the right thing" clause
1283
+ template<typename _Integer>
1284
+ void
1285
+ _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1286
+ { _M_fill_initialize(static_cast<size_type>(__n), __x); }
1287
+
1288
+ // Called by the range constructor to implement [23.1.1]/9
1289
+ template<typename _InputIterator>
1290
+ void
1291
+ _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1292
+ __false_type)
1293
+ {
1294
+ for (; __first != __last; ++__first)
1295
+ push_back(*__first);
1296
+ }
1297
+
1298
+ // Called by list(n,v,a), and the range constructor when it turns out
1299
+ // to be the same thing.
1300
+ void
1301
+ _M_fill_initialize(size_type __n, const value_type& __x)
1302
+ {
1303
+ for (; __n > 0; --__n)
1304
+ push_back(__x);
1305
+ }
1306
+
1307
+
1308
+ // Internal assign functions follow.
1309
+
1310
+ // Called by the range assign to implement [23.1.1]/9
1311
+
1312
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
1313
+ // 438. Ambiguity in the "do the right thing" clause
1314
+ template<typename _Integer>
1315
+ void
1316
+ _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1317
+ { _M_fill_assign(__n, __val); }
1318
+
1319
+ // Called by the range assign to implement [23.1.1]/9
1320
+ template<typename _InputIterator>
1321
+ void
1322
+ _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1323
+ __false_type);
1324
+
1325
+ // Called by assign(n,t), and the range assign when it turns out
1326
+ // to be the same thing.
1327
+ void
1328
+ _M_fill_assign(size_type __n, const value_type& __val);
1329
+
1330
+
1331
+ // Moves the elements from [first,last) before position.
1332
+ void
1333
+ _M_transfer(iterator __position, iterator __first, iterator __last)
1334
+ { __position._M_node->transfer(__first._M_node, __last._M_node); }
1335
+
1336
+ // Inserts new element at position given and with value given.
1337
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
1338
+ void
1339
+ _M_insert(iterator __position, const value_type& __x)
1340
+ {
1341
+ _Node* __tmp = _M_create_node(__x);
1342
+ __tmp->hook(__position._M_node);
1343
+ }
1344
+ #else
1345
+ template<typename... _Args>
1346
+ void
1347
+ _M_insert(iterator __position, _Args&&... __args)
1348
+ {
1349
+ _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
1350
+ __tmp->hook(__position._M_node);
1351
+ }
1352
+ #endif
1353
+
1354
+ // Erases element at position given.
1355
+ void
1356
+ _M_erase(iterator __position)
1357
+ {
1358
+ __position._M_node->unhook();
1359
+ _Node* __n = static_cast<_Node*>(__position._M_node);
1360
+ _M_get_Tp_allocator().destroy(&__n->_M_data);
1361
+ _M_put_node(__n);
1362
+ }
1363
+
1364
+ // To implement the splice (and merge) bits of N1599.
1365
+ void
1366
+ _M_check_equal_allocators(list& __x)
1367
+ {
1368
+ if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
1369
+ _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
1370
+ __throw_runtime_error(__N("list::_M_check_equal_allocators"));
1371
+ }
1372
+ };
1373
+
1374
+ /**
1375
+ * @brief List equality comparison.
1376
+ * @param x A %list.
1377
+ * @param y A %list of the same type as @a x.
1378
+ * @return True iff the size and elements of the lists are equal.
1379
+ *
1380
+ * This is an equivalence relation. It is linear in the size of
1381
+ * the lists. Lists are considered equivalent if their sizes are
1382
+ * equal, and if corresponding elements compare equal.
1383
+ */
1384
+ template<typename _Tp, typename _Alloc>
1385
+ inline bool
1386
+ operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
1387
+ {
1388
+ typedef typename list<_Tp, _Alloc>::const_iterator const_iterator;
1389
+ const_iterator __end1 = __x.end();
1390
+ const_iterator __end2 = __y.end();
1391
+
1392
+ const_iterator __i1 = __x.begin();
1393
+ const_iterator __i2 = __y.begin();
1394
+ while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
1395
+ {
1396
+ ++__i1;
1397
+ ++__i2;
1398
+ }
1399
+ return __i1 == __end1 && __i2 == __end2;
1400
+ }
1401
+
1402
+ /**
1403
+ * @brief List ordering relation.
1404
+ * @param x A %list.
1405
+ * @param y A %list of the same type as @a x.
1406
+ * @return True iff @a x is lexicographically less than @a y.
1407
+ *
1408
+ * This is a total ordering relation. It is linear in the size of the
1409
+ * lists. The elements must be comparable with @c <.
1410
+ *
1411
+ * See std::lexicographical_compare() for how the determination is made.
1412
+ */
1413
+ template<typename _Tp, typename _Alloc>
1414
+ inline bool
1415
+ operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
1416
+ { return std::lexicographical_compare(__x.begin(), __x.end(),
1417
+ __y.begin(), __y.end()); }
1418
+
1419
+ /// Based on operator==
1420
+ template<typename _Tp, typename _Alloc>
1421
+ inline bool
1422
+ operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
1423
+ { return !(__x == __y); }
1424
+
1425
+ /// Based on operator<
1426
+ template<typename _Tp, typename _Alloc>
1427
+ inline bool
1428
+ operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
1429
+ { return __y < __x; }
1430
+
1431
+ /// Based on operator<
1432
+ template<typename _Tp, typename _Alloc>
1433
+ inline bool
1434
+ operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
1435
+ { return !(__y < __x); }
1436
+
1437
+ /// Based on operator<
1438
+ template<typename _Tp, typename _Alloc>
1439
+ inline bool
1440
+ operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
1441
+ { return !(__x < __y); }
1442
+
1443
+ /// See std::list::swap().
1444
+ template<typename _Tp, typename _Alloc>
1445
+ inline void
1446
+ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
1447
+ { __x.swap(__y); }
1448
+
1449
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1450
+ template<typename _Tp, typename _Alloc>
1451
+ inline void
1452
+ swap(list<_Tp, _Alloc>&& __x, list<_Tp, _Alloc>& __y)
1453
+ { __x.swap(__y); }
1454
+
1455
+ template<typename _Tp, typename _Alloc>
1456
+ inline void
1457
+ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>&& __y)
1458
+ { __x.swap(__y); }
1459
+ #endif
1460
+
1461
+ _GLIBCXX_END_NESTED_NAMESPACE
1462
+
1463
+ #endif /* _STL_LIST_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_map.h ADDED
@@ -0,0 +1,827 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Map implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_map.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_MAP_H
63
+ #define _STL_MAP_H 1
64
+
65
+ #include <bits/functexcept.h>
66
+ #include <bits/concept_check.h>
67
+
68
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
69
+
70
+ /**
71
+ * @brief A standard container made up of (key,value) pairs, which can be
72
+ * retrieved based on a key, in logarithmic time.
73
+ *
74
+ * @ingroup Containers
75
+ * @ingroup Assoc_containers
76
+ *
77
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
78
+ * <a href="tables.html#66">reversible container</a>, and an
79
+ * <a href="tables.html#69">associative container</a> (using unique keys).
80
+ * For a @c map<Key,T> the key_type is Key, the mapped_type is T, and the
81
+ * value_type is std::pair<const Key,T>.
82
+ *
83
+ * Maps support bidirectional iterators.
84
+ *
85
+ * The private tree data is declared exactly the same way for map and
86
+ * multimap; the distinction is made entirely in how the tree functions are
87
+ * called (*_unique versus *_equal, same as the standard).
88
+ */
89
+ template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
90
+ typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
91
+ class map
92
+ {
93
+ public:
94
+ typedef _Key key_type;
95
+ typedef _Tp mapped_type;
96
+ typedef std::pair<const _Key, _Tp> value_type;
97
+ typedef _Compare key_compare;
98
+ typedef _Alloc allocator_type;
99
+
100
+ private:
101
+ // concept requirements
102
+ typedef typename _Alloc::value_type _Alloc_value_type;
103
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
104
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
105
+ _BinaryFunctionConcept)
106
+ __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
107
+
108
+ public:
109
+ class value_compare
110
+ : public std::binary_function<value_type, value_type, bool>
111
+ {
112
+ friend class map<_Key, _Tp, _Compare, _Alloc>;
113
+ protected:
114
+ _Compare comp;
115
+
116
+ value_compare(_Compare __c)
117
+ : comp(__c) { }
118
+
119
+ public:
120
+ bool operator()(const value_type& __x, const value_type& __y) const
121
+ { return comp(__x.first, __y.first); }
122
+ };
123
+
124
+ private:
125
+ /// This turns a red-black tree into a [multi]map.
126
+ typedef typename _Alloc::template rebind<value_type>::other
127
+ _Pair_alloc_type;
128
+
129
+ typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
130
+ key_compare, _Pair_alloc_type> _Rep_type;
131
+
132
+ /// The actual tree structure.
133
+ _Rep_type _M_t;
134
+
135
+ public:
136
+ // many of these are specified differently in ISO, but the following are
137
+ // "functionally equivalent"
138
+ typedef typename _Pair_alloc_type::pointer pointer;
139
+ typedef typename _Pair_alloc_type::const_pointer const_pointer;
140
+ typedef typename _Pair_alloc_type::reference reference;
141
+ typedef typename _Pair_alloc_type::const_reference const_reference;
142
+ typedef typename _Rep_type::iterator iterator;
143
+ typedef typename _Rep_type::const_iterator const_iterator;
144
+ typedef typename _Rep_type::size_type size_type;
145
+ typedef typename _Rep_type::difference_type difference_type;
146
+ typedef typename _Rep_type::reverse_iterator reverse_iterator;
147
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
148
+
149
+ // [23.3.1.1] construct/copy/destroy
150
+ // (get_allocator() is normally listed in this section, but seems to have
151
+ // been accidentally omitted in the printed standard)
152
+ /**
153
+ * @brief Default constructor creates no elements.
154
+ */
155
+ map()
156
+ : _M_t() { }
157
+
158
+ /**
159
+ * @brief Creates a %map with no elements.
160
+ * @param comp A comparison object.
161
+ * @param a An allocator object.
162
+ */
163
+ explicit
164
+ map(const _Compare& __comp,
165
+ const allocator_type& __a = allocator_type())
166
+ : _M_t(__comp, __a) { }
167
+
168
+ /**
169
+ * @brief %Map copy constructor.
170
+ * @param x A %map of identical element and allocator types.
171
+ *
172
+ * The newly-created %map uses a copy of the allocation object
173
+ * used by @a x.
174
+ */
175
+ map(const map& __x)
176
+ : _M_t(__x._M_t) { }
177
+
178
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
179
+ /**
180
+ * @brief %Map move constructor.
181
+ * @param x A %map of identical element and allocator types.
182
+ *
183
+ * The newly-created %map contains the exact contents of @a x.
184
+ * The contents of @a x are a valid, but unspecified %map.
185
+ */
186
+ map(map&& __x)
187
+ : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
188
+ #endif
189
+
190
+ /**
191
+ * @brief Builds a %map from a range.
192
+ * @param first An input iterator.
193
+ * @param last An input iterator.
194
+ *
195
+ * Create a %map consisting of copies of the elements from [first,last).
196
+ * This is linear in N if the range is already sorted, and NlogN
197
+ * otherwise (where N is distance(first,last)).
198
+ */
199
+ template<typename _InputIterator>
200
+ map(_InputIterator __first, _InputIterator __last)
201
+ : _M_t()
202
+ { _M_t._M_insert_unique(__first, __last); }
203
+
204
+ /**
205
+ * @brief Builds a %map from a range.
206
+ * @param first An input iterator.
207
+ * @param last An input iterator.
208
+ * @param comp A comparison functor.
209
+ * @param a An allocator object.
210
+ *
211
+ * Create a %map consisting of copies of the elements from [first,last).
212
+ * This is linear in N if the range is already sorted, and NlogN
213
+ * otherwise (where N is distance(first,last)).
214
+ */
215
+ template<typename _InputIterator>
216
+ map(_InputIterator __first, _InputIterator __last,
217
+ const _Compare& __comp,
218
+ const allocator_type& __a = allocator_type())
219
+ : _M_t(__comp, __a)
220
+ { _M_t._M_insert_unique(__first, __last); }
221
+
222
+ // FIXME There is no dtor declared, but we should have something
223
+ // generated by Doxygen. I don't know what tags to add to this
224
+ // paragraph to make that happen:
225
+ /**
226
+ * The dtor only erases the elements, and note that if the elements
227
+ * themselves are pointers, the pointed-to memory is not touched in any
228
+ * way. Managing the pointer is the user's responsibility.
229
+ */
230
+
231
+ /**
232
+ * @brief %Map assignment operator.
233
+ * @param x A %map of identical element and allocator types.
234
+ *
235
+ * All the elements of @a x are copied, but unlike the copy constructor,
236
+ * the allocator object is not copied.
237
+ */
238
+ map&
239
+ operator=(const map& __x)
240
+ {
241
+ _M_t = __x._M_t;
242
+ return *this;
243
+ }
244
+
245
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
246
+ /**
247
+ * @brief %Map move assignment operator.
248
+ * @param x A %map of identical element and allocator types.
249
+ *
250
+ * The contents of @a x are moved into this map (without copying).
251
+ * @a x is a valid, but unspecified %map.
252
+ */
253
+ map&
254
+ operator=(map&& __x)
255
+ {
256
+ // NB: DR 675.
257
+ this->clear();
258
+ this->swap(__x);
259
+ return *this;
260
+ }
261
+ #endif
262
+
263
+ /// Get a copy of the memory allocation object.
264
+ allocator_type
265
+ get_allocator() const
266
+ { return _M_t.get_allocator(); }
267
+
268
+ // iterators
269
+ /**
270
+ * Returns a read/write iterator that points to the first pair in the
271
+ * %map.
272
+ * Iteration is done in ascending order according to the keys.
273
+ */
274
+ iterator
275
+ begin()
276
+ { return _M_t.begin(); }
277
+
278
+ /**
279
+ * Returns a read-only (constant) iterator that points to the first pair
280
+ * in the %map. Iteration is done in ascending order according to the
281
+ * keys.
282
+ */
283
+ const_iterator
284
+ begin() const
285
+ { return _M_t.begin(); }
286
+
287
+ /**
288
+ * Returns a read/write iterator that points one past the last
289
+ * pair in the %map. Iteration is done in ascending order
290
+ * according to the keys.
291
+ */
292
+ iterator
293
+ end()
294
+ { return _M_t.end(); }
295
+
296
+ /**
297
+ * Returns a read-only (constant) iterator that points one past the last
298
+ * pair in the %map. Iteration is done in ascending order according to
299
+ * the keys.
300
+ */
301
+ const_iterator
302
+ end() const
303
+ { return _M_t.end(); }
304
+
305
+ /**
306
+ * Returns a read/write reverse iterator that points to the last pair in
307
+ * the %map. Iteration is done in descending order according to the
308
+ * keys.
309
+ */
310
+ reverse_iterator
311
+ rbegin()
312
+ { return _M_t.rbegin(); }
313
+
314
+ /**
315
+ * Returns a read-only (constant) reverse iterator that points to the
316
+ * last pair in the %map. Iteration is done in descending order
317
+ * according to the keys.
318
+ */
319
+ const_reverse_iterator
320
+ rbegin() const
321
+ { return _M_t.rbegin(); }
322
+
323
+ /**
324
+ * Returns a read/write reverse iterator that points to one before the
325
+ * first pair in the %map. Iteration is done in descending order
326
+ * according to the keys.
327
+ */
328
+ reverse_iterator
329
+ rend()
330
+ { return _M_t.rend(); }
331
+
332
+ /**
333
+ * Returns a read-only (constant) reverse iterator that points to one
334
+ * before the first pair in the %map. Iteration is done in descending
335
+ * order according to the keys.
336
+ */
337
+ const_reverse_iterator
338
+ rend() const
339
+ { return _M_t.rend(); }
340
+
341
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
342
+ /**
343
+ * Returns a read-only (constant) iterator that points to the first pair
344
+ * in the %map. Iteration is done in ascending order according to the
345
+ * keys.
346
+ */
347
+ const_iterator
348
+ cbegin() const
349
+ { return _M_t.begin(); }
350
+
351
+ /**
352
+ * Returns a read-only (constant) iterator that points one past the last
353
+ * pair in the %map. Iteration is done in ascending order according to
354
+ * the keys.
355
+ */
356
+ const_iterator
357
+ cend() const
358
+ { return _M_t.end(); }
359
+
360
+ /**
361
+ * Returns a read-only (constant) reverse iterator that points to the
362
+ * last pair in the %map. Iteration is done in descending order
363
+ * according to the keys.
364
+ */
365
+ const_reverse_iterator
366
+ crbegin() const
367
+ { return _M_t.rbegin(); }
368
+
369
+ /**
370
+ * Returns a read-only (constant) reverse iterator that points to one
371
+ * before the first pair in the %map. Iteration is done in descending
372
+ * order according to the keys.
373
+ */
374
+ const_reverse_iterator
375
+ crend() const
376
+ { return _M_t.rend(); }
377
+ #endif
378
+
379
+ // capacity
380
+ /** Returns true if the %map is empty. (Thus begin() would equal
381
+ * end().)
382
+ */
383
+ bool
384
+ empty() const
385
+ { return _M_t.empty(); }
386
+
387
+ /** Returns the size of the %map. */
388
+ size_type
389
+ size() const
390
+ { return _M_t.size(); }
391
+
392
+ /** Returns the maximum size of the %map. */
393
+ size_type
394
+ max_size() const
395
+ { return _M_t.max_size(); }
396
+
397
+ // [23.3.1.2] element access
398
+ /**
399
+ * @brief Subscript ( @c [] ) access to %map data.
400
+ * @param k The key for which data should be retrieved.
401
+ * @return A reference to the data of the (key,data) %pair.
402
+ *
403
+ * Allows for easy lookup with the subscript ( @c [] )
404
+ * operator. Returns data associated with the key specified in
405
+ * subscript. If the key does not exist, a pair with that key
406
+ * is created using default values, which is then returned.
407
+ *
408
+ * Lookup requires logarithmic time.
409
+ */
410
+ mapped_type&
411
+ operator[](const key_type& __k)
412
+ {
413
+ // concept requirements
414
+ __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
415
+
416
+ iterator __i = lower_bound(__k);
417
+ // __i->first is greater than or equivalent to __k.
418
+ if (__i == end() || key_comp()(__k, (*__i).first))
419
+ __i = insert(__i, value_type(__k, mapped_type()));
420
+ return (*__i).second;
421
+ }
422
+
423
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
424
+ // DR 464. Suggestion for new member functions in standard containers.
425
+ /**
426
+ * @brief Access to %map data.
427
+ * @param k The key for which data should be retrieved.
428
+ * @return A reference to the data whose key is equivalent to @a k, if
429
+ * such a data is present in the %map.
430
+ * @throw std::out_of_range If no such data is present.
431
+ */
432
+ mapped_type&
433
+ at(const key_type& __k)
434
+ {
435
+ iterator __i = lower_bound(__k);
436
+ if (__i == end() || key_comp()(__k, (*__i).first))
437
+ __throw_out_of_range(__N("map::at"));
438
+ return (*__i).second;
439
+ }
440
+
441
+ const mapped_type&
442
+ at(const key_type& __k) const
443
+ {
444
+ const_iterator __i = lower_bound(__k);
445
+ if (__i == end() || key_comp()(__k, (*__i).first))
446
+ __throw_out_of_range(__N("map::at"));
447
+ return (*__i).second;
448
+ }
449
+
450
+ // modifiers
451
+ /**
452
+ * @brief Attempts to insert a std::pair into the %map.
453
+
454
+ * @param x Pair to be inserted (see std::make_pair for easy creation
455
+ * of pairs).
456
+
457
+ * @return A pair, of which the first element is an iterator that
458
+ * points to the possibly inserted pair, and the second is
459
+ * a bool that is true if the pair was actually inserted.
460
+ *
461
+ * This function attempts to insert a (key, value) %pair into the %map.
462
+ * A %map relies on unique keys and thus a %pair is only inserted if its
463
+ * first element (the key) is not already present in the %map.
464
+ *
465
+ * Insertion requires logarithmic time.
466
+ */
467
+ std::pair<iterator, bool>
468
+ insert(const value_type& __x)
469
+ { return _M_t._M_insert_unique(__x); }
470
+
471
+ /**
472
+ * @brief Attempts to insert a std::pair into the %map.
473
+ * @param position An iterator that serves as a hint as to where the
474
+ * pair should be inserted.
475
+ * @param x Pair to be inserted (see std::make_pair for easy creation
476
+ * of pairs).
477
+ * @return An iterator that points to the element with key of @a x (may
478
+ * or may not be the %pair passed in).
479
+ *
480
+
481
+ * This function is not concerned about whether the insertion
482
+ * took place, and thus does not return a boolean like the
483
+ * single-argument insert() does. Note that the first
484
+ * parameter is only a hint and can potentially improve the
485
+ * performance of the insertion process. A bad hint would
486
+ * cause no gains in efficiency.
487
+ *
488
+ * See
489
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
490
+ * for more on "hinting".
491
+ *
492
+ * Insertion requires logarithmic time (if the hint is not taken).
493
+ */
494
+ iterator
495
+ insert(iterator __position, const value_type& __x)
496
+ { return _M_t._M_insert_unique_(__position, __x); }
497
+
498
+ /**
499
+ * @brief Template function that attempts to insert a range of elements.
500
+ * @param first Iterator pointing to the start of the range to be
501
+ * inserted.
502
+ * @param last Iterator pointing to the end of the range.
503
+ *
504
+ * Complexity similar to that of the range constructor.
505
+ */
506
+ template<typename _InputIterator>
507
+ void
508
+ insert(_InputIterator __first, _InputIterator __last)
509
+ { _M_t._M_insert_unique(__first, __last); }
510
+
511
+ /**
512
+ * @brief Erases an element from a %map.
513
+ * @param position An iterator pointing to the element to be erased.
514
+ *
515
+ * This function erases an element, pointed to by the given
516
+ * iterator, from a %map. Note that this function only erases
517
+ * the element, and that if the element is itself a pointer,
518
+ * the pointed-to memory is not touched in any way. Managing
519
+ * the pointer is the user's responsibility.
520
+ */
521
+ void
522
+ erase(iterator __position)
523
+ { _M_t.erase(__position); }
524
+
525
+ /**
526
+ * @brief Erases elements according to the provided key.
527
+ * @param x Key of element to be erased.
528
+ * @return The number of elements erased.
529
+ *
530
+ * This function erases all the elements located by the given key from
531
+ * a %map.
532
+ * Note that this function only erases the element, and that if
533
+ * the element is itself a pointer, the pointed-to memory is not touched
534
+ * in any way. Managing the pointer is the user's responsibility.
535
+ */
536
+ size_type
537
+ erase(const key_type& __x)
538
+ { return _M_t.erase(__x); }
539
+
540
+ /**
541
+ * @brief Erases a [first,last) range of elements from a %map.
542
+ * @param first Iterator pointing to the start of the range to be
543
+ * erased.
544
+ * @param last Iterator pointing to the end of the range to be erased.
545
+ *
546
+ * This function erases a sequence of elements from a %map.
547
+ * Note that this function only erases the element, and that if
548
+ * the element is itself a pointer, the pointed-to memory is not touched
549
+ * in any way. Managing the pointer is the user's responsibility.
550
+ */
551
+ void
552
+ erase(iterator __first, iterator __last)
553
+ { _M_t.erase(__first, __last); }
554
+
555
+ /**
556
+ * @brief Swaps data with another %map.
557
+ * @param x A %map of the same element and allocator types.
558
+ *
559
+ * This exchanges the elements between two maps in constant
560
+ * time. (It is only swapping a pointer, an integer, and an
561
+ * instance of the @c Compare type (which itself is often
562
+ * stateless and empty), so it should be quite fast.) Note
563
+ * that the global std::swap() function is specialized such
564
+ * that std::swap(m1,m2) will feed to this function.
565
+ */
566
+ void
567
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
568
+ swap(map&& __x)
569
+ #else
570
+ swap(map& __x)
571
+ #endif
572
+ { _M_t.swap(__x._M_t); }
573
+
574
+ /**
575
+ * Erases all elements in a %map. Note that this function only
576
+ * erases the elements, and that if the elements themselves are
577
+ * pointers, the pointed-to memory is not touched in any way.
578
+ * Managing the pointer is the user's responsibility.
579
+ */
580
+ void
581
+ clear()
582
+ { _M_t.clear(); }
583
+
584
+ // observers
585
+ /**
586
+ * Returns the key comparison object out of which the %map was
587
+ * constructed.
588
+ */
589
+ key_compare
590
+ key_comp() const
591
+ { return _M_t.key_comp(); }
592
+
593
+ /**
594
+ * Returns a value comparison object, built from the key comparison
595
+ * object out of which the %map was constructed.
596
+ */
597
+ value_compare
598
+ value_comp() const
599
+ { return value_compare(_M_t.key_comp()); }
600
+
601
+ // [23.3.1.3] map operations
602
+ /**
603
+ * @brief Tries to locate an element in a %map.
604
+ * @param x Key of (key, value) %pair to be located.
605
+ * @return Iterator pointing to sought-after element, or end() if not
606
+ * found.
607
+ *
608
+ * This function takes a key and tries to locate the element with which
609
+ * the key matches. If successful the function returns an iterator
610
+ * pointing to the sought after %pair. If unsuccessful it returns the
611
+ * past-the-end ( @c end() ) iterator.
612
+ */
613
+ iterator
614
+ find(const key_type& __x)
615
+ { return _M_t.find(__x); }
616
+
617
+ /**
618
+ * @brief Tries to locate an element in a %map.
619
+ * @param x Key of (key, value) %pair to be located.
620
+ * @return Read-only (constant) iterator pointing to sought-after
621
+ * element, or end() if not found.
622
+ *
623
+ * This function takes a key and tries to locate the element with which
624
+ * the key matches. If successful the function returns a constant
625
+ * iterator pointing to the sought after %pair. If unsuccessful it
626
+ * returns the past-the-end ( @c end() ) iterator.
627
+ */
628
+ const_iterator
629
+ find(const key_type& __x) const
630
+ { return _M_t.find(__x); }
631
+
632
+ /**
633
+ * @brief Finds the number of elements with given key.
634
+ * @param x Key of (key, value) pairs to be located.
635
+ * @return Number of elements with specified key.
636
+ *
637
+ * This function only makes sense for multimaps; for map the result will
638
+ * either be 0 (not present) or 1 (present).
639
+ */
640
+ size_type
641
+ count(const key_type& __x) const
642
+ { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
643
+
644
+ /**
645
+ * @brief Finds the beginning of a subsequence matching given key.
646
+ * @param x Key of (key, value) pair to be located.
647
+ * @return Iterator pointing to first element equal to or greater
648
+ * than key, or end().
649
+ *
650
+ * This function returns the first element of a subsequence of elements
651
+ * that matches the given key. If unsuccessful it returns an iterator
652
+ * pointing to the first element that has a greater value than given key
653
+ * or end() if no such element exists.
654
+ */
655
+ iterator
656
+ lower_bound(const key_type& __x)
657
+ { return _M_t.lower_bound(__x); }
658
+
659
+ /**
660
+ * @brief Finds the beginning of a subsequence matching given key.
661
+ * @param x Key of (key, value) pair to be located.
662
+ * @return Read-only (constant) iterator pointing to first element
663
+ * equal to or greater than key, or end().
664
+ *
665
+ * This function returns the first element of a subsequence of elements
666
+ * that matches the given key. If unsuccessful it returns an iterator
667
+ * pointing to the first element that has a greater value than given key
668
+ * or end() if no such element exists.
669
+ */
670
+ const_iterator
671
+ lower_bound(const key_type& __x) const
672
+ { return _M_t.lower_bound(__x); }
673
+
674
+ /**
675
+ * @brief Finds the end of a subsequence matching given key.
676
+ * @param x Key of (key, value) pair to be located.
677
+ * @return Iterator pointing to the first element
678
+ * greater than key, or end().
679
+ */
680
+ iterator
681
+ upper_bound(const key_type& __x)
682
+ { return _M_t.upper_bound(__x); }
683
+
684
+ /**
685
+ * @brief Finds the end of a subsequence matching given key.
686
+ * @param x Key of (key, value) pair to be located.
687
+ * @return Read-only (constant) iterator pointing to first iterator
688
+ * greater than key, or end().
689
+ */
690
+ const_iterator
691
+ upper_bound(const key_type& __x) const
692
+ { return _M_t.upper_bound(__x); }
693
+
694
+ /**
695
+ * @brief Finds a subsequence matching given key.
696
+ * @param x Key of (key, value) pairs to be located.
697
+ * @return Pair of iterators that possibly points to the subsequence
698
+ * matching given key.
699
+ *
700
+ * This function is equivalent to
701
+ * @code
702
+ * std::make_pair(c.lower_bound(val),
703
+ * c.upper_bound(val))
704
+ * @endcode
705
+ * (but is faster than making the calls separately).
706
+ *
707
+ * This function probably only makes sense for multimaps.
708
+ */
709
+ std::pair<iterator, iterator>
710
+ equal_range(const key_type& __x)
711
+ { return _M_t.equal_range(__x); }
712
+
713
+ /**
714
+ * @brief Finds a subsequence matching given key.
715
+ * @param x Key of (key, value) pairs to be located.
716
+ * @return Pair of read-only (constant) iterators that possibly points
717
+ * to the subsequence matching given key.
718
+ *
719
+ * This function is equivalent to
720
+ * @code
721
+ * std::make_pair(c.lower_bound(val),
722
+ * c.upper_bound(val))
723
+ * @endcode
724
+ * (but is faster than making the calls separately).
725
+ *
726
+ * This function probably only makes sense for multimaps.
727
+ */
728
+ std::pair<const_iterator, const_iterator>
729
+ equal_range(const key_type& __x) const
730
+ { return _M_t.equal_range(__x); }
731
+
732
+ template<typename _K1, typename _T1, typename _C1, typename _A1>
733
+ friend bool
734
+ operator==(const map<_K1, _T1, _C1, _A1>&,
735
+ const map<_K1, _T1, _C1, _A1>&);
736
+
737
+ template<typename _K1, typename _T1, typename _C1, typename _A1>
738
+ friend bool
739
+ operator<(const map<_K1, _T1, _C1, _A1>&,
740
+ const map<_K1, _T1, _C1, _A1>&);
741
+ };
742
+
743
+ /**
744
+ * @brief Map equality comparison.
745
+ * @param x A %map.
746
+ * @param y A %map of the same type as @a x.
747
+ * @return True iff the size and elements of the maps are equal.
748
+ *
749
+ * This is an equivalence relation. It is linear in the size of the
750
+ * maps. Maps are considered equivalent if their sizes are equal,
751
+ * and if corresponding elements compare equal.
752
+ */
753
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
754
+ inline bool
755
+ operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
756
+ const map<_Key, _Tp, _Compare, _Alloc>& __y)
757
+ { return __x._M_t == __y._M_t; }
758
+
759
+ /**
760
+ * @brief Map ordering relation.
761
+ * @param x A %map.
762
+ * @param y A %map of the same type as @a x.
763
+ * @return True iff @a x is lexicographically less than @a y.
764
+ *
765
+ * This is a total ordering relation. It is linear in the size of the
766
+ * maps. The elements must be comparable with @c <.
767
+ *
768
+ * See std::lexicographical_compare() for how the determination is made.
769
+ */
770
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
771
+ inline bool
772
+ operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
773
+ const map<_Key, _Tp, _Compare, _Alloc>& __y)
774
+ { return __x._M_t < __y._M_t; }
775
+
776
+ /// Based on operator==
777
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
778
+ inline bool
779
+ operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
780
+ const map<_Key, _Tp, _Compare, _Alloc>& __y)
781
+ { return !(__x == __y); }
782
+
783
+ /// Based on operator<
784
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
785
+ inline bool
786
+ operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x,
787
+ const map<_Key, _Tp, _Compare, _Alloc>& __y)
788
+ { return __y < __x; }
789
+
790
+ /// Based on operator<
791
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
792
+ inline bool
793
+ operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
794
+ const map<_Key, _Tp, _Compare, _Alloc>& __y)
795
+ { return !(__y < __x); }
796
+
797
+ /// Based on operator<
798
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
799
+ inline bool
800
+ operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
801
+ const map<_Key, _Tp, _Compare, _Alloc>& __y)
802
+ { return !(__x < __y); }
803
+
804
+ /// See std::map::swap().
805
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
806
+ inline void
807
+ swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
808
+ map<_Key, _Tp, _Compare, _Alloc>& __y)
809
+ { __x.swap(__y); }
810
+
811
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
812
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
813
+ inline void
814
+ swap(map<_Key, _Tp, _Compare, _Alloc>&& __x,
815
+ map<_Key, _Tp, _Compare, _Alloc>& __y)
816
+ { __x.swap(__y); }
817
+
818
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
819
+ inline void
820
+ swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
821
+ map<_Key, _Tp, _Compare, _Alloc>&& __y)
822
+ { __x.swap(__y); }
823
+ #endif
824
+
825
+ _GLIBCXX_END_NESTED_NAMESPACE
826
+
827
+ #endif /* _STL_MAP_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_move.h ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Move, forward and identity for C++0x + swap -*- C++ -*-
2
+
3
+ // Copyright (C) 2007 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file stl_move.h
31
+ * This is an internal header file, included by other library headers.
32
+ * You should not attempt to use it directly.
33
+ */
34
+
35
+ #ifndef _STL_MOVE_H
36
+ #define _STL_MOVE_H 1
37
+
38
+ #include <bits/c++config.h>
39
+ #include <bits/concept_check.h>
40
+
41
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
42
+ #include <type_traits>
43
+
44
+ _GLIBCXX_BEGIN_NAMESPACE(std)
45
+
46
+ // 20.2.2, forward/move
47
+ template<typename _Tp>
48
+ struct identity
49
+ {
50
+ typedef _Tp type;
51
+ };
52
+
53
+ template<typename _Tp>
54
+ inline _Tp&&
55
+ forward(typename std::identity<_Tp>::type&& __t)
56
+ { return __t; }
57
+
58
+ template<typename _Tp>
59
+ inline typename std::remove_reference<_Tp>::type&&
60
+ move(_Tp&& __t)
61
+ { return __t; }
62
+
63
+ _GLIBCXX_END_NAMESPACE
64
+
65
+ #define _GLIBCXX_MOVE(_Tp) std::move(_Tp)
66
+ #else
67
+ #define _GLIBCXX_MOVE(_Tp) (_Tp)
68
+ #endif
69
+
70
+ _GLIBCXX_BEGIN_NAMESPACE(std)
71
+
72
+ /**
73
+ * @brief Swaps two values.
74
+ * @param a A thing of arbitrary type.
75
+ * @param b Another thing of arbitrary type.
76
+ * @return Nothing.
77
+ */
78
+ template<typename _Tp>
79
+ inline void
80
+ swap(_Tp& __a, _Tp& __b)
81
+ {
82
+ // concept requirements
83
+ __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
84
+
85
+ _Tp __tmp = _GLIBCXX_MOVE(__a);
86
+ __a = _GLIBCXX_MOVE(__b);
87
+ __b = _GLIBCXX_MOVE(__tmp);
88
+ }
89
+
90
+ _GLIBCXX_END_NAMESPACE
91
+
92
+ #endif /* _STL_MOVE_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_multimap.h ADDED
@@ -0,0 +1,757 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Multimap implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_multimap.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_MULTIMAP_H
63
+ #define _STL_MULTIMAP_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+
67
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
68
+
69
+ /**
70
+ * @brief A standard container made up of (key,value) pairs, which can be
71
+ * retrieved based on a key, in logarithmic time.
72
+ *
73
+ * @ingroup Containers
74
+ * @ingroup Assoc_containers
75
+ *
76
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
77
+ * <a href="tables.html#66">reversible container</a>, and an
78
+ * <a href="tables.html#69">associative container</a> (using equivalent
79
+ * keys). For a @c multimap<Key,T> the key_type is Key, the mapped_type
80
+ * is T, and the value_type is std::pair<const Key,T>.
81
+ *
82
+ * Multimaps support bidirectional iterators.
83
+ *
84
+ * The private tree data is declared exactly the same way for map and
85
+ * multimap; the distinction is made entirely in how the tree functions are
86
+ * called (*_unique versus *_equal, same as the standard).
87
+ */
88
+ template <typename _Key, typename _Tp,
89
+ typename _Compare = std::less<_Key>,
90
+ typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
91
+ class multimap
92
+ {
93
+ public:
94
+ typedef _Key key_type;
95
+ typedef _Tp mapped_type;
96
+ typedef std::pair<const _Key, _Tp> value_type;
97
+ typedef _Compare key_compare;
98
+ typedef _Alloc allocator_type;
99
+
100
+ private:
101
+ // concept requirements
102
+ typedef typename _Alloc::value_type _Alloc_value_type;
103
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
104
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
105
+ _BinaryFunctionConcept)
106
+ __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
107
+
108
+ public:
109
+ class value_compare
110
+ : public std::binary_function<value_type, value_type, bool>
111
+ {
112
+ friend class multimap<_Key, _Tp, _Compare, _Alloc>;
113
+ protected:
114
+ _Compare comp;
115
+
116
+ value_compare(_Compare __c)
117
+ : comp(__c) { }
118
+
119
+ public:
120
+ bool operator()(const value_type& __x, const value_type& __y) const
121
+ { return comp(__x.first, __y.first); }
122
+ };
123
+
124
+ private:
125
+ /// This turns a red-black tree into a [multi]map.
126
+ typedef typename _Alloc::template rebind<value_type>::other
127
+ _Pair_alloc_type;
128
+
129
+ typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
130
+ key_compare, _Pair_alloc_type> _Rep_type;
131
+ /// The actual tree structure.
132
+ _Rep_type _M_t;
133
+
134
+ public:
135
+ // many of these are specified differently in ISO, but the following are
136
+ // "functionally equivalent"
137
+ typedef typename _Pair_alloc_type::pointer pointer;
138
+ typedef typename _Pair_alloc_type::const_pointer const_pointer;
139
+ typedef typename _Pair_alloc_type::reference reference;
140
+ typedef typename _Pair_alloc_type::const_reference const_reference;
141
+ typedef typename _Rep_type::iterator iterator;
142
+ typedef typename _Rep_type::const_iterator const_iterator;
143
+ typedef typename _Rep_type::size_type size_type;
144
+ typedef typename _Rep_type::difference_type difference_type;
145
+ typedef typename _Rep_type::reverse_iterator reverse_iterator;
146
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
147
+
148
+ // [23.3.2] construct/copy/destroy
149
+ // (get_allocator() is also listed in this section)
150
+ /**
151
+ * @brief Default constructor creates no elements.
152
+ */
153
+ multimap()
154
+ : _M_t() { }
155
+
156
+ /**
157
+ * @brief Creates a %multimap with no elements.
158
+ * @param comp A comparison object.
159
+ * @param a An allocator object.
160
+ */
161
+ explicit
162
+ multimap(const _Compare& __comp,
163
+ const allocator_type& __a = allocator_type())
164
+ : _M_t(__comp, __a) { }
165
+
166
+ /**
167
+ * @brief %Multimap copy constructor.
168
+ * @param x A %multimap of identical element and allocator types.
169
+ *
170
+ * The newly-created %multimap uses a copy of the allocation object
171
+ * used by @a x.
172
+ */
173
+ multimap(const multimap& __x)
174
+ : _M_t(__x._M_t) { }
175
+
176
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
177
+ /**
178
+ * @brief %Multimap move constructor.
179
+ * @param x A %multimap of identical element and allocator types.
180
+ *
181
+ * The newly-created %multimap contains the exact contents of @a x.
182
+ * The contents of @a x are a valid, but unspecified %multimap.
183
+ */
184
+ multimap(multimap&& __x)
185
+ : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
186
+ #endif
187
+
188
+ /**
189
+ * @brief Builds a %multimap from a range.
190
+ * @param first An input iterator.
191
+ * @param last An input iterator.
192
+ *
193
+ * Create a %multimap consisting of copies of the elements from
194
+ * [first,last). This is linear in N if the range is already sorted,
195
+ * and NlogN otherwise (where N is distance(first,last)).
196
+ */
197
+ template<typename _InputIterator>
198
+ multimap(_InputIterator __first, _InputIterator __last)
199
+ : _M_t()
200
+ { _M_t._M_insert_equal(__first, __last); }
201
+
202
+ /**
203
+ * @brief Builds a %multimap from a range.
204
+ * @param first An input iterator.
205
+ * @param last An input iterator.
206
+ * @param comp A comparison functor.
207
+ * @param a An allocator object.
208
+ *
209
+ * Create a %multimap consisting of copies of the elements from
210
+ * [first,last). This is linear in N if the range is already sorted,
211
+ * and NlogN otherwise (where N is distance(first,last)).
212
+ */
213
+ template<typename _InputIterator>
214
+ multimap(_InputIterator __first, _InputIterator __last,
215
+ const _Compare& __comp,
216
+ const allocator_type& __a = allocator_type())
217
+ : _M_t(__comp, __a)
218
+ { _M_t._M_insert_equal(__first, __last); }
219
+
220
+ // FIXME There is no dtor declared, but we should have something generated
221
+ // by Doxygen. I don't know what tags to add to this paragraph to make
222
+ // that happen:
223
+ /**
224
+ * The dtor only erases the elements, and note that if the elements
225
+ * themselves are pointers, the pointed-to memory is not touched in any
226
+ * way. Managing the pointer is the user's responsibility.
227
+ */
228
+
229
+ /**
230
+ * @brief %Multimap assignment operator.
231
+ * @param x A %multimap of identical element and allocator types.
232
+ *
233
+ * All the elements of @a x are copied, but unlike the copy constructor,
234
+ * the allocator object is not copied.
235
+ */
236
+ multimap&
237
+ operator=(const multimap& __x)
238
+ {
239
+ _M_t = __x._M_t;
240
+ return *this;
241
+ }
242
+
243
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
244
+ /**
245
+ * @brief %Multimap move assignment operator.
246
+ * @param x A %multimap of identical element and allocator types.
247
+ *
248
+ * The contents of @a x are moved into this multimap (without copying).
249
+ * @a x is a valid, but unspecified multimap.
250
+ */
251
+ multimap&
252
+ operator=(multimap&& __x)
253
+ {
254
+ // NB: DR 675.
255
+ this->clear();
256
+ this->swap(__x);
257
+ return *this;
258
+ }
259
+ #endif
260
+
261
+ /// Get a copy of the memory allocation object.
262
+ allocator_type
263
+ get_allocator() const
264
+ { return _M_t.get_allocator(); }
265
+
266
+ // iterators
267
+ /**
268
+ * Returns a read/write iterator that points to the first pair in the
269
+ * %multimap. Iteration is done in ascending order according to the
270
+ * keys.
271
+ */
272
+ iterator
273
+ begin()
274
+ { return _M_t.begin(); }
275
+
276
+ /**
277
+ * Returns a read-only (constant) iterator that points to the first pair
278
+ * in the %multimap. Iteration is done in ascending order according to
279
+ * the keys.
280
+ */
281
+ const_iterator
282
+ begin() const
283
+ { return _M_t.begin(); }
284
+
285
+ /**
286
+ * Returns a read/write iterator that points one past the last pair in
287
+ * the %multimap. Iteration is done in ascending order according to the
288
+ * keys.
289
+ */
290
+ iterator
291
+ end()
292
+ { return _M_t.end(); }
293
+
294
+ /**
295
+ * Returns a read-only (constant) iterator that points one past the last
296
+ * pair in the %multimap. Iteration is done in ascending order according
297
+ * to the keys.
298
+ */
299
+ const_iterator
300
+ end() const
301
+ { return _M_t.end(); }
302
+
303
+ /**
304
+ * Returns a read/write reverse iterator that points to the last pair in
305
+ * the %multimap. Iteration is done in descending order according to the
306
+ * keys.
307
+ */
308
+ reverse_iterator
309
+ rbegin()
310
+ { return _M_t.rbegin(); }
311
+
312
+ /**
313
+ * Returns a read-only (constant) reverse iterator that points to the
314
+ * last pair in the %multimap. Iteration is done in descending order
315
+ * according to the keys.
316
+ */
317
+ const_reverse_iterator
318
+ rbegin() const
319
+ { return _M_t.rbegin(); }
320
+
321
+ /**
322
+ * Returns a read/write reverse iterator that points to one before the
323
+ * first pair in the %multimap. Iteration is done in descending order
324
+ * according to the keys.
325
+ */
326
+ reverse_iterator
327
+ rend()
328
+ { return _M_t.rend(); }
329
+
330
+ /**
331
+ * Returns a read-only (constant) reverse iterator that points to one
332
+ * before the first pair in the %multimap. Iteration is done in
333
+ * descending order according to the keys.
334
+ */
335
+ const_reverse_iterator
336
+ rend() const
337
+ { return _M_t.rend(); }
338
+
339
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
340
+ /**
341
+ * Returns a read-only (constant) iterator that points to the first pair
342
+ * in the %multimap. Iteration is done in ascending order according to
343
+ * the keys.
344
+ */
345
+ const_iterator
346
+ cbegin() const
347
+ { return _M_t.begin(); }
348
+
349
+ /**
350
+ * Returns a read-only (constant) iterator that points one past the last
351
+ * pair in the %multimap. Iteration is done in ascending order according
352
+ * to the keys.
353
+ */
354
+ const_iterator
355
+ cend() const
356
+ { return _M_t.end(); }
357
+
358
+ /**
359
+ * Returns a read-only (constant) reverse iterator that points to the
360
+ * last pair in the %multimap. Iteration is done in descending order
361
+ * according to the keys.
362
+ */
363
+ const_reverse_iterator
364
+ crbegin() const
365
+ { return _M_t.rbegin(); }
366
+
367
+ /**
368
+ * Returns a read-only (constant) reverse iterator that points to one
369
+ * before the first pair in the %multimap. Iteration is done in
370
+ * descending order according to the keys.
371
+ */
372
+ const_reverse_iterator
373
+ crend() const
374
+ { return _M_t.rend(); }
375
+ #endif
376
+
377
+ // capacity
378
+ /** Returns true if the %multimap is empty. */
379
+ bool
380
+ empty() const
381
+ { return _M_t.empty(); }
382
+
383
+ /** Returns the size of the %multimap. */
384
+ size_type
385
+ size() const
386
+ { return _M_t.size(); }
387
+
388
+ /** Returns the maximum size of the %multimap. */
389
+ size_type
390
+ max_size() const
391
+ { return _M_t.max_size(); }
392
+
393
+ // modifiers
394
+ /**
395
+ * @brief Inserts a std::pair into the %multimap.
396
+ * @param x Pair to be inserted (see std::make_pair for easy creation
397
+ * of pairs).
398
+ * @return An iterator that points to the inserted (key,value) pair.
399
+ *
400
+ * This function inserts a (key, value) pair into the %multimap.
401
+ * Contrary to a std::map the %multimap does not rely on unique keys and
402
+ * thus multiple pairs with the same key can be inserted.
403
+ *
404
+ * Insertion requires logarithmic time.
405
+ */
406
+ iterator
407
+ insert(const value_type& __x)
408
+ { return _M_t._M_insert_equal(__x); }
409
+
410
+ /**
411
+ * @brief Inserts a std::pair into the %multimap.
412
+ * @param position An iterator that serves as a hint as to where the
413
+ * pair should be inserted.
414
+ * @param x Pair to be inserted (see std::make_pair for easy creation
415
+ * of pairs).
416
+ * @return An iterator that points to the inserted (key,value) pair.
417
+ *
418
+ * This function inserts a (key, value) pair into the %multimap.
419
+ * Contrary to a std::map the %multimap does not rely on unique keys and
420
+ * thus multiple pairs with the same key can be inserted.
421
+ * Note that the first parameter is only a hint and can potentially
422
+ * improve the performance of the insertion process. A bad hint would
423
+ * cause no gains in efficiency.
424
+ *
425
+ * For more on "hinting," see:
426
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
427
+ *
428
+ * Insertion requires logarithmic time (if the hint is not taken).
429
+ */
430
+ iterator
431
+ insert(iterator __position, const value_type& __x)
432
+ { return _M_t._M_insert_equal_(__position, __x); }
433
+
434
+ /**
435
+ * @brief A template function that attempts to insert a range
436
+ * of elements.
437
+ * @param first Iterator pointing to the start of the range to be
438
+ * inserted.
439
+ * @param last Iterator pointing to the end of the range.
440
+ *
441
+ * Complexity similar to that of the range constructor.
442
+ */
443
+ template<typename _InputIterator>
444
+ void
445
+ insert(_InputIterator __first, _InputIterator __last)
446
+ { _M_t._M_insert_equal(__first, __last); }
447
+
448
+ /**
449
+ * @brief Erases an element from a %multimap.
450
+ * @param position An iterator pointing to the element to be erased.
451
+ *
452
+ * This function erases an element, pointed to by the given iterator,
453
+ * from a %multimap. Note that this function only erases the element,
454
+ * and that if the element is itself a pointer, the pointed-to memory is
455
+ * not touched in any way. Managing the pointer is the user's
456
+ * responsibility.
457
+ */
458
+ void
459
+ erase(iterator __position)
460
+ { _M_t.erase(__position); }
461
+
462
+ /**
463
+ * @brief Erases elements according to the provided key.
464
+ * @param x Key of element to be erased.
465
+ * @return The number of elements erased.
466
+ *
467
+ * This function erases all elements located by the given key from a
468
+ * %multimap.
469
+ * Note that this function only erases the element, and that if
470
+ * the element is itself a pointer, the pointed-to memory is not touched
471
+ * in any way. Managing the pointer is the user's responsibility.
472
+ */
473
+ size_type
474
+ erase(const key_type& __x)
475
+ { return _M_t.erase(__x); }
476
+
477
+ /**
478
+ * @brief Erases a [first,last) range of elements from a %multimap.
479
+ * @param first Iterator pointing to the start of the range to be
480
+ * erased.
481
+ * @param last Iterator pointing to the end of the range to be erased.
482
+ *
483
+ * This function erases a sequence of elements from a %multimap.
484
+ * Note that this function only erases the elements, and that if
485
+ * the elements themselves are pointers, the pointed-to memory is not
486
+ * touched in any way. Managing the pointer is the user's responsibility.
487
+ */
488
+ void
489
+ erase(iterator __first, iterator __last)
490
+ { _M_t.erase(__first, __last); }
491
+
492
+ /**
493
+ * @brief Swaps data with another %multimap.
494
+ * @param x A %multimap of the same element and allocator types.
495
+ *
496
+ * This exchanges the elements between two multimaps in constant time.
497
+ * (It is only swapping a pointer, an integer, and an instance of
498
+ * the @c Compare type (which itself is often stateless and empty), so it
499
+ * should be quite fast.)
500
+ * Note that the global std::swap() function is specialized such that
501
+ * std::swap(m1,m2) will feed to this function.
502
+ */
503
+ void
504
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
505
+ swap(multimap&& __x)
506
+ #else
507
+ swap(multimap& __x)
508
+ #endif
509
+ { _M_t.swap(__x._M_t); }
510
+
511
+ /**
512
+ * Erases all elements in a %multimap. Note that this function only
513
+ * erases the elements, and that if the elements themselves are pointers,
514
+ * the pointed-to memory is not touched in any way. Managing the pointer
515
+ * is the user's responsibility.
516
+ */
517
+ void
518
+ clear()
519
+ { _M_t.clear(); }
520
+
521
+ // observers
522
+ /**
523
+ * Returns the key comparison object out of which the %multimap
524
+ * was constructed.
525
+ */
526
+ key_compare
527
+ key_comp() const
528
+ { return _M_t.key_comp(); }
529
+
530
+ /**
531
+ * Returns a value comparison object, built from the key comparison
532
+ * object out of which the %multimap was constructed.
533
+ */
534
+ value_compare
535
+ value_comp() const
536
+ { return value_compare(_M_t.key_comp()); }
537
+
538
+ // multimap operations
539
+ /**
540
+ * @brief Tries to locate an element in a %multimap.
541
+ * @param x Key of (key, value) pair to be located.
542
+ * @return Iterator pointing to sought-after element,
543
+ * or end() if not found.
544
+ *
545
+ * This function takes a key and tries to locate the element with which
546
+ * the key matches. If successful the function returns an iterator
547
+ * pointing to the sought after %pair. If unsuccessful it returns the
548
+ * past-the-end ( @c end() ) iterator.
549
+ */
550
+ iterator
551
+ find(const key_type& __x)
552
+ { return _M_t.find(__x); }
553
+
554
+ /**
555
+ * @brief Tries to locate an element in a %multimap.
556
+ * @param x Key of (key, value) pair to be located.
557
+ * @return Read-only (constant) iterator pointing to sought-after
558
+ * element, or end() if not found.
559
+ *
560
+ * This function takes a key and tries to locate the element with which
561
+ * the key matches. If successful the function returns a constant
562
+ * iterator pointing to the sought after %pair. If unsuccessful it
563
+ * returns the past-the-end ( @c end() ) iterator.
564
+ */
565
+ const_iterator
566
+ find(const key_type& __x) const
567
+ { return _M_t.find(__x); }
568
+
569
+ /**
570
+ * @brief Finds the number of elements with given key.
571
+ * @param x Key of (key, value) pairs to be located.
572
+ * @return Number of elements with specified key.
573
+ */
574
+ size_type
575
+ count(const key_type& __x) const
576
+ { return _M_t.count(__x); }
577
+
578
+ /**
579
+ * @brief Finds the beginning of a subsequence matching given key.
580
+ * @param x Key of (key, value) pair to be located.
581
+ * @return Iterator pointing to first element equal to or greater
582
+ * than key, or end().
583
+ *
584
+ * This function returns the first element of a subsequence of elements
585
+ * that matches the given key. If unsuccessful it returns an iterator
586
+ * pointing to the first element that has a greater value than given key
587
+ * or end() if no such element exists.
588
+ */
589
+ iterator
590
+ lower_bound(const key_type& __x)
591
+ { return _M_t.lower_bound(__x); }
592
+
593
+ /**
594
+ * @brief Finds the beginning of a subsequence matching given key.
595
+ * @param x Key of (key, value) pair to be located.
596
+ * @return Read-only (constant) iterator pointing to first element
597
+ * equal to or greater than key, or end().
598
+ *
599
+ * This function returns the first element of a subsequence of elements
600
+ * that matches the given key. If unsuccessful the iterator will point
601
+ * to the next greatest element or, if no such greater element exists, to
602
+ * end().
603
+ */
604
+ const_iterator
605
+ lower_bound(const key_type& __x) const
606
+ { return _M_t.lower_bound(__x); }
607
+
608
+ /**
609
+ * @brief Finds the end of a subsequence matching given key.
610
+ * @param x Key of (key, value) pair to be located.
611
+ * @return Iterator pointing to the first element
612
+ * greater than key, or end().
613
+ */
614
+ iterator
615
+ upper_bound(const key_type& __x)
616
+ { return _M_t.upper_bound(__x); }
617
+
618
+ /**
619
+ * @brief Finds the end of a subsequence matching given key.
620
+ * @param x Key of (key, value) pair to be located.
621
+ * @return Read-only (constant) iterator pointing to first iterator
622
+ * greater than key, or end().
623
+ */
624
+ const_iterator
625
+ upper_bound(const key_type& __x) const
626
+ { return _M_t.upper_bound(__x); }
627
+
628
+ /**
629
+ * @brief Finds a subsequence matching given key.
630
+ * @param x Key of (key, value) pairs to be located.
631
+ * @return Pair of iterators that possibly points to the subsequence
632
+ * matching given key.
633
+ *
634
+ * This function is equivalent to
635
+ * @code
636
+ * std::make_pair(c.lower_bound(val),
637
+ * c.upper_bound(val))
638
+ * @endcode
639
+ * (but is faster than making the calls separately).
640
+ */
641
+ std::pair<iterator, iterator>
642
+ equal_range(const key_type& __x)
643
+ { return _M_t.equal_range(__x); }
644
+
645
+ /**
646
+ * @brief Finds a subsequence matching given key.
647
+ * @param x Key of (key, value) pairs to be located.
648
+ * @return Pair of read-only (constant) iterators that possibly points
649
+ * to the subsequence matching given key.
650
+ *
651
+ * This function is equivalent to
652
+ * @code
653
+ * std::make_pair(c.lower_bound(val),
654
+ * c.upper_bound(val))
655
+ * @endcode
656
+ * (but is faster than making the calls separately).
657
+ */
658
+ std::pair<const_iterator, const_iterator>
659
+ equal_range(const key_type& __x) const
660
+ { return _M_t.equal_range(__x); }
661
+
662
+ template<typename _K1, typename _T1, typename _C1, typename _A1>
663
+ friend bool
664
+ operator==(const multimap<_K1, _T1, _C1, _A1>&,
665
+ const multimap<_K1, _T1, _C1, _A1>&);
666
+
667
+ template<typename _K1, typename _T1, typename _C1, typename _A1>
668
+ friend bool
669
+ operator<(const multimap<_K1, _T1, _C1, _A1>&,
670
+ const multimap<_K1, _T1, _C1, _A1>&);
671
+ };
672
+
673
+ /**
674
+ * @brief Multimap equality comparison.
675
+ * @param x A %multimap.
676
+ * @param y A %multimap of the same type as @a x.
677
+ * @return True iff the size and elements of the maps are equal.
678
+ *
679
+ * This is an equivalence relation. It is linear in the size of the
680
+ * multimaps. Multimaps are considered equivalent if their sizes are equal,
681
+ * and if corresponding elements compare equal.
682
+ */
683
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
684
+ inline bool
685
+ operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
686
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
687
+ { return __x._M_t == __y._M_t; }
688
+
689
+ /**
690
+ * @brief Multimap ordering relation.
691
+ * @param x A %multimap.
692
+ * @param y A %multimap of the same type as @a x.
693
+ * @return True iff @a x is lexicographically less than @a y.
694
+ *
695
+ * This is a total ordering relation. It is linear in the size of the
696
+ * multimaps. The elements must be comparable with @c <.
697
+ *
698
+ * See std::lexicographical_compare() for how the determination is made.
699
+ */
700
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
701
+ inline bool
702
+ operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
703
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
704
+ { return __x._M_t < __y._M_t; }
705
+
706
+ /// Based on operator==
707
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
708
+ inline bool
709
+ operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
710
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
711
+ { return !(__x == __y); }
712
+
713
+ /// Based on operator<
714
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
715
+ inline bool
716
+ operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
717
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
718
+ { return __y < __x; }
719
+
720
+ /// Based on operator<
721
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
722
+ inline bool
723
+ operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
724
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
725
+ { return !(__y < __x); }
726
+
727
+ /// Based on operator<
728
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
729
+ inline bool
730
+ operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
731
+ const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
732
+ { return !(__x < __y); }
733
+
734
+ /// See std::multimap::swap().
735
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
736
+ inline void
737
+ swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
738
+ multimap<_Key, _Tp, _Compare, _Alloc>& __y)
739
+ { __x.swap(__y); }
740
+
741
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
742
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
743
+ inline void
744
+ swap(multimap<_Key, _Tp, _Compare, _Alloc>&& __x,
745
+ multimap<_Key, _Tp, _Compare, _Alloc>& __y)
746
+ { __x.swap(__y); }
747
+
748
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
749
+ inline void
750
+ swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
751
+ multimap<_Key, _Tp, _Compare, _Alloc>&& __y)
752
+ { __x.swap(__y); }
753
+ #endif
754
+
755
+ _GLIBCXX_END_NESTED_NAMESPACE
756
+
757
+ #endif /* _STL_MULTIMAP_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_multiset.h ADDED
@@ -0,0 +1,654 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Multiset implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_multiset.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_MULTISET_H
63
+ #define _STL_MULTISET_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+
67
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
68
+
69
+ /**
70
+ * @brief A standard container made up of elements, which can be retrieved
71
+ * in logarithmic time.
72
+ *
73
+ * @ingroup Containers
74
+ * @ingroup Assoc_containers
75
+ *
76
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
77
+ * <a href="tables.html#66">reversible container</a>, and an
78
+ * <a href="tables.html#69">associative container</a> (using equivalent
79
+ * keys). For a @c multiset<Key> the key_type and value_type are Key.
80
+ *
81
+ * Multisets support bidirectional iterators.
82
+ *
83
+ * The private tree data is declared exactly the same way for set and
84
+ * multiset; the distinction is made entirely in how the tree functions are
85
+ * called (*_unique versus *_equal, same as the standard).
86
+ */
87
+ template <typename _Key, typename _Compare = std::less<_Key>,
88
+ typename _Alloc = std::allocator<_Key> >
89
+ class multiset
90
+ {
91
+ // concept requirements
92
+ typedef typename _Alloc::value_type _Alloc_value_type;
93
+ __glibcxx_class_requires(_Key, _SGIAssignableConcept)
94
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
95
+ _BinaryFunctionConcept)
96
+ __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
97
+
98
+ public:
99
+ // typedefs:
100
+ typedef _Key key_type;
101
+ typedef _Key value_type;
102
+ typedef _Compare key_compare;
103
+ typedef _Compare value_compare;
104
+ typedef _Alloc allocator_type;
105
+
106
+ private:
107
+ /// This turns a red-black tree into a [multi]set.
108
+ typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
109
+
110
+ typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
111
+ key_compare, _Key_alloc_type> _Rep_type;
112
+ /// The actual tree structure.
113
+ _Rep_type _M_t;
114
+
115
+ public:
116
+ typedef typename _Key_alloc_type::pointer pointer;
117
+ typedef typename _Key_alloc_type::const_pointer const_pointer;
118
+ typedef typename _Key_alloc_type::reference reference;
119
+ typedef typename _Key_alloc_type::const_reference const_reference;
120
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
121
+ // DR 103. set::iterator is required to be modifiable,
122
+ // but this allows modification of keys.
123
+ typedef typename _Rep_type::const_iterator iterator;
124
+ typedef typename _Rep_type::const_iterator const_iterator;
125
+ typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
126
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
127
+ typedef typename _Rep_type::size_type size_type;
128
+ typedef typename _Rep_type::difference_type difference_type;
129
+
130
+ // allocation/deallocation
131
+ /**
132
+ * @brief Default constructor creates no elements.
133
+ */
134
+ multiset()
135
+ : _M_t() { }
136
+
137
+ /**
138
+ * @brief Creates a %multiset with no elements.
139
+ * @param comp Comparator to use.
140
+ * @param a An allocator object.
141
+ */
142
+ explicit
143
+ multiset(const _Compare& __comp,
144
+ const allocator_type& __a = allocator_type())
145
+ : _M_t(__comp, __a) { }
146
+
147
+ /**
148
+ * @brief Builds a %multiset from a range.
149
+ * @param first An input iterator.
150
+ * @param last An input iterator.
151
+ *
152
+ * Create a %multiset consisting of copies of the elements from
153
+ * [first,last). This is linear in N if the range is already sorted,
154
+ * and NlogN otherwise (where N is distance(first,last)).
155
+ */
156
+ template<typename _InputIterator>
157
+ multiset(_InputIterator __first, _InputIterator __last)
158
+ : _M_t()
159
+ { _M_t._M_insert_equal(__first, __last); }
160
+
161
+ /**
162
+ * @brief Builds a %multiset from a range.
163
+ * @param first An input iterator.
164
+ * @param last An input iterator.
165
+ * @param comp A comparison functor.
166
+ * @param a An allocator object.
167
+ *
168
+ * Create a %multiset consisting of copies of the elements from
169
+ * [first,last). This is linear in N if the range is already sorted,
170
+ * and NlogN otherwise (where N is distance(first,last)).
171
+ */
172
+ template<typename _InputIterator>
173
+ multiset(_InputIterator __first, _InputIterator __last,
174
+ const _Compare& __comp,
175
+ const allocator_type& __a = allocator_type())
176
+ : _M_t(__comp, __a)
177
+ { _M_t._M_insert_equal(__first, __last); }
178
+
179
+ /**
180
+ * @brief %Multiset copy constructor.
181
+ * @param x A %multiset of identical element and allocator types.
182
+ *
183
+ * The newly-created %multiset uses a copy of the allocation object used
184
+ * by @a x.
185
+ */
186
+ multiset(const multiset& __x)
187
+ : _M_t(__x._M_t) { }
188
+
189
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
190
+ /**
191
+ * @brief %Multiset move constructor.
192
+ * @param x A %multiset of identical element and allocator types.
193
+ *
194
+ * The newly-created %multiset contains the exact contents of @a x.
195
+ * The contents of @a x are a valid, but unspecified %multiset.
196
+ */
197
+ multiset(multiset&& __x)
198
+ : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
199
+ #endif
200
+
201
+ /**
202
+ * @brief %Multiset assignment operator.
203
+ * @param x A %multiset of identical element and allocator types.
204
+ *
205
+ * All the elements of @a x are copied, but unlike the copy constructor,
206
+ * the allocator object is not copied.
207
+ */
208
+ multiset&
209
+ operator=(const multiset& __x)
210
+ {
211
+ _M_t = __x._M_t;
212
+ return *this;
213
+ }
214
+
215
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
216
+ /**
217
+ * @brief %Multiset move assignment operator.
218
+ * @param x A %multiset of identical element and allocator types.
219
+ *
220
+ * The contents of @a x are moved into this %multiset (without copying).
221
+ * @a x is a valid, but unspecified %multiset.
222
+ */
223
+ multiset&
224
+ operator=(multiset&& __x)
225
+ {
226
+ // NB: DR 675.
227
+ this->clear();
228
+ this->swap(__x);
229
+ return *this;
230
+ }
231
+ #endif
232
+
233
+ // accessors:
234
+
235
+ /// Returns the comparison object.
236
+ key_compare
237
+ key_comp() const
238
+ { return _M_t.key_comp(); }
239
+ /// Returns the comparison object.
240
+ value_compare
241
+ value_comp() const
242
+ { return _M_t.key_comp(); }
243
+ /// Returns the memory allocation object.
244
+ allocator_type
245
+ get_allocator() const
246
+ { return _M_t.get_allocator(); }
247
+
248
+ /**
249
+ * Returns a read-only (constant) iterator that points to the first
250
+ * element in the %multiset. Iteration is done in ascending order
251
+ * according to the keys.
252
+ */
253
+ iterator
254
+ begin() const
255
+ { return _M_t.begin(); }
256
+
257
+ /**
258
+ * Returns a read-only (constant) iterator that points one past the last
259
+ * element in the %multiset. Iteration is done in ascending order
260
+ * according to the keys.
261
+ */
262
+ iterator
263
+ end() const
264
+ { return _M_t.end(); }
265
+
266
+ /**
267
+ * Returns a read-only (constant) reverse iterator that points to the
268
+ * last element in the %multiset. Iteration is done in descending order
269
+ * according to the keys.
270
+ */
271
+ reverse_iterator
272
+ rbegin() const
273
+ { return _M_t.rbegin(); }
274
+
275
+ /**
276
+ * Returns a read-only (constant) reverse iterator that points to the
277
+ * last element in the %multiset. Iteration is done in descending order
278
+ * according to the keys.
279
+ */
280
+ reverse_iterator
281
+ rend() const
282
+ { return _M_t.rend(); }
283
+
284
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
285
+ /**
286
+ * Returns a read-only (constant) iterator that points to the first
287
+ * element in the %multiset. Iteration is done in ascending order
288
+ * according to the keys.
289
+ */
290
+ iterator
291
+ cbegin() const
292
+ { return _M_t.begin(); }
293
+
294
+ /**
295
+ * Returns a read-only (constant) iterator that points one past the last
296
+ * element in the %multiset. Iteration is done in ascending order
297
+ * according to the keys.
298
+ */
299
+ iterator
300
+ cend() const
301
+ { return _M_t.end(); }
302
+
303
+ /**
304
+ * Returns a read-only (constant) reverse iterator that points to the
305
+ * last element in the %multiset. Iteration is done in descending order
306
+ * according to the keys.
307
+ */
308
+ reverse_iterator
309
+ crbegin() const
310
+ { return _M_t.rbegin(); }
311
+
312
+ /**
313
+ * Returns a read-only (constant) reverse iterator that points to the
314
+ * last element in the %multiset. Iteration is done in descending order
315
+ * according to the keys.
316
+ */
317
+ reverse_iterator
318
+ crend() const
319
+ { return _M_t.rend(); }
320
+ #endif
321
+
322
+ /// Returns true if the %set is empty.
323
+ bool
324
+ empty() const
325
+ { return _M_t.empty(); }
326
+
327
+ /// Returns the size of the %set.
328
+ size_type
329
+ size() const
330
+ { return _M_t.size(); }
331
+
332
+ /// Returns the maximum size of the %set.
333
+ size_type
334
+ max_size() const
335
+ { return _M_t.max_size(); }
336
+
337
+ /**
338
+ * @brief Swaps data with another %multiset.
339
+ * @param x A %multiset of the same element and allocator types.
340
+ *
341
+ * This exchanges the elements between two multisets in constant time.
342
+ * (It is only swapping a pointer, an integer, and an instance of the @c
343
+ * Compare type (which itself is often stateless and empty), so it should
344
+ * be quite fast.)
345
+ * Note that the global std::swap() function is specialized such that
346
+ * std::swap(s1,s2) will feed to this function.
347
+ */
348
+ void
349
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
350
+ swap(multiset&& __x)
351
+ #else
352
+ swap(multiset& __x)
353
+ #endif
354
+ { _M_t.swap(__x._M_t); }
355
+
356
+ // insert/erase
357
+ /**
358
+ * @brief Inserts an element into the %multiset.
359
+ * @param x Element to be inserted.
360
+ * @return An iterator that points to the inserted element.
361
+ *
362
+ * This function inserts an element into the %multiset. Contrary
363
+ * to a std::set the %multiset does not rely on unique keys and thus
364
+ * multiple copies of the same element can be inserted.
365
+ *
366
+ * Insertion requires logarithmic time.
367
+ */
368
+ iterator
369
+ insert(const value_type& __x)
370
+ { return _M_t._M_insert_equal(__x); }
371
+
372
+ /**
373
+ * @brief Inserts an element into the %multiset.
374
+ * @param position An iterator that serves as a hint as to where the
375
+ * element should be inserted.
376
+ * @param x Element to be inserted.
377
+ * @return An iterator that points to the inserted element.
378
+ *
379
+ * This function inserts an element into the %multiset. Contrary
380
+ * to a std::set the %multiset does not rely on unique keys and thus
381
+ * multiple copies of the same element can be inserted.
382
+ *
383
+ * Note that the first parameter is only a hint and can potentially
384
+ * improve the performance of the insertion process. A bad hint would
385
+ * cause no gains in efficiency.
386
+ *
387
+ * See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
388
+ * for more on "hinting".
389
+ *
390
+ * Insertion requires logarithmic time (if the hint is not taken).
391
+ */
392
+ iterator
393
+ insert(iterator __position, const value_type& __x)
394
+ { return _M_t._M_insert_equal_(__position, __x); }
395
+
396
+ /**
397
+ * @brief A template function that attempts to insert a range of elements.
398
+ * @param first Iterator pointing to the start of the range to be
399
+ * inserted.
400
+ * @param last Iterator pointing to the end of the range.
401
+ *
402
+ * Complexity similar to that of the range constructor.
403
+ */
404
+ template<typename _InputIterator>
405
+ void
406
+ insert(_InputIterator __first, _InputIterator __last)
407
+ { _M_t._M_insert_equal(__first, __last); }
408
+
409
+ /**
410
+ * @brief Erases an element from a %multiset.
411
+ * @param position An iterator pointing to the element to be erased.
412
+ *
413
+ * This function erases an element, pointed to by the given iterator,
414
+ * from a %multiset. Note that this function only erases the element,
415
+ * and that if the element is itself a pointer, the pointed-to memory is
416
+ * not touched in any way. Managing the pointer is the user's
417
+ * responsibility.
418
+ */
419
+ void
420
+ erase(iterator __position)
421
+ { _M_t.erase(__position); }
422
+
423
+ /**
424
+ * @brief Erases elements according to the provided key.
425
+ * @param x Key of element to be erased.
426
+ * @return The number of elements erased.
427
+ *
428
+ * This function erases all elements located by the given key from a
429
+ * %multiset.
430
+ * Note that this function only erases the element, and that if
431
+ * the element is itself a pointer, the pointed-to memory is not touched
432
+ * in any way. Managing the pointer is the user's responsibility.
433
+ */
434
+ size_type
435
+ erase(const key_type& __x)
436
+ { return _M_t.erase(__x); }
437
+
438
+ /**
439
+ * @brief Erases a [first,last) range of elements from a %multiset.
440
+ * @param first Iterator pointing to the start of the range to be
441
+ * erased.
442
+ * @param last Iterator pointing to the end of the range to be erased.
443
+ *
444
+ * This function erases a sequence of elements from a %multiset.
445
+ * Note that this function only erases the elements, and that if
446
+ * the elements themselves are pointers, the pointed-to memory is not
447
+ * touched in any way. Managing the pointer is the user's responsibility.
448
+ */
449
+ void
450
+ erase(iterator __first, iterator __last)
451
+ { _M_t.erase(__first, __last); }
452
+
453
+ /**
454
+ * Erases all elements in a %multiset. Note that this function only
455
+ * erases the elements, and that if the elements themselves are pointers,
456
+ * the pointed-to memory is not touched in any way. Managing the pointer
457
+ * is the user's responsibility.
458
+ */
459
+ void
460
+ clear()
461
+ { _M_t.clear(); }
462
+
463
+ // multiset operations:
464
+
465
+ /**
466
+ * @brief Finds the number of elements with given key.
467
+ * @param x Key of elements to be located.
468
+ * @return Number of elements with specified key.
469
+ */
470
+ size_type
471
+ count(const key_type& __x) const
472
+ { return _M_t.count(__x); }
473
+
474
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
475
+ // 214. set::find() missing const overload
476
+ //@{
477
+ /**
478
+ * @brief Tries to locate an element in a %set.
479
+ * @param x Element to be located.
480
+ * @return Iterator pointing to sought-after element, or end() if not
481
+ * found.
482
+ *
483
+ * This function takes a key and tries to locate the element with which
484
+ * the key matches. If successful the function returns an iterator
485
+ * pointing to the sought after element. If unsuccessful it returns the
486
+ * past-the-end ( @c end() ) iterator.
487
+ */
488
+ iterator
489
+ find(const key_type& __x)
490
+ { return _M_t.find(__x); }
491
+
492
+ const_iterator
493
+ find(const key_type& __x) const
494
+ { return _M_t.find(__x); }
495
+ //@}
496
+
497
+ //@{
498
+ /**
499
+ * @brief Finds the beginning of a subsequence matching given key.
500
+ * @param x Key to be located.
501
+ * @return Iterator pointing to first element equal to or greater
502
+ * than key, or end().
503
+ *
504
+ * This function returns the first element of a subsequence of elements
505
+ * that matches the given key. If unsuccessful it returns an iterator
506
+ * pointing to the first element that has a greater value than given key
507
+ * or end() if no such element exists.
508
+ */
509
+ iterator
510
+ lower_bound(const key_type& __x)
511
+ { return _M_t.lower_bound(__x); }
512
+
513
+ const_iterator
514
+ lower_bound(const key_type& __x) const
515
+ { return _M_t.lower_bound(__x); }
516
+ //@}
517
+
518
+ //@{
519
+ /**
520
+ * @brief Finds the end of a subsequence matching given key.
521
+ * @param x Key to be located.
522
+ * @return Iterator pointing to the first element
523
+ * greater than key, or end().
524
+ */
525
+ iterator
526
+ upper_bound(const key_type& __x)
527
+ { return _M_t.upper_bound(__x); }
528
+
529
+ const_iterator
530
+ upper_bound(const key_type& __x) const
531
+ { return _M_t.upper_bound(__x); }
532
+ //@}
533
+
534
+ //@{
535
+ /**
536
+ * @brief Finds a subsequence matching given key.
537
+ * @param x Key to be located.
538
+ * @return Pair of iterators that possibly points to the subsequence
539
+ * matching given key.
540
+ *
541
+ * This function is equivalent to
542
+ * @code
543
+ * std::make_pair(c.lower_bound(val),
544
+ * c.upper_bound(val))
545
+ * @endcode
546
+ * (but is faster than making the calls separately).
547
+ *
548
+ * This function probably only makes sense for multisets.
549
+ */
550
+ std::pair<iterator, iterator>
551
+ equal_range(const key_type& __x)
552
+ { return _M_t.equal_range(__x); }
553
+
554
+ std::pair<const_iterator, const_iterator>
555
+ equal_range(const key_type& __x) const
556
+ { return _M_t.equal_range(__x); }
557
+
558
+ template<typename _K1, typename _C1, typename _A1>
559
+ friend bool
560
+ operator==(const multiset<_K1, _C1, _A1>&,
561
+ const multiset<_K1, _C1, _A1>&);
562
+
563
+ template<typename _K1, typename _C1, typename _A1>
564
+ friend bool
565
+ operator< (const multiset<_K1, _C1, _A1>&,
566
+ const multiset<_K1, _C1, _A1>&);
567
+ };
568
+
569
+ /**
570
+ * @brief Multiset equality comparison.
571
+ * @param x A %multiset.
572
+ * @param y A %multiset of the same type as @a x.
573
+ * @return True iff the size and elements of the multisets are equal.
574
+ *
575
+ * This is an equivalence relation. It is linear in the size of the
576
+ * multisets.
577
+ * Multisets are considered equivalent if their sizes are equal, and if
578
+ * corresponding elements compare equal.
579
+ */
580
+ template<typename _Key, typename _Compare, typename _Alloc>
581
+ inline bool
582
+ operator==(const multiset<_Key, _Compare, _Alloc>& __x,
583
+ const multiset<_Key, _Compare, _Alloc>& __y)
584
+ { return __x._M_t == __y._M_t; }
585
+
586
+ /**
587
+ * @brief Multiset ordering relation.
588
+ * @param x A %multiset.
589
+ * @param y A %multiset of the same type as @a x.
590
+ * @return True iff @a x is lexicographically less than @a y.
591
+ *
592
+ * This is a total ordering relation. It is linear in the size of the
593
+ * maps. The elements must be comparable with @c <.
594
+ *
595
+ * See std::lexicographical_compare() for how the determination is made.
596
+ */
597
+ template<typename _Key, typename _Compare, typename _Alloc>
598
+ inline bool
599
+ operator<(const multiset<_Key, _Compare, _Alloc>& __x,
600
+ const multiset<_Key, _Compare, _Alloc>& __y)
601
+ { return __x._M_t < __y._M_t; }
602
+
603
+ /// Returns !(x == y).
604
+ template<typename _Key, typename _Compare, typename _Alloc>
605
+ inline bool
606
+ operator!=(const multiset<_Key, _Compare, _Alloc>& __x,
607
+ const multiset<_Key, _Compare, _Alloc>& __y)
608
+ { return !(__x == __y); }
609
+
610
+ /// Returns y < x.
611
+ template<typename _Key, typename _Compare, typename _Alloc>
612
+ inline bool
613
+ operator>(const multiset<_Key,_Compare,_Alloc>& __x,
614
+ const multiset<_Key,_Compare,_Alloc>& __y)
615
+ { return __y < __x; }
616
+
617
+ /// Returns !(y < x)
618
+ template<typename _Key, typename _Compare, typename _Alloc>
619
+ inline bool
620
+ operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
621
+ const multiset<_Key, _Compare, _Alloc>& __y)
622
+ { return !(__y < __x); }
623
+
624
+ /// Returns !(x < y)
625
+ template<typename _Key, typename _Compare, typename _Alloc>
626
+ inline bool
627
+ operator>=(const multiset<_Key, _Compare, _Alloc>& __x,
628
+ const multiset<_Key, _Compare, _Alloc>& __y)
629
+ { return !(__x < __y); }
630
+
631
+ /// See std::multiset::swap().
632
+ template<typename _Key, typename _Compare, typename _Alloc>
633
+ inline void
634
+ swap(multiset<_Key, _Compare, _Alloc>& __x,
635
+ multiset<_Key, _Compare, _Alloc>& __y)
636
+ { __x.swap(__y); }
637
+
638
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
639
+ template<typename _Key, typename _Compare, typename _Alloc>
640
+ inline void
641
+ swap(multiset<_Key, _Compare, _Alloc>&& __x,
642
+ multiset<_Key, _Compare, _Alloc>& __y)
643
+ { __x.swap(__y); }
644
+
645
+ template<typename _Key, typename _Compare, typename _Alloc>
646
+ inline void
647
+ swap(multiset<_Key, _Compare, _Alloc>& __x,
648
+ multiset<_Key, _Compare, _Alloc>&& __y)
649
+ { __x.swap(__y); }
650
+ #endif
651
+
652
+ _GLIBCXX_END_NESTED_NAMESPACE
653
+
654
+ #endif /* _STL_MULTISET_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_numeric.h ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Numeric functions implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_numeric.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_NUMERIC_H
63
+ #define _STL_NUMERIC_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+ #include <debug/debug.h>
67
+
68
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
69
+
70
+ /**
71
+ * @brief Accumulate values in a range.
72
+ *
73
+ * Accumulates the values in the range [first,last) using operator+(). The
74
+ * initial value is @a init. The values are processed in order.
75
+ *
76
+ * @param first Start of range.
77
+ * @param last End of range.
78
+ * @param init Starting value to add other values to.
79
+ * @return The final sum.
80
+ */
81
+ template<typename _InputIterator, typename _Tp>
82
+ inline _Tp
83
+ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
84
+ {
85
+ // concept requirements
86
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
87
+ __glibcxx_requires_valid_range(__first, __last);
88
+
89
+ for (; __first != __last; ++__first)
90
+ __init = __init + *__first;
91
+ return __init;
92
+ }
93
+
94
+ /**
95
+ * @brief Accumulate values in a range with operation.
96
+ *
97
+ * Accumulates the values in the range [first,last) using the function
98
+ * object @a binary_op. The initial value is @a init. The values are
99
+ * processed in order.
100
+ *
101
+ * @param first Start of range.
102
+ * @param last End of range.
103
+ * @param init Starting value to add other values to.
104
+ * @param binary_op Function object to accumulate with.
105
+ * @return The final sum.
106
+ */
107
+ template<typename _InputIterator, typename _Tp, typename _BinaryOperation>
108
+ inline _Tp
109
+ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
110
+ _BinaryOperation __binary_op)
111
+ {
112
+ // concept requirements
113
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
114
+ __glibcxx_requires_valid_range(__first, __last);
115
+
116
+ for (; __first != __last; ++__first)
117
+ __init = __binary_op(__init, *__first);
118
+ return __init;
119
+ }
120
+
121
+ /**
122
+ * @brief Compute inner product of two ranges.
123
+ *
124
+ * Starting with an initial value of @a init, multiplies successive
125
+ * elements from the two ranges and adds each product into the accumulated
126
+ * value using operator+(). The values in the ranges are processed in
127
+ * order.
128
+ *
129
+ * @param first1 Start of range 1.
130
+ * @param last1 End of range 1.
131
+ * @param first2 Start of range 2.
132
+ * @param init Starting value to add other values to.
133
+ * @return The final inner product.
134
+ */
135
+ template<typename _InputIterator1, typename _InputIterator2, typename _Tp>
136
+ inline _Tp
137
+ inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
138
+ _InputIterator2 __first2, _Tp __init)
139
+ {
140
+ // concept requirements
141
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
142
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
143
+ __glibcxx_requires_valid_range(__first1, __last1);
144
+
145
+ for (; __first1 != __last1; ++__first1, ++__first2)
146
+ __init = __init + (*__first1 * *__first2);
147
+ return __init;
148
+ }
149
+
150
+ /**
151
+ * @brief Compute inner product of two ranges.
152
+ *
153
+ * Starting with an initial value of @a init, applies @a binary_op2 to
154
+ * successive elements from the two ranges and accumulates each result into
155
+ * the accumulated value using @a binary_op1. The values in the ranges are
156
+ * processed in order.
157
+ *
158
+ * @param first1 Start of range 1.
159
+ * @param last1 End of range 1.
160
+ * @param first2 Start of range 2.
161
+ * @param init Starting value to add other values to.
162
+ * @param binary_op1 Function object to accumulate with.
163
+ * @param binary_op2 Function object to apply to pairs of input values.
164
+ * @return The final inner product.
165
+ */
166
+ template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
167
+ typename _BinaryOperation1, typename _BinaryOperation2>
168
+ inline _Tp
169
+ inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
170
+ _InputIterator2 __first2, _Tp __init,
171
+ _BinaryOperation1 __binary_op1,
172
+ _BinaryOperation2 __binary_op2)
173
+ {
174
+ // concept requirements
175
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
176
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
177
+ __glibcxx_requires_valid_range(__first1, __last1);
178
+
179
+ for (; __first1 != __last1; ++__first1, ++__first2)
180
+ __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
181
+ return __init;
182
+ }
183
+
184
+ /**
185
+ * @brief Return list of partial sums
186
+ *
187
+ * Accumulates the values in the range [first,last) using operator+().
188
+ * As each successive input value is added into the total, that partial sum
189
+ * is written to @a result. Therefore, the first value in result is the
190
+ * first value of the input, the second value in result is the sum of the
191
+ * first and second input values, and so on.
192
+ *
193
+ * @param first Start of input range.
194
+ * @param last End of input range.
195
+ * @param result Output to write sums to.
196
+ * @return Iterator pointing just beyond the values written to result.
197
+ */
198
+ template<typename _InputIterator, typename _OutputIterator>
199
+ _OutputIterator
200
+ partial_sum(_InputIterator __first, _InputIterator __last,
201
+ _OutputIterator __result)
202
+ {
203
+ typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
204
+
205
+ // concept requirements
206
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
207
+ __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
208
+ _ValueType>)
209
+ __glibcxx_requires_valid_range(__first, __last);
210
+
211
+ if (__first == __last)
212
+ return __result;
213
+ _ValueType __value = *__first;
214
+ *__result = __value;
215
+ while (++__first != __last)
216
+ {
217
+ __value = __value + *__first;
218
+ *++__result = __value;
219
+ }
220
+ return ++__result;
221
+ }
222
+
223
+ /**
224
+ * @brief Return list of partial sums
225
+ *
226
+ * Accumulates the values in the range [first,last) using operator+().
227
+ * As each successive input value is added into the total, that partial sum
228
+ * is written to @a result. Therefore, the first value in result is the
229
+ * first value of the input, the second value in result is the sum of the
230
+ * first and second input values, and so on.
231
+ *
232
+ * @param first Start of input range.
233
+ * @param last End of input range.
234
+ * @param result Output to write sums to.
235
+ * @return Iterator pointing just beyond the values written to result.
236
+ */
237
+ template<typename _InputIterator, typename _OutputIterator,
238
+ typename _BinaryOperation>
239
+ _OutputIterator
240
+ partial_sum(_InputIterator __first, _InputIterator __last,
241
+ _OutputIterator __result, _BinaryOperation __binary_op)
242
+ {
243
+ typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
244
+
245
+ // concept requirements
246
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
247
+ __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
248
+ _ValueType>)
249
+ __glibcxx_requires_valid_range(__first, __last);
250
+
251
+ if (__first == __last)
252
+ return __result;
253
+ _ValueType __value = *__first;
254
+ *__result = __value;
255
+ while (++__first != __last)
256
+ {
257
+ __value = __binary_op(__value, *__first);
258
+ *++__result = __value;
259
+ }
260
+ return ++__result;
261
+ }
262
+
263
+ /**
264
+ * @brief Return differences between adjacent values.
265
+ *
266
+ * Computes the difference between adjacent values in the range
267
+ * [first,last) using operator-() and writes the result to @a result.
268
+ *
269
+ * @param first Start of input range.
270
+ * @param last End of input range.
271
+ * @param result Output to write sums to.
272
+ * @return Iterator pointing just beyond the values written to result.
273
+ */
274
+ template<typename _InputIterator, typename _OutputIterator>
275
+ _OutputIterator
276
+ adjacent_difference(_InputIterator __first,
277
+ _InputIterator __last, _OutputIterator __result)
278
+ {
279
+ typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
280
+
281
+ // concept requirements
282
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
283
+ __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
284
+ _ValueType>)
285
+ __glibcxx_requires_valid_range(__first, __last);
286
+
287
+ if (__first == __last)
288
+ return __result;
289
+ _ValueType __value = *__first;
290
+ *__result = __value;
291
+ while (++__first != __last)
292
+ {
293
+ _ValueType __tmp = *__first;
294
+ *++__result = __tmp - __value;
295
+ __value = __tmp;
296
+ }
297
+ return ++__result;
298
+ }
299
+
300
+ /**
301
+ * @brief Return differences between adjacent values.
302
+ *
303
+ * Computes the difference between adjacent values in the range
304
+ * [first,last) using the function object @a binary_op and writes the
305
+ * result to @a result.
306
+ *
307
+ * @param first Start of input range.
308
+ * @param last End of input range.
309
+ * @param result Output to write sums to.
310
+ * @return Iterator pointing just beyond the values written to result.
311
+ */
312
+ template<typename _InputIterator, typename _OutputIterator,
313
+ typename _BinaryOperation>
314
+ _OutputIterator
315
+ adjacent_difference(_InputIterator __first, _InputIterator __last,
316
+ _OutputIterator __result, _BinaryOperation __binary_op)
317
+ {
318
+ typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
319
+
320
+ // concept requirements
321
+ __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
322
+ __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
323
+ _ValueType>)
324
+ __glibcxx_requires_valid_range(__first, __last);
325
+
326
+ if (__first == __last)
327
+ return __result;
328
+ _ValueType __value = *__first;
329
+ *__result = __value;
330
+ while (++__first != __last)
331
+ {
332
+ _ValueType __tmp = *__first;
333
+ *++__result = __binary_op(__tmp, __value);
334
+ __value = __tmp;
335
+ }
336
+ return ++__result;
337
+ }
338
+
339
+ _GLIBCXX_END_NESTED_NAMESPACE
340
+
341
+ #endif /* _STL_NUMERIC_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_pair.h ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Pair implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_pair.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_PAIR_H
63
+ #define _STL_PAIR_H 1
64
+
65
+ #include <bits/stl_move.h> // for std::move / std::forward, std::decay, and
66
+ // std::swap
67
+
68
+ _GLIBCXX_BEGIN_NAMESPACE(std)
69
+
70
+ /// pair holds two objects of arbitrary type.
71
+ template<class _T1, class _T2>
72
+ struct pair
73
+ {
74
+ typedef _T1 first_type; ///< @c first_type is the first bound type
75
+ typedef _T2 second_type; ///< @c second_type is the second bound type
76
+
77
+ _T1 first; ///< @c first is a copy of the first object
78
+ _T2 second; ///< @c second is a copy of the second object
79
+
80
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
81
+ // 265. std::pair::pair() effects overly restrictive
82
+ /** The default constructor creates @c first and @c second using their
83
+ * respective default constructors. */
84
+ pair()
85
+ : first(), second() { }
86
+
87
+ /** Two objects may be passed to a @c pair constructor to be copied. */
88
+ pair(const _T1& __a, const _T2& __b)
89
+ : first(__a), second(__b) { }
90
+
91
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
92
+ template<class _U1, class _U2>
93
+ pair(_U1&& __x, _U2&& __y)
94
+ : first(std::forward<_U1>(__x)),
95
+ second(std::forward<_U2>(__y)) { }
96
+
97
+ pair(pair&& __p)
98
+ : first(std::move(__p.first)),
99
+ second(std::move(__p.second)) { }
100
+ #endif
101
+
102
+ /** There is also a templated copy ctor for the @c pair class itself. */
103
+ template<class _U1, class _U2>
104
+ pair(const pair<_U1, _U2>& __p)
105
+ : first(__p.first),
106
+ second(__p.second) { }
107
+
108
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
109
+ template<class _U1, class _U2>
110
+ pair(pair<_U1, _U2>&& __p)
111
+ : first(std::move(__p.first)),
112
+ second(std::move(__p.second)) { }
113
+
114
+ // http://gcc.gnu.org/ml/libstdc++/2007-08/msg00052.html
115
+ template<class _U1, class _Arg0, class... _Args>
116
+ pair(_U1&& __x, _Arg0&& __arg0, _Args&&... __args)
117
+ : first(std::forward<_U1>(__x)),
118
+ second(std::forward<_Arg0>(__arg0),
119
+ std::forward<_Args>(__args)...) { }
120
+
121
+ pair&
122
+ operator=(pair&& __p)
123
+ {
124
+ first = std::move(__p.first);
125
+ second = std::move(__p.second);
126
+ return *this;
127
+ }
128
+
129
+ template<class _U1, class _U2>
130
+ pair&
131
+ operator=(pair<_U1, _U2>&& __p)
132
+ {
133
+ first = std::move(__p.first);
134
+ second = std::move(__p.second);
135
+ return *this;
136
+ }
137
+
138
+ void
139
+ swap(pair&& __p)
140
+ {
141
+ using std::swap;
142
+ swap(first, __p.first);
143
+ swap(second, __p.second);
144
+ }
145
+ #endif
146
+ };
147
+
148
+ /// Two pairs of the same type are equal iff their members are equal.
149
+ template<class _T1, class _T2>
150
+ inline bool
151
+ operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
152
+ { return __x.first == __y.first && __x.second == __y.second; }
153
+
154
+ /// <http://gcc.gnu.org/onlinedocs/libstdc++/manual/utilities.html>
155
+ template<class _T1, class _T2>
156
+ inline bool
157
+ operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
158
+ { return __x.first < __y.first
159
+ || (!(__y.first < __x.first) && __x.second < __y.second); }
160
+
161
+ /// Uses @c operator== to find the result.
162
+ template<class _T1, class _T2>
163
+ inline bool
164
+ operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
165
+ { return !(__x == __y); }
166
+
167
+ /// Uses @c operator< to find the result.
168
+ template<class _T1, class _T2>
169
+ inline bool
170
+ operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
171
+ { return __y < __x; }
172
+
173
+ /// Uses @c operator< to find the result.
174
+ template<class _T1, class _T2>
175
+ inline bool
176
+ operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
177
+ { return !(__y < __x); }
178
+
179
+ /// Uses @c operator< to find the result.
180
+ template<class _T1, class _T2>
181
+ inline bool
182
+ operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
183
+ { return !(__x < __y); }
184
+
185
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
186
+ /// See std::pair::swap().
187
+ template<class _T1, class _T2>
188
+ inline void
189
+ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
190
+ { __x.swap(__y); }
191
+
192
+ template<class _T1, class _T2>
193
+ inline void
194
+ swap(pair<_T1, _T2>&& __x, pair<_T1, _T2>& __y)
195
+ { __x.swap(__y); }
196
+
197
+ template<class _T1, class _T2>
198
+ inline void
199
+ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>&& __y)
200
+ { __x.swap(__y); }
201
+ #endif
202
+
203
+ /**
204
+ * @brief A convenience wrapper for creating a pair from two objects.
205
+ * @param x The first object.
206
+ * @param y The second object.
207
+ * @return A newly-constructed pair<> object of the appropriate type.
208
+ *
209
+ * The standard requires that the objects be passed by reference-to-const,
210
+ * but LWG issue #181 says they should be passed by const value. We follow
211
+ * the LWG by default.
212
+ */
213
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
214
+ // 181. make_pair() unintended behavior
215
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
216
+ template<class _T1, class _T2>
217
+ inline pair<_T1, _T2>
218
+ make_pair(_T1 __x, _T2 __y)
219
+ { return pair<_T1, _T2>(__x, __y); }
220
+ #else
221
+ template<typename _Tp>
222
+ class reference_wrapper;
223
+
224
+ // Helper which adds a reference to a type when given a reference_wrapper
225
+ template<typename _Tp>
226
+ struct __strip_reference_wrapper
227
+ {
228
+ typedef _Tp __type;
229
+ };
230
+
231
+ template<typename _Tp>
232
+ struct __strip_reference_wrapper<reference_wrapper<_Tp> >
233
+ {
234
+ typedef _Tp& __type;
235
+ };
236
+
237
+ template<typename _Tp>
238
+ struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
239
+ {
240
+ typedef _Tp& __type;
241
+ };
242
+
243
+ template<typename _Tp>
244
+ struct __decay_and_strip
245
+ {
246
+ typedef typename __strip_reference_wrapper<
247
+ typename decay<_Tp>::type>::__type __type;
248
+ };
249
+
250
+ // NB: DR 706.
251
+ template<class _T1, class _T2>
252
+ inline pair<typename __decay_and_strip<_T1>::__type,
253
+ typename __decay_and_strip<_T2>::__type>
254
+ make_pair(_T1&& __x, _T2&& __y)
255
+ {
256
+ return pair<typename __decay_and_strip<_T1>::__type,
257
+ typename __decay_and_strip<_T2>::__type>
258
+ (std::forward<_T1>(__x), std::forward<_T2>(__y));
259
+ }
260
+ #endif
261
+
262
+ _GLIBCXX_END_NAMESPACE
263
+
264
+ #endif /* _STL_PAIR_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_queue.h ADDED
@@ -0,0 +1,584 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Queue implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_queue.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_QUEUE_H
63
+ #define _STL_QUEUE_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+ #include <debug/debug.h>
67
+
68
+ _GLIBCXX_BEGIN_NAMESPACE(std)
69
+
70
+ /**
71
+ * @brief A standard container giving FIFO behavior.
72
+ *
73
+ * @ingroup Containers
74
+ * @ingroup Sequences
75
+ *
76
+ * Meets many of the requirements of a
77
+ * <a href="tables.html#65">container</a>,
78
+ * but does not define anything to do with iterators. Very few of the
79
+ * other standard container interfaces are defined.
80
+ *
81
+ * This is not a true container, but an @e adaptor. It holds another
82
+ * container, and provides a wrapper interface to that container. The
83
+ * wrapper is what enforces strict first-in-first-out %queue behavior.
84
+ *
85
+ * The second template parameter defines the type of the underlying
86
+ * sequence/container. It defaults to std::deque, but it can be any type
87
+ * that supports @c front, @c back, @c push_back, and @c pop_front,
88
+ * such as std::list or an appropriate user-defined type.
89
+ *
90
+ * Members not found in "normal" containers are @c container_type,
91
+ * which is a typedef for the second Sequence parameter, and @c push and
92
+ * @c pop, which are standard %queue/FIFO operations.
93
+ */
94
+ template<typename _Tp, typename _Sequence = deque<_Tp> >
95
+ class queue
96
+ {
97
+ // concept requirements
98
+ typedef typename _Sequence::value_type _Sequence_value_type;
99
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
100
+ __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept)
101
+ __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
102
+ __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
103
+
104
+ template<typename _Tp1, typename _Seq1>
105
+ friend bool
106
+ operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
107
+
108
+ template<typename _Tp1, typename _Seq1>
109
+ friend bool
110
+ operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
111
+
112
+ public:
113
+ typedef typename _Sequence::value_type value_type;
114
+ typedef typename _Sequence::reference reference;
115
+ typedef typename _Sequence::const_reference const_reference;
116
+ typedef typename _Sequence::size_type size_type;
117
+ typedef _Sequence container_type;
118
+
119
+ protected:
120
+ /**
121
+ * 'c' is the underlying container. Maintainers wondering why
122
+ * this isn't uglified as per style guidelines should note that
123
+ * this name is specified in the standard, [23.2.3.1]. (Why?
124
+ * Presumably for the same reason that it's protected instead
125
+ * of private: to allow derivation. But none of the other
126
+ * containers allow for derivation. Odd.)
127
+ */
128
+ _Sequence c;
129
+
130
+ public:
131
+ /**
132
+ * @brief Default constructor creates no elements.
133
+ */
134
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
135
+ explicit
136
+ queue(const _Sequence& __c = _Sequence())
137
+ : c(__c) { }
138
+ #else
139
+ explicit
140
+ queue(const _Sequence& __c)
141
+ : c(__c) { }
142
+
143
+ explicit
144
+ queue(_Sequence&& __c = _Sequence())
145
+ : c(std::move(__c)) { }
146
+
147
+ queue(queue&& __q)
148
+ : c(std::move(__q.c)) { }
149
+
150
+ queue&
151
+ operator=(queue&& __q)
152
+ {
153
+ c = std::move(__q.c);
154
+ return *this;
155
+ }
156
+ #endif
157
+
158
+ /**
159
+ * Returns true if the %queue is empty.
160
+ */
161
+ bool
162
+ empty() const
163
+ { return c.empty(); }
164
+
165
+ /** Returns the number of elements in the %queue. */
166
+ size_type
167
+ size() const
168
+ { return c.size(); }
169
+
170
+ /**
171
+ * Returns a read/write reference to the data at the first
172
+ * element of the %queue.
173
+ */
174
+ reference
175
+ front()
176
+ {
177
+ __glibcxx_requires_nonempty();
178
+ return c.front();
179
+ }
180
+
181
+ /**
182
+ * Returns a read-only (constant) reference to the data at the first
183
+ * element of the %queue.
184
+ */
185
+ const_reference
186
+ front() const
187
+ {
188
+ __glibcxx_requires_nonempty();
189
+ return c.front();
190
+ }
191
+
192
+ /**
193
+ * Returns a read/write reference to the data at the last
194
+ * element of the %queue.
195
+ */
196
+ reference
197
+ back()
198
+ {
199
+ __glibcxx_requires_nonempty();
200
+ return c.back();
201
+ }
202
+
203
+ /**
204
+ * Returns a read-only (constant) reference to the data at the last
205
+ * element of the %queue.
206
+ */
207
+ const_reference
208
+ back() const
209
+ {
210
+ __glibcxx_requires_nonempty();
211
+ return c.back();
212
+ }
213
+
214
+ /**
215
+ * @brief Add data to the end of the %queue.
216
+ * @param x Data to be added.
217
+ *
218
+ * This is a typical %queue operation. The function creates an
219
+ * element at the end of the %queue and assigns the given data
220
+ * to it. The time complexity of the operation depends on the
221
+ * underlying sequence.
222
+ */
223
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
224
+ void
225
+ push(const value_type& __x)
226
+ { c.push_back(__x); }
227
+ #else
228
+ // NB: DR 756.
229
+ template<typename... _Args>
230
+ void
231
+ push(_Args&&... __args)
232
+ { c.push_back(std::forward<_Args>(__args)...); }
233
+ #endif
234
+
235
+ /**
236
+ * @brief Removes first element.
237
+ *
238
+ * This is a typical %queue operation. It shrinks the %queue by one.
239
+ * The time complexity of the operation depends on the underlying
240
+ * sequence.
241
+ *
242
+ * Note that no data is returned, and if the first element's
243
+ * data is needed, it should be retrieved before pop() is
244
+ * called.
245
+ */
246
+ void
247
+ pop()
248
+ {
249
+ __glibcxx_requires_nonempty();
250
+ c.pop_front();
251
+ }
252
+
253
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
254
+ void
255
+ swap(queue&& __q)
256
+ { c.swap(__q.c); }
257
+ #endif
258
+ };
259
+
260
+ /**
261
+ * @brief Queue equality comparison.
262
+ * @param x A %queue.
263
+ * @param y A %queue of the same type as @a x.
264
+ * @return True iff the size and elements of the queues are equal.
265
+ *
266
+ * This is an equivalence relation. Complexity and semantics depend on the
267
+ * underlying sequence type, but the expected rules are: this relation is
268
+ * linear in the size of the sequences, and queues are considered equivalent
269
+ * if their sequences compare equal.
270
+ */
271
+ template<typename _Tp, typename _Seq>
272
+ inline bool
273
+ operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
274
+ { return __x.c == __y.c; }
275
+
276
+ /**
277
+ * @brief Queue ordering relation.
278
+ * @param x A %queue.
279
+ * @param y A %queue of the same type as @a x.
280
+ * @return True iff @a x is lexicographically less than @a y.
281
+ *
282
+ * This is an total ordering relation. Complexity and semantics
283
+ * depend on the underlying sequence type, but the expected rules
284
+ * are: this relation is linear in the size of the sequences, the
285
+ * elements must be comparable with @c <, and
286
+ * std::lexicographical_compare() is usually used to make the
287
+ * determination.
288
+ */
289
+ template<typename _Tp, typename _Seq>
290
+ inline bool
291
+ operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
292
+ { return __x.c < __y.c; }
293
+
294
+ /// Based on operator==
295
+ template<typename _Tp, typename _Seq>
296
+ inline bool
297
+ operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
298
+ { return !(__x == __y); }
299
+
300
+ /// Based on operator<
301
+ template<typename _Tp, typename _Seq>
302
+ inline bool
303
+ operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
304
+ { return __y < __x; }
305
+
306
+ /// Based on operator<
307
+ template<typename _Tp, typename _Seq>
308
+ inline bool
309
+ operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
310
+ { return !(__y < __x); }
311
+
312
+ /// Based on operator<
313
+ template<typename _Tp, typename _Seq>
314
+ inline bool
315
+ operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
316
+ { return !(__x < __y); }
317
+
318
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
319
+ template<typename _Tp, typename _Seq>
320
+ inline void
321
+ swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
322
+ { __x.swap(__y); }
323
+
324
+ template<typename _Tp, typename _Seq>
325
+ inline void
326
+ swap(queue<_Tp, _Seq>&& __x, queue<_Tp, _Seq>& __y)
327
+ { __x.swap(__y); }
328
+
329
+ template<typename _Tp, typename _Seq>
330
+ inline void
331
+ swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>&& __y)
332
+ { __x.swap(__y); }
333
+ #endif
334
+
335
+ /**
336
+ * @brief A standard container automatically sorting its contents.
337
+ *
338
+ * @ingroup Containers
339
+ * @ingroup Sequences
340
+ *
341
+ * This is not a true container, but an @e adaptor. It holds
342
+ * another container, and provides a wrapper interface to that
343
+ * container. The wrapper is what enforces priority-based sorting
344
+ * and %queue behavior. Very few of the standard container/sequence
345
+ * interface requirements are met (e.g., iterators).
346
+ *
347
+ * The second template parameter defines the type of the underlying
348
+ * sequence/container. It defaults to std::vector, but it can be
349
+ * any type that supports @c front(), @c push_back, @c pop_back,
350
+ * and random-access iterators, such as std::deque or an
351
+ * appropriate user-defined type.
352
+ *
353
+ * The third template parameter supplies the means of making
354
+ * priority comparisons. It defaults to @c less<value_type> but
355
+ * can be anything defining a strict weak ordering.
356
+ *
357
+ * Members not found in "normal" containers are @c container_type,
358
+ * which is a typedef for the second Sequence parameter, and @c
359
+ * push, @c pop, and @c top, which are standard %queue operations.
360
+ *
361
+ * @note No equality/comparison operators are provided for
362
+ * %priority_queue.
363
+ *
364
+ * @note Sorting of the elements takes place as they are added to,
365
+ * and removed from, the %priority_queue using the
366
+ * %priority_queue's member functions. If you access the elements
367
+ * by other means, and change their data such that the sorting
368
+ * order would be different, the %priority_queue will not re-sort
369
+ * the elements for you. (How could it know to do so?)
370
+ */
371
+ template<typename _Tp, typename _Sequence = vector<_Tp>,
372
+ typename _Compare = less<typename _Sequence::value_type> >
373
+ class priority_queue
374
+ {
375
+ // concept requirements
376
+ typedef typename _Sequence::value_type _Sequence_value_type;
377
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
378
+ __glibcxx_class_requires(_Sequence, _SequenceConcept)
379
+ __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept)
380
+ __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
381
+ __glibcxx_class_requires4(_Compare, bool, _Tp, _Tp,
382
+ _BinaryFunctionConcept)
383
+
384
+ public:
385
+ typedef typename _Sequence::value_type value_type;
386
+ typedef typename _Sequence::reference reference;
387
+ typedef typename _Sequence::const_reference const_reference;
388
+ typedef typename _Sequence::size_type size_type;
389
+ typedef _Sequence container_type;
390
+
391
+ protected:
392
+ // See queue::c for notes on these names.
393
+ _Sequence c;
394
+ _Compare comp;
395
+
396
+ public:
397
+ /**
398
+ * @brief Default constructor creates no elements.
399
+ */
400
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
401
+ explicit
402
+ priority_queue(const _Compare& __x = _Compare(),
403
+ const _Sequence& __s = _Sequence())
404
+ : c(__s), comp(__x)
405
+ { std::make_heap(c.begin(), c.end(), comp); }
406
+ #else
407
+ explicit
408
+ priority_queue(const _Compare& __x,
409
+ const _Sequence& __s)
410
+ : c(__s), comp(__x)
411
+ { std::make_heap(c.begin(), c.end(), comp); }
412
+
413
+ explicit
414
+ priority_queue(const _Compare& __x = _Compare(),
415
+ _Sequence&& __s = _Sequence())
416
+ : c(std::move(__s)), comp(__x)
417
+ { std::make_heap(c.begin(), c.end(), comp); }
418
+ #endif
419
+
420
+ /**
421
+ * @brief Builds a %queue from a range.
422
+ * @param first An input iterator.
423
+ * @param last An input iterator.
424
+ * @param x A comparison functor describing a strict weak ordering.
425
+ * @param s An initial sequence with which to start.
426
+ *
427
+ * Begins by copying @a s, inserting a copy of the elements
428
+ * from @a [first,last) into the copy of @a s, then ordering
429
+ * the copy according to @a x.
430
+ *
431
+ * For more information on function objects, see the
432
+ * documentation on @link s20_3_1_base functor base
433
+ * classes@endlink.
434
+ */
435
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
436
+ template<typename _InputIterator>
437
+ priority_queue(_InputIterator __first, _InputIterator __last,
438
+ const _Compare& __x = _Compare(),
439
+ const _Sequence& __s = _Sequence())
440
+ : c(__s), comp(__x)
441
+ {
442
+ __glibcxx_requires_valid_range(__first, __last);
443
+ c.insert(c.end(), __first, __last);
444
+ std::make_heap(c.begin(), c.end(), comp);
445
+ }
446
+ #else
447
+ template<typename _InputIterator>
448
+ priority_queue(_InputIterator __first, _InputIterator __last,
449
+ const _Compare& __x,
450
+ const _Sequence& __s)
451
+ : c(__s), comp(__x)
452
+ {
453
+ __glibcxx_requires_valid_range(__first, __last);
454
+ c.insert(c.end(), __first, __last);
455
+ std::make_heap(c.begin(), c.end(), comp);
456
+ }
457
+
458
+ template<typename _InputIterator>
459
+ priority_queue(_InputIterator __first, _InputIterator __last,
460
+ const _Compare& __x = _Compare(),
461
+ _Sequence&& __s = _Sequence())
462
+ : c(std::move(__s)), comp(__x)
463
+ {
464
+ __glibcxx_requires_valid_range(__first, __last);
465
+ c.insert(c.end(), __first, __last);
466
+ std::make_heap(c.begin(), c.end(), comp);
467
+ }
468
+
469
+ priority_queue(priority_queue&& __pq)
470
+ : c(std::move(__pq.c)), comp(std::move(__pq.comp)) { }
471
+
472
+ priority_queue&
473
+ operator=(priority_queue&& __pq)
474
+ {
475
+ c = std::move(__pq.c);
476
+ comp = std::move(__pq.comp);
477
+ return *this;
478
+ }
479
+ #endif
480
+
481
+ /**
482
+ * Returns true if the %queue is empty.
483
+ */
484
+ bool
485
+ empty() const
486
+ { return c.empty(); }
487
+
488
+ /** Returns the number of elements in the %queue. */
489
+ size_type
490
+ size() const
491
+ { return c.size(); }
492
+
493
+ /**
494
+ * Returns a read-only (constant) reference to the data at the first
495
+ * element of the %queue.
496
+ */
497
+ const_reference
498
+ top() const
499
+ {
500
+ __glibcxx_requires_nonempty();
501
+ return c.front();
502
+ }
503
+
504
+ /**
505
+ * @brief Add data to the %queue.
506
+ * @param x Data to be added.
507
+ *
508
+ * This is a typical %queue operation.
509
+ * The time complexity of the operation depends on the underlying
510
+ * sequence.
511
+ */
512
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
513
+ void
514
+ push(const value_type& __x)
515
+ {
516
+ c.push_back(__x);
517
+ std::push_heap(c.begin(), c.end(), comp);
518
+ }
519
+ #else
520
+ // NB: DR 756.
521
+ template<typename... _Args>
522
+ void
523
+ push(_Args&&... __args)
524
+ {
525
+ c.push_back(std::forward<_Args>(__args)...);
526
+ std::push_heap(c.begin(), c.end(), comp);
527
+ }
528
+ #endif
529
+
530
+ /**
531
+ * @brief Removes first element.
532
+ *
533
+ * This is a typical %queue operation. It shrinks the %queue
534
+ * by one. The time complexity of the operation depends on the
535
+ * underlying sequence.
536
+ *
537
+ * Note that no data is returned, and if the first element's
538
+ * data is needed, it should be retrieved before pop() is
539
+ * called.
540
+ */
541
+ void
542
+ pop()
543
+ {
544
+ __glibcxx_requires_nonempty();
545
+ std::pop_heap(c.begin(), c.end(), comp);
546
+ c.pop_back();
547
+ }
548
+
549
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
550
+ void
551
+ swap(priority_queue&& __pq)
552
+ {
553
+ using std::swap;
554
+ c.swap(__pq.c);
555
+ swap(comp, __pq.comp);
556
+ }
557
+ #endif
558
+ };
559
+
560
+ // No equality/comparison operators are provided for priority_queue.
561
+
562
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
563
+ template<typename _Tp, typename _Sequence, typename _Compare>
564
+ inline void
565
+ swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
566
+ priority_queue<_Tp, _Sequence, _Compare>& __y)
567
+ { __x.swap(__y); }
568
+
569
+ template<typename _Tp, typename _Sequence, typename _Compare>
570
+ inline void
571
+ swap(priority_queue<_Tp, _Sequence, _Compare>&& __x,
572
+ priority_queue<_Tp, _Sequence, _Compare>& __y)
573
+ { __x.swap(__y); }
574
+
575
+ template<typename _Tp, typename _Sequence, typename _Compare>
576
+ inline void
577
+ swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
578
+ priority_queue<_Tp, _Sequence, _Compare>&& __y)
579
+ { __x.swap(__y); }
580
+ #endif
581
+
582
+ _GLIBCXX_END_NAMESPACE
583
+
584
+ #endif /* _STL_QUEUE_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_raw_storage_iter.h ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_raw_storage_iter.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_RAW_STORAGE_ITERATOR_H
63
+ #define _STL_RAW_STORAGE_ITERATOR_H 1
64
+
65
+ _GLIBCXX_BEGIN_NAMESPACE(std)
66
+
67
+ /**
68
+ * This iterator class lets algorithms store their results into
69
+ * uninitialized memory.
70
+ */
71
+ template <class _OutputIterator, class _Tp>
72
+ class raw_storage_iterator
73
+ : public iterator<output_iterator_tag, void, void, void, void>
74
+ {
75
+ protected:
76
+ _OutputIterator _M_iter;
77
+
78
+ public:
79
+ explicit
80
+ raw_storage_iterator(_OutputIterator __x)
81
+ : _M_iter(__x) {}
82
+
83
+ raw_storage_iterator&
84
+ operator*() { return *this; }
85
+
86
+ raw_storage_iterator&
87
+ operator=(const _Tp& __element)
88
+ {
89
+ std::_Construct(&*_M_iter, __element);
90
+ return *this;
91
+ }
92
+
93
+ raw_storage_iterator<_OutputIterator, _Tp>&
94
+ operator++()
95
+ {
96
+ ++_M_iter;
97
+ return *this;
98
+ }
99
+
100
+ raw_storage_iterator<_OutputIterator, _Tp>
101
+ operator++(int)
102
+ {
103
+ raw_storage_iterator<_OutputIterator, _Tp> __tmp = *this;
104
+ ++_M_iter;
105
+ return __tmp;
106
+ }
107
+ };
108
+
109
+ _GLIBCXX_END_NAMESPACE
110
+
111
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_relops.h ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // std::rel_ops implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2004, 2005, 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ * Copyright (c) 1996,1997
44
+ * Silicon Graphics
45
+ *
46
+ * Permission to use, copy, modify, distribute and sell this software
47
+ * and its documentation for any purpose is hereby granted without fee,
48
+ * provided that the above copyright notice appear in all copies and
49
+ * that both that copyright notice and this permission notice appear
50
+ * in supporting documentation. Silicon Graphics makes no
51
+ * representations about the suitability of this software for any
52
+ * purpose. It is provided "as is" without express or implied warranty.
53
+ *
54
+ */
55
+
56
+ /** @file stl_relops.h
57
+ * This is an internal header file, included by other library headers.
58
+ * You should not attempt to use it directly.
59
+ *
60
+ * Inclusion of this file has been removed from
61
+ * all of the other STL headers for safety reasons, except std_utility.h.
62
+ * For more information, see the thread of about twenty messages starting
63
+ * with http://gcc.gnu.org/ml/libstdc++/2001-01/msg00223.html, or
64
+ * http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.ambiguous_overloads
65
+ *
66
+ * Short summary: the rel_ops operators should be avoided for the present.
67
+ */
68
+
69
+ #ifndef _STL_RELOPS_H
70
+ #define _STL_RELOPS_H 1
71
+
72
+ _GLIBCXX_BEGIN_NAMESPACE(std)
73
+
74
+ namespace rel_ops
75
+ {
76
+ /** @namespace std::rel_ops
77
+ * @brief The generated relational operators are sequestered here.
78
+ */
79
+
80
+ /**
81
+ * @brief Defines @c != for arbitrary types, in terms of @c ==.
82
+ * @param x A thing.
83
+ * @param y Another thing.
84
+ * @return x != y
85
+ *
86
+ * This function uses @c == to determine its result.
87
+ */
88
+ template <class _Tp>
89
+ inline bool
90
+ operator!=(const _Tp& __x, const _Tp& __y)
91
+ { return !(__x == __y); }
92
+
93
+ /**
94
+ * @brief Defines @c > for arbitrary types, in terms of @c <.
95
+ * @param x A thing.
96
+ * @param y Another thing.
97
+ * @return x > y
98
+ *
99
+ * This function uses @c < to determine its result.
100
+ */
101
+ template <class _Tp>
102
+ inline bool
103
+ operator>(const _Tp& __x, const _Tp& __y)
104
+ { return __y < __x; }
105
+
106
+ /**
107
+ * @brief Defines @c <= for arbitrary types, in terms of @c <.
108
+ * @param x A thing.
109
+ * @param y Another thing.
110
+ * @return x <= y
111
+ *
112
+ * This function uses @c < to determine its result.
113
+ */
114
+ template <class _Tp>
115
+ inline bool
116
+ operator<=(const _Tp& __x, const _Tp& __y)
117
+ { return !(__y < __x); }
118
+
119
+ /**
120
+ * @brief Defines @c >= for arbitrary types, in terms of @c <.
121
+ * @param x A thing.
122
+ * @param y Another thing.
123
+ * @return x >= y
124
+ *
125
+ * This function uses @c < to determine its result.
126
+ */
127
+ template <class _Tp>
128
+ inline bool
129
+ operator>=(const _Tp& __x, const _Tp& __y)
130
+ { return !(__x < __y); }
131
+
132
+ } // namespace rel_ops
133
+
134
+ _GLIBCXX_END_NAMESPACE
135
+
136
+ #endif /* _STL_RELOPS_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_set.h ADDED
@@ -0,0 +1,665 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Set implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_set.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_SET_H
63
+ #define _STL_SET_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+
67
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
68
+
69
+ /**
70
+ * @brief A standard container made up of unique keys, which can be
71
+ * retrieved in logarithmic time.
72
+ *
73
+ * @ingroup Containers
74
+ * @ingroup Assoc_containers
75
+ *
76
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
77
+ * <a href="tables.html#66">reversible container</a>, and an
78
+ * <a href="tables.html#69">associative container</a> (using unique keys).
79
+ *
80
+ * Sets support bidirectional iterators.
81
+ *
82
+ * @param Key Type of key objects.
83
+ * @param Compare Comparison function object type, defaults to less<Key>.
84
+ * @param Alloc Allocator type, defaults to allocator<Key>.
85
+ *
86
+ * The private tree data is declared exactly the same way for set and
87
+ * multiset; the distinction is made entirely in how the tree functions are
88
+ * called (*_unique versus *_equal, same as the standard).
89
+ */
90
+ template<typename _Key, typename _Compare = std::less<_Key>,
91
+ typename _Alloc = std::allocator<_Key> >
92
+ class set
93
+ {
94
+ // concept requirements
95
+ typedef typename _Alloc::value_type _Alloc_value_type;
96
+ __glibcxx_class_requires(_Key, _SGIAssignableConcept)
97
+ __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
98
+ _BinaryFunctionConcept)
99
+ __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
100
+
101
+ public:
102
+ // typedefs:
103
+ //@{
104
+ /// Public typedefs.
105
+ typedef _Key key_type;
106
+ typedef _Key value_type;
107
+ typedef _Compare key_compare;
108
+ typedef _Compare value_compare;
109
+ typedef _Alloc allocator_type;
110
+ //@}
111
+
112
+ private:
113
+ typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
114
+
115
+ typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
116
+ key_compare, _Key_alloc_type> _Rep_type;
117
+ _Rep_type _M_t; // Red-black tree representing set.
118
+
119
+ public:
120
+ //@{
121
+ /// Iterator-related typedefs.
122
+ typedef typename _Key_alloc_type::pointer pointer;
123
+ typedef typename _Key_alloc_type::const_pointer const_pointer;
124
+ typedef typename _Key_alloc_type::reference reference;
125
+ typedef typename _Key_alloc_type::const_reference const_reference;
126
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
127
+ // DR 103. set::iterator is required to be modifiable,
128
+ // but this allows modification of keys.
129
+ typedef typename _Rep_type::const_iterator iterator;
130
+ typedef typename _Rep_type::const_iterator const_iterator;
131
+ typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
132
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
133
+ typedef typename _Rep_type::size_type size_type;
134
+ typedef typename _Rep_type::difference_type difference_type;
135
+ //@}
136
+
137
+ // allocation/deallocation
138
+ /**
139
+ * @brief Default constructor creates no elements.
140
+ */
141
+ set()
142
+ : _M_t() { }
143
+
144
+ /**
145
+ * @brief Creates a %set with no elements.
146
+ * @param comp Comparator to use.
147
+ * @param a An allocator object.
148
+ */
149
+ explicit
150
+ set(const _Compare& __comp,
151
+ const allocator_type& __a = allocator_type())
152
+ : _M_t(__comp, __a) { }
153
+
154
+ /**
155
+ * @brief Builds a %set from a range.
156
+ * @param first An input iterator.
157
+ * @param last An input iterator.
158
+ *
159
+ * Create a %set consisting of copies of the elements from [first,last).
160
+ * This is linear in N if the range is already sorted, and NlogN
161
+ * otherwise (where N is distance(first,last)).
162
+ */
163
+ template<typename _InputIterator>
164
+ set(_InputIterator __first, _InputIterator __last)
165
+ : _M_t()
166
+ { _M_t._M_insert_unique(__first, __last); }
167
+
168
+ /**
169
+ * @brief Builds a %set from a range.
170
+ * @param first An input iterator.
171
+ * @param last An input iterator.
172
+ * @param comp A comparison functor.
173
+ * @param a An allocator object.
174
+ *
175
+ * Create a %set consisting of copies of the elements from [first,last).
176
+ * This is linear in N if the range is already sorted, and NlogN
177
+ * otherwise (where N is distance(first,last)).
178
+ */
179
+ template<typename _InputIterator>
180
+ set(_InputIterator __first, _InputIterator __last,
181
+ const _Compare& __comp,
182
+ const allocator_type& __a = allocator_type())
183
+ : _M_t(__comp, __a)
184
+ { _M_t._M_insert_unique(__first, __last); }
185
+
186
+ /**
187
+ * @brief %Set copy constructor.
188
+ * @param x A %set of identical element and allocator types.
189
+ *
190
+ * The newly-created %set uses a copy of the allocation object used
191
+ * by @a x.
192
+ */
193
+ set(const set& __x)
194
+ : _M_t(__x._M_t) { }
195
+
196
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
197
+ /**
198
+ * @brief %Set move constructor
199
+ * @param x A %set of identical element and allocator types.
200
+ *
201
+ * The newly-created %set contains the exact contents of @a x.
202
+ * The contents of @a x are a valid, but unspecified %set.
203
+ */
204
+ set(set&& __x)
205
+ : _M_t(std::forward<_Rep_type>(__x._M_t)) { }
206
+ #endif
207
+
208
+ /**
209
+ * @brief %Set assignment operator.
210
+ * @param x A %set of identical element and allocator types.
211
+ *
212
+ * All the elements of @a x are copied, but unlike the copy constructor,
213
+ * the allocator object is not copied.
214
+ */
215
+ set&
216
+ operator=(const set& __x)
217
+ {
218
+ _M_t = __x._M_t;
219
+ return *this;
220
+ }
221
+
222
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
223
+ /**
224
+ * @brief %Set move assignment operator.
225
+ * @param x A %set of identical element and allocator types.
226
+ *
227
+ * The contents of @a x are moved into this %set (without copying).
228
+ * @a x is a valid, but unspecified %set.
229
+ */
230
+ set&
231
+ operator=(set&& __x)
232
+ {
233
+ // NB: DR 675.
234
+ this->clear();
235
+ this->swap(__x);
236
+ return *this;
237
+ }
238
+ #endif
239
+
240
+ // accessors:
241
+
242
+ /// Returns the comparison object with which the %set was constructed.
243
+ key_compare
244
+ key_comp() const
245
+ { return _M_t.key_comp(); }
246
+ /// Returns the comparison object with which the %set was constructed.
247
+ value_compare
248
+ value_comp() const
249
+ { return _M_t.key_comp(); }
250
+ /// Returns the allocator object with which the %set was constructed.
251
+ allocator_type
252
+ get_allocator() const
253
+ { return _M_t.get_allocator(); }
254
+
255
+ /**
256
+ * Returns a read-only (constant) iterator that points to the first
257
+ * element in the %set. Iteration is done in ascending order according
258
+ * to the keys.
259
+ */
260
+ iterator
261
+ begin() const
262
+ { return _M_t.begin(); }
263
+
264
+ /**
265
+ * Returns a read-only (constant) iterator that points one past the last
266
+ * element in the %set. Iteration is done in ascending order according
267
+ * to the keys.
268
+ */
269
+ iterator
270
+ end() const
271
+ { return _M_t.end(); }
272
+
273
+ /**
274
+ * Returns a read-only (constant) iterator that points to the last
275
+ * element in the %set. Iteration is done in descending order according
276
+ * to the keys.
277
+ */
278
+ reverse_iterator
279
+ rbegin() const
280
+ { return _M_t.rbegin(); }
281
+
282
+ /**
283
+ * Returns a read-only (constant) reverse iterator that points to the
284
+ * last pair in the %set. Iteration is done in descending order
285
+ * according to the keys.
286
+ */
287
+ reverse_iterator
288
+ rend() const
289
+ { return _M_t.rend(); }
290
+
291
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
292
+ /**
293
+ * Returns a read-only (constant) iterator that points to the first
294
+ * element in the %set. Iteration is done in ascending order according
295
+ * to the keys.
296
+ */
297
+ iterator
298
+ cbegin() const
299
+ { return _M_t.begin(); }
300
+
301
+ /**
302
+ * Returns a read-only (constant) iterator that points one past the last
303
+ * element in the %set. Iteration is done in ascending order according
304
+ * to the keys.
305
+ */
306
+ iterator
307
+ cend() const
308
+ { return _M_t.end(); }
309
+
310
+ /**
311
+ * Returns a read-only (constant) iterator that points to the last
312
+ * element in the %set. Iteration is done in descending order according
313
+ * to the keys.
314
+ */
315
+ reverse_iterator
316
+ crbegin() const
317
+ { return _M_t.rbegin(); }
318
+
319
+ /**
320
+ * Returns a read-only (constant) reverse iterator that points to the
321
+ * last pair in the %set. Iteration is done in descending order
322
+ * according to the keys.
323
+ */
324
+ reverse_iterator
325
+ crend() const
326
+ { return _M_t.rend(); }
327
+ #endif
328
+
329
+ /// Returns true if the %set is empty.
330
+ bool
331
+ empty() const
332
+ { return _M_t.empty(); }
333
+
334
+ /// Returns the size of the %set.
335
+ size_type
336
+ size() const
337
+ { return _M_t.size(); }
338
+
339
+ /// Returns the maximum size of the %set.
340
+ size_type
341
+ max_size() const
342
+ { return _M_t.max_size(); }
343
+
344
+ /**
345
+ * @brief Swaps data with another %set.
346
+ * @param x A %set of the same element and allocator types.
347
+ *
348
+ * This exchanges the elements between two sets in constant time.
349
+ * (It is only swapping a pointer, an integer, and an instance of
350
+ * the @c Compare type (which itself is often stateless and empty), so it
351
+ * should be quite fast.)
352
+ * Note that the global std::swap() function is specialized such that
353
+ * std::swap(s1,s2) will feed to this function.
354
+ */
355
+ void
356
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
357
+ swap(set&& __x)
358
+ #else
359
+ swap(set& __x)
360
+ #endif
361
+ { _M_t.swap(__x._M_t); }
362
+
363
+ // insert/erase
364
+ /**
365
+ * @brief Attempts to insert an element into the %set.
366
+ * @param x Element to be inserted.
367
+ * @return A pair, of which the first element is an iterator that points
368
+ * to the possibly inserted element, and the second is a bool
369
+ * that is true if the element was actually inserted.
370
+ *
371
+ * This function attempts to insert an element into the %set. A %set
372
+ * relies on unique keys and thus an element is only inserted if it is
373
+ * not already present in the %set.
374
+ *
375
+ * Insertion requires logarithmic time.
376
+ */
377
+ std::pair<iterator, bool>
378
+ insert(const value_type& __x)
379
+ {
380
+ std::pair<typename _Rep_type::iterator, bool> __p =
381
+ _M_t._M_insert_unique(__x);
382
+ return std::pair<iterator, bool>(__p.first, __p.second);
383
+ }
384
+
385
+ /**
386
+ * @brief Attempts to insert an element into the %set.
387
+ * @param position An iterator that serves as a hint as to where the
388
+ * element should be inserted.
389
+ * @param x Element to be inserted.
390
+ * @return An iterator that points to the element with key of @a x (may
391
+ * or may not be the element passed in).
392
+ *
393
+ * This function is not concerned about whether the insertion took place,
394
+ * and thus does not return a boolean like the single-argument insert()
395
+ * does. Note that the first parameter is only a hint and can
396
+ * potentially improve the performance of the insertion process. A bad
397
+ * hint would cause no gains in efficiency.
398
+ *
399
+ * For more on "hinting", see:
400
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
401
+ *
402
+ * Insertion requires logarithmic time (if the hint is not taken).
403
+ */
404
+ iterator
405
+ insert(iterator __position, const value_type& __x)
406
+ { return _M_t._M_insert_unique_(__position, __x); }
407
+
408
+ /**
409
+ * @brief A template function that attempts to insert a range
410
+ * of elements.
411
+ * @param first Iterator pointing to the start of the range to be
412
+ * inserted.
413
+ * @param last Iterator pointing to the end of the range.
414
+ *
415
+ * Complexity similar to that of the range constructor.
416
+ */
417
+ template<typename _InputIterator>
418
+ void
419
+ insert(_InputIterator __first, _InputIterator __last)
420
+ { _M_t._M_insert_unique(__first, __last); }
421
+
422
+ /**
423
+ * @brief Erases an element from a %set.
424
+ * @param position An iterator pointing to the element to be erased.
425
+ *
426
+ * This function erases an element, pointed to by the given iterator,
427
+ * from a %set. Note that this function only erases the element, and
428
+ * that if the element is itself a pointer, the pointed-to memory is not
429
+ * touched in any way. Managing the pointer is the user's responsibility.
430
+ */
431
+ void
432
+ erase(iterator __position)
433
+ { _M_t.erase(__position); }
434
+
435
+ /**
436
+ * @brief Erases elements according to the provided key.
437
+ * @param x Key of element to be erased.
438
+ * @return The number of elements erased.
439
+ *
440
+ * This function erases all the elements located by the given key from
441
+ * a %set.
442
+ * Note that this function only erases the element, and that if
443
+ * the element is itself a pointer, the pointed-to memory is not touched
444
+ * in any way. Managing the pointer is the user's responsibility.
445
+ */
446
+ size_type
447
+ erase(const key_type& __x)
448
+ { return _M_t.erase(__x); }
449
+
450
+ /**
451
+ * @brief Erases a [first,last) range of elements from a %set.
452
+ * @param first Iterator pointing to the start of the range to be
453
+ * erased.
454
+ * @param last Iterator pointing to the end of the range to be erased.
455
+ *
456
+ * This function erases a sequence of elements from a %set.
457
+ * Note that this function only erases the element, and that if
458
+ * the element is itself a pointer, the pointed-to memory is not touched
459
+ * in any way. Managing the pointer is the user's responsibility.
460
+ */
461
+ void
462
+ erase(iterator __first, iterator __last)
463
+ { _M_t.erase(__first, __last); }
464
+
465
+ /**
466
+ * Erases all elements in a %set. Note that this function only erases
467
+ * the elements, and that if the elements themselves are pointers, the
468
+ * pointed-to memory is not touched in any way. Managing the pointer is
469
+ * the user's responsibility.
470
+ */
471
+ void
472
+ clear()
473
+ { _M_t.clear(); }
474
+
475
+ // set operations:
476
+
477
+ /**
478
+ * @brief Finds the number of elements.
479
+ * @param x Element to located.
480
+ * @return Number of elements with specified key.
481
+ *
482
+ * This function only makes sense for multisets; for set the result will
483
+ * either be 0 (not present) or 1 (present).
484
+ */
485
+ size_type
486
+ count(const key_type& __x) const
487
+ { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
488
+
489
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
490
+ // 214. set::find() missing const overload
491
+ //@{
492
+ /**
493
+ * @brief Tries to locate an element in a %set.
494
+ * @param x Element to be located.
495
+ * @return Iterator pointing to sought-after element, or end() if not
496
+ * found.
497
+ *
498
+ * This function takes a key and tries to locate the element with which
499
+ * the key matches. If successful the function returns an iterator
500
+ * pointing to the sought after element. If unsuccessful it returns the
501
+ * past-the-end ( @c end() ) iterator.
502
+ */
503
+ iterator
504
+ find(const key_type& __x)
505
+ { return _M_t.find(__x); }
506
+
507
+ const_iterator
508
+ find(const key_type& __x) const
509
+ { return _M_t.find(__x); }
510
+ //@}
511
+
512
+ //@{
513
+ /**
514
+ * @brief Finds the beginning of a subsequence matching given key.
515
+ * @param x Key to be located.
516
+ * @return Iterator pointing to first element equal to or greater
517
+ * than key, or end().
518
+ *
519
+ * This function returns the first element of a subsequence of elements
520
+ * that matches the given key. If unsuccessful it returns an iterator
521
+ * pointing to the first element that has a greater value than given key
522
+ * or end() if no such element exists.
523
+ */
524
+ iterator
525
+ lower_bound(const key_type& __x)
526
+ { return _M_t.lower_bound(__x); }
527
+
528
+ const_iterator
529
+ lower_bound(const key_type& __x) const
530
+ { return _M_t.lower_bound(__x); }
531
+ //@}
532
+
533
+ //@{
534
+ /**
535
+ * @brief Finds the end of a subsequence matching given key.
536
+ * @param x Key to be located.
537
+ * @return Iterator pointing to the first element
538
+ * greater than key, or end().
539
+ */
540
+ iterator
541
+ upper_bound(const key_type& __x)
542
+ { return _M_t.upper_bound(__x); }
543
+
544
+ const_iterator
545
+ upper_bound(const key_type& __x) const
546
+ { return _M_t.upper_bound(__x); }
547
+ //@}
548
+
549
+ //@{
550
+ /**
551
+ * @brief Finds a subsequence matching given key.
552
+ * @param x Key to be located.
553
+ * @return Pair of iterators that possibly points to the subsequence
554
+ * matching given key.
555
+ *
556
+ * This function is equivalent to
557
+ * @code
558
+ * std::make_pair(c.lower_bound(val),
559
+ * c.upper_bound(val))
560
+ * @endcode
561
+ * (but is faster than making the calls separately).
562
+ *
563
+ * This function probably only makes sense for multisets.
564
+ */
565
+ std::pair<iterator, iterator>
566
+ equal_range(const key_type& __x)
567
+ { return _M_t.equal_range(__x); }
568
+
569
+ std::pair<const_iterator, const_iterator>
570
+ equal_range(const key_type& __x) const
571
+ { return _M_t.equal_range(__x); }
572
+ //@}
573
+
574
+ template<typename _K1, typename _C1, typename _A1>
575
+ friend bool
576
+ operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
577
+
578
+ template<typename _K1, typename _C1, typename _A1>
579
+ friend bool
580
+ operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
581
+ };
582
+
583
+
584
+ /**
585
+ * @brief Set equality comparison.
586
+ * @param x A %set.
587
+ * @param y A %set of the same type as @a x.
588
+ * @return True iff the size and elements of the sets are equal.
589
+ *
590
+ * This is an equivalence relation. It is linear in the size of the sets.
591
+ * Sets are considered equivalent if their sizes are equal, and if
592
+ * corresponding elements compare equal.
593
+ */
594
+ template<typename _Key, typename _Compare, typename _Alloc>
595
+ inline bool
596
+ operator==(const set<_Key, _Compare, _Alloc>& __x,
597
+ const set<_Key, _Compare, _Alloc>& __y)
598
+ { return __x._M_t == __y._M_t; }
599
+
600
+ /**
601
+ * @brief Set ordering relation.
602
+ * @param x A %set.
603
+ * @param y A %set of the same type as @a x.
604
+ * @return True iff @a x is lexicographically less than @a y.
605
+ *
606
+ * This is a total ordering relation. It is linear in the size of the
607
+ * maps. The elements must be comparable with @c <.
608
+ *
609
+ * See std::lexicographical_compare() for how the determination is made.
610
+ */
611
+ template<typename _Key, typename _Compare, typename _Alloc>
612
+ inline bool
613
+ operator<(const set<_Key, _Compare, _Alloc>& __x,
614
+ const set<_Key, _Compare, _Alloc>& __y)
615
+ { return __x._M_t < __y._M_t; }
616
+
617
+ /// Returns !(x == y).
618
+ template<typename _Key, typename _Compare, typename _Alloc>
619
+ inline bool
620
+ operator!=(const set<_Key, _Compare, _Alloc>& __x,
621
+ const set<_Key, _Compare, _Alloc>& __y)
622
+ { return !(__x == __y); }
623
+
624
+ /// Returns y < x.
625
+ template<typename _Key, typename _Compare, typename _Alloc>
626
+ inline bool
627
+ operator>(const set<_Key, _Compare, _Alloc>& __x,
628
+ const set<_Key, _Compare, _Alloc>& __y)
629
+ { return __y < __x; }
630
+
631
+ /// Returns !(y < x)
632
+ template<typename _Key, typename _Compare, typename _Alloc>
633
+ inline bool
634
+ operator<=(const set<_Key, _Compare, _Alloc>& __x,
635
+ const set<_Key, _Compare, _Alloc>& __y)
636
+ { return !(__y < __x); }
637
+
638
+ /// Returns !(x < y)
639
+ template<typename _Key, typename _Compare, typename _Alloc>
640
+ inline bool
641
+ operator>=(const set<_Key, _Compare, _Alloc>& __x,
642
+ const set<_Key, _Compare, _Alloc>& __y)
643
+ { return !(__x < __y); }
644
+
645
+ /// See std::set::swap().
646
+ template<typename _Key, typename _Compare, typename _Alloc>
647
+ inline void
648
+ swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
649
+ { __x.swap(__y); }
650
+
651
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
652
+ template<typename _Key, typename _Compare, typename _Alloc>
653
+ inline void
654
+ swap(set<_Key, _Compare, _Alloc>&& __x, set<_Key, _Compare, _Alloc>& __y)
655
+ { __x.swap(__y); }
656
+
657
+ template<typename _Key, typename _Compare, typename _Alloc>
658
+ inline void
659
+ swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>&& __y)
660
+ { __x.swap(__y); }
661
+ #endif
662
+
663
+ _GLIBCXX_END_NESTED_NAMESPACE
664
+
665
+ #endif /* _STL_SET_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_stack.h ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Stack implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_stack.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_STACK_H
63
+ #define _STL_STACK_H 1
64
+
65
+ #include <bits/concept_check.h>
66
+ #include <debug/debug.h>
67
+
68
+ _GLIBCXX_BEGIN_NAMESPACE(std)
69
+
70
+ /**
71
+ * @brief A standard container giving FILO behavior.
72
+ *
73
+ * @ingroup Containers
74
+ * @ingroup Sequences
75
+ *
76
+ * Meets many of the requirements of a
77
+ * <a href="tables.html#65">container</a>,
78
+ * but does not define anything to do with iterators. Very few of the
79
+ * other standard container interfaces are defined.
80
+ *
81
+ * This is not a true container, but an @e adaptor. It holds
82
+ * another container, and provides a wrapper interface to that
83
+ * container. The wrapper is what enforces strict
84
+ * first-in-last-out %stack behavior.
85
+ *
86
+ * The second template parameter defines the type of the underlying
87
+ * sequence/container. It defaults to std::deque, but it can be
88
+ * any type that supports @c back, @c push_back, and @c pop_front,
89
+ * such as std::list, std::vector, or an appropriate user-defined
90
+ * type.
91
+ *
92
+ * Members not found in "normal" containers are @c container_type,
93
+ * which is a typedef for the second Sequence parameter, and @c
94
+ * push, @c pop, and @c top, which are standard %stack/FILO
95
+ * operations.
96
+ */
97
+ template<typename _Tp, typename _Sequence = deque<_Tp> >
98
+ class stack
99
+ {
100
+ // concept requirements
101
+ typedef typename _Sequence::value_type _Sequence_value_type;
102
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
103
+ __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
104
+ __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
105
+
106
+ template<typename _Tp1, typename _Seq1>
107
+ friend bool
108
+ operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
109
+
110
+ template<typename _Tp1, typename _Seq1>
111
+ friend bool
112
+ operator<(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
113
+
114
+ public:
115
+ typedef typename _Sequence::value_type value_type;
116
+ typedef typename _Sequence::reference reference;
117
+ typedef typename _Sequence::const_reference const_reference;
118
+ typedef typename _Sequence::size_type size_type;
119
+ typedef _Sequence container_type;
120
+
121
+ protected:
122
+ // See queue::c for notes on this name.
123
+ _Sequence c;
124
+
125
+ public:
126
+ // XXX removed old def ctor, added def arg to this one to match 14882
127
+ /**
128
+ * @brief Default constructor creates no elements.
129
+ */
130
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
131
+ explicit
132
+ stack(const _Sequence& __c = _Sequence())
133
+ : c(__c) { }
134
+ #else
135
+ explicit
136
+ stack(const _Sequence& __c)
137
+ : c(__c) { }
138
+
139
+ explicit
140
+ stack(_Sequence&& __c = _Sequence())
141
+ : c(std::move(__c)) { }
142
+ #endif
143
+
144
+ /**
145
+ * Returns true if the %stack is empty.
146
+ */
147
+ bool
148
+ empty() const
149
+ { return c.empty(); }
150
+
151
+ /** Returns the number of elements in the %stack. */
152
+ size_type
153
+ size() const
154
+ { return c.size(); }
155
+
156
+ /**
157
+ * Returns a read/write reference to the data at the first
158
+ * element of the %stack.
159
+ */
160
+ reference
161
+ top()
162
+ {
163
+ __glibcxx_requires_nonempty();
164
+ return c.back();
165
+ }
166
+
167
+ /**
168
+ * Returns a read-only (constant) reference to the data at the first
169
+ * element of the %stack.
170
+ */
171
+ const_reference
172
+ top() const
173
+ {
174
+ __glibcxx_requires_nonempty();
175
+ return c.back();
176
+ }
177
+
178
+ /**
179
+ * @brief Add data to the top of the %stack.
180
+ * @param x Data to be added.
181
+ *
182
+ * This is a typical %stack operation. The function creates an
183
+ * element at the top of the %stack and assigns the given data
184
+ * to it. The time complexity of the operation depends on the
185
+ * underlying sequence.
186
+ */
187
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
188
+ void
189
+ push(const value_type& __x)
190
+ { c.push_back(__x); }
191
+ #else
192
+ // NB: DR 756.
193
+ template<typename... _Args>
194
+ void
195
+ push(_Args&&... __args)
196
+ { c.push_back(std::forward<_Args>(__args)...); }
197
+ #endif
198
+
199
+ /**
200
+ * @brief Removes first element.
201
+ *
202
+ * This is a typical %stack operation. It shrinks the %stack
203
+ * by one. The time complexity of the operation depends on the
204
+ * underlying sequence.
205
+ *
206
+ * Note that no data is returned, and if the first element's
207
+ * data is needed, it should be retrieved before pop() is
208
+ * called.
209
+ */
210
+ void
211
+ pop()
212
+ {
213
+ __glibcxx_requires_nonempty();
214
+ c.pop_back();
215
+ }
216
+
217
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
218
+ void
219
+ swap(stack&& __s)
220
+ { c.swap(__s.c); }
221
+ #endif
222
+ };
223
+
224
+ /**
225
+ * @brief Stack equality comparison.
226
+ * @param x A %stack.
227
+ * @param y A %stack of the same type as @a x.
228
+ * @return True iff the size and elements of the stacks are equal.
229
+ *
230
+ * This is an equivalence relation. Complexity and semantics
231
+ * depend on the underlying sequence type, but the expected rules
232
+ * are: this relation is linear in the size of the sequences, and
233
+ * stacks are considered equivalent if their sequences compare
234
+ * equal.
235
+ */
236
+ template<typename _Tp, typename _Seq>
237
+ inline bool
238
+ operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
239
+ { return __x.c == __y.c; }
240
+
241
+ /**
242
+ * @brief Stack ordering relation.
243
+ * @param x A %stack.
244
+ * @param y A %stack of the same type as @a x.
245
+ * @return True iff @a x is lexicographically less than @a y.
246
+ *
247
+ * This is an total ordering relation. Complexity and semantics
248
+ * depend on the underlying sequence type, but the expected rules
249
+ * are: this relation is linear in the size of the sequences, the
250
+ * elements must be comparable with @c <, and
251
+ * std::lexicographical_compare() is usually used to make the
252
+ * determination.
253
+ */
254
+ template<typename _Tp, typename _Seq>
255
+ inline bool
256
+ operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
257
+ { return __x.c < __y.c; }
258
+
259
+ /// Based on operator==
260
+ template<typename _Tp, typename _Seq>
261
+ inline bool
262
+ operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
263
+ { return !(__x == __y); }
264
+
265
+ /// Based on operator<
266
+ template<typename _Tp, typename _Seq>
267
+ inline bool
268
+ operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
269
+ { return __y < __x; }
270
+
271
+ /// Based on operator<
272
+ template<typename _Tp, typename _Seq>
273
+ inline bool
274
+ operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
275
+ { return !(__y < __x); }
276
+
277
+ /// Based on operator<
278
+ template<typename _Tp, typename _Seq>
279
+ inline bool
280
+ operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
281
+ { return !(__x < __y); }
282
+
283
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
284
+ template<typename _Tp, typename _Seq>
285
+ inline void
286
+ swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y)
287
+ { __x.swap(__y); }
288
+
289
+ template<typename _Tp, typename _Seq>
290
+ inline void
291
+ swap(stack<_Tp, _Seq>&& __x, stack<_Tp, _Seq>& __y)
292
+ { __x.swap(__y); }
293
+
294
+ template<typename _Tp, typename _Seq>
295
+ inline void
296
+ swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>&& __y)
297
+ { __x.swap(__y); }
298
+ #endif
299
+
300
+ _GLIBCXX_END_NAMESPACE
301
+
302
+ #endif /* _STL_STACK_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_tempbuf.h ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Temporary buffer implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_tempbuf.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_TEMPBUF_H
63
+ #define _STL_TEMPBUF_H 1
64
+
65
+ #include <bits/stl_algobase.h>
66
+ #include <bits/stl_construct.h>
67
+ #include <bits/stl_uninitialized.h>
68
+
69
+ _GLIBCXX_BEGIN_NAMESPACE(std)
70
+
71
+ /**
72
+ * @brief Allocates a temporary buffer.
73
+ * @param len The number of objects of type Tp.
74
+ * @return See full description.
75
+ *
76
+ * Reinventing the wheel, but this time with prettier spokes!
77
+ *
78
+ * This function tries to obtain storage for @c len adjacent Tp
79
+ * objects. The objects themselves are not constructed, of course.
80
+ * A pair<> is returned containing "the buffer s address and
81
+ * capacity (in the units of sizeof(Tp)), or a pair of 0 values if
82
+ * no storage can be obtained." Note that the capacity obtained
83
+ * may be less than that requested if the memory is unavailable;
84
+ * you should compare len with the .second return value.
85
+ *
86
+ * Provides the nothrow exception guarantee.
87
+ */
88
+ template<typename _Tp>
89
+ pair<_Tp*, ptrdiff_t>
90
+ get_temporary_buffer(ptrdiff_t __len)
91
+ {
92
+ const ptrdiff_t __max =
93
+ __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
94
+ if (__len > __max)
95
+ __len = __max;
96
+
97
+ while (__len > 0)
98
+ {
99
+ _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp),
100
+ std::nothrow));
101
+ if (__tmp != 0)
102
+ return std::pair<_Tp*, ptrdiff_t>(__tmp, __len);
103
+ __len /= 2;
104
+ }
105
+ return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0);
106
+ }
107
+
108
+ /**
109
+ * @brief The companion to get_temporary_buffer().
110
+ * @param p A buffer previously allocated by get_temporary_buffer.
111
+ * @return None.
112
+ *
113
+ * Frees the memory pointed to by p.
114
+ */
115
+ template<typename _Tp>
116
+ inline void
117
+ return_temporary_buffer(_Tp* __p)
118
+ { ::operator delete(__p, std::nothrow); }
119
+
120
+
121
+ /**
122
+ * This class is used in two places: stl_algo.h and ext/memory,
123
+ * where it is wrapped as the temporary_buffer class. See
124
+ * temporary_buffer docs for more notes.
125
+ */
126
+ template<typename _ForwardIterator, typename _Tp>
127
+ class _Temporary_buffer
128
+ {
129
+ // concept requirements
130
+ __glibcxx_class_requires(_ForwardIterator, _ForwardIteratorConcept)
131
+
132
+ public:
133
+ typedef _Tp value_type;
134
+ typedef value_type* pointer;
135
+ typedef pointer iterator;
136
+ typedef ptrdiff_t size_type;
137
+
138
+ protected:
139
+ size_type _M_original_len;
140
+ size_type _M_len;
141
+ pointer _M_buffer;
142
+
143
+ public:
144
+ /// As per Table mumble.
145
+ size_type
146
+ size() const
147
+ { return _M_len; }
148
+
149
+ /// Returns the size requested by the constructor; may be >size().
150
+ size_type
151
+ requested_size() const
152
+ { return _M_original_len; }
153
+
154
+ /// As per Table mumble.
155
+ iterator
156
+ begin()
157
+ { return _M_buffer; }
158
+
159
+ /// As per Table mumble.
160
+ iterator
161
+ end()
162
+ { return _M_buffer + _M_len; }
163
+
164
+ /**
165
+ * Constructs a temporary buffer of a size somewhere between
166
+ * zero and the size of the given range.
167
+ */
168
+ _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last);
169
+
170
+ ~_Temporary_buffer()
171
+ {
172
+ std::_Destroy(_M_buffer, _M_buffer + _M_len);
173
+ std::return_temporary_buffer(_M_buffer);
174
+ }
175
+
176
+ private:
177
+ // Disable copy constructor and assignment operator.
178
+ _Temporary_buffer(const _Temporary_buffer&);
179
+
180
+ void
181
+ operator=(const _Temporary_buffer&);
182
+ };
183
+
184
+ template<typename _ForwardIterator, typename _Tp>
185
+ _Temporary_buffer<_ForwardIterator, _Tp>::
186
+ _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
187
+ : _M_original_len(std::distance(__first, __last)),
188
+ _M_len(0), _M_buffer(0)
189
+ {
190
+ try
191
+ {
192
+ std::pair<pointer, size_type> __p(std::get_temporary_buffer<
193
+ value_type>(_M_original_len));
194
+ _M_buffer = __p.first;
195
+ _M_len = __p.second;
196
+ if (!__is_pod(_Tp) && _M_len > 0)
197
+ std::uninitialized_fill_n(_M_buffer, _M_len, *__first);
198
+ }
199
+ catch(...)
200
+ {
201
+ std::return_temporary_buffer(_M_buffer);
202
+ _M_buffer = 0;
203
+ _M_len = 0;
204
+ __throw_exception_again;
205
+ }
206
+ }
207
+
208
+ _GLIBCXX_END_NAMESPACE
209
+
210
+ #endif /* _STL_TEMPBUF_H */
211
+
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_tree.h ADDED
@@ -0,0 +1,1466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // RB tree implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1996,1997
34
+ * Silicon Graphics Computer Systems, Inc.
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Silicon Graphics makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1994
46
+ * Hewlett-Packard Company
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Hewlett-Packard Company makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ *
56
+ *
57
+ */
58
+
59
+ /** @file stl_tree.h
60
+ * This is an internal header file, included by other library headers.
61
+ * You should not attempt to use it directly.
62
+ */
63
+
64
+ #ifndef _STL_TREE_H
65
+ #define _STL_TREE_H 1
66
+
67
+ #include <bits/stl_algobase.h>
68
+ #include <bits/allocator.h>
69
+ #include <bits/stl_function.h>
70
+ #include <bits/cpp_type_traits.h>
71
+
72
+ _GLIBCXX_BEGIN_NAMESPACE(std)
73
+
74
+ // Red-black tree class, designed for use in implementing STL
75
+ // associative containers (set, multiset, map, and multimap). The
76
+ // insertion and deletion algorithms are based on those in Cormen,
77
+ // Leiserson, and Rivest, Introduction to Algorithms (MIT Press,
78
+ // 1990), except that
79
+ //
80
+ // (1) the header cell is maintained with links not only to the root
81
+ // but also to the leftmost node of the tree, to enable constant
82
+ // time begin(), and to the rightmost node of the tree, to enable
83
+ // linear time performance when used with the generic set algorithms
84
+ // (set_union, etc.)
85
+ //
86
+ // (2) when a node being deleted has two children its successor node
87
+ // is relinked into its place, rather than copied, so that the only
88
+ // iterators invalidated are those referring to the deleted node.
89
+
90
+ enum _Rb_tree_color { _S_red = false, _S_black = true };
91
+
92
+ struct _Rb_tree_node_base
93
+ {
94
+ typedef _Rb_tree_node_base* _Base_ptr;
95
+ typedef const _Rb_tree_node_base* _Const_Base_ptr;
96
+
97
+ _Rb_tree_color _M_color;
98
+ _Base_ptr _M_parent;
99
+ _Base_ptr _M_left;
100
+ _Base_ptr _M_right;
101
+
102
+ static _Base_ptr
103
+ _S_minimum(_Base_ptr __x)
104
+ {
105
+ while (__x->_M_left != 0) __x = __x->_M_left;
106
+ return __x;
107
+ }
108
+
109
+ static _Const_Base_ptr
110
+ _S_minimum(_Const_Base_ptr __x)
111
+ {
112
+ while (__x->_M_left != 0) __x = __x->_M_left;
113
+ return __x;
114
+ }
115
+
116
+ static _Base_ptr
117
+ _S_maximum(_Base_ptr __x)
118
+ {
119
+ while (__x->_M_right != 0) __x = __x->_M_right;
120
+ return __x;
121
+ }
122
+
123
+ static _Const_Base_ptr
124
+ _S_maximum(_Const_Base_ptr __x)
125
+ {
126
+ while (__x->_M_right != 0) __x = __x->_M_right;
127
+ return __x;
128
+ }
129
+ };
130
+
131
+ template<typename _Val>
132
+ struct _Rb_tree_node : public _Rb_tree_node_base
133
+ {
134
+ typedef _Rb_tree_node<_Val>* _Link_type;
135
+ _Val _M_value_field;
136
+ };
137
+
138
+ _Rb_tree_node_base*
139
+ _Rb_tree_increment(_Rb_tree_node_base* __x);
140
+
141
+ const _Rb_tree_node_base*
142
+ _Rb_tree_increment(const _Rb_tree_node_base* __x);
143
+
144
+ _Rb_tree_node_base*
145
+ _Rb_tree_decrement(_Rb_tree_node_base* __x);
146
+
147
+ const _Rb_tree_node_base*
148
+ _Rb_tree_decrement(const _Rb_tree_node_base* __x);
149
+
150
+ template<typename _Tp>
151
+ struct _Rb_tree_iterator
152
+ {
153
+ typedef _Tp value_type;
154
+ typedef _Tp& reference;
155
+ typedef _Tp* pointer;
156
+
157
+ typedef bidirectional_iterator_tag iterator_category;
158
+ typedef ptrdiff_t difference_type;
159
+
160
+ typedef _Rb_tree_iterator<_Tp> _Self;
161
+ typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
162
+ typedef _Rb_tree_node<_Tp>* _Link_type;
163
+
164
+ _Rb_tree_iterator()
165
+ : _M_node() { }
166
+
167
+ explicit
168
+ _Rb_tree_iterator(_Link_type __x)
169
+ : _M_node(__x) { }
170
+
171
+ reference
172
+ operator*() const
173
+ { return static_cast<_Link_type>(_M_node)->_M_value_field; }
174
+
175
+ pointer
176
+ operator->() const
177
+ { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
178
+
179
+ _Self&
180
+ operator++()
181
+ {
182
+ _M_node = _Rb_tree_increment(_M_node);
183
+ return *this;
184
+ }
185
+
186
+ _Self
187
+ operator++(int)
188
+ {
189
+ _Self __tmp = *this;
190
+ _M_node = _Rb_tree_increment(_M_node);
191
+ return __tmp;
192
+ }
193
+
194
+ _Self&
195
+ operator--()
196
+ {
197
+ _M_node = _Rb_tree_decrement(_M_node);
198
+ return *this;
199
+ }
200
+
201
+ _Self
202
+ operator--(int)
203
+ {
204
+ _Self __tmp = *this;
205
+ _M_node = _Rb_tree_decrement(_M_node);
206
+ return __tmp;
207
+ }
208
+
209
+ bool
210
+ operator==(const _Self& __x) const
211
+ { return _M_node == __x._M_node; }
212
+
213
+ bool
214
+ operator!=(const _Self& __x) const
215
+ { return _M_node != __x._M_node; }
216
+
217
+ _Base_ptr _M_node;
218
+ };
219
+
220
+ template<typename _Tp>
221
+ struct _Rb_tree_const_iterator
222
+ {
223
+ typedef _Tp value_type;
224
+ typedef const _Tp& reference;
225
+ typedef const _Tp* pointer;
226
+
227
+ typedef _Rb_tree_iterator<_Tp> iterator;
228
+
229
+ typedef bidirectional_iterator_tag iterator_category;
230
+ typedef ptrdiff_t difference_type;
231
+
232
+ typedef _Rb_tree_const_iterator<_Tp> _Self;
233
+ typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
234
+ typedef const _Rb_tree_node<_Tp>* _Link_type;
235
+
236
+ _Rb_tree_const_iterator()
237
+ : _M_node() { }
238
+
239
+ explicit
240
+ _Rb_tree_const_iterator(_Link_type __x)
241
+ : _M_node(__x) { }
242
+
243
+ _Rb_tree_const_iterator(const iterator& __it)
244
+ : _M_node(__it._M_node) { }
245
+
246
+ reference
247
+ operator*() const
248
+ { return static_cast<_Link_type>(_M_node)->_M_value_field; }
249
+
250
+ pointer
251
+ operator->() const
252
+ { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
253
+
254
+ _Self&
255
+ operator++()
256
+ {
257
+ _M_node = _Rb_tree_increment(_M_node);
258
+ return *this;
259
+ }
260
+
261
+ _Self
262
+ operator++(int)
263
+ {
264
+ _Self __tmp = *this;
265
+ _M_node = _Rb_tree_increment(_M_node);
266
+ return __tmp;
267
+ }
268
+
269
+ _Self&
270
+ operator--()
271
+ {
272
+ _M_node = _Rb_tree_decrement(_M_node);
273
+ return *this;
274
+ }
275
+
276
+ _Self
277
+ operator--(int)
278
+ {
279
+ _Self __tmp = *this;
280
+ _M_node = _Rb_tree_decrement(_M_node);
281
+ return __tmp;
282
+ }
283
+
284
+ bool
285
+ operator==(const _Self& __x) const
286
+ { return _M_node == __x._M_node; }
287
+
288
+ bool
289
+ operator!=(const _Self& __x) const
290
+ { return _M_node != __x._M_node; }
291
+
292
+ _Base_ptr _M_node;
293
+ };
294
+
295
+ template<typename _Val>
296
+ inline bool
297
+ operator==(const _Rb_tree_iterator<_Val>& __x,
298
+ const _Rb_tree_const_iterator<_Val>& __y)
299
+ { return __x._M_node == __y._M_node; }
300
+
301
+ template<typename _Val>
302
+ inline bool
303
+ operator!=(const _Rb_tree_iterator<_Val>& __x,
304
+ const _Rb_tree_const_iterator<_Val>& __y)
305
+ { return __x._M_node != __y._M_node; }
306
+
307
+ void
308
+ _Rb_tree_insert_and_rebalance(const bool __insert_left,
309
+ _Rb_tree_node_base* __x,
310
+ _Rb_tree_node_base* __p,
311
+ _Rb_tree_node_base& __header);
312
+
313
+ _Rb_tree_node_base*
314
+ _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
315
+ _Rb_tree_node_base& __header);
316
+
317
+
318
+ template<typename _Key, typename _Val, typename _KeyOfValue,
319
+ typename _Compare, typename _Alloc = allocator<_Val> >
320
+ class _Rb_tree
321
+ {
322
+ typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
323
+ _Node_allocator;
324
+
325
+ protected:
326
+ typedef _Rb_tree_node_base* _Base_ptr;
327
+ typedef const _Rb_tree_node_base* _Const_Base_ptr;
328
+
329
+ public:
330
+ typedef _Key key_type;
331
+ typedef _Val value_type;
332
+ typedef value_type* pointer;
333
+ typedef const value_type* const_pointer;
334
+ typedef value_type& reference;
335
+ typedef const value_type& const_reference;
336
+ typedef _Rb_tree_node<_Val>* _Link_type;
337
+ typedef const _Rb_tree_node<_Val>* _Const_Link_type;
338
+ typedef size_t size_type;
339
+ typedef ptrdiff_t difference_type;
340
+ typedef _Alloc allocator_type;
341
+
342
+ _Node_allocator&
343
+ _M_get_Node_allocator()
344
+ { return *static_cast<_Node_allocator*>(&this->_M_impl); }
345
+
346
+ const _Node_allocator&
347
+ _M_get_Node_allocator() const
348
+ { return *static_cast<const _Node_allocator*>(&this->_M_impl); }
349
+
350
+ allocator_type
351
+ get_allocator() const
352
+ { return allocator_type(_M_get_Node_allocator()); }
353
+
354
+ protected:
355
+ _Link_type
356
+ _M_get_node()
357
+ { return _M_impl._Node_allocator::allocate(1); }
358
+
359
+ void
360
+ _M_put_node(_Link_type __p)
361
+ { _M_impl._Node_allocator::deallocate(__p, 1); }
362
+
363
+ _Link_type
364
+ _M_create_node(const value_type& __x)
365
+ {
366
+ _Link_type __tmp = _M_get_node();
367
+ try
368
+ { get_allocator().construct(&__tmp->_M_value_field, __x); }
369
+ catch(...)
370
+ {
371
+ _M_put_node(__tmp);
372
+ __throw_exception_again;
373
+ }
374
+ return __tmp;
375
+ }
376
+
377
+ _Link_type
378
+ _M_clone_node(_Const_Link_type __x)
379
+ {
380
+ _Link_type __tmp = _M_create_node(__x->_M_value_field);
381
+ __tmp->_M_color = __x->_M_color;
382
+ __tmp->_M_left = 0;
383
+ __tmp->_M_right = 0;
384
+ return __tmp;
385
+ }
386
+
387
+ void
388
+ _M_destroy_node(_Link_type __p)
389
+ {
390
+ get_allocator().destroy(&__p->_M_value_field);
391
+ _M_put_node(__p);
392
+ }
393
+
394
+ protected:
395
+ template<typename _Key_compare,
396
+ bool _Is_pod_comparator = __is_pod(_Key_compare)>
397
+ struct _Rb_tree_impl : public _Node_allocator
398
+ {
399
+ _Key_compare _M_key_compare;
400
+ _Rb_tree_node_base _M_header;
401
+ size_type _M_node_count; // Keeps track of size of tree.
402
+
403
+ _Rb_tree_impl()
404
+ : _Node_allocator(), _M_key_compare(), _M_header(),
405
+ _M_node_count(0)
406
+ { _M_initialize(); }
407
+
408
+ _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
409
+ : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
410
+ _M_node_count(0)
411
+ { _M_initialize(); }
412
+
413
+ private:
414
+ void
415
+ _M_initialize()
416
+ {
417
+ this->_M_header._M_color = _S_red;
418
+ this->_M_header._M_parent = 0;
419
+ this->_M_header._M_left = &this->_M_header;
420
+ this->_M_header._M_right = &this->_M_header;
421
+ }
422
+ };
423
+
424
+ _Rb_tree_impl<_Compare> _M_impl;
425
+
426
+ protected:
427
+ _Base_ptr&
428
+ _M_root()
429
+ { return this->_M_impl._M_header._M_parent; }
430
+
431
+ _Const_Base_ptr
432
+ _M_root() const
433
+ { return this->_M_impl._M_header._M_parent; }
434
+
435
+ _Base_ptr&
436
+ _M_leftmost()
437
+ { return this->_M_impl._M_header._M_left; }
438
+
439
+ _Const_Base_ptr
440
+ _M_leftmost() const
441
+ { return this->_M_impl._M_header._M_left; }
442
+
443
+ _Base_ptr&
444
+ _M_rightmost()
445
+ { return this->_M_impl._M_header._M_right; }
446
+
447
+ _Const_Base_ptr
448
+ _M_rightmost() const
449
+ { return this->_M_impl._M_header._M_right; }
450
+
451
+ _Link_type
452
+ _M_begin()
453
+ { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
454
+
455
+ _Const_Link_type
456
+ _M_begin() const
457
+ {
458
+ return static_cast<_Const_Link_type>
459
+ (this->_M_impl._M_header._M_parent);
460
+ }
461
+
462
+ _Link_type
463
+ _M_end()
464
+ { return static_cast<_Link_type>(&this->_M_impl._M_header); }
465
+
466
+ _Const_Link_type
467
+ _M_end() const
468
+ { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
469
+
470
+ static const_reference
471
+ _S_value(_Const_Link_type __x)
472
+ { return __x->_M_value_field; }
473
+
474
+ static const _Key&
475
+ _S_key(_Const_Link_type __x)
476
+ { return _KeyOfValue()(_S_value(__x)); }
477
+
478
+ static _Link_type
479
+ _S_left(_Base_ptr __x)
480
+ { return static_cast<_Link_type>(__x->_M_left); }
481
+
482
+ static _Const_Link_type
483
+ _S_left(_Const_Base_ptr __x)
484
+ { return static_cast<_Const_Link_type>(__x->_M_left); }
485
+
486
+ static _Link_type
487
+ _S_right(_Base_ptr __x)
488
+ { return static_cast<_Link_type>(__x->_M_right); }
489
+
490
+ static _Const_Link_type
491
+ _S_right(_Const_Base_ptr __x)
492
+ { return static_cast<_Const_Link_type>(__x->_M_right); }
493
+
494
+ static const_reference
495
+ _S_value(_Const_Base_ptr __x)
496
+ { return static_cast<_Const_Link_type>(__x)->_M_value_field; }
497
+
498
+ static const _Key&
499
+ _S_key(_Const_Base_ptr __x)
500
+ { return _KeyOfValue()(_S_value(__x)); }
501
+
502
+ static _Base_ptr
503
+ _S_minimum(_Base_ptr __x)
504
+ { return _Rb_tree_node_base::_S_minimum(__x); }
505
+
506
+ static _Const_Base_ptr
507
+ _S_minimum(_Const_Base_ptr __x)
508
+ { return _Rb_tree_node_base::_S_minimum(__x); }
509
+
510
+ static _Base_ptr
511
+ _S_maximum(_Base_ptr __x)
512
+ { return _Rb_tree_node_base::_S_maximum(__x); }
513
+
514
+ static _Const_Base_ptr
515
+ _S_maximum(_Const_Base_ptr __x)
516
+ { return _Rb_tree_node_base::_S_maximum(__x); }
517
+
518
+ public:
519
+ typedef _Rb_tree_iterator<value_type> iterator;
520
+ typedef _Rb_tree_const_iterator<value_type> const_iterator;
521
+
522
+ typedef std::reverse_iterator<iterator> reverse_iterator;
523
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
524
+
525
+ private:
526
+ iterator
527
+ _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
528
+ const value_type& __v);
529
+
530
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
531
+ // 233. Insertion hints in associative containers.
532
+ iterator
533
+ _M_insert_lower(_Base_ptr __x, _Base_ptr __y, const value_type& __v);
534
+
535
+ iterator
536
+ _M_insert_equal_lower(const value_type& __x);
537
+
538
+ _Link_type
539
+ _M_copy(_Const_Link_type __x, _Link_type __p);
540
+
541
+ void
542
+ _M_erase(_Link_type __x);
543
+
544
+ iterator
545
+ _M_lower_bound(_Link_type __x, _Link_type __y,
546
+ const _Key& __k);
547
+
548
+ const_iterator
549
+ _M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
550
+ const _Key& __k) const;
551
+
552
+ iterator
553
+ _M_upper_bound(_Link_type __x, _Link_type __y,
554
+ const _Key& __k);
555
+
556
+ const_iterator
557
+ _M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
558
+ const _Key& __k) const;
559
+
560
+ public:
561
+ // allocation/deallocation
562
+ _Rb_tree() { }
563
+
564
+ _Rb_tree(const _Compare& __comp,
565
+ const allocator_type& __a = allocator_type())
566
+ : _M_impl(__comp, __a) { }
567
+
568
+ _Rb_tree(const _Rb_tree& __x)
569
+ : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator())
570
+ {
571
+ if (__x._M_root() != 0)
572
+ {
573
+ _M_root() = _M_copy(__x._M_begin(), _M_end());
574
+ _M_leftmost() = _S_minimum(_M_root());
575
+ _M_rightmost() = _S_maximum(_M_root());
576
+ _M_impl._M_node_count = __x._M_impl._M_node_count;
577
+ }
578
+ }
579
+
580
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
581
+ _Rb_tree(_Rb_tree&& __x);
582
+ #endif
583
+
584
+ ~_Rb_tree()
585
+ { _M_erase(_M_begin()); }
586
+
587
+ _Rb_tree&
588
+ operator=(const _Rb_tree& __x);
589
+
590
+ // Accessors.
591
+ _Compare
592
+ key_comp() const
593
+ { return _M_impl._M_key_compare; }
594
+
595
+ iterator
596
+ begin()
597
+ {
598
+ return iterator(static_cast<_Link_type>
599
+ (this->_M_impl._M_header._M_left));
600
+ }
601
+
602
+ const_iterator
603
+ begin() const
604
+ {
605
+ return const_iterator(static_cast<_Const_Link_type>
606
+ (this->_M_impl._M_header._M_left));
607
+ }
608
+
609
+ iterator
610
+ end()
611
+ { return iterator(static_cast<_Link_type>(&this->_M_impl._M_header)); }
612
+
613
+ const_iterator
614
+ end() const
615
+ {
616
+ return const_iterator(static_cast<_Const_Link_type>
617
+ (&this->_M_impl._M_header));
618
+ }
619
+
620
+ reverse_iterator
621
+ rbegin()
622
+ { return reverse_iterator(end()); }
623
+
624
+ const_reverse_iterator
625
+ rbegin() const
626
+ { return const_reverse_iterator(end()); }
627
+
628
+ reverse_iterator
629
+ rend()
630
+ { return reverse_iterator(begin()); }
631
+
632
+ const_reverse_iterator
633
+ rend() const
634
+ { return const_reverse_iterator(begin()); }
635
+
636
+ bool
637
+ empty() const
638
+ { return _M_impl._M_node_count == 0; }
639
+
640
+ size_type
641
+ size() const
642
+ { return _M_impl._M_node_count; }
643
+
644
+ size_type
645
+ max_size() const
646
+ { return get_allocator().max_size(); }
647
+
648
+ void
649
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
650
+ swap(_Rb_tree&& __t);
651
+ #else
652
+ swap(_Rb_tree& __t);
653
+ #endif
654
+
655
+ // Insert/erase.
656
+ pair<iterator, bool>
657
+ _M_insert_unique(const value_type& __x);
658
+
659
+ iterator
660
+ _M_insert_equal(const value_type& __x);
661
+
662
+ iterator
663
+ _M_insert_unique_(const_iterator __position, const value_type& __x);
664
+
665
+ iterator
666
+ _M_insert_equal_(const_iterator __position, const value_type& __x);
667
+
668
+ template<typename _InputIterator>
669
+ void
670
+ _M_insert_unique(_InputIterator __first, _InputIterator __last);
671
+
672
+ template<typename _InputIterator>
673
+ void
674
+ _M_insert_equal(_InputIterator __first, _InputIterator __last);
675
+
676
+ void
677
+ erase(iterator __position);
678
+
679
+ void
680
+ erase(const_iterator __position);
681
+
682
+ size_type
683
+ erase(const key_type& __x);
684
+
685
+ void
686
+ erase(iterator __first, iterator __last);
687
+
688
+ void
689
+ erase(const_iterator __first, const_iterator __last);
690
+
691
+ void
692
+ erase(const key_type* __first, const key_type* __last);
693
+
694
+ void
695
+ clear()
696
+ {
697
+ _M_erase(_M_begin());
698
+ _M_leftmost() = _M_end();
699
+ _M_root() = 0;
700
+ _M_rightmost() = _M_end();
701
+ _M_impl._M_node_count = 0;
702
+ }
703
+
704
+ // Set operations.
705
+ iterator
706
+ find(const key_type& __k);
707
+
708
+ const_iterator
709
+ find(const key_type& __k) const;
710
+
711
+ size_type
712
+ count(const key_type& __k) const;
713
+
714
+ iterator
715
+ lower_bound(const key_type& __k)
716
+ { return _M_lower_bound(_M_begin(), _M_end(), __k); }
717
+
718
+ const_iterator
719
+ lower_bound(const key_type& __k) const
720
+ { return _M_lower_bound(_M_begin(), _M_end(), __k); }
721
+
722
+ iterator
723
+ upper_bound(const key_type& __k)
724
+ { return _M_upper_bound(_M_begin(), _M_end(), __k); }
725
+
726
+ const_iterator
727
+ upper_bound(const key_type& __k) const
728
+ { return _M_upper_bound(_M_begin(), _M_end(), __k); }
729
+
730
+ pair<iterator, iterator>
731
+ equal_range(const key_type& __k);
732
+
733
+ pair<const_iterator, const_iterator>
734
+ equal_range(const key_type& __k) const;
735
+
736
+ // Debugging.
737
+ bool
738
+ __rb_verify() const;
739
+ };
740
+
741
+ template<typename _Key, typename _Val, typename _KeyOfValue,
742
+ typename _Compare, typename _Alloc>
743
+ inline bool
744
+ operator==(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
745
+ const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
746
+ {
747
+ return __x.size() == __y.size()
748
+ && std::equal(__x.begin(), __x.end(), __y.begin());
749
+ }
750
+
751
+ template<typename _Key, typename _Val, typename _KeyOfValue,
752
+ typename _Compare, typename _Alloc>
753
+ inline bool
754
+ operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
755
+ const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
756
+ {
757
+ return std::lexicographical_compare(__x.begin(), __x.end(),
758
+ __y.begin(), __y.end());
759
+ }
760
+
761
+ template<typename _Key, typename _Val, typename _KeyOfValue,
762
+ typename _Compare, typename _Alloc>
763
+ inline bool
764
+ operator!=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
765
+ const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
766
+ { return !(__x == __y); }
767
+
768
+ template<typename _Key, typename _Val, typename _KeyOfValue,
769
+ typename _Compare, typename _Alloc>
770
+ inline bool
771
+ operator>(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
772
+ const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
773
+ { return __y < __x; }
774
+
775
+ template<typename _Key, typename _Val, typename _KeyOfValue,
776
+ typename _Compare, typename _Alloc>
777
+ inline bool
778
+ operator<=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
779
+ const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
780
+ { return !(__y < __x); }
781
+
782
+ template<typename _Key, typename _Val, typename _KeyOfValue,
783
+ typename _Compare, typename _Alloc>
784
+ inline bool
785
+ operator>=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
786
+ const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
787
+ { return !(__x < __y); }
788
+
789
+ template<typename _Key, typename _Val, typename _KeyOfValue,
790
+ typename _Compare, typename _Alloc>
791
+ inline void
792
+ swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
793
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
794
+ { __x.swap(__y); }
795
+
796
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
797
+ template<typename _Key, typename _Val, typename _KeyOfValue,
798
+ typename _Compare, typename _Alloc>
799
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
800
+ _Rb_tree(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&& __x)
801
+ : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator())
802
+ {
803
+ if (__x._M_root() != 0)
804
+ {
805
+ _M_root() = __x._M_root();
806
+ _M_leftmost() = __x._M_leftmost();
807
+ _M_rightmost() = __x._M_rightmost();
808
+ _M_root()->_M_parent = _M_end();
809
+
810
+ __x._M_root() = 0;
811
+ __x._M_leftmost() = __x._M_end();
812
+ __x._M_rightmost() = __x._M_end();
813
+
814
+ this->_M_impl._M_node_count = __x._M_impl._M_node_count;
815
+ __x._M_impl._M_node_count = 0;
816
+ }
817
+ }
818
+ #endif
819
+
820
+ template<typename _Key, typename _Val, typename _KeyOfValue,
821
+ typename _Compare, typename _Alloc>
822
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
823
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
824
+ operator=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x)
825
+ {
826
+ if (this != &__x)
827
+ {
828
+ // Note that _Key may be a constant type.
829
+ clear();
830
+ _M_impl._M_key_compare = __x._M_impl._M_key_compare;
831
+ if (__x._M_root() != 0)
832
+ {
833
+ _M_root() = _M_copy(__x._M_begin(), _M_end());
834
+ _M_leftmost() = _S_minimum(_M_root());
835
+ _M_rightmost() = _S_maximum(_M_root());
836
+ _M_impl._M_node_count = __x._M_impl._M_node_count;
837
+ }
838
+ }
839
+ return *this;
840
+ }
841
+
842
+ template<typename _Key, typename _Val, typename _KeyOfValue,
843
+ typename _Compare, typename _Alloc>
844
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
845
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
846
+ _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)
847
+ {
848
+ bool __insert_left = (__x != 0 || __p == _M_end()
849
+ || _M_impl._M_key_compare(_KeyOfValue()(__v),
850
+ _S_key(__p)));
851
+
852
+ _Link_type __z = _M_create_node(__v);
853
+
854
+ _Rb_tree_insert_and_rebalance(__insert_left, __z,
855
+ const_cast<_Base_ptr>(__p),
856
+ this->_M_impl._M_header);
857
+ ++_M_impl._M_node_count;
858
+ return iterator(__z);
859
+ }
860
+
861
+ template<typename _Key, typename _Val, typename _KeyOfValue,
862
+ typename _Compare, typename _Alloc>
863
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
864
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
865
+ _M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v)
866
+ {
867
+ bool __insert_left = (__x != 0 || __p == _M_end()
868
+ || !_M_impl._M_key_compare(_S_key(__p),
869
+ _KeyOfValue()(__v)));
870
+
871
+ _Link_type __z = _M_create_node(__v);
872
+
873
+ _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
874
+ this->_M_impl._M_header);
875
+ ++_M_impl._M_node_count;
876
+ return iterator(__z);
877
+ }
878
+
879
+ template<typename _Key, typename _Val, typename _KeyOfValue,
880
+ typename _Compare, typename _Alloc>
881
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
882
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
883
+ _M_insert_equal_lower(const _Val& __v)
884
+ {
885
+ _Link_type __x = _M_begin();
886
+ _Link_type __y = _M_end();
887
+ while (__x != 0)
888
+ {
889
+ __y = __x;
890
+ __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
891
+ _S_left(__x) : _S_right(__x);
892
+ }
893
+ return _M_insert_lower(__x, __y, __v);
894
+ }
895
+
896
+ template<typename _Key, typename _Val, typename _KoV,
897
+ typename _Compare, typename _Alloc>
898
+ typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
899
+ _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
900
+ _M_copy(_Const_Link_type __x, _Link_type __p)
901
+ {
902
+ // Structural copy. __x and __p must be non-null.
903
+ _Link_type __top = _M_clone_node(__x);
904
+ __top->_M_parent = __p;
905
+
906
+ try
907
+ {
908
+ if (__x->_M_right)
909
+ __top->_M_right = _M_copy(_S_right(__x), __top);
910
+ __p = __top;
911
+ __x = _S_left(__x);
912
+
913
+ while (__x != 0)
914
+ {
915
+ _Link_type __y = _M_clone_node(__x);
916
+ __p->_M_left = __y;
917
+ __y->_M_parent = __p;
918
+ if (__x->_M_right)
919
+ __y->_M_right = _M_copy(_S_right(__x), __y);
920
+ __p = __y;
921
+ __x = _S_left(__x);
922
+ }
923
+ }
924
+ catch(...)
925
+ {
926
+ _M_erase(__top);
927
+ __throw_exception_again;
928
+ }
929
+ return __top;
930
+ }
931
+
932
+ template<typename _Key, typename _Val, typename _KeyOfValue,
933
+ typename _Compare, typename _Alloc>
934
+ void
935
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
936
+ _M_erase(_Link_type __x)
937
+ {
938
+ // Erase without rebalancing.
939
+ while (__x != 0)
940
+ {
941
+ _M_erase(_S_right(__x));
942
+ _Link_type __y = _S_left(__x);
943
+ _M_destroy_node(__x);
944
+ __x = __y;
945
+ }
946
+ }
947
+
948
+ template<typename _Key, typename _Val, typename _KeyOfValue,
949
+ typename _Compare, typename _Alloc>
950
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
951
+ _Compare, _Alloc>::iterator
952
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
953
+ _M_lower_bound(_Link_type __x, _Link_type __y,
954
+ const _Key& __k)
955
+ {
956
+ while (__x != 0)
957
+ if (!_M_impl._M_key_compare(_S_key(__x), __k))
958
+ __y = __x, __x = _S_left(__x);
959
+ else
960
+ __x = _S_right(__x);
961
+ return iterator(__y);
962
+ }
963
+
964
+ template<typename _Key, typename _Val, typename _KeyOfValue,
965
+ typename _Compare, typename _Alloc>
966
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
967
+ _Compare, _Alloc>::const_iterator
968
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
969
+ _M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
970
+ const _Key& __k) const
971
+ {
972
+ while (__x != 0)
973
+ if (!_M_impl._M_key_compare(_S_key(__x), __k))
974
+ __y = __x, __x = _S_left(__x);
975
+ else
976
+ __x = _S_right(__x);
977
+ return const_iterator(__y);
978
+ }
979
+
980
+ template<typename _Key, typename _Val, typename _KeyOfValue,
981
+ typename _Compare, typename _Alloc>
982
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
983
+ _Compare, _Alloc>::iterator
984
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
985
+ _M_upper_bound(_Link_type __x, _Link_type __y,
986
+ const _Key& __k)
987
+ {
988
+ while (__x != 0)
989
+ if (_M_impl._M_key_compare(__k, _S_key(__x)))
990
+ __y = __x, __x = _S_left(__x);
991
+ else
992
+ __x = _S_right(__x);
993
+ return iterator(__y);
994
+ }
995
+
996
+ template<typename _Key, typename _Val, typename _KeyOfValue,
997
+ typename _Compare, typename _Alloc>
998
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
999
+ _Compare, _Alloc>::const_iterator
1000
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1001
+ _M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
1002
+ const _Key& __k) const
1003
+ {
1004
+ while (__x != 0)
1005
+ if (_M_impl._M_key_compare(__k, _S_key(__x)))
1006
+ __y = __x, __x = _S_left(__x);
1007
+ else
1008
+ __x = _S_right(__x);
1009
+ return const_iterator(__y);
1010
+ }
1011
+
1012
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1013
+ typename _Compare, typename _Alloc>
1014
+ pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
1015
+ _Compare, _Alloc>::iterator,
1016
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
1017
+ _Compare, _Alloc>::iterator>
1018
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1019
+ equal_range(const _Key& __k)
1020
+ {
1021
+ _Link_type __x = _M_begin();
1022
+ _Link_type __y = _M_end();
1023
+ while (__x != 0)
1024
+ {
1025
+ if (_M_impl._M_key_compare(_S_key(__x), __k))
1026
+ __x = _S_right(__x);
1027
+ else if (_M_impl._M_key_compare(__k, _S_key(__x)))
1028
+ __y = __x, __x = _S_left(__x);
1029
+ else
1030
+ {
1031
+ _Link_type __xu(__x), __yu(__y);
1032
+ __y = __x, __x = _S_left(__x);
1033
+ __xu = _S_right(__xu);
1034
+ return pair<iterator,
1035
+ iterator>(_M_lower_bound(__x, __y, __k),
1036
+ _M_upper_bound(__xu, __yu, __k));
1037
+ }
1038
+ }
1039
+ return pair<iterator, iterator>(iterator(__y),
1040
+ iterator(__y));
1041
+ }
1042
+
1043
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1044
+ typename _Compare, typename _Alloc>
1045
+ pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
1046
+ _Compare, _Alloc>::const_iterator,
1047
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
1048
+ _Compare, _Alloc>::const_iterator>
1049
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1050
+ equal_range(const _Key& __k) const
1051
+ {
1052
+ _Const_Link_type __x = _M_begin();
1053
+ _Const_Link_type __y = _M_end();
1054
+ while (__x != 0)
1055
+ {
1056
+ if (_M_impl._M_key_compare(_S_key(__x), __k))
1057
+ __x = _S_right(__x);
1058
+ else if (_M_impl._M_key_compare(__k, _S_key(__x)))
1059
+ __y = __x, __x = _S_left(__x);
1060
+ else
1061
+ {
1062
+ _Const_Link_type __xu(__x), __yu(__y);
1063
+ __y = __x, __x = _S_left(__x);
1064
+ __xu = _S_right(__xu);
1065
+ return pair<const_iterator,
1066
+ const_iterator>(_M_lower_bound(__x, __y, __k),
1067
+ _M_upper_bound(__xu, __yu, __k));
1068
+ }
1069
+ }
1070
+ return pair<const_iterator, const_iterator>(const_iterator(__y),
1071
+ const_iterator(__y));
1072
+ }
1073
+
1074
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1075
+ typename _Compare, typename _Alloc>
1076
+ void
1077
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1078
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1079
+ swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&& __t)
1080
+ #else
1081
+ swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t)
1082
+ #endif
1083
+ {
1084
+ if (_M_root() == 0)
1085
+ {
1086
+ if (__t._M_root() != 0)
1087
+ {
1088
+ _M_root() = __t._M_root();
1089
+ _M_leftmost() = __t._M_leftmost();
1090
+ _M_rightmost() = __t._M_rightmost();
1091
+ _M_root()->_M_parent = _M_end();
1092
+
1093
+ __t._M_root() = 0;
1094
+ __t._M_leftmost() = __t._M_end();
1095
+ __t._M_rightmost() = __t._M_end();
1096
+ }
1097
+ }
1098
+ else if (__t._M_root() == 0)
1099
+ {
1100
+ __t._M_root() = _M_root();
1101
+ __t._M_leftmost() = _M_leftmost();
1102
+ __t._M_rightmost() = _M_rightmost();
1103
+ __t._M_root()->_M_parent = __t._M_end();
1104
+
1105
+ _M_root() = 0;
1106
+ _M_leftmost() = _M_end();
1107
+ _M_rightmost() = _M_end();
1108
+ }
1109
+ else
1110
+ {
1111
+ std::swap(_M_root(),__t._M_root());
1112
+ std::swap(_M_leftmost(),__t._M_leftmost());
1113
+ std::swap(_M_rightmost(),__t._M_rightmost());
1114
+
1115
+ _M_root()->_M_parent = _M_end();
1116
+ __t._M_root()->_M_parent = __t._M_end();
1117
+ }
1118
+ // No need to swap header's color as it does not change.
1119
+ std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count);
1120
+ std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare);
1121
+
1122
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
1123
+ // 431. Swapping containers with unequal allocators.
1124
+ std::__alloc_swap<_Node_allocator>::
1125
+ _S_do_it(_M_get_Node_allocator(), __t._M_get_Node_allocator());
1126
+ }
1127
+
1128
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1129
+ typename _Compare, typename _Alloc>
1130
+ pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
1131
+ _Compare, _Alloc>::iterator, bool>
1132
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1133
+ _M_insert_unique(const _Val& __v)
1134
+ {
1135
+ _Link_type __x = _M_begin();
1136
+ _Link_type __y = _M_end();
1137
+ bool __comp = true;
1138
+ while (__x != 0)
1139
+ {
1140
+ __y = __x;
1141
+ __comp = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x));
1142
+ __x = __comp ? _S_left(__x) : _S_right(__x);
1143
+ }
1144
+ iterator __j = iterator(__y);
1145
+ if (__comp)
1146
+ {
1147
+ if (__j == begin())
1148
+ return pair<iterator, bool>(_M_insert_(__x, __y, __v), true);
1149
+ else
1150
+ --__j;
1151
+ }
1152
+ if (_M_impl._M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))
1153
+ return pair<iterator, bool>(_M_insert_(__x, __y, __v), true);
1154
+ return pair<iterator, bool>(__j, false);
1155
+ }
1156
+
1157
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1158
+ typename _Compare, typename _Alloc>
1159
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1160
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1161
+ _M_insert_equal(const _Val& __v)
1162
+ {
1163
+ _Link_type __x = _M_begin();
1164
+ _Link_type __y = _M_end();
1165
+ while (__x != 0)
1166
+ {
1167
+ __y = __x;
1168
+ __x = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ?
1169
+ _S_left(__x) : _S_right(__x);
1170
+ }
1171
+ return _M_insert_(__x, __y, __v);
1172
+ }
1173
+
1174
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1175
+ typename _Compare, typename _Alloc>
1176
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1177
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1178
+ _M_insert_unique_(const_iterator __position, const _Val& __v)
1179
+ {
1180
+ // end()
1181
+ if (__position._M_node == _M_end())
1182
+ {
1183
+ if (size() > 0
1184
+ && _M_impl._M_key_compare(_S_key(_M_rightmost()),
1185
+ _KeyOfValue()(__v)))
1186
+ return _M_insert_(0, _M_rightmost(), __v);
1187
+ else
1188
+ return _M_insert_unique(__v).first;
1189
+ }
1190
+ else if (_M_impl._M_key_compare(_KeyOfValue()(__v),
1191
+ _S_key(__position._M_node)))
1192
+ {
1193
+ // First, try before...
1194
+ const_iterator __before = __position;
1195
+ if (__position._M_node == _M_leftmost()) // begin()
1196
+ return _M_insert_(_M_leftmost(), _M_leftmost(), __v);
1197
+ else if (_M_impl._M_key_compare(_S_key((--__before)._M_node),
1198
+ _KeyOfValue()(__v)))
1199
+ {
1200
+ if (_S_right(__before._M_node) == 0)
1201
+ return _M_insert_(0, __before._M_node, __v);
1202
+ else
1203
+ return _M_insert_(__position._M_node,
1204
+ __position._M_node, __v);
1205
+ }
1206
+ else
1207
+ return _M_insert_unique(__v).first;
1208
+ }
1209
+ else if (_M_impl._M_key_compare(_S_key(__position._M_node),
1210
+ _KeyOfValue()(__v)))
1211
+ {
1212
+ // ... then try after.
1213
+ const_iterator __after = __position;
1214
+ if (__position._M_node == _M_rightmost())
1215
+ return _M_insert_(0, _M_rightmost(), __v);
1216
+ else if (_M_impl._M_key_compare(_KeyOfValue()(__v),
1217
+ _S_key((++__after)._M_node)))
1218
+ {
1219
+ if (_S_right(__position._M_node) == 0)
1220
+ return _M_insert_(0, __position._M_node, __v);
1221
+ else
1222
+ return _M_insert_(__after._M_node, __after._M_node, __v);
1223
+ }
1224
+ else
1225
+ return _M_insert_unique(__v).first;
1226
+ }
1227
+ else
1228
+ // Equivalent keys.
1229
+ return iterator(static_cast<_Link_type>
1230
+ (const_cast<_Base_ptr>(__position._M_node)));
1231
+ }
1232
+
1233
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1234
+ typename _Compare, typename _Alloc>
1235
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1236
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1237
+ _M_insert_equal_(const_iterator __position, const _Val& __v)
1238
+ {
1239
+ // end()
1240
+ if (__position._M_node == _M_end())
1241
+ {
1242
+ if (size() > 0
1243
+ && !_M_impl._M_key_compare(_KeyOfValue()(__v),
1244
+ _S_key(_M_rightmost())))
1245
+ return _M_insert_(0, _M_rightmost(), __v);
1246
+ else
1247
+ return _M_insert_equal(__v);
1248
+ }
1249
+ else if (!_M_impl._M_key_compare(_S_key(__position._M_node),
1250
+ _KeyOfValue()(__v)))
1251
+ {
1252
+ // First, try before...
1253
+ const_iterator __before = __position;
1254
+ if (__position._M_node == _M_leftmost()) // begin()
1255
+ return _M_insert_(_M_leftmost(), _M_leftmost(), __v);
1256
+ else if (!_M_impl._M_key_compare(_KeyOfValue()(__v),
1257
+ _S_key((--__before)._M_node)))
1258
+ {
1259
+ if (_S_right(__before._M_node) == 0)
1260
+ return _M_insert_(0, __before._M_node, __v);
1261
+ else
1262
+ return _M_insert_(__position._M_node,
1263
+ __position._M_node, __v);
1264
+ }
1265
+ else
1266
+ return _M_insert_equal(__v);
1267
+ }
1268
+ else
1269
+ {
1270
+ // ... then try after.
1271
+ const_iterator __after = __position;
1272
+ if (__position._M_node == _M_rightmost())
1273
+ return _M_insert_(0, _M_rightmost(), __v);
1274
+ else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node),
1275
+ _KeyOfValue()(__v)))
1276
+ {
1277
+ if (_S_right(__position._M_node) == 0)
1278
+ return _M_insert_(0, __position._M_node, __v);
1279
+ else
1280
+ return _M_insert_(__after._M_node, __after._M_node, __v);
1281
+ }
1282
+ else
1283
+ return _M_insert_equal_lower(__v);
1284
+ }
1285
+ }
1286
+
1287
+ template<typename _Key, typename _Val, typename _KoV,
1288
+ typename _Cmp, typename _Alloc>
1289
+ template<class _II>
1290
+ void
1291
+ _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>::
1292
+ _M_insert_unique(_II __first, _II __last)
1293
+ {
1294
+ for (; __first != __last; ++__first)
1295
+ _M_insert_unique_(end(), *__first);
1296
+ }
1297
+
1298
+ template<typename _Key, typename _Val, typename _KoV,
1299
+ typename _Cmp, typename _Alloc>
1300
+ template<class _II>
1301
+ void
1302
+ _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>::
1303
+ _M_insert_equal(_II __first, _II __last)
1304
+ {
1305
+ for (; __first != __last; ++__first)
1306
+ _M_insert_equal_(end(), *__first);
1307
+ }
1308
+
1309
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1310
+ typename _Compare, typename _Alloc>
1311
+ inline void
1312
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1313
+ erase(iterator __position)
1314
+ {
1315
+ _Link_type __y =
1316
+ static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
1317
+ (__position._M_node,
1318
+ this->_M_impl._M_header));
1319
+ _M_destroy_node(__y);
1320
+ --_M_impl._M_node_count;
1321
+ }
1322
+
1323
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1324
+ typename _Compare, typename _Alloc>
1325
+ inline void
1326
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1327
+ erase(const_iterator __position)
1328
+ {
1329
+ _Link_type __y =
1330
+ static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
1331
+ (const_cast<_Base_ptr>(__position._M_node),
1332
+ this->_M_impl._M_header));
1333
+ _M_destroy_node(__y);
1334
+ --_M_impl._M_node_count;
1335
+ }
1336
+
1337
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1338
+ typename _Compare, typename _Alloc>
1339
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
1340
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1341
+ erase(const _Key& __x)
1342
+ {
1343
+ pair<iterator, iterator> __p = equal_range(__x);
1344
+ const size_type __old_size = size();
1345
+ erase(__p.first, __p.second);
1346
+ return __old_size - size();
1347
+ }
1348
+
1349
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1350
+ typename _Compare, typename _Alloc>
1351
+ void
1352
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1353
+ erase(iterator __first, iterator __last)
1354
+ {
1355
+ if (__first == begin() && __last == end())
1356
+ clear();
1357
+ else
1358
+ while (__first != __last)
1359
+ erase(__first++);
1360
+ }
1361
+
1362
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1363
+ typename _Compare, typename _Alloc>
1364
+ void
1365
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1366
+ erase(const_iterator __first, const_iterator __last)
1367
+ {
1368
+ if (__first == begin() && __last == end())
1369
+ clear();
1370
+ else
1371
+ while (__first != __last)
1372
+ erase(__first++);
1373
+ }
1374
+
1375
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1376
+ typename _Compare, typename _Alloc>
1377
+ void
1378
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1379
+ erase(const _Key* __first, const _Key* __last)
1380
+ {
1381
+ while (__first != __last)
1382
+ erase(*__first++);
1383
+ }
1384
+
1385
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1386
+ typename _Compare, typename _Alloc>
1387
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
1388
+ _Compare, _Alloc>::iterator
1389
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1390
+ find(const _Key& __k)
1391
+ {
1392
+ iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
1393
+ return (__j == end()
1394
+ || _M_impl._M_key_compare(__k,
1395
+ _S_key(__j._M_node))) ? end() : __j;
1396
+ }
1397
+
1398
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1399
+ typename _Compare, typename _Alloc>
1400
+ typename _Rb_tree<_Key, _Val, _KeyOfValue,
1401
+ _Compare, _Alloc>::const_iterator
1402
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1403
+ find(const _Key& __k) const
1404
+ {
1405
+ const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
1406
+ return (__j == end()
1407
+ || _M_impl._M_key_compare(__k,
1408
+ _S_key(__j._M_node))) ? end() : __j;
1409
+ }
1410
+
1411
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1412
+ typename _Compare, typename _Alloc>
1413
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
1414
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1415
+ count(const _Key& __k) const
1416
+ {
1417
+ pair<const_iterator, const_iterator> __p = equal_range(__k);
1418
+ const size_type __n = std::distance(__p.first, __p.second);
1419
+ return __n;
1420
+ }
1421
+
1422
+ unsigned int
1423
+ _Rb_tree_black_count(const _Rb_tree_node_base* __node,
1424
+ const _Rb_tree_node_base* __root);
1425
+
1426
+ template<typename _Key, typename _Val, typename _KeyOfValue,
1427
+ typename _Compare, typename _Alloc>
1428
+ bool
1429
+ _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
1430
+ {
1431
+ if (_M_impl._M_node_count == 0 || begin() == end())
1432
+ return _M_impl._M_node_count == 0 && begin() == end()
1433
+ && this->_M_impl._M_header._M_left == _M_end()
1434
+ && this->_M_impl._M_header._M_right == _M_end();
1435
+
1436
+ unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
1437
+ for (const_iterator __it = begin(); __it != end(); ++__it)
1438
+ {
1439
+ _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node);
1440
+ _Const_Link_type __L = _S_left(__x);
1441
+ _Const_Link_type __R = _S_right(__x);
1442
+
1443
+ if (__x->_M_color == _S_red)
1444
+ if ((__L && __L->_M_color == _S_red)
1445
+ || (__R && __R->_M_color == _S_red))
1446
+ return false;
1447
+
1448
+ if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L)))
1449
+ return false;
1450
+ if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x)))
1451
+ return false;
1452
+
1453
+ if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
1454
+ return false;
1455
+ }
1456
+
1457
+ if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
1458
+ return false;
1459
+ if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
1460
+ return false;
1461
+ return true;
1462
+ }
1463
+
1464
+ _GLIBCXX_END_NAMESPACE
1465
+
1466
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_uninitialized.h ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Raw memory manipulators -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996,1997
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_uninitialized.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_UNINITIALIZED_H
63
+ #define _STL_UNINITIALIZED_H 1
64
+
65
+ _GLIBCXX_BEGIN_NAMESPACE(std)
66
+
67
+ template<bool>
68
+ struct __uninitialized_copy
69
+ {
70
+ template<typename _InputIterator, typename _ForwardIterator>
71
+ static _ForwardIterator
72
+ uninitialized_copy(_InputIterator __first, _InputIterator __last,
73
+ _ForwardIterator __result)
74
+ {
75
+ _ForwardIterator __cur = __result;
76
+ try
77
+ {
78
+ for (; __first != __last; ++__first, ++__cur)
79
+ ::new(static_cast<void*>(&*__cur)) typename
80
+ iterator_traits<_ForwardIterator>::value_type(*__first);
81
+ return __cur;
82
+ }
83
+ catch(...)
84
+ {
85
+ std::_Destroy(__result, __cur);
86
+ __throw_exception_again;
87
+ }
88
+ }
89
+ };
90
+
91
+ template<>
92
+ struct __uninitialized_copy<true>
93
+ {
94
+ template<typename _InputIterator, typename _ForwardIterator>
95
+ static _ForwardIterator
96
+ uninitialized_copy(_InputIterator __first, _InputIterator __last,
97
+ _ForwardIterator __result)
98
+ { return std::copy(__first, __last, __result); }
99
+ };
100
+
101
+ /**
102
+ * @brief Copies the range [first,last) into result.
103
+ * @param first An input iterator.
104
+ * @param last An input iterator.
105
+ * @param result An output iterator.
106
+ * @return result + (first - last)
107
+ *
108
+ * Like copy(), but does not require an initialized output range.
109
+ */
110
+ template<typename _InputIterator, typename _ForwardIterator>
111
+ inline _ForwardIterator
112
+ uninitialized_copy(_InputIterator __first, _InputIterator __last,
113
+ _ForwardIterator __result)
114
+ {
115
+ typedef typename iterator_traits<_InputIterator>::value_type
116
+ _ValueType1;
117
+ typedef typename iterator_traits<_ForwardIterator>::value_type
118
+ _ValueType2;
119
+
120
+ return std::__uninitialized_copy<(__is_pod(_ValueType1)
121
+ && __is_pod(_ValueType2))>::
122
+ uninitialized_copy(__first, __last, __result);
123
+ }
124
+
125
+
126
+ template<bool>
127
+ struct __uninitialized_fill
128
+ {
129
+ template<typename _ForwardIterator, typename _Tp>
130
+ static void
131
+ uninitialized_fill(_ForwardIterator __first,
132
+ _ForwardIterator __last, const _Tp& __x)
133
+ {
134
+ _ForwardIterator __cur = __first;
135
+ try
136
+ {
137
+ for (; __cur != __last; ++__cur)
138
+ std::_Construct(&*__cur, __x);
139
+ }
140
+ catch(...)
141
+ {
142
+ std::_Destroy(__first, __cur);
143
+ __throw_exception_again;
144
+ }
145
+ }
146
+ };
147
+
148
+ template<>
149
+ struct __uninitialized_fill<true>
150
+ {
151
+ template<typename _ForwardIterator, typename _Tp>
152
+ static void
153
+ uninitialized_fill(_ForwardIterator __first,
154
+ _ForwardIterator __last, const _Tp& __x)
155
+ { std::fill(__first, __last, __x); }
156
+ };
157
+
158
+ /**
159
+ * @brief Copies the value x into the range [first,last).
160
+ * @param first An input iterator.
161
+ * @param last An input iterator.
162
+ * @param x The source value.
163
+ * @return Nothing.
164
+ *
165
+ * Like fill(), but does not require an initialized output range.
166
+ */
167
+ template<typename _ForwardIterator, typename _Tp>
168
+ inline void
169
+ uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
170
+ const _Tp& __x)
171
+ {
172
+ typedef typename iterator_traits<_ForwardIterator>::value_type
173
+ _ValueType;
174
+
175
+ std::__uninitialized_fill<__is_pod(_ValueType)>::
176
+ uninitialized_fill(__first, __last, __x);
177
+ }
178
+
179
+
180
+ template<bool>
181
+ struct __uninitialized_fill_n
182
+ {
183
+ template<typename _ForwardIterator, typename _Size, typename _Tp>
184
+ static void
185
+ uninitialized_fill_n(_ForwardIterator __first, _Size __n,
186
+ const _Tp& __x)
187
+ {
188
+ _ForwardIterator __cur = __first;
189
+ try
190
+ {
191
+ for (; __n > 0; --__n, ++__cur)
192
+ std::_Construct(&*__cur, __x);
193
+ }
194
+ catch(...)
195
+ {
196
+ std::_Destroy(__first, __cur);
197
+ __throw_exception_again;
198
+ }
199
+ }
200
+ };
201
+
202
+ template<>
203
+ struct __uninitialized_fill_n<true>
204
+ {
205
+ template<typename _ForwardIterator, typename _Size, typename _Tp>
206
+ static void
207
+ uninitialized_fill_n(_ForwardIterator __first, _Size __n,
208
+ const _Tp& __x)
209
+ { std::fill_n(__first, __n, __x); }
210
+ };
211
+
212
+ /**
213
+ * @brief Copies the value x into the range [first,first+n).
214
+ * @param first An input iterator.
215
+ * @param n The number of copies to make.
216
+ * @param x The source value.
217
+ * @return Nothing.
218
+ *
219
+ * Like fill_n(), but does not require an initialized output range.
220
+ */
221
+ template<typename _ForwardIterator, typename _Size, typename _Tp>
222
+ inline void
223
+ uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
224
+ {
225
+ typedef typename iterator_traits<_ForwardIterator>::value_type
226
+ _ValueType;
227
+
228
+ std::__uninitialized_fill_n<__is_pod(_ValueType)>::
229
+ uninitialized_fill_n(__first, __n, __x);
230
+ }
231
+
232
+ // Extensions: versions of uninitialized_copy, uninitialized_fill,
233
+ // and uninitialized_fill_n that take an allocator parameter.
234
+ // We dispatch back to the standard versions when we're given the
235
+ // default allocator. For nondefault allocators we do not use
236
+ // any of the POD optimizations.
237
+
238
+ template<typename _InputIterator, typename _ForwardIterator,
239
+ typename _Allocator>
240
+ _ForwardIterator
241
+ __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
242
+ _ForwardIterator __result, _Allocator& __alloc)
243
+ {
244
+ _ForwardIterator __cur = __result;
245
+ try
246
+ {
247
+ for (; __first != __last; ++__first, ++__cur)
248
+ __alloc.construct(&*__cur, *__first);
249
+ return __cur;
250
+ }
251
+ catch(...)
252
+ {
253
+ std::_Destroy(__result, __cur, __alloc);
254
+ __throw_exception_again;
255
+ }
256
+ }
257
+
258
+ template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
259
+ inline _ForwardIterator
260
+ __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
261
+ _ForwardIterator __result, allocator<_Tp>&)
262
+ { return std::uninitialized_copy(__first, __last, __result); }
263
+
264
+ template<typename _InputIterator, typename _ForwardIterator,
265
+ typename _Allocator>
266
+ inline _ForwardIterator
267
+ __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
268
+ _ForwardIterator __result, _Allocator& __alloc)
269
+ {
270
+ return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
271
+ _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
272
+ __result, __alloc);
273
+ }
274
+
275
+ template<typename _ForwardIterator, typename _Tp, typename _Allocator>
276
+ void
277
+ __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
278
+ const _Tp& __x, _Allocator& __alloc)
279
+ {
280
+ _ForwardIterator __cur = __first;
281
+ try
282
+ {
283
+ for (; __cur != __last; ++__cur)
284
+ __alloc.construct(&*__cur, __x);
285
+ }
286
+ catch(...)
287
+ {
288
+ std::_Destroy(__first, __cur, __alloc);
289
+ __throw_exception_again;
290
+ }
291
+ }
292
+
293
+ template<typename _ForwardIterator, typename _Tp, typename _Tp2>
294
+ inline void
295
+ __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
296
+ const _Tp& __x, allocator<_Tp2>&)
297
+ { std::uninitialized_fill(__first, __last, __x); }
298
+
299
+ template<typename _ForwardIterator, typename _Size, typename _Tp,
300
+ typename _Allocator>
301
+ void
302
+ __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
303
+ const _Tp& __x, _Allocator& __alloc)
304
+ {
305
+ _ForwardIterator __cur = __first;
306
+ try
307
+ {
308
+ for (; __n > 0; --__n, ++__cur)
309
+ __alloc.construct(&*__cur, __x);
310
+ }
311
+ catch(...)
312
+ {
313
+ std::_Destroy(__first, __cur, __alloc);
314
+ __throw_exception_again;
315
+ }
316
+ }
317
+
318
+ template<typename _ForwardIterator, typename _Size, typename _Tp,
319
+ typename _Tp2>
320
+ inline void
321
+ __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
322
+ const _Tp& __x, allocator<_Tp2>&)
323
+ { std::uninitialized_fill_n(__first, __n, __x); }
324
+
325
+
326
+ // Extensions: __uninitialized_copy_move, __uninitialized_move_copy,
327
+ // __uninitialized_fill_move, __uninitialized_move_fill.
328
+ // All of these algorithms take a user-supplied allocator, which is used
329
+ // for construction and destruction.
330
+
331
+ // __uninitialized_copy_move
332
+ // Copies [first1, last1) into [result, result + (last1 - first1)), and
333
+ // move [first2, last2) into
334
+ // [result, result + (last1 - first1) + (last2 - first2)).
335
+ template<typename _InputIterator1, typename _InputIterator2,
336
+ typename _ForwardIterator, typename _Allocator>
337
+ inline _ForwardIterator
338
+ __uninitialized_copy_move(_InputIterator1 __first1,
339
+ _InputIterator1 __last1,
340
+ _InputIterator2 __first2,
341
+ _InputIterator2 __last2,
342
+ _ForwardIterator __result,
343
+ _Allocator& __alloc)
344
+ {
345
+ _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
346
+ __result,
347
+ __alloc);
348
+ try
349
+ {
350
+ return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
351
+ }
352
+ catch(...)
353
+ {
354
+ std::_Destroy(__result, __mid, __alloc);
355
+ __throw_exception_again;
356
+ }
357
+ }
358
+
359
+ // __uninitialized_move_copy
360
+ // Moves [first1, last1) into [result, result + (last1 - first1)), and
361
+ // copies [first2, last2) into
362
+ // [result, result + (last1 - first1) + (last2 - first2)).
363
+ template<typename _InputIterator1, typename _InputIterator2,
364
+ typename _ForwardIterator, typename _Allocator>
365
+ inline _ForwardIterator
366
+ __uninitialized_move_copy(_InputIterator1 __first1,
367
+ _InputIterator1 __last1,
368
+ _InputIterator2 __first2,
369
+ _InputIterator2 __last2,
370
+ _ForwardIterator __result,
371
+ _Allocator& __alloc)
372
+ {
373
+ _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
374
+ __result,
375
+ __alloc);
376
+ try
377
+ {
378
+ return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
379
+ }
380
+ catch(...)
381
+ {
382
+ std::_Destroy(__result, __mid, __alloc);
383
+ __throw_exception_again;
384
+ }
385
+ }
386
+
387
+ // __uninitialized_fill_move
388
+ // Fills [result, mid) with x, and moves [first, last) into
389
+ // [mid, mid + (last - first)).
390
+ template<typename _ForwardIterator, typename _Tp, typename _InputIterator,
391
+ typename _Allocator>
392
+ inline _ForwardIterator
393
+ __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
394
+ const _Tp& __x, _InputIterator __first,
395
+ _InputIterator __last, _Allocator& __alloc)
396
+ {
397
+ std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
398
+ try
399
+ {
400
+ return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
401
+ }
402
+ catch(...)
403
+ {
404
+ std::_Destroy(__result, __mid, __alloc);
405
+ __throw_exception_again;
406
+ }
407
+ }
408
+
409
+ // __uninitialized_move_fill
410
+ // Moves [first1, last1) into [first2, first2 + (last1 - first1)), and
411
+ // fills [first2 + (last1 - first1), last2) with x.
412
+ template<typename _InputIterator, typename _ForwardIterator, typename _Tp,
413
+ typename _Allocator>
414
+ inline void
415
+ __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
416
+ _ForwardIterator __first2,
417
+ _ForwardIterator __last2, const _Tp& __x,
418
+ _Allocator& __alloc)
419
+ {
420
+ _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
421
+ __first2,
422
+ __alloc);
423
+ try
424
+ {
425
+ std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
426
+ }
427
+ catch(...)
428
+ {
429
+ std::_Destroy(__first2, __mid2, __alloc);
430
+ __throw_exception_again;
431
+ }
432
+ }
433
+
434
+ _GLIBCXX_END_NAMESPACE
435
+
436
+ #endif /* _STL_UNINITIALIZED_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stl_vector.h ADDED
@@ -0,0 +1,1174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Vector implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file stl_vector.h
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _STL_VECTOR_H
63
+ #define _STL_VECTOR_H 1
64
+
65
+ #include <bits/stl_iterator_base_funcs.h>
66
+ #include <bits/functexcept.h>
67
+ #include <bits/concept_check.h>
68
+
69
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
70
+
71
+ /// See bits/stl_deque.h's _Deque_base for an explanation.
72
+ template<typename _Tp, typename _Alloc>
73
+ struct _Vector_base
74
+ {
75
+ typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
76
+
77
+ struct _Vector_impl
78
+ : public _Tp_alloc_type
79
+ {
80
+ _Tp* _M_start;
81
+ _Tp* _M_finish;
82
+ _Tp* _M_end_of_storage;
83
+
84
+ _Vector_impl()
85
+ : _Tp_alloc_type(), _M_start(0), _M_finish(0), _M_end_of_storage(0)
86
+ { }
87
+
88
+ _Vector_impl(_Tp_alloc_type const& __a)
89
+ : _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
90
+ { }
91
+ };
92
+
93
+ public:
94
+ typedef _Alloc allocator_type;
95
+
96
+ _Tp_alloc_type&
97
+ _M_get_Tp_allocator()
98
+ { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); }
99
+
100
+ const _Tp_alloc_type&
101
+ _M_get_Tp_allocator() const
102
+ { return *static_cast<const _Tp_alloc_type*>(&this->_M_impl); }
103
+
104
+ allocator_type
105
+ get_allocator() const
106
+ { return allocator_type(_M_get_Tp_allocator()); }
107
+
108
+ _Vector_base()
109
+ : _M_impl() { }
110
+
111
+ _Vector_base(const allocator_type& __a)
112
+ : _M_impl(__a) { }
113
+
114
+ _Vector_base(size_t __n, const allocator_type& __a)
115
+ : _M_impl(__a)
116
+ {
117
+ this->_M_impl._M_start = this->_M_allocate(__n);
118
+ this->_M_impl._M_finish = this->_M_impl._M_start;
119
+ this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
120
+ }
121
+
122
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
123
+ _Vector_base(_Vector_base&& __x)
124
+ : _M_impl(__x._M_get_Tp_allocator())
125
+ {
126
+ this->_M_impl._M_start = __x._M_impl._M_start;
127
+ this->_M_impl._M_finish = __x._M_impl._M_finish;
128
+ this->_M_impl._M_end_of_storage = __x._M_impl._M_end_of_storage;
129
+ __x._M_impl._M_start = 0;
130
+ __x._M_impl._M_finish = 0;
131
+ __x._M_impl._M_end_of_storage = 0;
132
+ }
133
+ #endif
134
+
135
+ ~_Vector_base()
136
+ { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
137
+ - this->_M_impl._M_start); }
138
+
139
+ public:
140
+ _Vector_impl _M_impl;
141
+
142
+ _Tp*
143
+ _M_allocate(size_t __n)
144
+ { return __n != 0 ? _M_impl.allocate(__n) : 0; }
145
+
146
+ void
147
+ _M_deallocate(_Tp* __p, size_t __n)
148
+ {
149
+ if (__p)
150
+ _M_impl.deallocate(__p, __n);
151
+ }
152
+ };
153
+
154
+
155
+ /**
156
+ * @brief A standard container which offers fixed time access to
157
+ * individual elements in any order.
158
+ *
159
+ * @ingroup Containers
160
+ * @ingroup Sequences
161
+ *
162
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
163
+ * <a href="tables.html#66">reversible container</a>, and a
164
+ * <a href="tables.html#67">sequence</a>, including the
165
+ * <a href="tables.html#68">optional sequence requirements</a> with the
166
+ * %exception of @c push_front and @c pop_front.
167
+ *
168
+ * In some terminology a %vector can be described as a dynamic
169
+ * C-style array, it offers fast and efficient access to individual
170
+ * elements in any order and saves the user from worrying about
171
+ * memory and size allocation. Subscripting ( @c [] ) access is
172
+ * also provided as with C-style arrays.
173
+ */
174
+ template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
175
+ class vector : protected _Vector_base<_Tp, _Alloc>
176
+ {
177
+ // Concept requirements.
178
+ typedef typename _Alloc::value_type _Alloc_value_type;
179
+ __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
180
+ __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
181
+
182
+ typedef _Vector_base<_Tp, _Alloc> _Base;
183
+ typedef vector<_Tp, _Alloc> vector_type;
184
+ typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
185
+
186
+ public:
187
+ typedef _Tp value_type;
188
+ typedef typename _Tp_alloc_type::pointer pointer;
189
+ typedef typename _Tp_alloc_type::const_pointer const_pointer;
190
+ typedef typename _Tp_alloc_type::reference reference;
191
+ typedef typename _Tp_alloc_type::const_reference const_reference;
192
+ typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
193
+ typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type>
194
+ const_iterator;
195
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
196
+ typedef std::reverse_iterator<iterator> reverse_iterator;
197
+ typedef size_t size_type;
198
+ typedef ptrdiff_t difference_type;
199
+ typedef _Alloc allocator_type;
200
+
201
+ protected:
202
+ using _Base::_M_allocate;
203
+ using _Base::_M_deallocate;
204
+ using _Base::_M_impl;
205
+ using _Base::_M_get_Tp_allocator;
206
+
207
+ public:
208
+ // [23.2.4.1] construct/copy/destroy
209
+ // (assign() and get_allocator() are also listed in this section)
210
+ /**
211
+ * @brief Default constructor creates no elements.
212
+ */
213
+ vector()
214
+ : _Base() { }
215
+
216
+ /**
217
+ * @brief Creates a %vector with no elements.
218
+ * @param a An allocator object.
219
+ */
220
+ explicit
221
+ vector(const allocator_type& __a)
222
+ : _Base(__a) { }
223
+
224
+ /**
225
+ * @brief Creates a %vector with copies of an exemplar element.
226
+ * @param n The number of elements to initially create.
227
+ * @param value An element to copy.
228
+ * @param a An allocator.
229
+ *
230
+ * This constructor fills the %vector with @a n copies of @a value.
231
+ */
232
+ explicit
233
+ vector(size_type __n, const value_type& __value = value_type(),
234
+ const allocator_type& __a = allocator_type())
235
+ : _Base(__n, __a)
236
+ { _M_fill_initialize(__n, __value); }
237
+
238
+ /**
239
+ * @brief %Vector copy constructor.
240
+ * @param x A %vector of identical element and allocator types.
241
+ *
242
+ * The newly-created %vector uses a copy of the allocation
243
+ * object used by @a x. All the elements of @a x are copied,
244
+ * but any extra memory in
245
+ * @a x (for fast expansion) will not be copied.
246
+ */
247
+ vector(const vector& __x)
248
+ : _Base(__x.size(), __x._M_get_Tp_allocator())
249
+ { this->_M_impl._M_finish =
250
+ std::__uninitialized_copy_a(__x.begin(), __x.end(),
251
+ this->_M_impl._M_start,
252
+ _M_get_Tp_allocator());
253
+ }
254
+
255
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
256
+ /**
257
+ * @brief %Vector move constructor.
258
+ * @param x A %vector of identical element and allocator types.
259
+ *
260
+ * The newly-created %vector contains the exact contents of @a x.
261
+ * The contents of @a x are a valid, but unspecified %vector.
262
+ */
263
+ vector(vector&& __x)
264
+ : _Base(std::forward<_Base>(__x)) { }
265
+ #endif
266
+
267
+ /**
268
+ * @brief Builds a %vector from a range.
269
+ * @param first An input iterator.
270
+ * @param last An input iterator.
271
+ * @param a An allocator.
272
+ *
273
+ * Create a %vector consisting of copies of the elements from
274
+ * [first,last).
275
+ *
276
+ * If the iterators are forward, bidirectional, or
277
+ * random-access, then this will call the elements' copy
278
+ * constructor N times (where N is distance(first,last)) and do
279
+ * no memory reallocation. But if only input iterators are
280
+ * used, then this will do at most 2N calls to the copy
281
+ * constructor, and logN memory reallocations.
282
+ */
283
+ template<typename _InputIterator>
284
+ vector(_InputIterator __first, _InputIterator __last,
285
+ const allocator_type& __a = allocator_type())
286
+ : _Base(__a)
287
+ {
288
+ // Check whether it's an integral type. If so, it's not an iterator.
289
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
290
+ _M_initialize_dispatch(__first, __last, _Integral());
291
+ }
292
+
293
+ /**
294
+ * The dtor only erases the elements, and note that if the
295
+ * elements themselves are pointers, the pointed-to memory is
296
+ * not touched in any way. Managing the pointer is the user's
297
+ * responsibility.
298
+ */
299
+ ~vector()
300
+ { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
301
+ _M_get_Tp_allocator()); }
302
+
303
+ /**
304
+ * @brief %Vector assignment operator.
305
+ * @param x A %vector of identical element and allocator types.
306
+ *
307
+ * All the elements of @a x are copied, but any extra memory in
308
+ * @a x (for fast expansion) will not be copied. Unlike the
309
+ * copy constructor, the allocator object is not copied.
310
+ */
311
+ vector&
312
+ operator=(const vector& __x);
313
+
314
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
315
+ /**
316
+ * @brief %Vector move assignment operator.
317
+ * @param x A %vector of identical element and allocator types.
318
+ *
319
+ * The contents of @a x are moved into this %vector (without copying).
320
+ * @a x is a valid, but unspecified %vector.
321
+ */
322
+ vector&
323
+ operator=(vector&& __x)
324
+ {
325
+ // NB: DR 675.
326
+ this->clear();
327
+ this->swap(__x);
328
+ return *this;
329
+ }
330
+ #endif
331
+
332
+ /**
333
+ * @brief Assigns a given value to a %vector.
334
+ * @param n Number of elements to be assigned.
335
+ * @param val Value to be assigned.
336
+ *
337
+ * This function fills a %vector with @a n copies of the given
338
+ * value. Note that the assignment completely changes the
339
+ * %vector and that the resulting %vector's size is the same as
340
+ * the number of elements assigned. Old data may be lost.
341
+ */
342
+ void
343
+ assign(size_type __n, const value_type& __val)
344
+ { _M_fill_assign(__n, __val); }
345
+
346
+ /**
347
+ * @brief Assigns a range to a %vector.
348
+ * @param first An input iterator.
349
+ * @param last An input iterator.
350
+ *
351
+ * This function fills a %vector with copies of the elements in the
352
+ * range [first,last).
353
+ *
354
+ * Note that the assignment completely changes the %vector and
355
+ * that the resulting %vector's size is the same as the number
356
+ * of elements assigned. Old data may be lost.
357
+ */
358
+ template<typename _InputIterator>
359
+ void
360
+ assign(_InputIterator __first, _InputIterator __last)
361
+ {
362
+ // Check whether it's an integral type. If so, it's not an iterator.
363
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
364
+ _M_assign_dispatch(__first, __last, _Integral());
365
+ }
366
+
367
+ /// Get a copy of the memory allocation object.
368
+ using _Base::get_allocator;
369
+
370
+ // iterators
371
+ /**
372
+ * Returns a read/write iterator that points to the first
373
+ * element in the %vector. Iteration is done in ordinary
374
+ * element order.
375
+ */
376
+ iterator
377
+ begin()
378
+ { return iterator(this->_M_impl._M_start); }
379
+
380
+ /**
381
+ * Returns a read-only (constant) iterator that points to the
382
+ * first element in the %vector. Iteration is done in ordinary
383
+ * element order.
384
+ */
385
+ const_iterator
386
+ begin() const
387
+ { return const_iterator(this->_M_impl._M_start); }
388
+
389
+ /**
390
+ * Returns a read/write iterator that points one past the last
391
+ * element in the %vector. Iteration is done in ordinary
392
+ * element order.
393
+ */
394
+ iterator
395
+ end()
396
+ { return iterator(this->_M_impl._M_finish); }
397
+
398
+ /**
399
+ * Returns a read-only (constant) iterator that points one past
400
+ * the last element in the %vector. Iteration is done in
401
+ * ordinary element order.
402
+ */
403
+ const_iterator
404
+ end() const
405
+ { return const_iterator(this->_M_impl._M_finish); }
406
+
407
+ /**
408
+ * Returns a read/write reverse iterator that points to the
409
+ * last element in the %vector. Iteration is done in reverse
410
+ * element order.
411
+ */
412
+ reverse_iterator
413
+ rbegin()
414
+ { return reverse_iterator(end()); }
415
+
416
+ /**
417
+ * Returns a read-only (constant) reverse iterator that points
418
+ * to the last element in the %vector. Iteration is done in
419
+ * reverse element order.
420
+ */
421
+ const_reverse_iterator
422
+ rbegin() const
423
+ { return const_reverse_iterator(end()); }
424
+
425
+ /**
426
+ * Returns a read/write reverse iterator that points to one
427
+ * before the first element in the %vector. Iteration is done
428
+ * in reverse element order.
429
+ */
430
+ reverse_iterator
431
+ rend()
432
+ { return reverse_iterator(begin()); }
433
+
434
+ /**
435
+ * Returns a read-only (constant) reverse iterator that points
436
+ * to one before the first element in the %vector. Iteration
437
+ * is done in reverse element order.
438
+ */
439
+ const_reverse_iterator
440
+ rend() const
441
+ { return const_reverse_iterator(begin()); }
442
+
443
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
444
+ /**
445
+ * Returns a read-only (constant) iterator that points to the
446
+ * first element in the %vector. Iteration is done in ordinary
447
+ * element order.
448
+ */
449
+ const_iterator
450
+ cbegin() const
451
+ { return const_iterator(this->_M_impl._M_start); }
452
+
453
+ /**
454
+ * Returns a read-only (constant) iterator that points one past
455
+ * the last element in the %vector. Iteration is done in
456
+ * ordinary element order.
457
+ */
458
+ const_iterator
459
+ cend() const
460
+ { return const_iterator(this->_M_impl._M_finish); }
461
+
462
+ /**
463
+ * Returns a read-only (constant) reverse iterator that points
464
+ * to the last element in the %vector. Iteration is done in
465
+ * reverse element order.
466
+ */
467
+ const_reverse_iterator
468
+ crbegin() const
469
+ { return const_reverse_iterator(end()); }
470
+
471
+ /**
472
+ * Returns a read-only (constant) reverse iterator that points
473
+ * to one before the first element in the %vector. Iteration
474
+ * is done in reverse element order.
475
+ */
476
+ const_reverse_iterator
477
+ crend() const
478
+ { return const_reverse_iterator(begin()); }
479
+ #endif
480
+
481
+ // [23.2.4.2] capacity
482
+ /** Returns the number of elements in the %vector. */
483
+ size_type
484
+ size() const
485
+ { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
486
+
487
+ /** Returns the size() of the largest possible %vector. */
488
+ size_type
489
+ max_size() const
490
+ { return _M_get_Tp_allocator().max_size(); }
491
+
492
+ /**
493
+ * @brief Resizes the %vector to the specified number of elements.
494
+ * @param new_size Number of elements the %vector should contain.
495
+ * @param x Data with which new elements should be populated.
496
+ *
497
+ * This function will %resize the %vector to the specified
498
+ * number of elements. If the number is smaller than the
499
+ * %vector's current size the %vector is truncated, otherwise
500
+ * the %vector is extended and new elements are populated with
501
+ * given data.
502
+ */
503
+ void
504
+ resize(size_type __new_size, value_type __x = value_type())
505
+ {
506
+ if (__new_size < size())
507
+ _M_erase_at_end(this->_M_impl._M_start + __new_size);
508
+ else
509
+ insert(end(), __new_size - size(), __x);
510
+ }
511
+
512
+ /**
513
+ * Returns the total number of elements that the %vector can
514
+ * hold before needing to allocate more memory.
515
+ */
516
+ size_type
517
+ capacity() const
518
+ { return size_type(this->_M_impl._M_end_of_storage
519
+ - this->_M_impl._M_start); }
520
+
521
+ /**
522
+ * Returns true if the %vector is empty. (Thus begin() would
523
+ * equal end().)
524
+ */
525
+ bool
526
+ empty() const
527
+ { return begin() == end(); }
528
+
529
+ /**
530
+ * @brief Attempt to preallocate enough memory for specified number of
531
+ * elements.
532
+ * @param n Number of elements required.
533
+ * @throw std::length_error If @a n exceeds @c max_size().
534
+ *
535
+ * This function attempts to reserve enough memory for the
536
+ * %vector to hold the specified number of elements. If the
537
+ * number requested is more than max_size(), length_error is
538
+ * thrown.
539
+ *
540
+ * The advantage of this function is that if optimal code is a
541
+ * necessity and the user can determine the number of elements
542
+ * that will be required, the user can reserve the memory in
543
+ * %advance, and thus prevent a possible reallocation of memory
544
+ * and copying of %vector data.
545
+ */
546
+ void
547
+ reserve(size_type __n);
548
+
549
+ // element access
550
+ /**
551
+ * @brief Subscript access to the data contained in the %vector.
552
+ * @param n The index of the element for which data should be
553
+ * accessed.
554
+ * @return Read/write reference to data.
555
+ *
556
+ * This operator allows for easy, array-style, data access.
557
+ * Note that data access with this operator is unchecked and
558
+ * out_of_range lookups are not defined. (For checked lookups
559
+ * see at().)
560
+ */
561
+ reference
562
+ operator[](size_type __n)
563
+ { return *(this->_M_impl._M_start + __n); }
564
+
565
+ /**
566
+ * @brief Subscript access to the data contained in the %vector.
567
+ * @param n The index of the element for which data should be
568
+ * accessed.
569
+ * @return Read-only (constant) reference to data.
570
+ *
571
+ * This operator allows for easy, array-style, data access.
572
+ * Note that data access with this operator is unchecked and
573
+ * out_of_range lookups are not defined. (For checked lookups
574
+ * see at().)
575
+ */
576
+ const_reference
577
+ operator[](size_type __n) const
578
+ { return *(this->_M_impl._M_start + __n); }
579
+
580
+ protected:
581
+ /// Safety check used only from at().
582
+ void
583
+ _M_range_check(size_type __n) const
584
+ {
585
+ if (__n >= this->size())
586
+ __throw_out_of_range(__N("vector::_M_range_check"));
587
+ }
588
+
589
+ public:
590
+ /**
591
+ * @brief Provides access to the data contained in the %vector.
592
+ * @param n The index of the element for which data should be
593
+ * accessed.
594
+ * @return Read/write reference to data.
595
+ * @throw std::out_of_range If @a n is an invalid index.
596
+ *
597
+ * This function provides for safer data access. The parameter
598
+ * is first checked that it is in the range of the vector. The
599
+ * function throws out_of_range if the check fails.
600
+ */
601
+ reference
602
+ at(size_type __n)
603
+ {
604
+ _M_range_check(__n);
605
+ return (*this)[__n];
606
+ }
607
+
608
+ /**
609
+ * @brief Provides access to the data contained in the %vector.
610
+ * @param n The index of the element for which data should be
611
+ * accessed.
612
+ * @return Read-only (constant) reference to data.
613
+ * @throw std::out_of_range If @a n is an invalid index.
614
+ *
615
+ * This function provides for safer data access. The parameter
616
+ * is first checked that it is in the range of the vector. The
617
+ * function throws out_of_range if the check fails.
618
+ */
619
+ const_reference
620
+ at(size_type __n) const
621
+ {
622
+ _M_range_check(__n);
623
+ return (*this)[__n];
624
+ }
625
+
626
+ /**
627
+ * Returns a read/write reference to the data at the first
628
+ * element of the %vector.
629
+ */
630
+ reference
631
+ front()
632
+ { return *begin(); }
633
+
634
+ /**
635
+ * Returns a read-only (constant) reference to the data at the first
636
+ * element of the %vector.
637
+ */
638
+ const_reference
639
+ front() const
640
+ { return *begin(); }
641
+
642
+ /**
643
+ * Returns a read/write reference to the data at the last
644
+ * element of the %vector.
645
+ */
646
+ reference
647
+ back()
648
+ { return *(end() - 1); }
649
+
650
+ /**
651
+ * Returns a read-only (constant) reference to the data at the
652
+ * last element of the %vector.
653
+ */
654
+ const_reference
655
+ back() const
656
+ { return *(end() - 1); }
657
+
658
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
659
+ // DR 464. Suggestion for new member functions in standard containers.
660
+ // data access
661
+ /**
662
+ * Returns a pointer such that [data(), data() + size()) is a valid
663
+ * range. For a non-empty %vector, data() == &front().
664
+ */
665
+ pointer
666
+ data()
667
+ { return pointer(this->_M_impl._M_start); }
668
+
669
+ const_pointer
670
+ data() const
671
+ { return const_pointer(this->_M_impl._M_start); }
672
+
673
+ // [23.2.4.3] modifiers
674
+ /**
675
+ * @brief Add data to the end of the %vector.
676
+ * @param x Data to be added.
677
+ *
678
+ * This is a typical stack operation. The function creates an
679
+ * element at the end of the %vector and assigns the given data
680
+ * to it. Due to the nature of a %vector this operation can be
681
+ * done in constant time if the %vector has preallocated space
682
+ * available.
683
+ */
684
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
685
+ void
686
+ push_back(const value_type& __x)
687
+ {
688
+ if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
689
+ {
690
+ this->_M_impl.construct(this->_M_impl._M_finish, __x);
691
+ ++this->_M_impl._M_finish;
692
+ }
693
+ else
694
+ _M_insert_aux(end(), __x);
695
+ }
696
+ #else
697
+ template<typename... _Args>
698
+ void
699
+ push_back(_Args&&... __args)
700
+ {
701
+ if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
702
+ {
703
+ this->_M_impl.construct(this->_M_impl._M_finish,
704
+ std::forward<_Args>(__args)...);
705
+ ++this->_M_impl._M_finish;
706
+ }
707
+ else
708
+ _M_insert_aux(end(), std::forward<_Args>(__args)...);
709
+ }
710
+ #endif
711
+
712
+ /**
713
+ * @brief Removes last element.
714
+ *
715
+ * This is a typical stack operation. It shrinks the %vector by one.
716
+ *
717
+ * Note that no data is returned, and if the last element's
718
+ * data is needed, it should be retrieved before pop_back() is
719
+ * called.
720
+ */
721
+ void
722
+ pop_back()
723
+ {
724
+ --this->_M_impl._M_finish;
725
+ this->_M_impl.destroy(this->_M_impl._M_finish);
726
+ }
727
+
728
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
729
+ /**
730
+ * @brief Inserts an object in %vector before specified iterator.
731
+ * @param position An iterator into the %vector.
732
+ * @param args Arguments.
733
+ * @return An iterator that points to the inserted data.
734
+ *
735
+ * This function will insert an object of type T constructed
736
+ * with T(std::forward<Args>(args)...) before the specified location.
737
+ * Note that this kind of operation could be expensive for a %vector
738
+ * and if it is frequently used the user should consider using
739
+ * std::list.
740
+ */
741
+ template<typename... _Args>
742
+ iterator
743
+ emplace(iterator __position, _Args&&... __args);
744
+ #endif
745
+
746
+ /**
747
+ * @brief Inserts given value into %vector before specified iterator.
748
+ * @param position An iterator into the %vector.
749
+ * @param x Data to be inserted.
750
+ * @return An iterator that points to the inserted data.
751
+ *
752
+ * This function will insert a copy of the given value before
753
+ * the specified location. Note that this kind of operation
754
+ * could be expensive for a %vector and if it is frequently
755
+ * used the user should consider using std::list.
756
+ */
757
+ iterator
758
+ insert(iterator __position, const value_type& __x);
759
+
760
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
761
+ /**
762
+ * @brief Inserts given rvalue into %vector before specified iterator.
763
+ * @param position An iterator into the %vector.
764
+ * @param x Data to be inserted.
765
+ * @return An iterator that points to the inserted data.
766
+ *
767
+ * This function will insert a copy of the given rvalue before
768
+ * the specified location. Note that this kind of operation
769
+ * could be expensive for a %vector and if it is frequently
770
+ * used the user should consider using std::list.
771
+ */
772
+ iterator
773
+ insert(iterator __position, value_type&& __x)
774
+ { return emplace(__position, std::move(__x)); }
775
+ #endif
776
+
777
+ /**
778
+ * @brief Inserts a number of copies of given data into the %vector.
779
+ * @param position An iterator into the %vector.
780
+ * @param n Number of elements to be inserted.
781
+ * @param x Data to be inserted.
782
+ *
783
+ * This function will insert a specified number of copies of
784
+ * the given data before the location specified by @a position.
785
+ *
786
+ * Note that this kind of operation could be expensive for a
787
+ * %vector and if it is frequently used the user should
788
+ * consider using std::list.
789
+ */
790
+ void
791
+ insert(iterator __position, size_type __n, const value_type& __x)
792
+ { _M_fill_insert(__position, __n, __x); }
793
+
794
+ /**
795
+ * @brief Inserts a range into the %vector.
796
+ * @param position An iterator into the %vector.
797
+ * @param first An input iterator.
798
+ * @param last An input iterator.
799
+ *
800
+ * This function will insert copies of the data in the range
801
+ * [first,last) into the %vector before the location specified
802
+ * by @a pos.
803
+ *
804
+ * Note that this kind of operation could be expensive for a
805
+ * %vector and if it is frequently used the user should
806
+ * consider using std::list.
807
+ */
808
+ template<typename _InputIterator>
809
+ void
810
+ insert(iterator __position, _InputIterator __first,
811
+ _InputIterator __last)
812
+ {
813
+ // Check whether it's an integral type. If so, it's not an iterator.
814
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
815
+ _M_insert_dispatch(__position, __first, __last, _Integral());
816
+ }
817
+
818
+ /**
819
+ * @brief Remove element at given position.
820
+ * @param position Iterator pointing to element to be erased.
821
+ * @return An iterator pointing to the next element (or end()).
822
+ *
823
+ * This function will erase the element at the given position and thus
824
+ * shorten the %vector by one.
825
+ *
826
+ * Note This operation could be expensive and if it is
827
+ * frequently used the user should consider using std::list.
828
+ * The user is also cautioned that this function only erases
829
+ * the element, and that if the element is itself a pointer,
830
+ * the pointed-to memory is not touched in any way. Managing
831
+ * the pointer is the user's responsibility.
832
+ */
833
+ iterator
834
+ erase(iterator __position);
835
+
836
+ /**
837
+ * @brief Remove a range of elements.
838
+ * @param first Iterator pointing to the first element to be erased.
839
+ * @param last Iterator pointing to one past the last element to be
840
+ * erased.
841
+ * @return An iterator pointing to the element pointed to by @a last
842
+ * prior to erasing (or end()).
843
+ *
844
+ * This function will erase the elements in the range [first,last) and
845
+ * shorten the %vector accordingly.
846
+ *
847
+ * Note This operation could be expensive and if it is
848
+ * frequently used the user should consider using std::list.
849
+ * The user is also cautioned that this function only erases
850
+ * the elements, and that if the elements themselves are
851
+ * pointers, the pointed-to memory is not touched in any way.
852
+ * Managing the pointer is the user's responsibility.
853
+ */
854
+ iterator
855
+ erase(iterator __first, iterator __last);
856
+
857
+ /**
858
+ * @brief Swaps data with another %vector.
859
+ * @param x A %vector of the same element and allocator types.
860
+ *
861
+ * This exchanges the elements between two vectors in constant time.
862
+ * (Three pointers, so it should be quite fast.)
863
+ * Note that the global std::swap() function is specialized such that
864
+ * std::swap(v1,v2) will feed to this function.
865
+ */
866
+ void
867
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
868
+ swap(vector&& __x)
869
+ #else
870
+ swap(vector& __x)
871
+ #endif
872
+ {
873
+ std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
874
+ std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
875
+ std::swap(this->_M_impl._M_end_of_storage,
876
+ __x._M_impl._M_end_of_storage);
877
+
878
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
879
+ // 431. Swapping containers with unequal allocators.
880
+ std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
881
+ __x._M_get_Tp_allocator());
882
+ }
883
+
884
+ /**
885
+ * Erases all the elements. Note that this function only erases the
886
+ * elements, and that if the elements themselves are pointers, the
887
+ * pointed-to memory is not touched in any way. Managing the pointer is
888
+ * the user's responsibility.
889
+ */
890
+ void
891
+ clear()
892
+ { _M_erase_at_end(this->_M_impl._M_start); }
893
+
894
+ protected:
895
+ /**
896
+ * Memory expansion handler. Uses the member allocation function to
897
+ * obtain @a n bytes of memory, and then copies [first,last) into it.
898
+ */
899
+ template<typename _ForwardIterator>
900
+ pointer
901
+ _M_allocate_and_copy(size_type __n,
902
+ _ForwardIterator __first, _ForwardIterator __last)
903
+ {
904
+ pointer __result = this->_M_allocate(__n);
905
+ try
906
+ {
907
+ std::__uninitialized_copy_a(__first, __last, __result,
908
+ _M_get_Tp_allocator());
909
+ return __result;
910
+ }
911
+ catch(...)
912
+ {
913
+ _M_deallocate(__result, __n);
914
+ __throw_exception_again;
915
+ }
916
+ }
917
+
918
+
919
+ // Internal constructor functions follow.
920
+
921
+ // Called by the range constructor to implement [23.1.1]/9
922
+
923
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
924
+ // 438. Ambiguity in the "do the right thing" clause
925
+ template<typename _Integer>
926
+ void
927
+ _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
928
+ {
929
+ this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n));
930
+ this->_M_impl._M_end_of_storage =
931
+ this->_M_impl._M_start + static_cast<size_type>(__n);
932
+ _M_fill_initialize(static_cast<size_type>(__n), __value);
933
+ }
934
+
935
+ // Called by the range constructor to implement [23.1.1]/9
936
+ template<typename _InputIterator>
937
+ void
938
+ _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
939
+ __false_type)
940
+ {
941
+ typedef typename std::iterator_traits<_InputIterator>::
942
+ iterator_category _IterCategory;
943
+ _M_range_initialize(__first, __last, _IterCategory());
944
+ }
945
+
946
+ // Called by the second initialize_dispatch above
947
+ template<typename _InputIterator>
948
+ void
949
+ _M_range_initialize(_InputIterator __first,
950
+ _InputIterator __last, std::input_iterator_tag)
951
+ {
952
+ for (; __first != __last; ++__first)
953
+ push_back(*__first);
954
+ }
955
+
956
+ // Called by the second initialize_dispatch above
957
+ template<typename _ForwardIterator>
958
+ void
959
+ _M_range_initialize(_ForwardIterator __first,
960
+ _ForwardIterator __last, std::forward_iterator_tag)
961
+ {
962
+ const size_type __n = std::distance(__first, __last);
963
+ this->_M_impl._M_start = this->_M_allocate(__n);
964
+ this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
965
+ this->_M_impl._M_finish =
966
+ std::__uninitialized_copy_a(__first, __last,
967
+ this->_M_impl._M_start,
968
+ _M_get_Tp_allocator());
969
+ }
970
+
971
+ // Called by the first initialize_dispatch above and by the
972
+ // vector(n,value,a) constructor.
973
+ void
974
+ _M_fill_initialize(size_type __n, const value_type& __value)
975
+ {
976
+ std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
977
+ _M_get_Tp_allocator());
978
+ this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
979
+ }
980
+
981
+
982
+ // Internal assign functions follow. The *_aux functions do the actual
983
+ // assignment work for the range versions.
984
+
985
+ // Called by the range assign to implement [23.1.1]/9
986
+
987
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
988
+ // 438. Ambiguity in the "do the right thing" clause
989
+ template<typename _Integer>
990
+ void
991
+ _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
992
+ { _M_fill_assign(__n, __val); }
993
+
994
+ // Called by the range assign to implement [23.1.1]/9
995
+ template<typename _InputIterator>
996
+ void
997
+ _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
998
+ __false_type)
999
+ {
1000
+ typedef typename std::iterator_traits<_InputIterator>::
1001
+ iterator_category _IterCategory;
1002
+ _M_assign_aux(__first, __last, _IterCategory());
1003
+ }
1004
+
1005
+ // Called by the second assign_dispatch above
1006
+ template<typename _InputIterator>
1007
+ void
1008
+ _M_assign_aux(_InputIterator __first, _InputIterator __last,
1009
+ std::input_iterator_tag);
1010
+
1011
+ // Called by the second assign_dispatch above
1012
+ template<typename _ForwardIterator>
1013
+ void
1014
+ _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1015
+ std::forward_iterator_tag);
1016
+
1017
+ // Called by assign(n,t), and the range assign when it turns out
1018
+ // to be the same thing.
1019
+ void
1020
+ _M_fill_assign(size_type __n, const value_type& __val);
1021
+
1022
+
1023
+ // Internal insert functions follow.
1024
+
1025
+ // Called by the range insert to implement [23.1.1]/9
1026
+
1027
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
1028
+ // 438. Ambiguity in the "do the right thing" clause
1029
+ template<typename _Integer>
1030
+ void
1031
+ _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
1032
+ __true_type)
1033
+ { _M_fill_insert(__pos, __n, __val); }
1034
+
1035
+ // Called by the range insert to implement [23.1.1]/9
1036
+ template<typename _InputIterator>
1037
+ void
1038
+ _M_insert_dispatch(iterator __pos, _InputIterator __first,
1039
+ _InputIterator __last, __false_type)
1040
+ {
1041
+ typedef typename std::iterator_traits<_InputIterator>::
1042
+ iterator_category _IterCategory;
1043
+ _M_range_insert(__pos, __first, __last, _IterCategory());
1044
+ }
1045
+
1046
+ // Called by the second insert_dispatch above
1047
+ template<typename _InputIterator>
1048
+ void
1049
+ _M_range_insert(iterator __pos, _InputIterator __first,
1050
+ _InputIterator __last, std::input_iterator_tag);
1051
+
1052
+ // Called by the second insert_dispatch above
1053
+ template<typename _ForwardIterator>
1054
+ void
1055
+ _M_range_insert(iterator __pos, _ForwardIterator __first,
1056
+ _ForwardIterator __last, std::forward_iterator_tag);
1057
+
1058
+ // Called by insert(p,n,x), and the range insert when it turns out to be
1059
+ // the same thing.
1060
+ void
1061
+ _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
1062
+
1063
+ // Called by insert(p,x)
1064
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
1065
+ void
1066
+ _M_insert_aux(iterator __position, const value_type& __x);
1067
+ #else
1068
+ template<typename... _Args>
1069
+ void
1070
+ _M_insert_aux(iterator __position, _Args&&... __args);
1071
+ #endif
1072
+
1073
+ // Called by the latter.
1074
+ size_type
1075
+ _M_check_len(size_type __n, const char* __s) const
1076
+ {
1077
+ if (max_size() - size() < __n)
1078
+ __throw_length_error(__N(__s));
1079
+
1080
+ const size_type __len = size() + std::max(size(), __n);
1081
+ return (__len < size() || __len > max_size()) ? max_size() : __len;
1082
+ }
1083
+
1084
+ // Internal erase functions follow.
1085
+
1086
+ // Called by erase(q1,q2), clear(), resize(), _M_fill_assign,
1087
+ // _M_assign_aux.
1088
+ void
1089
+ _M_erase_at_end(pointer __pos)
1090
+ {
1091
+ std::_Destroy(__pos, this->_M_impl._M_finish, _M_get_Tp_allocator());
1092
+ this->_M_impl._M_finish = __pos;
1093
+ }
1094
+ };
1095
+
1096
+
1097
+ /**
1098
+ * @brief Vector equality comparison.
1099
+ * @param x A %vector.
1100
+ * @param y A %vector of the same type as @a x.
1101
+ * @return True iff the size and elements of the vectors are equal.
1102
+ *
1103
+ * This is an equivalence relation. It is linear in the size of the
1104
+ * vectors. Vectors are considered equivalent if their sizes are equal,
1105
+ * and if corresponding elements compare equal.
1106
+ */
1107
+ template<typename _Tp, typename _Alloc>
1108
+ inline bool
1109
+ operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
1110
+ { return (__x.size() == __y.size()
1111
+ && std::equal(__x.begin(), __x.end(), __y.begin())); }
1112
+
1113
+ /**
1114
+ * @brief Vector ordering relation.
1115
+ * @param x A %vector.
1116
+ * @param y A %vector of the same type as @a x.
1117
+ * @return True iff @a x is lexicographically less than @a y.
1118
+ *
1119
+ * This is a total ordering relation. It is linear in the size of the
1120
+ * vectors. The elements must be comparable with @c <.
1121
+ *
1122
+ * See std::lexicographical_compare() for how the determination is made.
1123
+ */
1124
+ template<typename _Tp, typename _Alloc>
1125
+ inline bool
1126
+ operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
1127
+ { return std::lexicographical_compare(__x.begin(), __x.end(),
1128
+ __y.begin(), __y.end()); }
1129
+
1130
+ /// Based on operator==
1131
+ template<typename _Tp, typename _Alloc>
1132
+ inline bool
1133
+ operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
1134
+ { return !(__x == __y); }
1135
+
1136
+ /// Based on operator<
1137
+ template<typename _Tp, typename _Alloc>
1138
+ inline bool
1139
+ operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
1140
+ { return __y < __x; }
1141
+
1142
+ /// Based on operator<
1143
+ template<typename _Tp, typename _Alloc>
1144
+ inline bool
1145
+ operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
1146
+ { return !(__y < __x); }
1147
+
1148
+ /// Based on operator<
1149
+ template<typename _Tp, typename _Alloc>
1150
+ inline bool
1151
+ operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
1152
+ { return !(__x < __y); }
1153
+
1154
+ /// See std::vector::swap().
1155
+ template<typename _Tp, typename _Alloc>
1156
+ inline void
1157
+ swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
1158
+ { __x.swap(__y); }
1159
+
1160
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
1161
+ template<typename _Tp, typename _Alloc>
1162
+ inline void
1163
+ swap(vector<_Tp, _Alloc>&& __x, vector<_Tp, _Alloc>& __y)
1164
+ { __x.swap(__y); }
1165
+
1166
+ template<typename _Tp, typename _Alloc>
1167
+ inline void
1168
+ swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>&& __y)
1169
+ { __x.swap(__y); }
1170
+ #endif
1171
+
1172
+ _GLIBCXX_END_NESTED_NAMESPACE
1173
+
1174
+ #endif /* _STL_VECTOR_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stream_iterator.h ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Stream iterators
2
+
3
+ // Copyright (C) 2001, 2004, 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file stream_iterator.h
31
+ * This is an internal header file, included by other library headers.
32
+ * You should not attempt to use it directly.
33
+ */
34
+
35
+ #ifndef _STREAM_ITERATOR_H
36
+ #define _STREAM_ITERATOR_H 1
37
+
38
+ #pragma GCC system_header
39
+
40
+ #include <debug/debug.h>
41
+
42
+ _GLIBCXX_BEGIN_NAMESPACE(std)
43
+
44
+ /// Provides input iterator semantics for streams.
45
+ template<typename _Tp, typename _CharT = char,
46
+ typename _Traits = char_traits<_CharT>, typename _Dist = ptrdiff_t>
47
+ class istream_iterator
48
+ : public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
49
+ {
50
+ public:
51
+ typedef _CharT char_type;
52
+ typedef _Traits traits_type;
53
+ typedef basic_istream<_CharT, _Traits> istream_type;
54
+
55
+ private:
56
+ istream_type* _M_stream;
57
+ _Tp _M_value;
58
+ bool _M_ok;
59
+
60
+ public:
61
+ /// Construct end of input stream iterator.
62
+ istream_iterator()
63
+ : _M_stream(0), _M_value(), _M_ok(false) {}
64
+
65
+ /// Construct start of input stream iterator.
66
+ istream_iterator(istream_type& __s)
67
+ : _M_stream(&__s)
68
+ { _M_read(); }
69
+
70
+ istream_iterator(const istream_iterator& __obj)
71
+ : _M_stream(__obj._M_stream), _M_value(__obj._M_value),
72
+ _M_ok(__obj._M_ok)
73
+ { }
74
+
75
+ const _Tp&
76
+ operator*() const
77
+ {
78
+ __glibcxx_requires_cond(_M_ok,
79
+ _M_message(__gnu_debug::__msg_deref_istream)
80
+ ._M_iterator(*this));
81
+ return _M_value;
82
+ }
83
+
84
+ const _Tp*
85
+ operator->() const { return &(operator*()); }
86
+
87
+ istream_iterator&
88
+ operator++()
89
+ {
90
+ __glibcxx_requires_cond(_M_ok,
91
+ _M_message(__gnu_debug::__msg_inc_istream)
92
+ ._M_iterator(*this));
93
+ _M_read();
94
+ return *this;
95
+ }
96
+
97
+ istream_iterator
98
+ operator++(int)
99
+ {
100
+ __glibcxx_requires_cond(_M_ok,
101
+ _M_message(__gnu_debug::__msg_inc_istream)
102
+ ._M_iterator(*this));
103
+ istream_iterator __tmp = *this;
104
+ _M_read();
105
+ return __tmp;
106
+ }
107
+
108
+ bool
109
+ _M_equal(const istream_iterator& __x) const
110
+ { return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }
111
+
112
+ private:
113
+ void
114
+ _M_read()
115
+ {
116
+ _M_ok = (_M_stream && *_M_stream) ? true : false;
117
+ if (_M_ok)
118
+ {
119
+ *_M_stream >> _M_value;
120
+ _M_ok = *_M_stream ? true : false;
121
+ }
122
+ }
123
+ };
124
+
125
+ /// Return true if x and y are both end or not end, or x and y are the same.
126
+ template<typename _Tp, typename _CharT, typename _Traits, typename _Dist>
127
+ inline bool
128
+ operator==(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
129
+ const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
130
+ { return __x._M_equal(__y); }
131
+
132
+ /// Return false if x and y are both end or not end, or x and y are the same.
133
+ template <class _Tp, class _CharT, class _Traits, class _Dist>
134
+ inline bool
135
+ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
136
+ const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y)
137
+ { return !__x._M_equal(__y); }
138
+
139
+ /**
140
+ * @brief Provides output iterator semantics for streams.
141
+ *
142
+ * This class provides an iterator to write to an ostream. The type Tp is
143
+ * the only type written by this iterator and there must be an
144
+ * operator<<(Tp) defined.
145
+ *
146
+ * @param Tp The type to write to the ostream.
147
+ * @param CharT The ostream char_type.
148
+ * @param Traits The ostream char_traits.
149
+ */
150
+ template<typename _Tp, typename _CharT = char,
151
+ typename _Traits = char_traits<_CharT> >
152
+ class ostream_iterator
153
+ : public iterator<output_iterator_tag, void, void, void, void>
154
+ {
155
+ public:
156
+ //@{
157
+ /// Public typedef
158
+ typedef _CharT char_type;
159
+ typedef _Traits traits_type;
160
+ typedef basic_ostream<_CharT, _Traits> ostream_type;
161
+ //@}
162
+
163
+ private:
164
+ ostream_type* _M_stream;
165
+ const _CharT* _M_string;
166
+
167
+ public:
168
+ /// Construct from an ostream.
169
+ ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {}
170
+
171
+ /**
172
+ * Construct from an ostream.
173
+ *
174
+ * The delimiter string @a c is written to the stream after every Tp
175
+ * written to the stream. The delimiter is not copied, and thus must
176
+ * not be destroyed while this iterator is in use.
177
+ *
178
+ * @param s Underlying ostream to write to.
179
+ * @param c CharT delimiter string to insert.
180
+ */
181
+ ostream_iterator(ostream_type& __s, const _CharT* __c)
182
+ : _M_stream(&__s), _M_string(__c) { }
183
+
184
+ /// Copy constructor.
185
+ ostream_iterator(const ostream_iterator& __obj)
186
+ : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { }
187
+
188
+ /// Writes @a value to underlying ostream using operator<<. If
189
+ /// constructed with delimiter string, writes delimiter to ostream.
190
+ ostream_iterator&
191
+ operator=(const _Tp& __value)
192
+ {
193
+ __glibcxx_requires_cond(_M_stream != 0,
194
+ _M_message(__gnu_debug::__msg_output_ostream)
195
+ ._M_iterator(*this));
196
+ *_M_stream << __value;
197
+ if (_M_string) *_M_stream << _M_string;
198
+ return *this;
199
+ }
200
+
201
+ ostream_iterator&
202
+ operator*()
203
+ { return *this; }
204
+
205
+ ostream_iterator&
206
+ operator++()
207
+ { return *this; }
208
+
209
+ ostream_iterator&
210
+ operator++(int)
211
+ { return *this; }
212
+ };
213
+
214
+ _GLIBCXX_END_NAMESPACE
215
+
216
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/streambuf.tcc ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Stream buffer classes -*- C++ -*-
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file streambuf.tcc
32
+ * This is an internal header file, included by other library headers.
33
+ * You should not attempt to use it directly.
34
+ */
35
+
36
+ //
37
+ // ISO C++ 14882: 27.5 Stream buffers
38
+ //
39
+
40
+ #ifndef _STREAMBUF_TCC
41
+ #define _STREAMBUF_TCC 1
42
+
43
+ #pragma GCC system_header
44
+
45
+ _GLIBCXX_BEGIN_NAMESPACE(std)
46
+
47
+ template<typename _CharT, typename _Traits>
48
+ streamsize
49
+ basic_streambuf<_CharT, _Traits>::
50
+ xsgetn(char_type* __s, streamsize __n)
51
+ {
52
+ streamsize __ret = 0;
53
+ while (__ret < __n)
54
+ {
55
+ const streamsize __buf_len = this->egptr() - this->gptr();
56
+ if (__buf_len)
57
+ {
58
+ const streamsize __remaining = __n - __ret;
59
+ const streamsize __len = std::min(__buf_len, __remaining);
60
+ traits_type::copy(__s, this->gptr(), __len);
61
+ __ret += __len;
62
+ __s += __len;
63
+ this->gbump(__len);
64
+ }
65
+
66
+ if (__ret < __n)
67
+ {
68
+ const int_type __c = this->uflow();
69
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
70
+ {
71
+ traits_type::assign(*__s++, traits_type::to_char_type(__c));
72
+ ++__ret;
73
+ }
74
+ else
75
+ break;
76
+ }
77
+ }
78
+ return __ret;
79
+ }
80
+
81
+ template<typename _CharT, typename _Traits>
82
+ streamsize
83
+ basic_streambuf<_CharT, _Traits>::
84
+ xsputn(const char_type* __s, streamsize __n)
85
+ {
86
+ streamsize __ret = 0;
87
+ while (__ret < __n)
88
+ {
89
+ const streamsize __buf_len = this->epptr() - this->pptr();
90
+ if (__buf_len)
91
+ {
92
+ const streamsize __remaining = __n - __ret;
93
+ const streamsize __len = std::min(__buf_len, __remaining);
94
+ traits_type::copy(this->pptr(), __s, __len);
95
+ __ret += __len;
96
+ __s += __len;
97
+ this->pbump(__len);
98
+ }
99
+
100
+ if (__ret < __n)
101
+ {
102
+ int_type __c = this->overflow(traits_type::to_int_type(*__s));
103
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
104
+ {
105
+ ++__ret;
106
+ ++__s;
107
+ }
108
+ else
109
+ break;
110
+ }
111
+ }
112
+ return __ret;
113
+ }
114
+
115
+ // Conceivably, this could be used to implement buffer-to-buffer
116
+ // copies, if this was ever desired in an un-ambiguous way by the
117
+ // standard.
118
+ template<typename _CharT, typename _Traits>
119
+ streamsize
120
+ __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin,
121
+ basic_streambuf<_CharT, _Traits>* __sbout,
122
+ bool& __ineof)
123
+ {
124
+ streamsize __ret = 0;
125
+ __ineof = true;
126
+ typename _Traits::int_type __c = __sbin->sgetc();
127
+ while (!_Traits::eq_int_type(__c, _Traits::eof()))
128
+ {
129
+ __c = __sbout->sputc(_Traits::to_char_type(__c));
130
+ if (_Traits::eq_int_type(__c, _Traits::eof()))
131
+ {
132
+ __ineof = false;
133
+ break;
134
+ }
135
+ ++__ret;
136
+ __c = __sbin->snextc();
137
+ }
138
+ return __ret;
139
+ }
140
+
141
+ template<typename _CharT, typename _Traits>
142
+ inline streamsize
143
+ __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
144
+ basic_streambuf<_CharT, _Traits>* __sbout)
145
+ {
146
+ bool __ineof;
147
+ return __copy_streambufs_eof(__sbin, __sbout, __ineof);
148
+ }
149
+
150
+ // Inhibit implicit instantiations for required instantiations,
151
+ // which are defined via explicit instantiations elsewhere.
152
+ // NB: This syntax is a GNU extension.
153
+ #if _GLIBCXX_EXTERN_TEMPLATE
154
+ extern template class basic_streambuf<char>;
155
+ extern template
156
+ streamsize
157
+ __copy_streambufs(basic_streambuf<char>*,
158
+ basic_streambuf<char>*);
159
+ extern template
160
+ streamsize
161
+ __copy_streambufs_eof(basic_streambuf<char>*,
162
+ basic_streambuf<char>*, bool&);
163
+
164
+ #ifdef _GLIBCXX_USE_WCHAR_T
165
+ extern template class basic_streambuf<wchar_t>;
166
+ extern template
167
+ streamsize
168
+ __copy_streambufs(basic_streambuf<wchar_t>*,
169
+ basic_streambuf<wchar_t>*);
170
+ extern template
171
+ streamsize
172
+ __copy_streambufs_eof(basic_streambuf<wchar_t>*,
173
+ basic_streambuf<wchar_t>*, bool&);
174
+ #endif
175
+ #endif
176
+
177
+ _GLIBCXX_END_NAMESPACE
178
+
179
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/streambuf_iterator.h ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Streambuf iterators
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4
+ // 2006, 2007
5
+ // Free Software Foundation, Inc.
6
+ //
7
+ // This file is part of the GNU ISO C++ Library. This library is free
8
+ // software; you can redistribute it and/or modify it under the
9
+ // terms of the GNU General Public License as published by the
10
+ // Free Software Foundation; either version 2, or (at your option)
11
+ // any later version.
12
+
13
+ // This library is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License along
19
+ // with this library; see the file COPYING. If not, write to the Free
20
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21
+ // USA.
22
+
23
+ // As a special exception, you may use this file as part of a free software
24
+ // library without restriction. Specifically, if other files instantiate
25
+ // templates or use macros or inline functions from this file, or you compile
26
+ // this file and link it with other files to produce an executable, this
27
+ // file does not by itself cause the resulting executable to be covered by
28
+ // the GNU General Public License. This exception does not however
29
+ // invalidate any other reasons why the executable file might be covered by
30
+ // the GNU General Public License.
31
+
32
+ /** @file streambuf_iterator.h
33
+ * This is an internal header file, included by other library headers.
34
+ * You should not attempt to use it directly.
35
+ */
36
+
37
+ #ifndef _STREAMBUF_ITERATOR_H
38
+ #define _STREAMBUF_ITERATOR_H 1
39
+
40
+ #pragma GCC system_header
41
+
42
+ #include <streambuf>
43
+ #include <debug/debug.h>
44
+
45
+ _GLIBCXX_BEGIN_NAMESPACE(std)
46
+
47
+ // 24.5.3 Template class istreambuf_iterator
48
+ /// Provides input iterator semantics for streambufs.
49
+ template<typename _CharT, typename _Traits>
50
+ class istreambuf_iterator
51
+ : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type,
52
+ _CharT*, _CharT&>
53
+ {
54
+ public:
55
+ // Types:
56
+ //@{
57
+ /// Public typedefs
58
+ typedef _CharT char_type;
59
+ typedef _Traits traits_type;
60
+ typedef typename _Traits::int_type int_type;
61
+ typedef basic_streambuf<_CharT, _Traits> streambuf_type;
62
+ typedef basic_istream<_CharT, _Traits> istream_type;
63
+ //@}
64
+
65
+ template<typename _CharT2>
66
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
67
+ ostreambuf_iterator<_CharT2> >::__type
68
+ copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
69
+ ostreambuf_iterator<_CharT2>);
70
+
71
+ template<bool _IsMove, typename _CharT2>
72
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
73
+ _CharT2*>::__type
74
+ __copy_move_a2(istreambuf_iterator<_CharT2>,
75
+ istreambuf_iterator<_CharT2>, _CharT2*);
76
+
77
+ template<typename _CharT2>
78
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
79
+ istreambuf_iterator<_CharT2> >::__type
80
+ find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
81
+ const _CharT2&);
82
+
83
+ private:
84
+ // 24.5.3 istreambuf_iterator
85
+ // p 1
86
+ // If the end of stream is reached (streambuf_type::sgetc()
87
+ // returns traits_type::eof()), the iterator becomes equal to
88
+ // the "end of stream" iterator value.
89
+ // NB: This implementation assumes the "end of stream" value
90
+ // is EOF, or -1.
91
+ mutable streambuf_type* _M_sbuf;
92
+ mutable int_type _M_c;
93
+
94
+ public:
95
+ /// Construct end of input stream iterator.
96
+ istreambuf_iterator() throw()
97
+ : _M_sbuf(0), _M_c(traits_type::eof()) { }
98
+
99
+ /// Construct start of input stream iterator.
100
+ istreambuf_iterator(istream_type& __s) throw()
101
+ : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { }
102
+
103
+ /// Construct start of streambuf iterator.
104
+ istreambuf_iterator(streambuf_type* __s) throw()
105
+ : _M_sbuf(__s), _M_c(traits_type::eof()) { }
106
+
107
+ /// Return the current character pointed to by iterator. This returns
108
+ /// streambuf.sgetc(). It cannot be assigned. NB: The result of
109
+ /// operator*() on an end of stream is undefined.
110
+ char_type
111
+ operator*() const
112
+ {
113
+ #ifdef _GLIBCXX_DEBUG_PEDANTIC
114
+ // Dereferencing a past-the-end istreambuf_iterator is a
115
+ // libstdc++ extension
116
+ __glibcxx_requires_cond(!_M_at_eof(),
117
+ _M_message(__gnu_debug::__msg_deref_istreambuf)
118
+ ._M_iterator(*this));
119
+ #endif
120
+ return traits_type::to_char_type(_M_get());
121
+ }
122
+
123
+ /// Advance the iterator. Calls streambuf.sbumpc().
124
+ istreambuf_iterator&
125
+ operator++()
126
+ {
127
+ __glibcxx_requires_cond(!_M_at_eof(),
128
+ _M_message(__gnu_debug::__msg_inc_istreambuf)
129
+ ._M_iterator(*this));
130
+ if (_M_sbuf)
131
+ {
132
+ _M_sbuf->sbumpc();
133
+ _M_c = traits_type::eof();
134
+ }
135
+ return *this;
136
+ }
137
+
138
+ /// Advance the iterator. Calls streambuf.sbumpc().
139
+ istreambuf_iterator
140
+ operator++(int)
141
+ {
142
+ __glibcxx_requires_cond(!_M_at_eof(),
143
+ _M_message(__gnu_debug::__msg_inc_istreambuf)
144
+ ._M_iterator(*this));
145
+
146
+ istreambuf_iterator __old = *this;
147
+ if (_M_sbuf)
148
+ {
149
+ __old._M_c = _M_sbuf->sbumpc();
150
+ _M_c = traits_type::eof();
151
+ }
152
+ return __old;
153
+ }
154
+
155
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
156
+ // 110 istreambuf_iterator::equal not const
157
+ // NB: there is also number 111 (NAD, Future) pending on this function.
158
+ /// Return true both iterators are end or both are not end.
159
+ bool
160
+ equal(const istreambuf_iterator& __b) const
161
+ { return _M_at_eof() == __b._M_at_eof(); }
162
+
163
+ private:
164
+ int_type
165
+ _M_get() const
166
+ {
167
+ const int_type __eof = traits_type::eof();
168
+ int_type __ret = __eof;
169
+ if (_M_sbuf)
170
+ {
171
+ if (!traits_type::eq_int_type(_M_c, __eof))
172
+ __ret = _M_c;
173
+ else if (!traits_type::eq_int_type((__ret = _M_sbuf->sgetc()),
174
+ __eof))
175
+ _M_c = __ret;
176
+ else
177
+ _M_sbuf = 0;
178
+ }
179
+ return __ret;
180
+ }
181
+
182
+ bool
183
+ _M_at_eof() const
184
+ {
185
+ const int_type __eof = traits_type::eof();
186
+ return traits_type::eq_int_type(_M_get(), __eof);
187
+ }
188
+ };
189
+
190
+ template<typename _CharT, typename _Traits>
191
+ inline bool
192
+ operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
193
+ const istreambuf_iterator<_CharT, _Traits>& __b)
194
+ { return __a.equal(__b); }
195
+
196
+ template<typename _CharT, typename _Traits>
197
+ inline bool
198
+ operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
199
+ const istreambuf_iterator<_CharT, _Traits>& __b)
200
+ { return !__a.equal(__b); }
201
+
202
+ /// Provides output iterator semantics for streambufs.
203
+ template<typename _CharT, typename _Traits>
204
+ class ostreambuf_iterator
205
+ : public iterator<output_iterator_tag, void, void, void, void>
206
+ {
207
+ public:
208
+ // Types:
209
+ //@{
210
+ /// Public typedefs
211
+ typedef _CharT char_type;
212
+ typedef _Traits traits_type;
213
+ typedef basic_streambuf<_CharT, _Traits> streambuf_type;
214
+ typedef basic_ostream<_CharT, _Traits> ostream_type;
215
+ //@}
216
+
217
+ template<typename _CharT2>
218
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
219
+ ostreambuf_iterator<_CharT2> >::__type
220
+ copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
221
+ ostreambuf_iterator<_CharT2>);
222
+
223
+ private:
224
+ streambuf_type* _M_sbuf;
225
+ bool _M_failed;
226
+
227
+ public:
228
+ /// Construct output iterator from ostream.
229
+ ostreambuf_iterator(ostream_type& __s) throw ()
230
+ : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
231
+
232
+ /// Construct output iterator from streambuf.
233
+ ostreambuf_iterator(streambuf_type* __s) throw ()
234
+ : _M_sbuf(__s), _M_failed(!_M_sbuf) { }
235
+
236
+ /// Write character to streambuf. Calls streambuf.sputc().
237
+ ostreambuf_iterator&
238
+ operator=(_CharT __c)
239
+ {
240
+ if (!_M_failed &&
241
+ _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof()))
242
+ _M_failed = true;
243
+ return *this;
244
+ }
245
+
246
+ /// Return *this.
247
+ ostreambuf_iterator&
248
+ operator*()
249
+ { return *this; }
250
+
251
+ /// Return *this.
252
+ ostreambuf_iterator&
253
+ operator++(int)
254
+ { return *this; }
255
+
256
+ /// Return *this.
257
+ ostreambuf_iterator&
258
+ operator++()
259
+ { return *this; }
260
+
261
+ /// Return true if previous operator=() failed.
262
+ bool
263
+ failed() const throw()
264
+ { return _M_failed; }
265
+
266
+ ostreambuf_iterator&
267
+ _M_put(const _CharT* __ws, streamsize __len)
268
+ {
269
+ if (__builtin_expect(!_M_failed, true)
270
+ && __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len,
271
+ false))
272
+ _M_failed = true;
273
+ return *this;
274
+ }
275
+ };
276
+
277
+ // Overloads for streambuf iterators.
278
+ template<typename _CharT>
279
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
280
+ ostreambuf_iterator<_CharT> >::__type
281
+ copy(istreambuf_iterator<_CharT> __first,
282
+ istreambuf_iterator<_CharT> __last,
283
+ ostreambuf_iterator<_CharT> __result)
284
+ {
285
+ if (__first._M_sbuf && !__last._M_sbuf && !__result._M_failed)
286
+ {
287
+ bool __ineof;
288
+ __copy_streambufs_eof(__first._M_sbuf, __result._M_sbuf, __ineof);
289
+ if (!__ineof)
290
+ __result._M_failed = true;
291
+ }
292
+ return __result;
293
+ }
294
+
295
+ template<bool _IsMove, typename _CharT>
296
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
297
+ ostreambuf_iterator<_CharT> >::__type
298
+ __copy_move_a2(_CharT* __first, _CharT* __last,
299
+ ostreambuf_iterator<_CharT> __result)
300
+ {
301
+ const streamsize __num = __last - __first;
302
+ if (__num > 0)
303
+ __result._M_put(__first, __num);
304
+ return __result;
305
+ }
306
+
307
+ template<bool _IsMove, typename _CharT>
308
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
309
+ ostreambuf_iterator<_CharT> >::__type
310
+ __copy_move_a2(const _CharT* __first, const _CharT* __last,
311
+ ostreambuf_iterator<_CharT> __result)
312
+ {
313
+ const streamsize __num = __last - __first;
314
+ if (__num > 0)
315
+ __result._M_put(__first, __num);
316
+ return __result;
317
+ }
318
+
319
+ template<bool _IsMove, typename _CharT>
320
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
321
+ _CharT*>::__type
322
+ __copy_move_a2(istreambuf_iterator<_CharT> __first,
323
+ istreambuf_iterator<_CharT> __last, _CharT* __result)
324
+ {
325
+ typedef istreambuf_iterator<_CharT> __is_iterator_type;
326
+ typedef typename __is_iterator_type::traits_type traits_type;
327
+ typedef typename __is_iterator_type::streambuf_type streambuf_type;
328
+ typedef typename traits_type::int_type int_type;
329
+
330
+ if (__first._M_sbuf && !__last._M_sbuf)
331
+ {
332
+ streambuf_type* __sb = __first._M_sbuf;
333
+ int_type __c = __sb->sgetc();
334
+ while (!traits_type::eq_int_type(__c, traits_type::eof()))
335
+ {
336
+ const streamsize __n = __sb->egptr() - __sb->gptr();
337
+ if (__n > 1)
338
+ {
339
+ traits_type::copy(__result, __sb->gptr(), __n);
340
+ __sb->gbump(__n);
341
+ __result += __n;
342
+ __c = __sb->underflow();
343
+ }
344
+ else
345
+ {
346
+ *__result++ = traits_type::to_char_type(__c);
347
+ __c = __sb->snextc();
348
+ }
349
+ }
350
+ }
351
+ return __result;
352
+ }
353
+
354
+ template<typename _CharT>
355
+ typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
356
+ istreambuf_iterator<_CharT> >::__type
357
+ find(istreambuf_iterator<_CharT> __first,
358
+ istreambuf_iterator<_CharT> __last, const _CharT& __val)
359
+ {
360
+ typedef istreambuf_iterator<_CharT> __is_iterator_type;
361
+ typedef typename __is_iterator_type::traits_type traits_type;
362
+ typedef typename __is_iterator_type::streambuf_type streambuf_type;
363
+ typedef typename traits_type::int_type int_type;
364
+
365
+ if (__first._M_sbuf && !__last._M_sbuf)
366
+ {
367
+ const int_type __ival = traits_type::to_int_type(__val);
368
+ streambuf_type* __sb = __first._M_sbuf;
369
+ int_type __c = __sb->sgetc();
370
+ while (!traits_type::eq_int_type(__c, traits_type::eof())
371
+ && !traits_type::eq_int_type(__c, __ival))
372
+ {
373
+ streamsize __n = __sb->egptr() - __sb->gptr();
374
+ if (__n > 1)
375
+ {
376
+ const _CharT* __p = traits_type::find(__sb->gptr(),
377
+ __n, __val);
378
+ if (__p)
379
+ __n = __p - __sb->gptr();
380
+ __sb->gbump(__n);
381
+ __c = __sb->sgetc();
382
+ }
383
+ else
384
+ __c = __sb->snextc();
385
+ }
386
+
387
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
388
+ __first._M_c = __c;
389
+ else
390
+ __first._M_sbuf = 0;
391
+ }
392
+ return __first;
393
+ }
394
+
395
+ _GLIBCXX_END_NAMESPACE
396
+
397
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/stringfwd.h ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // String support -*- 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file stringfwd.h
31
+ * This is an internal header file, included by other library headers.
32
+ * You should not attempt to use it directly.
33
+ */
34
+
35
+ //
36
+ // ISO C++ 14882: 21 Strings library
37
+ //
38
+
39
+ #ifndef _STRINGFWD_H
40
+ #define _STRINGFWD_H 1
41
+
42
+ #pragma GCC system_header
43
+
44
+ #include <bits/c++config.h>
45
+
46
+ _GLIBCXX_BEGIN_NAMESPACE(std)
47
+
48
+ template<typename _Alloc>
49
+ class allocator;
50
+
51
+ template<class _CharT>
52
+ struct char_traits;
53
+
54
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
55
+ typename _Alloc = allocator<_CharT> >
56
+ class basic_string;
57
+
58
+ template<> struct char_traits<char>;
59
+
60
+ typedef basic_string<char> string;
61
+
62
+ #ifdef _GLIBCXX_USE_WCHAR_T
63
+ template<> struct char_traits<wchar_t>;
64
+
65
+ typedef basic_string<wchar_t> wstring;
66
+ #endif
67
+
68
+ _GLIBCXX_END_NAMESPACE
69
+
70
+ #endif // _STRINGFWD_H
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_after.h ADDED
@@ -0,0 +1,554 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The template and inlines for the -*- C++ -*- internal _Meta class.
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file valarray_after.h
32
+ * This is an internal header file, included by other library headers.
33
+ * You should not attempt to use it directly.
34
+ */
35
+
36
+ // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
37
+
38
+ #ifndef _VALARRAY_AFTER_H
39
+ #define _VALARRAY_AFTER_H 1
40
+
41
+ #pragma GCC system_header
42
+
43
+ _GLIBCXX_BEGIN_NAMESPACE(std)
44
+
45
+ //
46
+ // gslice_array closure.
47
+ //
48
+ template<class _Dom>
49
+ class _GBase
50
+ {
51
+ public:
52
+ typedef typename _Dom::value_type value_type;
53
+
54
+ _GBase (const _Dom& __e, const valarray<size_t>& __i)
55
+ : _M_expr (__e), _M_index(__i) {}
56
+
57
+ value_type
58
+ operator[] (size_t __i) const
59
+ { return _M_expr[_M_index[__i]]; }
60
+
61
+ size_t
62
+ size () const
63
+ { return _M_index.size(); }
64
+
65
+ private:
66
+ const _Dom& _M_expr;
67
+ const valarray<size_t>& _M_index;
68
+ };
69
+
70
+ template<typename _Tp>
71
+ class _GBase<_Array<_Tp> >
72
+ {
73
+ public:
74
+ typedef _Tp value_type;
75
+
76
+ _GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
77
+ : _M_array (__a), _M_index(__i) {}
78
+
79
+ value_type
80
+ operator[] (size_t __i) const
81
+ { return _M_array._M_data[_M_index[__i]]; }
82
+
83
+ size_t
84
+ size () const
85
+ { return _M_index.size(); }
86
+
87
+ private:
88
+ const _Array<_Tp> _M_array;
89
+ const valarray<size_t>& _M_index;
90
+ };
91
+
92
+ template<class _Dom>
93
+ struct _GClos<_Expr, _Dom>
94
+ : _GBase<_Dom>
95
+ {
96
+ typedef _GBase<_Dom> _Base;
97
+ typedef typename _Base::value_type value_type;
98
+
99
+ _GClos (const _Dom& __e, const valarray<size_t>& __i)
100
+ : _Base (__e, __i) {}
101
+ };
102
+
103
+ template<typename _Tp>
104
+ struct _GClos<_ValArray, _Tp>
105
+ : _GBase<_Array<_Tp> >
106
+ {
107
+ typedef _GBase<_Array<_Tp> > _Base;
108
+ typedef typename _Base::value_type value_type;
109
+
110
+ _GClos (_Array<_Tp> __a, const valarray<size_t>& __i)
111
+ : _Base (__a, __i) {}
112
+ };
113
+
114
+ //
115
+ // indirect_array closure
116
+ //
117
+ template<class _Dom>
118
+ class _IBase
119
+ {
120
+ public:
121
+ typedef typename _Dom::value_type value_type;
122
+
123
+ _IBase (const _Dom& __e, const valarray<size_t>& __i)
124
+ : _M_expr (__e), _M_index (__i) {}
125
+
126
+ value_type
127
+ operator[] (size_t __i) const
128
+ { return _M_expr[_M_index[__i]]; }
129
+
130
+ size_t
131
+ size() const
132
+ { return _M_index.size(); }
133
+
134
+ private:
135
+ const _Dom& _M_expr;
136
+ const valarray<size_t>& _M_index;
137
+ };
138
+
139
+ template<class _Dom>
140
+ struct _IClos<_Expr, _Dom>
141
+ : _IBase<_Dom>
142
+ {
143
+ typedef _IBase<_Dom> _Base;
144
+ typedef typename _Base::value_type value_type;
145
+
146
+ _IClos (const _Dom& __e, const valarray<size_t>& __i)
147
+ : _Base (__e, __i) {}
148
+ };
149
+
150
+ template<typename _Tp>
151
+ struct _IClos<_ValArray, _Tp>
152
+ : _IBase<valarray<_Tp> >
153
+ {
154
+ typedef _IBase<valarray<_Tp> > _Base;
155
+ typedef _Tp value_type;
156
+
157
+ _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)
158
+ : _Base (__a, __i) {}
159
+ };
160
+
161
+ //
162
+ // class _Expr
163
+ //
164
+ template<class _Clos, typename _Tp>
165
+ class _Expr
166
+ {
167
+ public:
168
+ typedef _Tp value_type;
169
+
170
+ _Expr(const _Clos&);
171
+
172
+ const _Clos& operator()() const;
173
+
174
+ value_type operator[](size_t) const;
175
+ valarray<value_type> operator[](slice) const;
176
+ valarray<value_type> operator[](const gslice&) const;
177
+ valarray<value_type> operator[](const valarray<bool>&) const;
178
+ valarray<value_type> operator[](const valarray<size_t>&) const;
179
+
180
+ _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type>
181
+ operator+() const;
182
+
183
+ _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type>
184
+ operator-() const;
185
+
186
+ _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type>
187
+ operator~() const;
188
+
189
+ _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool>
190
+ operator!() const;
191
+
192
+ size_t size() const;
193
+ value_type sum() const;
194
+
195
+ valarray<value_type> shift(int) const;
196
+ valarray<value_type> cshift(int) const;
197
+
198
+ value_type min() const;
199
+ value_type max() const;
200
+
201
+ valarray<value_type> apply(value_type (*)(const value_type&)) const;
202
+ valarray<value_type> apply(value_type (*)(value_type)) const;
203
+
204
+ private:
205
+ const _Clos _M_closure;
206
+ };
207
+
208
+ template<class _Clos, typename _Tp>
209
+ inline
210
+ _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}
211
+
212
+ template<class _Clos, typename _Tp>
213
+ inline const _Clos&
214
+ _Expr<_Clos, _Tp>::operator()() const
215
+ { return _M_closure; }
216
+
217
+ template<class _Clos, typename _Tp>
218
+ inline _Tp
219
+ _Expr<_Clos, _Tp>::operator[](size_t __i) const
220
+ { return _M_closure[__i]; }
221
+
222
+ template<class _Clos, typename _Tp>
223
+ inline valarray<_Tp>
224
+ _Expr<_Clos, _Tp>::operator[](slice __s) const
225
+ {
226
+ valarray<_Tp> __v = valarray<_Tp>(*this)[__s];
227
+ return __v;
228
+ }
229
+
230
+ template<class _Clos, typename _Tp>
231
+ inline valarray<_Tp>
232
+ _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const
233
+ {
234
+ valarray<_Tp> __v = valarray<_Tp>(*this)[__gs];
235
+ return __v;
236
+ }
237
+
238
+ template<class _Clos, typename _Tp>
239
+ inline valarray<_Tp>
240
+ _Expr<_Clos, _Tp>::operator[](const valarray<bool>& __m) const
241
+ {
242
+ valarray<_Tp> __v = valarray<_Tp>(*this)[__m];
243
+ return __v;
244
+ }
245
+
246
+ template<class _Clos, typename _Tp>
247
+ inline valarray<_Tp>
248
+ _Expr<_Clos, _Tp>::operator[](const valarray<size_t>& __i) const
249
+ {
250
+ valarray<_Tp> __v = valarray<_Tp>(*this)[__i];
251
+ return __v;
252
+ }
253
+
254
+ template<class _Clos, typename _Tp>
255
+ inline size_t
256
+ _Expr<_Clos, _Tp>::size() const
257
+ { return _M_closure.size(); }
258
+
259
+ template<class _Clos, typename _Tp>
260
+ inline valarray<_Tp>
261
+ _Expr<_Clos, _Tp>::shift(int __n) const
262
+ {
263
+ valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n);
264
+ return __v;
265
+ }
266
+
267
+ template<class _Clos, typename _Tp>
268
+ inline valarray<_Tp>
269
+ _Expr<_Clos, _Tp>::cshift(int __n) const
270
+ {
271
+ valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n);
272
+ return __v;
273
+ }
274
+
275
+ template<class _Clos, typename _Tp>
276
+ inline valarray<_Tp>
277
+ _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
278
+ {
279
+ valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);
280
+ return __v;
281
+ }
282
+
283
+ template<class _Clos, typename _Tp>
284
+ inline valarray<_Tp>
285
+ _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
286
+ {
287
+ valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);
288
+ return __v;
289
+ }
290
+
291
+ // XXX: replace this with a more robust summation algorithm.
292
+ template<class _Clos, typename _Tp>
293
+ inline _Tp
294
+ _Expr<_Clos, _Tp>::sum() const
295
+ {
296
+ size_t __n = _M_closure.size();
297
+ if (__n == 0)
298
+ return _Tp();
299
+ else
300
+ {
301
+ _Tp __s = _M_closure[--__n];
302
+ while (__n != 0)
303
+ __s += _M_closure[--__n];
304
+ return __s;
305
+ }
306
+ }
307
+
308
+ template<class _Clos, typename _Tp>
309
+ inline _Tp
310
+ _Expr<_Clos, _Tp>::min() const
311
+ { return __valarray_min(_M_closure); }
312
+
313
+ template<class _Clos, typename _Tp>
314
+ inline _Tp
315
+ _Expr<_Clos, _Tp>::max() const
316
+ { return __valarray_max(_M_closure); }
317
+
318
+ template<class _Dom, typename _Tp>
319
+ inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool>
320
+ _Expr<_Dom, _Tp>::operator!() const
321
+ {
322
+ typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure;
323
+ return _Expr<_Closure, _Tp>(_Closure(this->_M_closure));
324
+ }
325
+
326
+ #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
327
+ template<class _Dom, typename _Tp> \
328
+ inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \
329
+ _Expr<_Dom, _Tp>::operator _Op() const \
330
+ { \
331
+ typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \
332
+ return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \
333
+ }
334
+
335
+ _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
336
+ _DEFINE_EXPR_UNARY_OPERATOR(-, __negate)
337
+ _DEFINE_EXPR_UNARY_OPERATOR(~, __bitwise_not)
338
+
339
+ #undef _DEFINE_EXPR_UNARY_OPERATOR
340
+
341
+ #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
342
+ template<class _Dom1, class _Dom2> \
343
+ inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \
344
+ typename __fun<_Name, typename _Dom1::value_type>::result_type> \
345
+ operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \
346
+ const _Expr<_Dom2, typename _Dom2::value_type>& __w) \
347
+ { \
348
+ typedef typename _Dom1::value_type _Arg; \
349
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
350
+ typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \
351
+ return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \
352
+ } \
353
+ \
354
+ template<class _Dom> \
355
+ inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \
356
+ typename _Dom::value_type>, \
357
+ typename __fun<_Name, typename _Dom::value_type>::result_type> \
358
+ operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \
359
+ const typename _Dom::value_type& __t) \
360
+ { \
361
+ typedef typename _Dom::value_type _Arg; \
362
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
363
+ typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \
364
+ return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \
365
+ } \
366
+ \
367
+ template<class _Dom> \
368
+ inline _Expr<_BinClos<_Name, _Constant, _Expr, \
369
+ typename _Dom::value_type, _Dom>, \
370
+ typename __fun<_Name, typename _Dom::value_type>::result_type> \
371
+ operator _Op(const typename _Dom::value_type& __t, \
372
+ const _Expr<_Dom, typename _Dom::value_type>& __v) \
373
+ { \
374
+ typedef typename _Dom::value_type _Arg; \
375
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
376
+ typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \
377
+ return _Expr<_Closure, _Value>(_Closure(__t, __v())); \
378
+ } \
379
+ \
380
+ template<class _Dom> \
381
+ inline _Expr<_BinClos<_Name, _Expr, _ValArray, \
382
+ _Dom, typename _Dom::value_type>, \
383
+ typename __fun<_Name, typename _Dom::value_type>::result_type> \
384
+ operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \
385
+ const valarray<typename _Dom::value_type>& __v) \
386
+ { \
387
+ typedef typename _Dom::value_type _Arg; \
388
+ typedef typename __fun<_Name, _Arg>::result_type _Value; \
389
+ typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \
390
+ return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \
391
+ } \
392
+ \
393
+ template<class _Dom> \
394
+ inline _Expr<_BinClos<_Name, _ValArray, _Expr, \
395
+ typename _Dom::value_type, _Dom>, \
396
+ typename __fun<_Name, typename _Dom::value_type>::result_type> \
397
+ operator _Op(const valarray<typename _Dom::value_type>& __v, \
398
+ const _Expr<_Dom, typename _Dom::value_type>& __e) \
399
+ { \
400
+ typedef typename _Dom::value_type _Tp; \
401
+ typedef typename __fun<_Name, _Tp>::result_type _Value; \
402
+ typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \
403
+ return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \
404
+ }
405
+
406
+ _DEFINE_EXPR_BINARY_OPERATOR(+, __plus)
407
+ _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
408
+ _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
409
+ _DEFINE_EXPR_BINARY_OPERATOR(/, __divides)
410
+ _DEFINE_EXPR_BINARY_OPERATOR(%, __modulus)
411
+ _DEFINE_EXPR_BINARY_OPERATOR(^, __bitwise_xor)
412
+ _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
413
+ _DEFINE_EXPR_BINARY_OPERATOR(|, __bitwise_or)
414
+ _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)
415
+ _DEFINE_EXPR_BINARY_OPERATOR(>>, __shift_right)
416
+ _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
417
+ _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
418
+ _DEFINE_EXPR_BINARY_OPERATOR(==, __equal_to)
419
+ _DEFINE_EXPR_BINARY_OPERATOR(!=, __not_equal_to)
420
+ _DEFINE_EXPR_BINARY_OPERATOR(<, __less)
421
+ _DEFINE_EXPR_BINARY_OPERATOR(>, __greater)
422
+ _DEFINE_EXPR_BINARY_OPERATOR(<=, __less_equal)
423
+ _DEFINE_EXPR_BINARY_OPERATOR(>=, __greater_equal)
424
+
425
+ #undef _DEFINE_EXPR_BINARY_OPERATOR
426
+
427
+ #define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
428
+ template<class _Dom> \
429
+ inline _Expr<_UnClos<__##_Name, _Expr, _Dom>, \
430
+ typename _Dom::value_type> \
431
+ _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \
432
+ { \
433
+ typedef typename _Dom::value_type _Tp; \
434
+ typedef _UnClos<__##_Name, _Expr, _Dom> _Closure; \
435
+ return _Expr<_Closure, _Tp>(_Closure(__e())); \
436
+ } \
437
+ \
438
+ template<typename _Tp> \
439
+ inline _Expr<_UnClos<__##_Name, _ValArray, _Tp>, _Tp> \
440
+ _Name(const valarray<_Tp>& __v) \
441
+ { \
442
+ typedef _UnClos<__##_Name, _ValArray, _Tp> _Closure; \
443
+ return _Expr<_Closure, _Tp>(_Closure(__v)); \
444
+ }
445
+
446
+ _DEFINE_EXPR_UNARY_FUNCTION(abs)
447
+ _DEFINE_EXPR_UNARY_FUNCTION(cos)
448
+ _DEFINE_EXPR_UNARY_FUNCTION(acos)
449
+ _DEFINE_EXPR_UNARY_FUNCTION(cosh)
450
+ _DEFINE_EXPR_UNARY_FUNCTION(sin)
451
+ _DEFINE_EXPR_UNARY_FUNCTION(asin)
452
+ _DEFINE_EXPR_UNARY_FUNCTION(sinh)
453
+ _DEFINE_EXPR_UNARY_FUNCTION(tan)
454
+ _DEFINE_EXPR_UNARY_FUNCTION(tanh)
455
+ _DEFINE_EXPR_UNARY_FUNCTION(atan)
456
+ _DEFINE_EXPR_UNARY_FUNCTION(exp)
457
+ _DEFINE_EXPR_UNARY_FUNCTION(log)
458
+ _DEFINE_EXPR_UNARY_FUNCTION(log10)
459
+ _DEFINE_EXPR_UNARY_FUNCTION(sqrt)
460
+
461
+ #undef _DEFINE_EXPR_UNARY_FUNCTION
462
+
463
+ #define _DEFINE_EXPR_BINARY_FUNCTION(_Fun) \
464
+ template<class _Dom1, class _Dom2> \
465
+ inline _Expr<_BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2>, \
466
+ typename _Dom1::value_type> \
467
+ _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \
468
+ const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \
469
+ { \
470
+ typedef typename _Dom1::value_type _Tp; \
471
+ typedef _BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \
472
+ return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \
473
+ } \
474
+ \
475
+ template<class _Dom> \
476
+ inline _Expr<_BinClos<__##_Fun, _Expr, _ValArray, _Dom, \
477
+ typename _Dom::value_type>, \
478
+ typename _Dom::value_type> \
479
+ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
480
+ const valarray<typename _Dom::value_type>& __v) \
481
+ { \
482
+ typedef typename _Dom::value_type _Tp; \
483
+ typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure; \
484
+ return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \
485
+ } \
486
+ \
487
+ template<class _Dom> \
488
+ inline _Expr<_BinClos<__##_Fun, _ValArray, _Expr, \
489
+ typename _Dom::value_type, _Dom>, \
490
+ typename _Dom::value_type> \
491
+ _Fun(const valarray<typename _Dom::valarray>& __v, \
492
+ const _Expr<_Dom, typename _Dom::value_type>& __e) \
493
+ { \
494
+ typedef typename _Dom::value_type _Tp; \
495
+ typedef _BinClos<__##_Fun, _ValArray, _Expr, _Tp, _Dom> _Closure; \
496
+ return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \
497
+ } \
498
+ \
499
+ template<class _Dom> \
500
+ inline _Expr<_BinClos<__##_Fun, _Expr, _Constant, _Dom, \
501
+ typename _Dom::value_type>, \
502
+ typename _Dom::value_type> \
503
+ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
504
+ const typename _Dom::value_type& __t) \
505
+ { \
506
+ typedef typename _Dom::value_type _Tp; \
507
+ typedef _BinClos<__##_Fun, _Expr, _Constant, _Dom, _Tp> _Closure;\
508
+ return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \
509
+ } \
510
+ \
511
+ template<class _Dom> \
512
+ inline _Expr<_BinClos<__##_Fun, _Constant, _Expr, \
513
+ typename _Dom::value_type, _Dom>, \
514
+ typename _Dom::value_type> \
515
+ _Fun(const typename _Dom::value_type& __t, \
516
+ const _Expr<_Dom, typename _Dom::value_type>& __e) \
517
+ { \
518
+ typedef typename _Dom::value_type _Tp; \
519
+ typedef _BinClos<__##_Fun, _Constant, _Expr, _Tp, _Dom> _Closure; \
520
+ return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \
521
+ } \
522
+ \
523
+ template<typename _Tp> \
524
+ inline _Expr<_BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \
525
+ _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
526
+ { \
527
+ typedef _BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
528
+ return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \
529
+ } \
530
+ \
531
+ template<typename _Tp> \
532
+ inline _Expr<_BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \
533
+ _Fun(const valarray<_Tp>& __v, const _Tp& __t) \
534
+ { \
535
+ typedef _BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp> _Closure; \
536
+ return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \
537
+ } \
538
+ \
539
+ template<typename _Tp> \
540
+ inline _Expr<_BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \
541
+ _Fun(const _Tp& __t, const valarray<_Tp>& __v) \
542
+ { \
543
+ typedef _BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp> _Closure; \
544
+ return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
545
+ }
546
+
547
+ _DEFINE_EXPR_BINARY_FUNCTION(atan2)
548
+ _DEFINE_EXPR_BINARY_FUNCTION(pow)
549
+
550
+ #undef _DEFINE_EXPR_BINARY_FUNCTION
551
+
552
+ _GLIBCXX_END_NAMESPACE
553
+
554
+ #endif /* _CPP_VALARRAY_AFTER_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_array.h ADDED
@@ -0,0 +1,704 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The template and inlines for the -*- C++ -*- internal _Array helper class.
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4
+ // 2006, 2007
5
+ // Free Software Foundation, Inc.
6
+ //
7
+ // This file is part of the GNU ISO C++ Library. This library is free
8
+ // software; you can redistribute it and/or modify it under the
9
+ // terms of the GNU General Public License as published by the
10
+ // Free Software Foundation; either version 2, or (at your option)
11
+ // any later version.
12
+
13
+ // This library is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License along
19
+ // with this library; see the file COPYING. If not, write to the Free
20
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21
+ // USA.
22
+
23
+ // As a special exception, you may use this file as part of a free software
24
+ // library without restriction. Specifically, if other files instantiate
25
+ // templates or use macros or inline functions from this file, or you compile
26
+ // this file and link it with other files to produce an executable, this
27
+ // file does not by itself cause the resulting executable to be covered by
28
+ // the GNU General Public License. This exception does not however
29
+ // invalidate any other reasons why the executable file might be covered by
30
+ // the GNU General Public License.
31
+
32
+ /** @file valarray_array.h
33
+ * This is an internal header file, included by other library headers.
34
+ * You should not attempt to use it directly.
35
+ */
36
+
37
+ // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
38
+
39
+ #ifndef _VALARRAY_ARRAY_H
40
+ #define _VALARRAY_ARRAY_H 1
41
+
42
+ #pragma GCC system_header
43
+
44
+ #include <bits/c++config.h>
45
+ #include <bits/cpp_type_traits.h>
46
+ #include <cstdlib>
47
+ #include <new>
48
+
49
+ _GLIBCXX_BEGIN_NAMESPACE(std)
50
+
51
+ //
52
+ // Helper functions on raw pointers
53
+ //
54
+
55
+ // We get memory by the old fashion way
56
+ inline void*
57
+ __valarray_get_memory(size_t __n)
58
+ { return operator new(__n); }
59
+
60
+ template<typename _Tp>
61
+ inline _Tp*__restrict__
62
+ __valarray_get_storage(size_t __n)
63
+ {
64
+ return static_cast<_Tp*__restrict__>
65
+ (std::__valarray_get_memory(__n * sizeof(_Tp)));
66
+ }
67
+
68
+ // Return memory to the system
69
+ inline void
70
+ __valarray_release_memory(void* __p)
71
+ { operator delete(__p); }
72
+
73
+ // Turn a raw-memory into an array of _Tp filled with _Tp()
74
+ // This is required in 'valarray<T> v(n);'
75
+ template<typename _Tp, bool>
76
+ struct _Array_default_ctor
77
+ {
78
+ // Please note that this isn't exception safe. But
79
+ // valarrays aren't required to be exception safe.
80
+ inline static void
81
+ _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
82
+ {
83
+ while (__b != __e)
84
+ new(__b++) _Tp();
85
+ }
86
+ };
87
+
88
+ template<typename _Tp>
89
+ struct _Array_default_ctor<_Tp, true>
90
+ {
91
+ // For fundamental types, it suffices to say 'memset()'
92
+ inline static void
93
+ _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
94
+ { __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); }
95
+ };
96
+
97
+ template<typename _Tp>
98
+ inline void
99
+ __valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
100
+ {
101
+ _Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e);
102
+ }
103
+
104
+ // Turn a raw-memory into an array of _Tp filled with __t
105
+ // This is the required in valarray<T> v(n, t). Also
106
+ // used in valarray<>::resize().
107
+ template<typename _Tp, bool>
108
+ struct _Array_init_ctor
109
+ {
110
+ // Please note that this isn't exception safe. But
111
+ // valarrays aren't required to be exception safe.
112
+ inline static void
113
+ _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t)
114
+ {
115
+ while (__b != __e)
116
+ new(__b++) _Tp(__t);
117
+ }
118
+ };
119
+
120
+ template<typename _Tp>
121
+ struct _Array_init_ctor<_Tp, true>
122
+ {
123
+ inline static void
124
+ _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t)
125
+ {
126
+ while (__b != __e)
127
+ *__b++ = __t;
128
+ }
129
+ };
130
+
131
+ template<typename _Tp>
132
+ inline void
133
+ __valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e,
134
+ const _Tp __t)
135
+ {
136
+ _Array_init_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e, __t);
137
+ }
138
+
139
+ //
140
+ // copy-construct raw array [__o, *) from plain array [__b, __e)
141
+ // We can't just say 'memcpy()'
142
+ //
143
+ template<typename _Tp, bool>
144
+ struct _Array_copy_ctor
145
+ {
146
+ // Please note that this isn't exception safe. But
147
+ // valarrays aren't required to be exception safe.
148
+ inline static void
149
+ _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e,
150
+ _Tp* __restrict__ __o)
151
+ {
152
+ while (__b != __e)
153
+ new(__o++) _Tp(*__b++);
154
+ }
155
+ };
156
+
157
+ template<typename _Tp>
158
+ struct _Array_copy_ctor<_Tp, true>
159
+ {
160
+ inline static void
161
+ _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e,
162
+ _Tp* __restrict__ __o)
163
+ { __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp)); }
164
+ };
165
+
166
+ template<typename _Tp>
167
+ inline void
168
+ __valarray_copy_construct(const _Tp* __restrict__ __b,
169
+ const _Tp* __restrict__ __e,
170
+ _Tp* __restrict__ __o)
171
+ {
172
+ _Array_copy_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e, __o);
173
+ }
174
+
175
+ // copy-construct raw array [__o, *) from strided array __a[<__n : __s>]
176
+ template<typename _Tp>
177
+ inline void
178
+ __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n,
179
+ size_t __s, _Tp* __restrict__ __o)
180
+ {
181
+ if (__is_pod(_Tp))
182
+ while (__n--)
183
+ {
184
+ *__o++ = *__a;
185
+ __a += __s;
186
+ }
187
+ else
188
+ while (__n--)
189
+ {
190
+ new(__o++) _Tp(*__a);
191
+ __a += __s;
192
+ }
193
+ }
194
+
195
+ // copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]]
196
+ template<typename _Tp>
197
+ inline void
198
+ __valarray_copy_construct (const _Tp* __restrict__ __a,
199
+ const size_t* __restrict__ __i,
200
+ _Tp* __restrict__ __o, size_t __n)
201
+ {
202
+ if (__is_pod(_Tp))
203
+ while (__n--)
204
+ *__o++ = __a[*__i++];
205
+ else
206
+ while (__n--)
207
+ new (__o++) _Tp(__a[*__i++]);
208
+ }
209
+
210
+ // Do the necessary cleanup when we're done with arrays.
211
+ template<typename _Tp>
212
+ inline void
213
+ __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
214
+ {
215
+ if (!__is_pod(_Tp))
216
+ while (__b != __e)
217
+ {
218
+ __b->~_Tp();
219
+ ++__b;
220
+ }
221
+ }
222
+
223
+ // Fill a plain array __a[<__n>] with __t
224
+ template<typename _Tp>
225
+ inline void
226
+ __valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t)
227
+ {
228
+ while (__n--)
229
+ *__a++ = __t;
230
+ }
231
+
232
+ // fill strided array __a[<__n-1 : __s>] with __t
233
+ template<typename _Tp>
234
+ inline void
235
+ __valarray_fill(_Tp* __restrict__ __a, size_t __n,
236
+ size_t __s, const _Tp& __t)
237
+ {
238
+ for (size_t __i = 0; __i < __n; ++__i, __a += __s)
239
+ *__a = __t;
240
+ }
241
+
242
+ // fill indirect array __a[__i[<__n>]] with __i
243
+ template<typename _Tp>
244
+ inline void
245
+ __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i,
246
+ size_t __n, const _Tp& __t)
247
+ {
248
+ for (size_t __j = 0; __j < __n; ++__j, ++__i)
249
+ __a[*__i] = __t;
250
+ }
251
+
252
+ // copy plain array __a[<__n>] in __b[<__n>]
253
+ // For non-fundamental types, it is wrong to say 'memcpy()'
254
+ template<typename _Tp, bool>
255
+ struct _Array_copier
256
+ {
257
+ inline static void
258
+ _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b)
259
+ {
260
+ while(__n--)
261
+ *__b++ = *__a++;
262
+ }
263
+ };
264
+
265
+ template<typename _Tp>
266
+ struct _Array_copier<_Tp, true>
267
+ {
268
+ inline static void
269
+ _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b)
270
+ { __builtin_memcpy(__b, __a, __n * sizeof (_Tp)); }
271
+ };
272
+
273
+ // Copy a plain array __a[<__n>] into a play array __b[<>]
274
+ template<typename _Tp>
275
+ inline void
276
+ __valarray_copy(const _Tp* __restrict__ __a, size_t __n,
277
+ _Tp* __restrict__ __b)
278
+ {
279
+ _Array_copier<_Tp, __is_pod(_Tp)>::_S_do_it(__a, __n, __b);
280
+ }
281
+
282
+ // Copy strided array __a[<__n : __s>] in plain __b[<__n>]
283
+ template<typename _Tp>
284
+ inline void
285
+ __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s,
286
+ _Tp* __restrict__ __b)
287
+ {
288
+ for (size_t __i = 0; __i < __n; ++__i, ++__b, __a += __s)
289
+ *__b = *__a;
290
+ }
291
+
292
+ // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>]
293
+ template<typename _Tp>
294
+ inline void
295
+ __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b,
296
+ size_t __n, size_t __s)
297
+ {
298
+ for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s)
299
+ *__b = *__a;
300
+ }
301
+
302
+ // Copy strided array __src[<__n : __s1>] into another
303
+ // strided array __dst[< : __s2>]. Their sizes must match.
304
+ template<typename _Tp>
305
+ inline void
306
+ __valarray_copy(const _Tp* __restrict__ __src, size_t __n, size_t __s1,
307
+ _Tp* __restrict__ __dst, size_t __s2)
308
+ {
309
+ for (size_t __i = 0; __i < __n; ++__i)
310
+ __dst[__i * __s2] = __src[__i * __s1];
311
+ }
312
+
313
+ // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>]
314
+ template<typename _Tp>
315
+ inline void
316
+ __valarray_copy(const _Tp* __restrict__ __a,
317
+ const size_t* __restrict__ __i,
318
+ _Tp* __restrict__ __b, size_t __n)
319
+ {
320
+ for (size_t __j = 0; __j < __n; ++__j, ++__b, ++__i)
321
+ *__b = __a[*__i];
322
+ }
323
+
324
+ // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]]
325
+ template<typename _Tp>
326
+ inline void
327
+ __valarray_copy(const _Tp* __restrict__ __a, size_t __n,
328
+ _Tp* __restrict__ __b, const size_t* __restrict__ __i)
329
+ {
330
+ for (size_t __j = 0; __j < __n; ++__j, ++__a, ++__i)
331
+ __b[*__i] = *__a;
332
+ }
333
+
334
+ // Copy the __n first elements of an indexed array __src[<__i>] into
335
+ // another indexed array __dst[<__j>].
336
+ template<typename _Tp>
337
+ inline void
338
+ __valarray_copy(const _Tp* __restrict__ __src, size_t __n,
339
+ const size_t* __restrict__ __i,
340
+ _Tp* __restrict__ __dst, const size_t* __restrict__ __j)
341
+ {
342
+ for (size_t __k = 0; __k < __n; ++__k)
343
+ __dst[*__j++] = __src[*__i++];
344
+ }
345
+
346
+ //
347
+ // Compute the sum of elements in range [__f, __l)
348
+ // This is a naive algorithm. It suffers from cancelling.
349
+ // In the future try to specialize
350
+ // for _Tp = float, double, long double using a more accurate
351
+ // algorithm.
352
+ //
353
+ template<typename _Tp>
354
+ inline _Tp
355
+ __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l)
356
+ {
357
+ _Tp __r = _Tp();
358
+ while (__f != __l)
359
+ __r += *__f++;
360
+ return __r;
361
+ }
362
+
363
+ // Compute the product of all elements in range [__f, __l)
364
+ template<typename _Tp>
365
+ inline _Tp
366
+ __valarray_product(const _Tp* __restrict__ __f,
367
+ const _Tp* __restrict__ __l)
368
+ {
369
+ _Tp __r = _Tp(1);
370
+ while (__f != __l)
371
+ __r = __r * *__f++;
372
+ return __r;
373
+ }
374
+
375
+ // Compute the min/max of an array-expression
376
+ template<typename _Ta>
377
+ inline typename _Ta::value_type
378
+ __valarray_min(const _Ta& __a)
379
+ {
380
+ size_t __s = __a.size();
381
+ typedef typename _Ta::value_type _Value_type;
382
+ _Value_type __r = __s == 0 ? _Value_type() : __a[0];
383
+ for (size_t __i = 1; __i < __s; ++__i)
384
+ {
385
+ _Value_type __t = __a[__i];
386
+ if (__t < __r)
387
+ __r = __t;
388
+ }
389
+ return __r;
390
+ }
391
+
392
+ template<typename _Ta>
393
+ inline typename _Ta::value_type
394
+ __valarray_max(const _Ta& __a)
395
+ {
396
+ size_t __s = __a.size();
397
+ typedef typename _Ta::value_type _Value_type;
398
+ _Value_type __r = __s == 0 ? _Value_type() : __a[0];
399
+ for (size_t __i = 1; __i < __s; ++__i)
400
+ {
401
+ _Value_type __t = __a[__i];
402
+ if (__t > __r)
403
+ __r = __t;
404
+ }
405
+ return __r;
406
+ }
407
+
408
+ //
409
+ // Helper class _Array, first layer of valarray abstraction.
410
+ // All operations on valarray should be forwarded to this class
411
+ // whenever possible. -- gdr
412
+ //
413
+
414
+ template<typename _Tp>
415
+ struct _Array
416
+ {
417
+ explicit _Array(size_t);
418
+ explicit _Array(_Tp* const __restrict__);
419
+ explicit _Array(const valarray<_Tp>&);
420
+ _Array(const _Tp* __restrict__, size_t);
421
+
422
+ _Tp* begin() const;
423
+
424
+ _Tp* const __restrict__ _M_data;
425
+ };
426
+
427
+
428
+ // Copy-construct plain array __b[<__n>] from indexed array __a[__i[<__n>]]
429
+ template<typename _Tp>
430
+ inline void
431
+ __valarray_copy_construct(_Array<_Tp> __a, _Array<size_t> __i,
432
+ _Array<_Tp> __b, size_t __n)
433
+ { std::__valarray_copy_construct(__a._M_data, __i._M_data,
434
+ __b._M_data, __n); }
435
+
436
+ // Copy-construct plain array __b[<__n>] from strided array __a[<__n : __s>]
437
+ template<typename _Tp>
438
+ inline void
439
+ __valarray_copy_construct(_Array<_Tp> __a, size_t __n, size_t __s,
440
+ _Array<_Tp> __b)
441
+ { std::__valarray_copy_construct(__a._M_data, __n, __s, __b._M_data); }
442
+
443
+ template<typename _Tp>
444
+ inline void
445
+ __valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t)
446
+ { std::__valarray_fill(__a._M_data, __n, __t); }
447
+
448
+ template<typename _Tp>
449
+ inline void
450
+ __valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t)
451
+ { std::__valarray_fill(__a._M_data, __n, __s, __t); }
452
+
453
+ template<typename _Tp>
454
+ inline void
455
+ __valarray_fill(_Array<_Tp> __a, _Array<size_t> __i,
456
+ size_t __n, const _Tp& __t)
457
+ { std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); }
458
+
459
+ // Copy a plain array __a[<__n>] into a play array __b[<>]
460
+ template<typename _Tp>
461
+ inline void
462
+ __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b)
463
+ { std::__valarray_copy(__a._M_data, __n, __b._M_data); }
464
+
465
+ // Copy strided array __a[<__n : __s>] in plain __b[<__n>]
466
+ template<typename _Tp>
467
+ inline void
468
+ __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b)
469
+ { std::__valarray_copy(__a._M_data, __n, __s, __b._M_data); }
470
+
471
+ // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>]
472
+ template<typename _Tp>
473
+ inline void
474
+ __valarray_copy(_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s)
475
+ { __valarray_copy(__a._M_data, __b._M_data, __n, __s); }
476
+
477
+ // Copy strided array __src[<__n : __s1>] into another
478
+ // strided array __dst[< : __s2>]. Their sizes must match.
479
+ template<typename _Tp>
480
+ inline void
481
+ __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s1,
482
+ _Array<_Tp> __b, size_t __s2)
483
+ { std::__valarray_copy(__a._M_data, __n, __s1, __b._M_data, __s2); }
484
+
485
+ // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>]
486
+ template<typename _Tp>
487
+ inline void
488
+ __valarray_copy(_Array<_Tp> __a, _Array<size_t> __i,
489
+ _Array<_Tp> __b, size_t __n)
490
+ { std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); }
491
+
492
+ // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]]
493
+ template<typename _Tp>
494
+ inline void
495
+ __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
496
+ _Array<size_t> __i)
497
+ { std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); }
498
+
499
+ // Copy the __n first elements of an indexed array __src[<__i>] into
500
+ // another indexed array __dst[<__j>].
501
+ template<typename _Tp>
502
+ inline void
503
+ __valarray_copy(_Array<_Tp> __src, size_t __n, _Array<size_t> __i,
504
+ _Array<_Tp> __dst, _Array<size_t> __j)
505
+ {
506
+ std::__valarray_copy(__src._M_data, __n, __i._M_data,
507
+ __dst._M_data, __j._M_data);
508
+ }
509
+
510
+ template<typename _Tp>
511
+ inline
512
+ _Array<_Tp>::_Array(size_t __n)
513
+ : _M_data(__valarray_get_storage<_Tp>(__n))
514
+ { std::__valarray_default_construct(_M_data, _M_data + __n); }
515
+
516
+ template<typename _Tp>
517
+ inline
518
+ _Array<_Tp>::_Array(_Tp* const __restrict__ __p)
519
+ : _M_data (__p) {}
520
+
521
+ template<typename _Tp>
522
+ inline
523
+ _Array<_Tp>::_Array(const valarray<_Tp>& __v)
524
+ : _M_data (__v._M_data) {}
525
+
526
+ template<typename _Tp>
527
+ inline
528
+ _Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s)
529
+ : _M_data(__valarray_get_storage<_Tp>(__s))
530
+ { std::__valarray_copy_construct(__b, __s, _M_data); }
531
+
532
+ template<typename _Tp>
533
+ inline _Tp*
534
+ _Array<_Tp>::begin () const
535
+ { return _M_data; }
536
+
537
+ #define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \
538
+ template<typename _Tp> \
539
+ inline void \
540
+ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \
541
+ { \
542
+ for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \
543
+ *__p _Op##= __t; \
544
+ } \
545
+ \
546
+ template<typename _Tp> \
547
+ inline void \
548
+ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \
549
+ { \
550
+ _Tp* __p = __a._M_data; \
551
+ for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \
552
+ *__p _Op##= *__q; \
553
+ } \
554
+ \
555
+ template<typename _Tp, class _Dom> \
556
+ void \
557
+ _Array_augmented_##_Name(_Array<_Tp> __a, \
558
+ const _Expr<_Dom, _Tp>& __e, size_t __n) \
559
+ { \
560
+ _Tp* __p(__a._M_data); \
561
+ for (size_t __i = 0; __i < __n; ++__i, ++__p) \
562
+ *__p _Op##= __e[__i]; \
563
+ } \
564
+ \
565
+ template<typename _Tp> \
566
+ inline void \
567
+ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \
568
+ _Array<_Tp> __b) \
569
+ { \
570
+ _Tp* __q(__b._M_data); \
571
+ for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \
572
+ __p += __s, ++__q) \
573
+ *__p _Op##= *__q; \
574
+ } \
575
+ \
576
+ template<typename _Tp> \
577
+ inline void \
578
+ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \
579
+ size_t __n, size_t __s) \
580
+ { \
581
+ _Tp* __q(__b._M_data); \
582
+ for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
583
+ ++__p, __q += __s) \
584
+ *__p _Op##= *__q; \
585
+ } \
586
+ \
587
+ template<typename _Tp, class _Dom> \
588
+ void \
589
+ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \
590
+ const _Expr<_Dom, _Tp>& __e, size_t __n) \
591
+ { \
592
+ _Tp* __p(__a._M_data); \
593
+ for (size_t __i = 0; __i < __n; ++__i, __p += __s) \
594
+ *__p _Op##= __e[__i]; \
595
+ } \
596
+ \
597
+ template<typename _Tp> \
598
+ inline void \
599
+ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \
600
+ _Array<_Tp> __b, size_t __n) \
601
+ { \
602
+ _Tp* __q(__b._M_data); \
603
+ for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \
604
+ ++__j, ++__q) \
605
+ __a._M_data[*__j] _Op##= *__q; \
606
+ } \
607
+ \
608
+ template<typename _Tp> \
609
+ inline void \
610
+ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
611
+ _Array<_Tp> __b, _Array<size_t> __i) \
612
+ { \
613
+ _Tp* __p(__a._M_data); \
614
+ for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \
615
+ ++__j, ++__p) \
616
+ *__p _Op##= __b._M_data[*__j]; \
617
+ } \
618
+ \
619
+ template<typename _Tp, class _Dom> \
620
+ void \
621
+ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \
622
+ const _Expr<_Dom, _Tp>& __e, size_t __n) \
623
+ { \
624
+ size_t* __j(__i._M_data); \
625
+ for (size_t __k = 0; __k<__n; ++__k, ++__j) \
626
+ __a._M_data[*__j] _Op##= __e[__k]; \
627
+ } \
628
+ \
629
+ template<typename _Tp> \
630
+ void \
631
+ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
632
+ _Array<_Tp> __b, size_t __n) \
633
+ { \
634
+ bool* __ok(__m._M_data); \
635
+ _Tp* __p(__a._M_data); \
636
+ for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \
637
+ ++__q, ++__ok, ++__p) \
638
+ { \
639
+ while (! *__ok) \
640
+ { \
641
+ ++__ok; \
642
+ ++__p; \
643
+ } \
644
+ *__p _Op##= *__q; \
645
+ } \
646
+ } \
647
+ \
648
+ template<typename _Tp> \
649
+ void \
650
+ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
651
+ _Array<_Tp> __b, _Array<bool> __m) \
652
+ { \
653
+ bool* __ok(__m._M_data); \
654
+ _Tp* __q(__b._M_data); \
655
+ for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
656
+ ++__p, ++__ok, ++__q) \
657
+ { \
658
+ while (! *__ok) \
659
+ { \
660
+ ++__ok; \
661
+ ++__q; \
662
+ } \
663
+ *__p _Op##= *__q; \
664
+ } \
665
+ } \
666
+ \
667
+ template<typename _Tp, class _Dom> \
668
+ void \
669
+ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
670
+ const _Expr<_Dom, _Tp>& __e, size_t __n) \
671
+ { \
672
+ bool* __ok(__m._M_data); \
673
+ _Tp* __p(__a._M_data); \
674
+ for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \
675
+ { \
676
+ while (! *__ok) \
677
+ { \
678
+ ++__ok; \
679
+ ++__p; \
680
+ } \
681
+ *__p _Op##= __e[__i]; \
682
+ } \
683
+ }
684
+
685
+ _DEFINE_ARRAY_FUNCTION(+, __plus)
686
+ _DEFINE_ARRAY_FUNCTION(-, __minus)
687
+ _DEFINE_ARRAY_FUNCTION(*, __multiplies)
688
+ _DEFINE_ARRAY_FUNCTION(/, __divides)
689
+ _DEFINE_ARRAY_FUNCTION(%, __modulus)
690
+ _DEFINE_ARRAY_FUNCTION(^, __bitwise_xor)
691
+ _DEFINE_ARRAY_FUNCTION(|, __bitwise_or)
692
+ _DEFINE_ARRAY_FUNCTION(&, __bitwise_and)
693
+ _DEFINE_ARRAY_FUNCTION(<<, __shift_left)
694
+ _DEFINE_ARRAY_FUNCTION(>>, __shift_right)
695
+
696
+ #undef _DEFINE_ARRAY_FUNCTION
697
+
698
+ _GLIBCXX_END_NAMESPACE
699
+
700
+ #ifndef _GLIBCXX_EXPORT_TEMPLATE
701
+ # include <bits/valarray_array.tcc>
702
+ #endif
703
+
704
+ #endif /* _ARRAY_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_array.tcc ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The template and inlines for the -*- C++ -*- internal _Array helper class.
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2003, 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file valarray_array.tcc
31
+ * This is an internal header file, included by other library headers.
32
+ * You should not attempt to use it directly.
33
+ */
34
+
35
+ // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
36
+
37
+ #ifndef _VALARRAY_ARRAY_TCC
38
+ #define _VALARRAY_ARRAY_TCC 1
39
+
40
+ _GLIBCXX_BEGIN_NAMESPACE(std)
41
+
42
+ template<typename _Tp>
43
+ void
44
+ __valarray_fill(_Array<_Tp> __a, size_t __n, _Array<bool> __m,
45
+ const _Tp& __t)
46
+ {
47
+ _Tp* __p = __a._M_data;
48
+ bool* __ok (__m._M_data);
49
+ for (size_t __i=0; __i < __n; ++__i, ++__ok, ++__p)
50
+ {
51
+ while (!*__ok)
52
+ {
53
+ ++__ok;
54
+ ++__p;
55
+ }
56
+ *__p = __t;
57
+ }
58
+ }
59
+
60
+ // Copy n elements of a into consecutive elements of b. When m is
61
+ // false, the corresponding element of a is skipped. m must contain
62
+ // at least n true elements. a must contain at least n elements and
63
+ // enough elements to match up with m through the nth true element
64
+ // of m. I.e. if n is 10, m has 15 elements with 5 false followed
65
+ // by 10 true, a must have 15 elements.
66
+ template<typename _Tp>
67
+ void
68
+ __valarray_copy(_Array<_Tp> __a, _Array<bool> __m, _Array<_Tp> __b,
69
+ size_t __n)
70
+ {
71
+ _Tp* __p (__a._M_data);
72
+ bool* __ok (__m._M_data);
73
+ for (_Tp* __q = __b._M_data; __q < __b._M_data + __n;
74
+ ++__q, ++__ok, ++__p)
75
+ {
76
+ while (! *__ok)
77
+ {
78
+ ++__ok;
79
+ ++__p;
80
+ }
81
+ *__q = *__p;
82
+ }
83
+ }
84
+
85
+ // Copy n consecutive elements from a into elements of b. Elements
86
+ // of b are skipped if the corresponding element of m is false. m
87
+ // must contain at least n true elements. b must have at least as
88
+ // many elements as the index of the nth true element of m. I.e. if
89
+ // m has 15 elements with 5 false followed by 10 true, b must have
90
+ // at least 15 elements.
91
+ template<typename _Tp>
92
+ void
93
+ __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
94
+ _Array<bool> __m)
95
+ {
96
+ _Tp* __q (__b._M_data);
97
+ bool* __ok (__m._M_data);
98
+ for (_Tp* __p = __a._M_data; __p < __a._M_data+__n;
99
+ ++__p, ++__ok, ++__q)
100
+ {
101
+ while (! *__ok)
102
+ {
103
+ ++__ok;
104
+ ++__q;
105
+ }
106
+ *__q = *__p;
107
+ }
108
+ }
109
+
110
+ // Copy n elements from a into elements of b. Elements of a are
111
+ // skipped if the corresponding element of m is false. Elements of
112
+ // b are skipped if the corresponding element of k is false. m and
113
+ // k must contain at least n true elements. a and b must have at
114
+ // least as many elements as the index of the nth true element of m.
115
+ template<typename _Tp>
116
+ void
117
+ __valarray_copy(_Array<_Tp> __a, _Array<bool> __m, size_t __n,
118
+ _Array<_Tp> __b, _Array<bool> __k)
119
+ {
120
+ _Tp* __p (__a._M_data);
121
+ _Tp* __q (__b._M_data);
122
+ bool* __srcok (__m._M_data);
123
+ bool* __dstok (__k._M_data);
124
+ for (size_t __i = 0; __i < __n;
125
+ ++__srcok, ++__p, ++__dstok, ++__q, ++__i)
126
+ {
127
+ while (! *__srcok)
128
+ {
129
+ ++__srcok;
130
+ ++__p;
131
+ }
132
+ while (! *__dstok)
133
+ {
134
+ ++__dstok;
135
+ ++__q;
136
+ }
137
+ *__q = *__p;
138
+ }
139
+ }
140
+
141
+ // Copy n consecutive elements of e into consecutive elements of a.
142
+ // I.e. a[i] = e[i].
143
+ template<typename _Tp, class _Dom>
144
+ void
145
+ __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
146
+ {
147
+ _Tp* __p (__a._M_data);
148
+ for (size_t __i = 0; __i < __n; ++__i, ++__p)
149
+ *__p = __e[__i];
150
+ }
151
+
152
+ // Copy n consecutive elements of e into elements of a using stride
153
+ // s. I.e., a[0] = e[0], a[s] = e[1], a[2*s] = e[2].
154
+ template<typename _Tp, class _Dom>
155
+ void
156
+ __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
157
+ _Array<_Tp> __a, size_t __s)
158
+ {
159
+ _Tp* __p (__a._M_data);
160
+ for (size_t __i = 0; __i < __n; ++__i, __p += __s)
161
+ *__p = __e[__i];
162
+ }
163
+
164
+ // Copy n consecutive elements of e into elements of a indexed by
165
+ // contents of i. I.e., a[i[0]] = e[0].
166
+ template<typename _Tp, class _Dom>
167
+ void
168
+ __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
169
+ _Array<_Tp> __a, _Array<size_t> __i)
170
+ {
171
+ size_t* __j (__i._M_data);
172
+ for (size_t __k = 0; __k < __n; ++__k, ++__j)
173
+ __a._M_data[*__j] = __e[__k];
174
+ }
175
+
176
+ // Copy n elements of e indexed by contents of f into elements of a
177
+ // indexed by contents of i. I.e., a[i[0]] = e[f[0]].
178
+ template<typename _Tp>
179
+ void
180
+ __valarray_copy(_Array<_Tp> __e, _Array<size_t> __f,
181
+ size_t __n,
182
+ _Array<_Tp> __a, _Array<size_t> __i)
183
+ {
184
+ size_t* __g (__f._M_data);
185
+ size_t* __j (__i._M_data);
186
+ for (size_t __k = 0; __k < __n; ++__k, ++__j, ++__g)
187
+ __a._M_data[*__j] = __e._M_data[*__g];
188
+ }
189
+
190
+ // Copy n consecutive elements of e into elements of a. Elements of
191
+ // a are skipped if the corresponding element of m is false. m must
192
+ // have at least n true elements and a must have at least as many
193
+ // elements as the index of the nth true element of m. I.e. if m
194
+ // has 5 false followed by 10 true elements and n == 10, a must have
195
+ // at least 15 elements.
196
+ template<typename _Tp, class _Dom>
197
+ void
198
+ __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
199
+ _Array<_Tp> __a, _Array<bool> __m)
200
+ {
201
+ bool* __ok (__m._M_data);
202
+ _Tp* __p (__a._M_data);
203
+ for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p)
204
+ {
205
+ while (! *__ok)
206
+ {
207
+ ++__ok;
208
+ ++__p;
209
+ }
210
+ *__p = __e[__i];
211
+ }
212
+ }
213
+
214
+
215
+ template<typename _Tp, class _Dom>
216
+ void
217
+ __valarray_copy_construct(const _Expr<_Dom, _Tp>& __e, size_t __n,
218
+ _Array<_Tp> __a)
219
+ {
220
+ _Tp* __p (__a._M_data);
221
+ for (size_t __i = 0; __i < __n; ++__i, ++__p)
222
+ new (__p) _Tp(__e[__i]);
223
+ }
224
+
225
+
226
+ template<typename _Tp>
227
+ void
228
+ __valarray_copy_construct(_Array<_Tp> __a, _Array<bool> __m,
229
+ _Array<_Tp> __b, size_t __n)
230
+ {
231
+ _Tp* __p (__a._M_data);
232
+ bool* __ok (__m._M_data);
233
+ for (_Tp* __q = __b._M_data; __q < __b._M_data+__n; ++__q, ++__ok, ++__p)
234
+ {
235
+ while (! *__ok)
236
+ {
237
+ ++__ok;
238
+ ++__p;
239
+ }
240
+ new (__q) _Tp(*__p);
241
+ }
242
+ }
243
+
244
+ _GLIBCXX_END_NAMESPACE
245
+
246
+ #endif /* _VALARRAY_ARRAY_TCC */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/valarray_before.h ADDED
@@ -0,0 +1,735 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The template and inlines for the -*- C++ -*- internal _Meta class.
2
+
3
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file valarray_before.h
32
+ * This is an internal header file, included by other library headers.
33
+ * You should not attempt to use it directly.
34
+ */
35
+
36
+ // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
37
+
38
+ #ifndef _VALARRAY_BEFORE_H
39
+ #define _VALARRAY_BEFORE_H 1
40
+
41
+ #pragma GCC system_header
42
+
43
+ #include <bits/slice_array.h>
44
+
45
+ _GLIBCXX_BEGIN_NAMESPACE(std)
46
+
47
+ //
48
+ // Implementing a loosened valarray return value is tricky.
49
+ // First we need to meet 26.3.1/3: we should not add more than
50
+ // two levels of template nesting. Therefore we resort to template
51
+ // template to "flatten" loosened return value types.
52
+ // At some point we use partial specialization to remove one level
53
+ // template nesting due to _Expr<>
54
+ //
55
+
56
+ // This class is NOT defined. It doesn't need to.
57
+ template<typename _Tp1, typename _Tp2> class _Constant;
58
+
59
+ // Implementations of unary functions applied to valarray<>s.
60
+ // I use hard-coded object functions here instead of a generic
61
+ // approach like pointers to function:
62
+ // 1) correctness: some functions take references, others values.
63
+ // we can't deduce the correct type afterwards.
64
+ // 2) efficiency -- object functions can be easily inlined
65
+ // 3) be Koenig-lookup-friendly
66
+
67
+ struct __abs
68
+ {
69
+ template<typename _Tp>
70
+ _Tp operator()(const _Tp& __t) const
71
+ { return abs(__t); }
72
+ };
73
+
74
+ struct __cos
75
+ {
76
+ template<typename _Tp>
77
+ _Tp operator()(const _Tp& __t) const
78
+ { return cos(__t); }
79
+ };
80
+
81
+ struct __acos
82
+ {
83
+ template<typename _Tp>
84
+ _Tp operator()(const _Tp& __t) const
85
+ { return acos(__t); }
86
+ };
87
+
88
+ struct __cosh
89
+ {
90
+ template<typename _Tp>
91
+ _Tp operator()(const _Tp& __t) const
92
+ { return cosh(__t); }
93
+ };
94
+
95
+ struct __sin
96
+ {
97
+ template<typename _Tp>
98
+ _Tp operator()(const _Tp& __t) const
99
+ { return sin(__t); }
100
+ };
101
+
102
+ struct __asin
103
+ {
104
+ template<typename _Tp>
105
+ _Tp operator()(const _Tp& __t) const
106
+ { return asin(__t); }
107
+ };
108
+
109
+ struct __sinh
110
+ {
111
+ template<typename _Tp>
112
+ _Tp operator()(const _Tp& __t) const
113
+ { return sinh(__t); }
114
+ };
115
+
116
+ struct __tan
117
+ {
118
+ template<typename _Tp>
119
+ _Tp operator()(const _Tp& __t) const
120
+ { return tan(__t); }
121
+ };
122
+
123
+ struct __atan
124
+ {
125
+ template<typename _Tp>
126
+ _Tp operator()(const _Tp& __t) const
127
+ { return atan(__t); }
128
+ };
129
+
130
+ struct __tanh
131
+ {
132
+ template<typename _Tp>
133
+ _Tp operator()(const _Tp& __t) const
134
+ { return tanh(__t); }
135
+ };
136
+
137
+ struct __exp
138
+ {
139
+ template<typename _Tp>
140
+ _Tp operator()(const _Tp& __t) const
141
+ { return exp(__t); }
142
+ };
143
+
144
+ struct __log
145
+ {
146
+ template<typename _Tp>
147
+ _Tp operator()(const _Tp& __t) const
148
+ { return log(__t); }
149
+ };
150
+
151
+ struct __log10
152
+ {
153
+ template<typename _Tp>
154
+ _Tp operator()(const _Tp& __t) const
155
+ { return log10(__t); }
156
+ };
157
+
158
+ struct __sqrt
159
+ {
160
+ template<typename _Tp>
161
+ _Tp operator()(const _Tp& __t) const
162
+ { return sqrt(__t); }
163
+ };
164
+
165
+ // In the past, we used to tailor operator applications semantics
166
+ // to the specialization of standard function objects (i.e. plus<>, etc.)
167
+ // That is incorrect. Therefore we provide our own surrogates.
168
+
169
+ struct __unary_plus
170
+ {
171
+ template<typename _Tp>
172
+ _Tp operator()(const _Tp& __t) const
173
+ { return +__t; }
174
+ };
175
+
176
+ struct __negate
177
+ {
178
+ template<typename _Tp>
179
+ _Tp operator()(const _Tp& __t) const
180
+ { return -__t; }
181
+ };
182
+
183
+ struct __bitwise_not
184
+ {
185
+ template<typename _Tp>
186
+ _Tp operator()(const _Tp& __t) const
187
+ { return ~__t; }
188
+ };
189
+
190
+ struct __plus
191
+ {
192
+ template<typename _Tp>
193
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
194
+ { return __x + __y; }
195
+ };
196
+
197
+ struct __minus
198
+ {
199
+ template<typename _Tp>
200
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
201
+ { return __x - __y; }
202
+ };
203
+
204
+ struct __multiplies
205
+ {
206
+ template<typename _Tp>
207
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
208
+ { return __x * __y; }
209
+ };
210
+
211
+ struct __divides
212
+ {
213
+ template<typename _Tp>
214
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
215
+ { return __x / __y; }
216
+ };
217
+
218
+ struct __modulus
219
+ {
220
+ template<typename _Tp>
221
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
222
+ { return __x % __y; }
223
+ };
224
+
225
+ struct __bitwise_xor
226
+ {
227
+ template<typename _Tp>
228
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
229
+ { return __x ^ __y; }
230
+ };
231
+
232
+ struct __bitwise_and
233
+ {
234
+ template<typename _Tp>
235
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
236
+ { return __x & __y; }
237
+ };
238
+
239
+ struct __bitwise_or
240
+ {
241
+ template<typename _Tp>
242
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
243
+ { return __x | __y; }
244
+ };
245
+
246
+ struct __shift_left
247
+ {
248
+ template<typename _Tp>
249
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
250
+ { return __x << __y; }
251
+ };
252
+
253
+ struct __shift_right
254
+ {
255
+ template<typename _Tp>
256
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
257
+ { return __x >> __y; }
258
+ };
259
+
260
+ struct __logical_and
261
+ {
262
+ template<typename _Tp>
263
+ bool operator()(const _Tp& __x, const _Tp& __y) const
264
+ { return __x && __y; }
265
+ };
266
+
267
+ struct __logical_or
268
+ {
269
+ template<typename _Tp>
270
+ bool operator()(const _Tp& __x, const _Tp& __y) const
271
+ { return __x || __y; }
272
+ };
273
+
274
+ struct __logical_not
275
+ {
276
+ template<typename _Tp>
277
+ bool operator()(const _Tp& __x) const { return !__x; }
278
+ };
279
+
280
+ struct __equal_to
281
+ {
282
+ template<typename _Tp>
283
+ bool operator()(const _Tp& __x, const _Tp& __y) const
284
+ { return __x == __y; }
285
+ };
286
+
287
+ struct __not_equal_to
288
+ {
289
+ template<typename _Tp>
290
+ bool operator()(const _Tp& __x, const _Tp& __y) const
291
+ { return __x != __y; }
292
+ };
293
+
294
+ struct __less
295
+ {
296
+ template<typename _Tp>
297
+ bool operator()(const _Tp& __x, const _Tp& __y) const
298
+ { return __x < __y; }
299
+ };
300
+
301
+ struct __greater
302
+ {
303
+ template<typename _Tp>
304
+ bool operator()(const _Tp& __x, const _Tp& __y) const
305
+ { return __x > __y; }
306
+ };
307
+
308
+ struct __less_equal
309
+ {
310
+ template<typename _Tp>
311
+ bool operator()(const _Tp& __x, const _Tp& __y) const
312
+ { return __x <= __y; }
313
+ };
314
+
315
+ struct __greater_equal
316
+ {
317
+ template<typename _Tp>
318
+ bool operator()(const _Tp& __x, const _Tp& __y) const
319
+ { return __x >= __y; }
320
+ };
321
+
322
+ // The few binary functions we miss.
323
+ struct __atan2
324
+ {
325
+ template<typename _Tp>
326
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
327
+ { return atan2(__x, __y); }
328
+ };
329
+
330
+ struct __pow
331
+ {
332
+ template<typename _Tp>
333
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
334
+ { return pow(__x, __y); }
335
+ };
336
+
337
+
338
+ // We need these bits in order to recover the return type of
339
+ // some functions/operators now that we're no longer using
340
+ // function templates.
341
+ template<typename, typename _Tp>
342
+ struct __fun
343
+ {
344
+ typedef _Tp result_type;
345
+ };
346
+
347
+ // several specializations for relational operators.
348
+ template<typename _Tp>
349
+ struct __fun<__logical_not, _Tp>
350
+ {
351
+ typedef bool result_type;
352
+ };
353
+
354
+ template<typename _Tp>
355
+ struct __fun<__logical_and, _Tp>
356
+ {
357
+ typedef bool result_type;
358
+ };
359
+
360
+ template<typename _Tp>
361
+ struct __fun<__logical_or, _Tp>
362
+ {
363
+ typedef bool result_type;
364
+ };
365
+
366
+ template<typename _Tp>
367
+ struct __fun<__less, _Tp>
368
+ {
369
+ typedef bool result_type;
370
+ };
371
+
372
+ template<typename _Tp>
373
+ struct __fun<__greater, _Tp>
374
+ {
375
+ typedef bool result_type;
376
+ };
377
+
378
+ template<typename _Tp>
379
+ struct __fun<__less_equal, _Tp>
380
+ {
381
+ typedef bool result_type;
382
+ };
383
+
384
+ template<typename _Tp>
385
+ struct __fun<__greater_equal, _Tp>
386
+ {
387
+ typedef bool result_type;
388
+ };
389
+
390
+ template<typename _Tp>
391
+ struct __fun<__equal_to, _Tp>
392
+ {
393
+ typedef bool result_type;
394
+ };
395
+
396
+ template<typename _Tp>
397
+ struct __fun<__not_equal_to, _Tp>
398
+ {
399
+ typedef bool result_type;
400
+ };
401
+
402
+ //
403
+ // Apply function taking a value/const reference closure
404
+ //
405
+
406
+ template<typename _Dom, typename _Arg>
407
+ class _FunBase
408
+ {
409
+ public:
410
+ typedef typename _Dom::value_type value_type;
411
+
412
+ _FunBase(const _Dom& __e, value_type __f(_Arg))
413
+ : _M_expr(__e), _M_func(__f) {}
414
+
415
+ value_type operator[](size_t __i) const
416
+ { return _M_func (_M_expr[__i]); }
417
+
418
+ size_t size() const { return _M_expr.size ();}
419
+
420
+ private:
421
+ const _Dom& _M_expr;
422
+ value_type (*_M_func)(_Arg);
423
+ };
424
+
425
+ template<class _Dom>
426
+ struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type>
427
+ {
428
+ typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
429
+ typedef typename _Base::value_type value_type;
430
+ typedef value_type _Tp;
431
+
432
+ _ValFunClos(const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {}
433
+ };
434
+
435
+ template<typename _Tp>
436
+ struct _ValFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, _Tp>
437
+ {
438
+ typedef _FunBase<valarray<_Tp>, _Tp> _Base;
439
+ typedef _Tp value_type;
440
+
441
+ _ValFunClos(const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {}
442
+ };
443
+
444
+ template<class _Dom>
445
+ struct _RefFunClos<_Expr, _Dom>
446
+ : _FunBase<_Dom, const typename _Dom::value_type&>
447
+ {
448
+ typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
449
+ typedef typename _Base::value_type value_type;
450
+ typedef value_type _Tp;
451
+
452
+ _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&))
453
+ : _Base(__e, __f) {}
454
+ };
455
+
456
+ template<typename _Tp>
457
+ struct _RefFunClos<_ValArray, _Tp>
458
+ : _FunBase<valarray<_Tp>, const _Tp&>
459
+ {
460
+ typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
461
+ typedef _Tp value_type;
462
+
463
+ _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&))
464
+ : _Base(__v, __f) {}
465
+ };
466
+
467
+ //
468
+ // Unary expression closure.
469
+ //
470
+
471
+ template<class _Oper, class _Arg>
472
+ class _UnBase
473
+ {
474
+ public:
475
+ typedef typename _Arg::value_type _Vt;
476
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
477
+
478
+ _UnBase(const _Arg& __e) : _M_expr(__e) {}
479
+
480
+ value_type operator[](size_t __i) const
481
+ { return _Oper()(_M_expr[__i]); }
482
+
483
+ size_t size() const { return _M_expr.size(); }
484
+
485
+ private:
486
+ const _Arg& _M_expr;
487
+ };
488
+
489
+ template<class _Oper, class _Dom>
490
+ struct _UnClos<_Oper, _Expr, _Dom>
491
+ : _UnBase<_Oper, _Dom>
492
+ {
493
+ typedef _Dom _Arg;
494
+ typedef _UnBase<_Oper, _Dom> _Base;
495
+ typedef typename _Base::value_type value_type;
496
+
497
+ _UnClos(const _Arg& __e) : _Base(__e) {}
498
+ };
499
+
500
+ template<class _Oper, typename _Tp>
501
+ struct _UnClos<_Oper, _ValArray, _Tp>
502
+ : _UnBase<_Oper, valarray<_Tp> >
503
+ {
504
+ typedef valarray<_Tp> _Arg;
505
+ typedef _UnBase<_Oper, valarray<_Tp> > _Base;
506
+ typedef typename _Base::value_type value_type;
507
+
508
+ _UnClos(const _Arg& __e) : _Base(__e) {}
509
+ };
510
+
511
+
512
+ //
513
+ // Binary expression closure.
514
+ //
515
+
516
+ template<class _Oper, class _FirstArg, class _SecondArg>
517
+ class _BinBase
518
+ {
519
+ public:
520
+ typedef typename _FirstArg::value_type _Vt;
521
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
522
+
523
+ _BinBase(const _FirstArg& __e1, const _SecondArg& __e2)
524
+ : _M_expr1(__e1), _M_expr2(__e2) {}
525
+
526
+ value_type operator[](size_t __i) const
527
+ { return _Oper()(_M_expr1[__i], _M_expr2[__i]); }
528
+
529
+ size_t size() const { return _M_expr1.size(); }
530
+
531
+ private:
532
+ const _FirstArg& _M_expr1;
533
+ const _SecondArg& _M_expr2;
534
+ };
535
+
536
+
537
+ template<class _Oper, class _Clos>
538
+ class _BinBase2
539
+ {
540
+ public:
541
+ typedef typename _Clos::value_type _Vt;
542
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
543
+
544
+ _BinBase2(const _Clos& __e, const _Vt& __t)
545
+ : _M_expr1(__e), _M_expr2(__t) {}
546
+
547
+ value_type operator[](size_t __i) const
548
+ { return _Oper()(_M_expr1[__i], _M_expr2); }
549
+
550
+ size_t size() const { return _M_expr1.size(); }
551
+
552
+ private:
553
+ const _Clos& _M_expr1;
554
+ const _Vt& _M_expr2;
555
+ };
556
+
557
+ template<class _Oper, class _Clos>
558
+ class _BinBase1
559
+ {
560
+ public:
561
+ typedef typename _Clos::value_type _Vt;
562
+ typedef typename __fun<_Oper, _Vt>::result_type value_type;
563
+
564
+ _BinBase1(const _Vt& __t, const _Clos& __e)
565
+ : _M_expr1(__t), _M_expr2(__e) {}
566
+
567
+ value_type operator[](size_t __i) const
568
+ { return _Oper()(_M_expr1, _M_expr2[__i]); }
569
+
570
+ size_t size() const { return _M_expr2.size(); }
571
+
572
+ private:
573
+ const _Vt& _M_expr1;
574
+ const _Clos& _M_expr2;
575
+ };
576
+
577
+ template<class _Oper, class _Dom1, class _Dom2>
578
+ struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
579
+ : _BinBase<_Oper, _Dom1, _Dom2>
580
+ {
581
+ typedef _BinBase<_Oper, _Dom1, _Dom2> _Base;
582
+ typedef typename _Base::value_type value_type;
583
+
584
+ _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
585
+ };
586
+
587
+ template<class _Oper, typename _Tp>
588
+ struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp>
589
+ : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> >
590
+ {
591
+ typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base;
592
+ typedef typename _Base::value_type value_type;
593
+
594
+ _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w)
595
+ : _Base(__v, __w) {}
596
+ };
597
+
598
+ template<class _Oper, class _Dom>
599
+ struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type>
600
+ : _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> >
601
+ {
602
+ typedef typename _Dom::value_type _Tp;
603
+ typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
604
+ typedef typename _Base::value_type value_type;
605
+
606
+ _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
607
+ : _Base(__e1, __e2) {}
608
+ };
609
+
610
+ template<class _Oper, class _Dom>
611
+ struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom>
612
+ : _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom>
613
+ {
614
+ typedef typename _Dom::value_type _Tp;
615
+ typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base;
616
+ typedef typename _Base::value_type value_type;
617
+
618
+ _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2)
619
+ : _Base(__e1, __e2) {}
620
+ };
621
+
622
+ template<class _Oper, class _Dom>
623
+ struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type>
624
+ : _BinBase2<_Oper, _Dom>
625
+ {
626
+ typedef typename _Dom::value_type _Tp;
627
+ typedef _BinBase2<_Oper,_Dom> _Base;
628
+ typedef typename _Base::value_type value_type;
629
+
630
+ _BinClos(const _Dom& __e1, const _Tp& __e2) : _Base(__e1, __e2) {}
631
+ };
632
+
633
+ template<class _Oper, class _Dom>
634
+ struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom>
635
+ : _BinBase1<_Oper, _Dom>
636
+ {
637
+ typedef typename _Dom::value_type _Tp;
638
+ typedef _BinBase1<_Oper, _Dom> _Base;
639
+ typedef typename _Base::value_type value_type;
640
+
641
+ _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {}
642
+ };
643
+
644
+ template<class _Oper, typename _Tp>
645
+ struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp>
646
+ : _BinBase2<_Oper, valarray<_Tp> >
647
+ {
648
+ typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
649
+ typedef typename _Base::value_type value_type;
650
+
651
+ _BinClos(const valarray<_Tp>& __v, const _Tp& __t) : _Base(__v, __t) {}
652
+ };
653
+
654
+ template<class _Oper, typename _Tp>
655
+ struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp>
656
+ : _BinBase1<_Oper, valarray<_Tp> >
657
+ {
658
+ typedef _BinBase1<_Oper, valarray<_Tp> > _Base;
659
+ typedef typename _Base::value_type value_type;
660
+
661
+ _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {}
662
+ };
663
+
664
+ //
665
+ // slice_array closure.
666
+ //
667
+ template<typename _Dom>
668
+ class _SBase
669
+ {
670
+ public:
671
+ typedef typename _Dom::value_type value_type;
672
+
673
+ _SBase (const _Dom& __e, const slice& __s)
674
+ : _M_expr (__e), _M_slice (__s) {}
675
+
676
+ value_type
677
+ operator[] (size_t __i) const
678
+ { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
679
+
680
+ size_t
681
+ size() const
682
+ { return _M_slice.size (); }
683
+
684
+ private:
685
+ const _Dom& _M_expr;
686
+ const slice& _M_slice;
687
+ };
688
+
689
+ template<typename _Tp>
690
+ class _SBase<_Array<_Tp> >
691
+ {
692
+ public:
693
+ typedef _Tp value_type;
694
+
695
+ _SBase (_Array<_Tp> __a, const slice& __s)
696
+ : _M_array (__a._M_data+__s.start()), _M_size (__s.size()),
697
+ _M_stride (__s.stride()) {}
698
+
699
+ value_type
700
+ operator[] (size_t __i) const
701
+ { return _M_array._M_data[__i * _M_stride]; }
702
+
703
+ size_t
704
+ size() const
705
+ { return _M_size; }
706
+
707
+ private:
708
+ const _Array<_Tp> _M_array;
709
+ const size_t _M_size;
710
+ const size_t _M_stride;
711
+ };
712
+
713
+ template<class _Dom>
714
+ struct _SClos<_Expr, _Dom>
715
+ : _SBase<_Dom>
716
+ {
717
+ typedef _SBase<_Dom> _Base;
718
+ typedef typename _Base::value_type value_type;
719
+
720
+ _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {}
721
+ };
722
+
723
+ template<typename _Tp>
724
+ struct _SClos<_ValArray, _Tp>
725
+ : _SBase<_Array<_Tp> >
726
+ {
727
+ typedef _SBase<_Array<_Tp> > _Base;
728
+ typedef _Tp value_type;
729
+
730
+ _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {}
731
+ };
732
+
733
+ _GLIBCXX_END_NAMESPACE
734
+
735
+ #endif /* _CPP_VALARRAY_BEFORE_H */
mingw/lib/gcc/mingw32/4.3.3/include/c++/bits/vector.tcc ADDED
@@ -0,0 +1,656 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Vector implementation (out of line) -*- C++ -*-
2
+
3
+ // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /*
32
+ *
33
+ * Copyright (c) 1994
34
+ * Hewlett-Packard Company
35
+ *
36
+ * Permission to use, copy, modify, distribute and sell this software
37
+ * and its documentation for any purpose is hereby granted without fee,
38
+ * provided that the above copyright notice appear in all copies and
39
+ * that both that copyright notice and this permission notice appear
40
+ * in supporting documentation. Hewlett-Packard Company makes no
41
+ * representations about the suitability of this software for any
42
+ * purpose. It is provided "as is" without express or implied warranty.
43
+ *
44
+ *
45
+ * Copyright (c) 1996
46
+ * Silicon Graphics Computer Systems, Inc.
47
+ *
48
+ * Permission to use, copy, modify, distribute and sell this software
49
+ * and its documentation for any purpose is hereby granted without fee,
50
+ * provided that the above copyright notice appear in all copies and
51
+ * that both that copyright notice and this permission notice appear
52
+ * in supporting documentation. Silicon Graphics makes no
53
+ * representations about the suitability of this software for any
54
+ * purpose. It is provided "as is" without express or implied warranty.
55
+ */
56
+
57
+ /** @file vector.tcc
58
+ * This is an internal header file, included by other library headers.
59
+ * You should not attempt to use it directly.
60
+ */
61
+
62
+ #ifndef _VECTOR_TCC
63
+ #define _VECTOR_TCC 1
64
+
65
+ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
66
+
67
+ template<typename _Tp, typename _Alloc>
68
+ void
69
+ vector<_Tp, _Alloc>::
70
+ reserve(size_type __n)
71
+ {
72
+ if (__n > this->max_size())
73
+ __throw_length_error(__N("vector::reserve"));
74
+ if (this->capacity() < __n)
75
+ {
76
+ const size_type __old_size = size();
77
+ pointer __tmp = _M_allocate_and_copy(__n,
78
+ _GLIBCXX_MAKE_MOVE_ITERATOR(this->_M_impl._M_start),
79
+ _GLIBCXX_MAKE_MOVE_ITERATOR(this->_M_impl._M_finish));
80
+ std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
81
+ _M_get_Tp_allocator());
82
+ _M_deallocate(this->_M_impl._M_start,
83
+ this->_M_impl._M_end_of_storage
84
+ - this->_M_impl._M_start);
85
+ this->_M_impl._M_start = __tmp;
86
+ this->_M_impl._M_finish = __tmp + __old_size;
87
+ this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
88
+ }
89
+ }
90
+
91
+ template<typename _Tp, typename _Alloc>
92
+ typename vector<_Tp, _Alloc>::iterator
93
+ vector<_Tp, _Alloc>::
94
+ insert(iterator __position, const value_type& __x)
95
+ {
96
+ const size_type __n = __position - begin();
97
+ if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
98
+ && __position == end())
99
+ {
100
+ this->_M_impl.construct(this->_M_impl._M_finish, __x);
101
+ ++this->_M_impl._M_finish;
102
+ }
103
+ else
104
+ {
105
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
106
+ if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
107
+ {
108
+ _Tp __x_copy = __x;
109
+ _M_insert_aux(__position, std::move(__x_copy));
110
+ }
111
+ else
112
+ #endif
113
+ _M_insert_aux(__position, __x);
114
+ }
115
+ return iterator(this->_M_impl._M_start + __n);
116
+ }
117
+
118
+ template<typename _Tp, typename _Alloc>
119
+ typename vector<_Tp, _Alloc>::iterator
120
+ vector<_Tp, _Alloc>::
121
+ erase(iterator __position)
122
+ {
123
+ if (__position + 1 != end())
124
+ _GLIBCXX_MOVE3(__position + 1, end(), __position);
125
+ --this->_M_impl._M_finish;
126
+ this->_M_impl.destroy(this->_M_impl._M_finish);
127
+ return __position;
128
+ }
129
+
130
+ template<typename _Tp, typename _Alloc>
131
+ typename vector<_Tp, _Alloc>::iterator
132
+ vector<_Tp, _Alloc>::
133
+ erase(iterator __first, iterator __last)
134
+ {
135
+ if (__last != end())
136
+ _GLIBCXX_MOVE3(__last, end(), __first);
137
+ _M_erase_at_end(__first.base() + (end() - __last));
138
+ return __first;
139
+ }
140
+
141
+ template<typename _Tp, typename _Alloc>
142
+ vector<_Tp, _Alloc>&
143
+ vector<_Tp, _Alloc>::
144
+ operator=(const vector<_Tp, _Alloc>& __x)
145
+ {
146
+ if (&__x != this)
147
+ {
148
+ const size_type __xlen = __x.size();
149
+ if (__xlen > capacity())
150
+ {
151
+ pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(),
152
+ __x.end());
153
+ std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
154
+ _M_get_Tp_allocator());
155
+ _M_deallocate(this->_M_impl._M_start,
156
+ this->_M_impl._M_end_of_storage
157
+ - this->_M_impl._M_start);
158
+ this->_M_impl._M_start = __tmp;
159
+ this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
160
+ }
161
+ else if (size() >= __xlen)
162
+ {
163
+ std::_Destroy(std::copy(__x.begin(), __x.end(), begin()),
164
+ end(), _M_get_Tp_allocator());
165
+ }
166
+ else
167
+ {
168
+ std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(),
169
+ this->_M_impl._M_start);
170
+ std::__uninitialized_copy_a(__x._M_impl._M_start + size(),
171
+ __x._M_impl._M_finish,
172
+ this->_M_impl._M_finish,
173
+ _M_get_Tp_allocator());
174
+ }
175
+ this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
176
+ }
177
+ return *this;
178
+ }
179
+
180
+ template<typename _Tp, typename _Alloc>
181
+ void
182
+ vector<_Tp, _Alloc>::
183
+ _M_fill_assign(size_t __n, const value_type& __val)
184
+ {
185
+ if (__n > capacity())
186
+ {
187
+ vector __tmp(__n, __val, _M_get_Tp_allocator());
188
+ __tmp.swap(*this);
189
+ }
190
+ else if (__n > size())
191
+ {
192
+ std::fill(begin(), end(), __val);
193
+ std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
194
+ __n - size(), __val,
195
+ _M_get_Tp_allocator());
196
+ this->_M_impl._M_finish += __n - size();
197
+ }
198
+ else
199
+ _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val));
200
+ }
201
+
202
+ template<typename _Tp, typename _Alloc>
203
+ template<typename _InputIterator>
204
+ void
205
+ vector<_Tp, _Alloc>::
206
+ _M_assign_aux(_InputIterator __first, _InputIterator __last,
207
+ std::input_iterator_tag)
208
+ {
209
+ pointer __cur(this->_M_impl._M_start);
210
+ for (; __first != __last && __cur != this->_M_impl._M_finish;
211
+ ++__cur, ++__first)
212
+ *__cur = *__first;
213
+ if (__first == __last)
214
+ _M_erase_at_end(__cur);
215
+ else
216
+ insert(end(), __first, __last);
217
+ }
218
+
219
+ template<typename _Tp, typename _Alloc>
220
+ template<typename _ForwardIterator>
221
+ void
222
+ vector<_Tp, _Alloc>::
223
+ _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
224
+ std::forward_iterator_tag)
225
+ {
226
+ const size_type __len = std::distance(__first, __last);
227
+
228
+ if (__len > capacity())
229
+ {
230
+ pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
231
+ std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
232
+ _M_get_Tp_allocator());
233
+ _M_deallocate(this->_M_impl._M_start,
234
+ this->_M_impl._M_end_of_storage
235
+ - this->_M_impl._M_start);
236
+ this->_M_impl._M_start = __tmp;
237
+ this->_M_impl._M_finish = this->_M_impl._M_start + __len;
238
+ this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
239
+ }
240
+ else if (size() >= __len)
241
+ _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start));
242
+ else
243
+ {
244
+ _ForwardIterator __mid = __first;
245
+ std::advance(__mid, size());
246
+ std::copy(__first, __mid, this->_M_impl._M_start);
247
+ this->_M_impl._M_finish =
248
+ std::__uninitialized_copy_a(__mid, __last,
249
+ this->_M_impl._M_finish,
250
+ _M_get_Tp_allocator());
251
+ }
252
+ }
253
+
254
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
255
+ template<typename _Tp, typename _Alloc>
256
+ template<typename... _Args>
257
+ typename vector<_Tp, _Alloc>::iterator
258
+ vector<_Tp, _Alloc>::
259
+ emplace(iterator __position, _Args&&... __args)
260
+ {
261
+ const size_type __n = __position - begin();
262
+ if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
263
+ && __position == end())
264
+ {
265
+ this->_M_impl.construct(this->_M_impl._M_finish,
266
+ std::forward<_Args>(__args)...);
267
+ ++this->_M_impl._M_finish;
268
+ }
269
+ else
270
+ _M_insert_aux(__position, std::forward<_Args>(__args)...);
271
+ return iterator(this->_M_impl._M_start + __n);
272
+ }
273
+
274
+ template<typename _Tp, typename _Alloc>
275
+ template<typename... _Args>
276
+ void
277
+ vector<_Tp, _Alloc>::
278
+ _M_insert_aux(iterator __position, _Args&&... __args)
279
+ #else
280
+ template<typename _Tp, typename _Alloc>
281
+ void
282
+ vector<_Tp, _Alloc>::
283
+ _M_insert_aux(iterator __position, const _Tp& __x)
284
+ #endif
285
+ {
286
+ if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
287
+ {
288
+ this->_M_impl.construct(this->_M_impl._M_finish,
289
+ _GLIBCXX_MOVE(*(this->_M_impl._M_finish
290
+ - 1)));
291
+ ++this->_M_impl._M_finish;
292
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
293
+ _Tp __x_copy = __x;
294
+ #endif
295
+ _GLIBCXX_MOVE_BACKWARD3(__position.base(),
296
+ this->_M_impl._M_finish - 2,
297
+ this->_M_impl._M_finish - 1);
298
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
299
+ *__position = __x_copy;
300
+ #else
301
+ *__position = _Tp(std::forward<_Args>(__args)...);
302
+ #endif
303
+ }
304
+ else
305
+ {
306
+ const size_type __len =
307
+ _M_check_len(size_type(1), "vector::_M_insert_aux");
308
+ pointer __new_start(this->_M_allocate(__len));
309
+ pointer __new_finish(__new_start);
310
+ try
311
+ {
312
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
313
+ this->_M_impl.construct(__new_start + (__position - begin()),
314
+ std::forward<_Args>(__args)...);
315
+ #endif
316
+ __new_finish =
317
+ std::__uninitialized_move_a(this->_M_impl._M_start,
318
+ __position.base(), __new_start,
319
+ _M_get_Tp_allocator());
320
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
321
+ this->_M_impl.construct(__new_finish, __x);
322
+ #endif
323
+ ++__new_finish;
324
+ __new_finish =
325
+ std::__uninitialized_move_a(__position.base(),
326
+ this->_M_impl._M_finish,
327
+ __new_finish,
328
+ _M_get_Tp_allocator());
329
+ }
330
+ catch(...)
331
+ {
332
+ std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator());
333
+ _M_deallocate(__new_start, __len);
334
+ __throw_exception_again;
335
+ }
336
+ std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
337
+ _M_get_Tp_allocator());
338
+ _M_deallocate(this->_M_impl._M_start,
339
+ this->_M_impl._M_end_of_storage
340
+ - this->_M_impl._M_start);
341
+ this->_M_impl._M_start = __new_start;
342
+ this->_M_impl._M_finish = __new_finish;
343
+ this->_M_impl._M_end_of_storage = __new_start + __len;
344
+ }
345
+ }
346
+
347
+ template<typename _Tp, typename _Alloc>
348
+ void
349
+ vector<_Tp, _Alloc>::
350
+ _M_fill_insert(iterator __position, size_type __n, const value_type& __x)
351
+ {
352
+ if (__n != 0)
353
+ {
354
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
355
+ value_type __x_copy = __x;
356
+ #endif
357
+ if (size_type(this->_M_impl._M_end_of_storage
358
+ - this->_M_impl._M_finish) >= __n)
359
+ {
360
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
361
+ value_type __x_copy = __x;
362
+ #endif
363
+ const size_type __elems_after = end() - __position;
364
+ pointer __old_finish(this->_M_impl._M_finish);
365
+ if (__elems_after > __n)
366
+ {
367
+ std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
368
+ this->_M_impl._M_finish,
369
+ this->_M_impl._M_finish,
370
+ _M_get_Tp_allocator());
371
+ this->_M_impl._M_finish += __n;
372
+ _GLIBCXX_MOVE_BACKWARD3(__position.base(),
373
+ __old_finish - __n, __old_finish);
374
+ std::fill(__position.base(), __position.base() + __n,
375
+ __x_copy);
376
+ }
377
+ else
378
+ {
379
+ std::__uninitialized_fill_n_a(this->_M_impl._M_finish,
380
+ __n - __elems_after,
381
+ __x_copy,
382
+ _M_get_Tp_allocator());
383
+ this->_M_impl._M_finish += __n - __elems_after;
384
+ std::__uninitialized_move_a(__position.base(), __old_finish,
385
+ this->_M_impl._M_finish,
386
+ _M_get_Tp_allocator());
387
+ this->_M_impl._M_finish += __elems_after;
388
+ std::fill(__position.base(), __old_finish, __x_copy);
389
+ }
390
+ }
391
+ else
392
+ {
393
+ const size_type __len =
394
+ _M_check_len(__n, "vector::_M_fill_insert");
395
+ pointer __new_start(this->_M_allocate(__len));
396
+ pointer __new_finish(__new_start);
397
+ try
398
+ {
399
+ __new_finish =
400
+ std::__uninitialized_move_a(this->_M_impl._M_start,
401
+ __position.base(),
402
+ __new_start,
403
+ _M_get_Tp_allocator());
404
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
405
+ std::__uninitialized_fill_n_a(__new_finish, __n, __x_copy,
406
+ #else
407
+ std::__uninitialized_fill_n_a(__new_finish, __n, __x,
408
+ #endif
409
+ _M_get_Tp_allocator());
410
+ __new_finish += __n;
411
+ __new_finish =
412
+ std::__uninitialized_move_a(__position.base(),
413
+ this->_M_impl._M_finish,
414
+ __new_finish,
415
+ _M_get_Tp_allocator());
416
+ }
417
+ catch(...)
418
+ {
419
+ std::_Destroy(__new_start, __new_finish,
420
+ _M_get_Tp_allocator());
421
+ _M_deallocate(__new_start, __len);
422
+ __throw_exception_again;
423
+ }
424
+ std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
425
+ _M_get_Tp_allocator());
426
+ _M_deallocate(this->_M_impl._M_start,
427
+ this->_M_impl._M_end_of_storage
428
+ - this->_M_impl._M_start);
429
+ this->_M_impl._M_start = __new_start;
430
+ this->_M_impl._M_finish = __new_finish;
431
+ this->_M_impl._M_end_of_storage = __new_start + __len;
432
+ }
433
+ }
434
+ }
435
+
436
+ template<typename _Tp, typename _Alloc>
437
+ template<typename _InputIterator>
438
+ void
439
+ vector<_Tp, _Alloc>::
440
+ _M_range_insert(iterator __pos, _InputIterator __first,
441
+ _InputIterator __last, std::input_iterator_tag)
442
+ {
443
+ for (; __first != __last; ++__first)
444
+ {
445
+ __pos = insert(__pos, *__first);
446
+ ++__pos;
447
+ }
448
+ }
449
+
450
+ template<typename _Tp, typename _Alloc>
451
+ template<typename _ForwardIterator>
452
+ void
453
+ vector<_Tp, _Alloc>::
454
+ _M_range_insert(iterator __position, _ForwardIterator __first,
455
+ _ForwardIterator __last, std::forward_iterator_tag)
456
+ {
457
+ if (__first != __last)
458
+ {
459
+ const size_type __n = std::distance(__first, __last);
460
+ if (size_type(this->_M_impl._M_end_of_storage
461
+ - this->_M_impl._M_finish) >= __n)
462
+ {
463
+ const size_type __elems_after = end() - __position;
464
+ pointer __old_finish(this->_M_impl._M_finish);
465
+ if (__elems_after > __n)
466
+ {
467
+ std::__uninitialized_move_a(this->_M_impl._M_finish - __n,
468
+ this->_M_impl._M_finish,
469
+ this->_M_impl._M_finish,
470
+ _M_get_Tp_allocator());
471
+ this->_M_impl._M_finish += __n;
472
+ _GLIBCXX_MOVE_BACKWARD3(__position.base(),
473
+ __old_finish - __n, __old_finish);
474
+ std::copy(__first, __last, __position);
475
+ }
476
+ else
477
+ {
478
+ _ForwardIterator __mid = __first;
479
+ std::advance(__mid, __elems_after);
480
+ std::__uninitialized_copy_a(__mid, __last,
481
+ this->_M_impl._M_finish,
482
+ _M_get_Tp_allocator());
483
+ this->_M_impl._M_finish += __n - __elems_after;
484
+ std::__uninitialized_move_a(__position.base(),
485
+ __old_finish,
486
+ this->_M_impl._M_finish,
487
+ _M_get_Tp_allocator());
488
+ this->_M_impl._M_finish += __elems_after;
489
+ std::copy(__first, __mid, __position);
490
+ }
491
+ }
492
+ else
493
+ {
494
+ const size_type __len =
495
+ _M_check_len(__n, "vector::_M_range_insert");
496
+ pointer __new_start(this->_M_allocate(__len));
497
+ pointer __new_finish(__new_start);
498
+ try
499
+ {
500
+ __new_finish =
501
+ std::__uninitialized_move_a(this->_M_impl._M_start,
502
+ __position.base(),
503
+ __new_start,
504
+ _M_get_Tp_allocator());
505
+ __new_finish =
506
+ std::__uninitialized_copy_a(__first, __last,
507
+ __new_finish,
508
+ _M_get_Tp_allocator());
509
+ __new_finish =
510
+ std::__uninitialized_move_a(__position.base(),
511
+ this->_M_impl._M_finish,
512
+ __new_finish,
513
+ _M_get_Tp_allocator());
514
+ }
515
+ catch(...)
516
+ {
517
+ std::_Destroy(__new_start, __new_finish,
518
+ _M_get_Tp_allocator());
519
+ _M_deallocate(__new_start, __len);
520
+ __throw_exception_again;
521
+ }
522
+ std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
523
+ _M_get_Tp_allocator());
524
+ _M_deallocate(this->_M_impl._M_start,
525
+ this->_M_impl._M_end_of_storage
526
+ - this->_M_impl._M_start);
527
+ this->_M_impl._M_start = __new_start;
528
+ this->_M_impl._M_finish = __new_finish;
529
+ this->_M_impl._M_end_of_storage = __new_start + __len;
530
+ }
531
+ }
532
+ }
533
+
534
+
535
+ // vector<bool>
536
+
537
+ template<typename _Alloc>
538
+ void
539
+ vector<bool, _Alloc>::
540
+ reserve(size_type __n)
541
+ {
542
+ if (__n > this->max_size())
543
+ __throw_length_error(__N("vector::reserve"));
544
+ if (this->capacity() < __n)
545
+ {
546
+ _Bit_type* __q = this->_M_allocate(__n);
547
+ this->_M_impl._M_finish = _M_copy_aligned(begin(), end(),
548
+ iterator(__q, 0));
549
+ this->_M_deallocate();
550
+ this->_M_impl._M_start = iterator(__q, 0);
551
+ this->_M_impl._M_end_of_storage = (__q + (__n + int(_S_word_bit) - 1)
552
+ / int(_S_word_bit));
553
+ }
554
+ }
555
+
556
+ template<typename _Alloc>
557
+ void
558
+ vector<bool, _Alloc>::
559
+ _M_fill_insert(iterator __position, size_type __n, bool __x)
560
+ {
561
+ if (__n == 0)
562
+ return;
563
+ if (capacity() - size() >= __n)
564
+ {
565
+ std::copy_backward(__position, end(),
566
+ this->_M_impl._M_finish + difference_type(__n));
567
+ std::fill(__position, __position + difference_type(__n), __x);
568
+ this->_M_impl._M_finish += difference_type(__n);
569
+ }
570
+ else
571
+ {
572
+ const size_type __len =
573
+ _M_check_len(__n, "vector<bool>::_M_fill_insert");
574
+ _Bit_type * __q = this->_M_allocate(__len);
575
+ iterator __i = _M_copy_aligned(begin(), __position,
576
+ iterator(__q, 0));
577
+ std::fill(__i, __i + difference_type(__n), __x);
578
+ this->_M_impl._M_finish = std::copy(__position, end(),
579
+ __i + difference_type(__n));
580
+ this->_M_deallocate();
581
+ this->_M_impl._M_end_of_storage = (__q + ((__len
582
+ + int(_S_word_bit) - 1)
583
+ / int(_S_word_bit)));
584
+ this->_M_impl._M_start = iterator(__q, 0);
585
+ }
586
+ }
587
+
588
+ template<typename _Alloc>
589
+ template<typename _ForwardIterator>
590
+ void
591
+ vector<bool, _Alloc>::
592
+ _M_insert_range(iterator __position, _ForwardIterator __first,
593
+ _ForwardIterator __last, std::forward_iterator_tag)
594
+ {
595
+ if (__first != __last)
596
+ {
597
+ size_type __n = std::distance(__first, __last);
598
+ if (capacity() - size() >= __n)
599
+ {
600
+ std::copy_backward(__position, end(),
601
+ this->_M_impl._M_finish
602
+ + difference_type(__n));
603
+ std::copy(__first, __last, __position);
604
+ this->_M_impl._M_finish += difference_type(__n);
605
+ }
606
+ else
607
+ {
608
+ const size_type __len =
609
+ _M_check_len(__n, "vector<bool>::_M_insert_range");
610
+ _Bit_type * __q = this->_M_allocate(__len);
611
+ iterator __i = _M_copy_aligned(begin(), __position,
612
+ iterator(__q, 0));
613
+ __i = std::copy(__first, __last, __i);
614
+ this->_M_impl._M_finish = std::copy(__position, end(), __i);
615
+ this->_M_deallocate();
616
+ this->_M_impl._M_end_of_storage = (__q
617
+ + ((__len
618
+ + int(_S_word_bit) - 1)
619
+ / int(_S_word_bit)));
620
+ this->_M_impl._M_start = iterator(__q, 0);
621
+ }
622
+ }
623
+ }
624
+
625
+ template<typename _Alloc>
626
+ void
627
+ vector<bool, _Alloc>::
628
+ _M_insert_aux(iterator __position, bool __x)
629
+ {
630
+ if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage)
631
+ {
632
+ std::copy_backward(__position, this->_M_impl._M_finish,
633
+ this->_M_impl._M_finish + 1);
634
+ *__position = __x;
635
+ ++this->_M_impl._M_finish;
636
+ }
637
+ else
638
+ {
639
+ const size_type __len =
640
+ _M_check_len(size_type(1), "vector<bool>::_M_insert_aux");
641
+ _Bit_type * __q = this->_M_allocate(__len);
642
+ iterator __i = _M_copy_aligned(begin(), __position,
643
+ iterator(__q, 0));
644
+ *__i++ = __x;
645
+ this->_M_impl._M_finish = std::copy(__position, end(), __i);
646
+ this->_M_deallocate();
647
+ this->_M_impl._M_end_of_storage = (__q + ((__len
648
+ + int(_S_word_bit) - 1)
649
+ / int(_S_word_bit)));
650
+ this->_M_impl._M_start = iterator(__q, 0);
651
+ }
652
+ }
653
+
654
+ _GLIBCXX_END_NESTED_NAMESPACE
655
+
656
+ #endif /* _VECTOR_TCC */
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/bitset ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging bitset implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file debug/bitset
31
+ * This file is a GNU debug extension to the Standard C++ Library.
32
+ */
33
+
34
+ #ifndef _GLIBCXX_DEBUG_BITSET
35
+ #define _GLIBCXX_DEBUG_BITSET
36
+
37
+ #include <bitset>
38
+ #include <debug/safe_sequence.h>
39
+ #include <debug/safe_iterator.h>
40
+
41
+ namespace std
42
+ {
43
+ namespace __debug
44
+ {
45
+ template<size_t _Nb>
46
+ class bitset
47
+ : public _GLIBCXX_STD_D::bitset<_Nb>,
48
+ public __gnu_debug::_Safe_sequence_base
49
+ {
50
+ typedef _GLIBCXX_STD_D::bitset<_Nb> _Base;
51
+ typedef __gnu_debug::_Safe_sequence_base _Safe_base;
52
+
53
+ public:
54
+ // bit reference:
55
+ class reference
56
+ : private _Base::reference, public __gnu_debug::_Safe_iterator_base
57
+ {
58
+ typedef typename _Base::reference _Base_ref;
59
+
60
+ friend class bitset;
61
+ reference();
62
+
63
+ reference(const _Base_ref& __base, bitset* __seq)
64
+ : _Base_ref(__base), _Safe_iterator_base(__seq, false)
65
+ { }
66
+
67
+ public:
68
+ reference(const reference& __x)
69
+ : _Base_ref(__x), _Safe_iterator_base(__x, false)
70
+ { }
71
+
72
+ reference&
73
+ operator=(bool __x)
74
+ {
75
+ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
76
+ _M_message(__gnu_debug::__msg_bad_bitset_write)
77
+ ._M_iterator(*this));
78
+ *static_cast<_Base_ref*>(this) = __x;
79
+ return *this;
80
+ }
81
+
82
+ reference&
83
+ operator=(const reference& __x)
84
+ {
85
+ _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(),
86
+ _M_message(__gnu_debug::__msg_bad_bitset_read)
87
+ ._M_iterator(__x));
88
+ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
89
+ _M_message(__gnu_debug::__msg_bad_bitset_write)
90
+ ._M_iterator(*this));
91
+ *static_cast<_Base_ref*>(this) = __x;
92
+ return *this;
93
+ }
94
+
95
+ bool
96
+ operator~() const
97
+ {
98
+ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
99
+ _M_message(__gnu_debug::__msg_bad_bitset_read)
100
+ ._M_iterator(*this));
101
+ return ~(*static_cast<const _Base_ref*>(this));
102
+ }
103
+
104
+ operator bool() const
105
+ {
106
+ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
107
+ _M_message(__gnu_debug::__msg_bad_bitset_read)
108
+ ._M_iterator(*this));
109
+ return *static_cast<const _Base_ref*>(this);
110
+ }
111
+
112
+ reference&
113
+ flip()
114
+ {
115
+ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
116
+ _M_message(__gnu_debug::__msg_bad_bitset_flip)
117
+ ._M_iterator(*this));
118
+ _Base_ref::flip();
119
+ return *this;
120
+ }
121
+ };
122
+
123
+ // 23.3.5.1 constructors:
124
+ bitset() : _Base() { }
125
+
126
+ bitset(unsigned long __val) : _Base(__val) { }
127
+
128
+ template<typename _CharT, typename _Traits, typename _Allocator>
129
+ explicit
130
+ bitset(const std::basic_string<_CharT,_Traits,_Allocator>& __str,
131
+ typename std::basic_string<_CharT,_Traits,_Allocator>::size_type
132
+ __pos = 0,
133
+ typename std::basic_string<_CharT,_Traits,_Allocator>::size_type
134
+ __n = (std::basic_string<_CharT,_Traits,_Allocator>::npos))
135
+ : _Base(__str, __pos, __n) { }
136
+
137
+ bitset(const _Base& __x) : _Base(__x), _Safe_base() { }
138
+
139
+ // 23.3.5.2 bitset operations:
140
+ bitset<_Nb>&
141
+ operator&=(const bitset<_Nb>& __rhs)
142
+ {
143
+ _M_base() &= __rhs;
144
+ return *this;
145
+ }
146
+
147
+ bitset<_Nb>&
148
+ operator|=(const bitset<_Nb>& __rhs)
149
+ {
150
+ _M_base() |= __rhs;
151
+ return *this;
152
+ }
153
+
154
+ bitset<_Nb>&
155
+ operator^=(const bitset<_Nb>& __rhs)
156
+ {
157
+ _M_base() ^= __rhs;
158
+ return *this;
159
+ }
160
+
161
+ bitset<_Nb>&
162
+ operator<<=(size_t __pos)
163
+ {
164
+ _M_base() <<= __pos;
165
+ return *this;
166
+ }
167
+
168
+ bitset<_Nb>&
169
+ operator>>=(size_t __pos)
170
+ {
171
+ _M_base() >>= __pos;
172
+ return *this;
173
+ }
174
+
175
+ bitset<_Nb>&
176
+ set()
177
+ {
178
+ _Base::set();
179
+ return *this;
180
+ }
181
+
182
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
183
+ // 186. bitset::set() second parameter should be bool
184
+ bitset<_Nb>&
185
+ set(size_t __pos, bool __val = true)
186
+ {
187
+ _Base::set(__pos, __val);
188
+ return *this;
189
+ }
190
+
191
+ bitset<_Nb>&
192
+ reset()
193
+ {
194
+ _Base::reset();
195
+ return *this;
196
+ }
197
+
198
+ bitset<_Nb>&
199
+ reset(size_t __pos)
200
+ {
201
+ _Base::reset(__pos);
202
+ return *this;
203
+ }
204
+
205
+ bitset<_Nb> operator~() const { return bitset(~_M_base()); }
206
+
207
+ bitset<_Nb>&
208
+ flip()
209
+ {
210
+ _Base::flip();
211
+ return *this;
212
+ }
213
+
214
+ bitset<_Nb>&
215
+ flip(size_t __pos)
216
+ {
217
+ _Base::flip(__pos);
218
+ return *this;
219
+ }
220
+
221
+ // element access:
222
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
223
+ // 11. Bitset minor problems
224
+ reference
225
+ operator[](size_t __pos)
226
+ {
227
+ __glibcxx_check_subscript(__pos);
228
+ return reference(_M_base()[__pos], this);
229
+ }
230
+
231
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
232
+ // 11. Bitset minor problems
233
+ bool
234
+ operator[](size_t __pos) const
235
+ {
236
+ __glibcxx_check_subscript(__pos);
237
+ return _M_base()[__pos];
238
+ }
239
+
240
+ using _Base::to_ulong;
241
+
242
+ template <typename _CharT, typename _Traits, typename _Allocator>
243
+ std::basic_string<_CharT, _Traits, _Allocator>
244
+ to_string() const
245
+ { return _M_base().template to_string<_CharT, _Traits, _Allocator>(); }
246
+
247
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
248
+ // 434. bitset::to_string() hard to use.
249
+ template<typename _CharT, typename _Traits>
250
+ std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
251
+ to_string() const
252
+ { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
253
+
254
+ template<typename _CharT>
255
+ std::basic_string<_CharT, std::char_traits<_CharT>,
256
+ std::allocator<_CharT> >
257
+ to_string() const
258
+ {
259
+ return to_string<_CharT, std::char_traits<_CharT>,
260
+ std::allocator<_CharT> >();
261
+ }
262
+
263
+ std::basic_string<char, std::char_traits<char>, std::allocator<char> >
264
+ to_string() const
265
+ {
266
+ return to_string<char,std::char_traits<char>,std::allocator<char> >();
267
+ }
268
+
269
+ using _Base::count;
270
+ using _Base::size;
271
+
272
+ bool
273
+ operator==(const bitset<_Nb>& __rhs) const
274
+ { return _M_base() == __rhs; }
275
+
276
+ bool
277
+ operator!=(const bitset<_Nb>& __rhs) const
278
+ { return _M_base() != __rhs; }
279
+
280
+ using _Base::test;
281
+ using _Base::all;
282
+ using _Base::any;
283
+ using _Base::none;
284
+
285
+ bitset<_Nb>
286
+ operator<<(size_t __pos) const
287
+ { return bitset<_Nb>(_M_base() << __pos); }
288
+
289
+ bitset<_Nb>
290
+ operator>>(size_t __pos) const
291
+ { return bitset<_Nb>(_M_base() >> __pos); }
292
+
293
+ _Base&
294
+ _M_base() { return *this; }
295
+
296
+ const _Base&
297
+ _M_base() const { return *this; }
298
+ };
299
+
300
+ template<size_t _Nb>
301
+ bitset<_Nb>
302
+ operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
303
+ { return bitset<_Nb>(__x) &= __y; }
304
+
305
+ template<size_t _Nb>
306
+ bitset<_Nb>
307
+ operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
308
+ { return bitset<_Nb>(__x) |= __y; }
309
+
310
+ template<size_t _Nb>
311
+ bitset<_Nb>
312
+ operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
313
+ { return bitset<_Nb>(__x) ^= __y; }
314
+
315
+ template<typename _CharT, typename _Traits, size_t _Nb>
316
+ std::basic_istream<_CharT, _Traits>&
317
+ operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
318
+ { return __is >> __x._M_base(); }
319
+
320
+ template<typename _CharT, typename _Traits, size_t _Nb>
321
+ std::basic_ostream<_CharT, _Traits>&
322
+ operator<<(std::basic_ostream<_CharT, _Traits>& __os,
323
+ const bitset<_Nb>& __x)
324
+ { return __os << __x._M_base(); }
325
+ } // namespace __debug
326
+ } // namespace std
327
+
328
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/debug.h ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging support implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/debug.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
36
+ #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
37
+
38
+ /** Macros and namespaces used by the implementation outside of debug
39
+ * wrappers to verify certain properties. The __glibcxx_requires_xxx
40
+ * macros are merely wrappers around the __glibcxx_check_xxx wrappers
41
+ * when we are compiling with debug mode, but disappear when we are
42
+ * in release mode so that there is no checking performed in, e.g.,
43
+ * the standard library algorithms.
44
+ */
45
+
46
+ // Debug mode namespaces.
47
+
48
+ /**
49
+ * @namespace std::__debug
50
+ * @brief GNU debug code, replaces standard behavior with debug behavior.
51
+ */
52
+ namespace std
53
+ {
54
+ namespace __debug { }
55
+ }
56
+
57
+ /** @namespace __gnu_debug
58
+ * @brief GNU debug classes for public use.
59
+ */
60
+ namespace __gnu_debug
61
+ {
62
+ using namespace std::__debug;
63
+ }
64
+
65
+ #ifndef _GLIBCXX_DEBUG
66
+
67
+ # define _GLIBCXX_DEBUG_ASSERT(_Condition)
68
+ # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
69
+ # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
70
+ # define __glibcxx_requires_cond(_Cond,_Msg)
71
+ # define __glibcxx_requires_valid_range(_First,_Last)
72
+ # define __glibcxx_requires_sorted(_First,_Last)
73
+ # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
74
+ # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
75
+ # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
76
+ # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
77
+ # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
78
+ # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
79
+ # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
80
+ # define __glibcxx_requires_heap(_First,_Last)
81
+ # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
82
+ # define __glibcxx_requires_nonempty()
83
+ # define __glibcxx_requires_string(_String)
84
+ # define __glibcxx_requires_string_len(_String,_Len)
85
+ # define __glibcxx_requires_subscript(_N)
86
+
87
+ #else
88
+
89
+ # include <cstdio>
90
+ # include <debug/macros.h>
91
+
92
+ namespace std
93
+ {
94
+ namespace __debug
95
+ {
96
+ // Avoid the use of assert, because we're trying to keep the <cassert>
97
+ // include out of the mix.
98
+ inline void
99
+ __replacement_assert(const char* __file, int __line,
100
+ const char* __function, const char* __condition)
101
+ {
102
+ printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
103
+ __function, __condition);
104
+ __builtin_abort();
105
+ }
106
+ } // namespace __debug
107
+ } // namespace std
108
+
109
+ #define _GLIBCXX_DEBUG_ASSERT(_Condition) \
110
+ do \
111
+ { \
112
+ if (! (_Condition)) \
113
+ std::__debug::__replacement_assert(__FILE__, __LINE__, \
114
+ __PRETTY_FUNCTION__, #_Condition); \
115
+ } while (false)
116
+
117
+ #ifdef _GLIBCXX_DEBUG_PEDANTIC
118
+ # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
119
+ #else
120
+ # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
121
+ #endif
122
+
123
+ # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
124
+
125
+ # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
126
+ # define __glibcxx_requires_valid_range(_First,_Last) \
127
+ __glibcxx_check_valid_range(_First,_Last)
128
+ # define __glibcxx_requires_sorted(_First,_Last) \
129
+ __glibcxx_check_sorted(_First,_Last)
130
+ # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
131
+ __glibcxx_check_sorted_pred(_First,_Last,_Pred)
132
+ # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
133
+ __glibcxx_check_sorted_set(_First1,_Last1,_First2)
134
+ # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
135
+ __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
136
+ # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
137
+ __glibcxx_check_partitioned_lower(_First,_Last,_Value)
138
+ # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
139
+ __glibcxx_check_partitioned_upper(_First,_Last,_Value)
140
+ # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
141
+ __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
142
+ # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
143
+ __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
144
+ # define __glibcxx_requires_heap(_First,_Last) \
145
+ __glibcxx_check_heap(_First,_Last)
146
+ # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
147
+ __glibcxx_check_heap_pred(_First,_Last,_Pred)
148
+ # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
149
+ # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
150
+ # define __glibcxx_requires_string_len(_String,_Len) \
151
+ __glibcxx_check_string_len(_String,_Len)
152
+ # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
153
+
154
+ # include <debug/functions.h>
155
+ # include <debug/formatter.h>
156
+
157
+ #endif
158
+
159
+ #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/deque ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging deque implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/deque
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_DEQUE
36
+ #define _GLIBCXX_DEBUG_DEQUE 1
37
+
38
+ #include <deque>
39
+ #include <debug/safe_sequence.h>
40
+ #include <debug/safe_iterator.h>
41
+
42
+ namespace std
43
+ {
44
+ namespace __debug
45
+ {
46
+ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
47
+ class deque
48
+ : public _GLIBCXX_STD_D::deque<_Tp, _Allocator>,
49
+ public __gnu_debug::_Safe_sequence<deque<_Tp, _Allocator> >
50
+ {
51
+ typedef _GLIBCXX_STD_D::deque<_Tp, _Allocator> _Base;
52
+ typedef __gnu_debug::_Safe_sequence<deque> _Safe_base;
53
+
54
+ public:
55
+ typedef typename _Base::reference reference;
56
+ typedef typename _Base::const_reference const_reference;
57
+
58
+ typedef __gnu_debug::_Safe_iterator<typename _Base::iterator,deque>
59
+ iterator;
60
+ typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,deque>
61
+ const_iterator;
62
+
63
+ typedef typename _Base::size_type size_type;
64
+ typedef typename _Base::difference_type difference_type;
65
+
66
+ typedef _Tp value_type;
67
+ typedef _Allocator allocator_type;
68
+ typedef typename _Base::pointer pointer;
69
+ typedef typename _Base::const_pointer const_pointer;
70
+ typedef std::reverse_iterator<iterator> reverse_iterator;
71
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
72
+
73
+ // 23.2.1.1 construct/copy/destroy:
74
+ explicit deque(const _Allocator& __a = _Allocator())
75
+ : _Base(__a) { }
76
+
77
+ explicit deque(size_type __n, const _Tp& __value = _Tp(),
78
+ const _Allocator& __a = _Allocator())
79
+ : _Base(__n, __value, __a) { }
80
+
81
+ template<class _InputIterator>
82
+ deque(_InputIterator __first, _InputIterator __last,
83
+ const _Allocator& __a = _Allocator())
84
+ : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __a)
85
+ { }
86
+
87
+ deque(const deque& __x)
88
+ : _Base(__x), _Safe_base() { }
89
+
90
+ deque(const _Base& __x)
91
+ : _Base(__x), _Safe_base() { }
92
+
93
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
94
+ deque(deque&& __x)
95
+ : _Base(std::forward<deque>(__x)), _Safe_base()
96
+ { this->_M_swap(__x); }
97
+ #endif
98
+
99
+ ~deque() { }
100
+
101
+ deque&
102
+ operator=(const deque& __x)
103
+ {
104
+ *static_cast<_Base*>(this) = __x;
105
+ this->_M_invalidate_all();
106
+ return *this;
107
+ }
108
+
109
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
110
+ deque&
111
+ operator=(deque&& __x)
112
+ {
113
+ // NB: DR 675.
114
+ clear();
115
+ swap(__x);
116
+ return *this;
117
+ }
118
+ #endif
119
+
120
+ template<class _InputIterator>
121
+ void
122
+ assign(_InputIterator __first, _InputIterator __last)
123
+ {
124
+ __glibcxx_check_valid_range(__first, __last);
125
+ _Base::assign(__first, __last);
126
+ this->_M_invalidate_all();
127
+ }
128
+
129
+ void
130
+ assign(size_type __n, const _Tp& __t)
131
+ {
132
+ _Base::assign(__n, __t);
133
+ this->_M_invalidate_all();
134
+ }
135
+
136
+ using _Base::get_allocator;
137
+
138
+ // iterators:
139
+ iterator
140
+ begin()
141
+ { return iterator(_Base::begin(), this); }
142
+
143
+ const_iterator
144
+ begin() const
145
+ { return const_iterator(_Base::begin(), this); }
146
+
147
+ iterator
148
+ end()
149
+ { return iterator(_Base::end(), this); }
150
+
151
+ const_iterator
152
+ end() const
153
+ { return const_iterator(_Base::end(), this); }
154
+
155
+ reverse_iterator
156
+ rbegin()
157
+ { return reverse_iterator(end()); }
158
+
159
+ const_reverse_iterator
160
+ rbegin() const
161
+ { return const_reverse_iterator(end()); }
162
+
163
+ reverse_iterator
164
+ rend()
165
+ { return reverse_iterator(begin()); }
166
+
167
+ const_reverse_iterator
168
+ rend() const
169
+ { return const_reverse_iterator(begin()); }
170
+
171
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
172
+ const_iterator
173
+ cbegin() const
174
+ { return const_iterator(_Base::begin(), this); }
175
+
176
+ const_iterator
177
+ cend() const
178
+ { return const_iterator(_Base::end(), this); }
179
+
180
+ const_reverse_iterator
181
+ crbegin() const
182
+ { return const_reverse_iterator(end()); }
183
+
184
+ const_reverse_iterator
185
+ crend() const
186
+ { return const_reverse_iterator(begin()); }
187
+ #endif
188
+
189
+ // 23.2.1.2 capacity:
190
+ using _Base::size;
191
+ using _Base::max_size;
192
+
193
+ void
194
+ resize(size_type __sz, _Tp __c = _Tp())
195
+ {
196
+ typedef typename _Base::const_iterator _Base_const_iterator;
197
+ typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
198
+
199
+ bool __invalidate_all = __sz > this->size();
200
+ if (__sz < this->size())
201
+ this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
202
+
203
+ _Base::resize(__sz, __c);
204
+
205
+ if (__invalidate_all)
206
+ this->_M_invalidate_all();
207
+ }
208
+
209
+ using _Base::empty;
210
+
211
+ // element access:
212
+ reference
213
+ operator[](size_type __n)
214
+ {
215
+ __glibcxx_check_subscript(__n);
216
+ return _M_base()[__n];
217
+ }
218
+
219
+ const_reference
220
+ operator[](size_type __n) const
221
+ {
222
+ __glibcxx_check_subscript(__n);
223
+ return _M_base()[__n];
224
+ }
225
+
226
+ using _Base::at;
227
+
228
+ reference
229
+ front()
230
+ {
231
+ __glibcxx_check_nonempty();
232
+ return _Base::front();
233
+ }
234
+
235
+ const_reference
236
+ front() const
237
+ {
238
+ __glibcxx_check_nonempty();
239
+ return _Base::front();
240
+ }
241
+
242
+ reference
243
+ back()
244
+ {
245
+ __glibcxx_check_nonempty();
246
+ return _Base::back();
247
+ }
248
+
249
+ const_reference
250
+ back() const
251
+ {
252
+ __glibcxx_check_nonempty();
253
+ return _Base::back();
254
+ }
255
+
256
+ // 23.2.1.3 modifiers:
257
+ #ifndef __GXX_EXPERIMENTAL_CXX0X__
258
+ void
259
+ push_front(const _Tp& __x)
260
+ {
261
+ _Base::push_front(__x);
262
+ this->_M_invalidate_all();
263
+ }
264
+
265
+ void
266
+ push_back(const _Tp& __x)
267
+ {
268
+ _Base::push_back(__x);
269
+ this->_M_invalidate_all();
270
+ }
271
+ #else
272
+ template<typename... _Args>
273
+ void
274
+ push_front(_Args&&... __args)
275
+ {
276
+ _Base::push_front(std::forward<_Args>(__args)...);
277
+ this->_M_invalidate_all();
278
+ }
279
+
280
+ template<typename... _Args>
281
+ void
282
+ push_back(_Args&&... __args)
283
+ {
284
+ _Base::push_back(std::forward<_Args>(__args)...);
285
+ this->_M_invalidate_all();
286
+ }
287
+
288
+ template<typename... _Args>
289
+ iterator
290
+ emplace(iterator __position, _Args&&... __args)
291
+ {
292
+ __glibcxx_check_insert(__position);
293
+ typename _Base::iterator __res = _Base::emplace(__position.base(),
294
+ std::forward<_Args>(__args)...);
295
+ this->_M_invalidate_all();
296
+ return iterator(__res, this);
297
+ }
298
+ #endif
299
+
300
+ iterator
301
+ insert(iterator __position, const _Tp& __x)
302
+ {
303
+ __glibcxx_check_insert(__position);
304
+ typename _Base::iterator __res = _Base::insert(__position.base(), __x);
305
+ this->_M_invalidate_all();
306
+ return iterator(__res, this);
307
+ }
308
+
309
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
310
+ iterator
311
+ insert(iterator __position, _Tp&& __x)
312
+ { return emplace(__position, std::move(__x)); }
313
+ #endif
314
+
315
+ void
316
+ insert(iterator __position, size_type __n, const _Tp& __x)
317
+ {
318
+ __glibcxx_check_insert(__position);
319
+ _Base::insert(__position.base(), __n, __x);
320
+ this->_M_invalidate_all();
321
+ }
322
+
323
+ template<class _InputIterator>
324
+ void
325
+ insert(iterator __position,
326
+ _InputIterator __first, _InputIterator __last)
327
+ {
328
+ __glibcxx_check_insert_range(__position, __first, __last);
329
+ _Base::insert(__position.base(), __first, __last);
330
+ this->_M_invalidate_all();
331
+ }
332
+
333
+ void
334
+ pop_front()
335
+ {
336
+ __glibcxx_check_nonempty();
337
+ iterator __victim = begin();
338
+ __victim._M_invalidate();
339
+ _Base::pop_front();
340
+ }
341
+
342
+ void
343
+ pop_back()
344
+ {
345
+ __glibcxx_check_nonempty();
346
+ iterator __victim = end();
347
+ --__victim;
348
+ __victim._M_invalidate();
349
+ _Base::pop_back();
350
+ }
351
+
352
+ iterator
353
+ erase(iterator __position)
354
+ {
355
+ __glibcxx_check_erase(__position);
356
+ if (__position == begin() || __position == end()-1)
357
+ {
358
+ __position._M_invalidate();
359
+ return iterator(_Base::erase(__position.base()), this);
360
+ }
361
+ else
362
+ {
363
+ typename _Base::iterator __res = _Base::erase(__position.base());
364
+ this->_M_invalidate_all();
365
+ return iterator(__res, this);
366
+ }
367
+ }
368
+
369
+ iterator
370
+ erase(iterator __first, iterator __last)
371
+ {
372
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
373
+ // 151. can't currently clear() empty container
374
+ __glibcxx_check_erase_range(__first, __last);
375
+ if (__first == begin() || __last == end())
376
+ {
377
+ this->_M_detach_singular();
378
+ for (iterator __position = __first; __position != __last; )
379
+ {
380
+ iterator __victim = __position++;
381
+ __victim._M_invalidate();
382
+ }
383
+ try
384
+ {
385
+ return iterator(_Base::erase(__first.base(), __last.base()),
386
+ this);
387
+ }
388
+ catch(...)
389
+ {
390
+ this->_M_revalidate_singular();
391
+ __throw_exception_again;
392
+ }
393
+ }
394
+ else
395
+ {
396
+ typename _Base::iterator __res = _Base::erase(__first.base(),
397
+ __last.base());
398
+ this->_M_invalidate_all();
399
+ return iterator(__res, this);
400
+ }
401
+ }
402
+
403
+ void
404
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
405
+ swap(deque&& __x)
406
+ #else
407
+ swap(deque& __x)
408
+ #endif
409
+ {
410
+ _Base::swap(__x);
411
+ this->_M_swap(__x);
412
+ }
413
+
414
+ void
415
+ clear()
416
+ {
417
+ _Base::clear();
418
+ this->_M_invalidate_all();
419
+ }
420
+
421
+ _Base&
422
+ _M_base() { return *this; }
423
+
424
+ const _Base&
425
+ _M_base() const { return *this; }
426
+ };
427
+
428
+ template<typename _Tp, typename _Alloc>
429
+ inline bool
430
+ operator==(const deque<_Tp, _Alloc>& __lhs,
431
+ const deque<_Tp, _Alloc>& __rhs)
432
+ { return __lhs._M_base() == __rhs._M_base(); }
433
+
434
+ template<typename _Tp, typename _Alloc>
435
+ inline bool
436
+ operator!=(const deque<_Tp, _Alloc>& __lhs,
437
+ const deque<_Tp, _Alloc>& __rhs)
438
+ { return __lhs._M_base() != __rhs._M_base(); }
439
+
440
+ template<typename _Tp, typename _Alloc>
441
+ inline bool
442
+ operator<(const deque<_Tp, _Alloc>& __lhs,
443
+ const deque<_Tp, _Alloc>& __rhs)
444
+ { return __lhs._M_base() < __rhs._M_base(); }
445
+
446
+ template<typename _Tp, typename _Alloc>
447
+ inline bool
448
+ operator<=(const deque<_Tp, _Alloc>& __lhs,
449
+ const deque<_Tp, _Alloc>& __rhs)
450
+ { return __lhs._M_base() <= __rhs._M_base(); }
451
+
452
+ template<typename _Tp, typename _Alloc>
453
+ inline bool
454
+ operator>=(const deque<_Tp, _Alloc>& __lhs,
455
+ const deque<_Tp, _Alloc>& __rhs)
456
+ { return __lhs._M_base() >= __rhs._M_base(); }
457
+
458
+ template<typename _Tp, typename _Alloc>
459
+ inline bool
460
+ operator>(const deque<_Tp, _Alloc>& __lhs,
461
+ const deque<_Tp, _Alloc>& __rhs)
462
+ { return __lhs._M_base() > __rhs._M_base(); }
463
+
464
+ template<typename _Tp, typename _Alloc>
465
+ inline void
466
+ swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
467
+ { __lhs.swap(__rhs); }
468
+
469
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
470
+ template<typename _Tp, typename _Alloc>
471
+ inline void
472
+ swap(deque<_Tp, _Alloc>&& __lhs, deque<_Tp, _Alloc>& __rhs)
473
+ { __lhs.swap(__rhs); }
474
+
475
+ template<typename _Tp, typename _Alloc>
476
+ inline void
477
+ swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>&& __rhs)
478
+ { __lhs.swap(__rhs); }
479
+ #endif
480
+
481
+ } // namespace __debug
482
+ } // namespace std
483
+
484
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/formatter.h ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debug-mode error formatting implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file debug/formatter.h
31
+ * This file is a GNU debug extension to the Standard C++ Library.
32
+ */
33
+
34
+ #ifndef _GLIBCXX_DEBUG_FORMATTER_H
35
+ #define _GLIBCXX_DEBUG_FORMATTER_H 1
36
+
37
+ #include <typeinfo>
38
+ #include <debug/debug.h>
39
+
40
+ namespace __gnu_debug
41
+ {
42
+ using std::type_info;
43
+
44
+ /** Determine if the two types are the same. */
45
+ template<typename _Type1, typename _Type2>
46
+ struct __is_same
47
+ {
48
+ static const bool value = false;
49
+ };
50
+
51
+ template<typename _Type>
52
+ struct __is_same<_Type, _Type>
53
+ {
54
+ static const bool value = true;
55
+ };
56
+
57
+ template<bool> struct __truth { };
58
+
59
+ class _Safe_sequence_base;
60
+
61
+ template<typename _Iterator, typename _Sequence>
62
+ class _Safe_iterator;
63
+
64
+ template<typename _Sequence>
65
+ class _Safe_sequence;
66
+
67
+ enum _Debug_msg_id
68
+ {
69
+ // General checks
70
+ __msg_valid_range,
71
+ __msg_insert_singular,
72
+ __msg_insert_different,
73
+ __msg_erase_bad,
74
+ __msg_erase_different,
75
+ __msg_subscript_oob,
76
+ __msg_empty,
77
+ __msg_unpartitioned,
78
+ __msg_unpartitioned_pred,
79
+ __msg_unsorted,
80
+ __msg_unsorted_pred,
81
+ __msg_not_heap,
82
+ __msg_not_heap_pred,
83
+ // std::bitset checks
84
+ __msg_bad_bitset_write,
85
+ __msg_bad_bitset_read,
86
+ __msg_bad_bitset_flip,
87
+ // std::list checks
88
+ __msg_self_splice,
89
+ __msg_splice_alloc,
90
+ __msg_splice_bad,
91
+ __msg_splice_other,
92
+ __msg_splice_overlap,
93
+ // iterator checks
94
+ __msg_init_singular,
95
+ __msg_init_copy_singular,
96
+ __msg_init_const_singular,
97
+ __msg_copy_singular,
98
+ __msg_bad_deref,
99
+ __msg_bad_inc,
100
+ __msg_bad_dec,
101
+ __msg_iter_subscript_oob,
102
+ __msg_advance_oob,
103
+ __msg_retreat_oob,
104
+ __msg_iter_compare_bad,
105
+ __msg_compare_different,
106
+ __msg_iter_order_bad,
107
+ __msg_order_different,
108
+ __msg_distance_bad,
109
+ __msg_distance_different,
110
+ // istream_iterator
111
+ __msg_deref_istream,
112
+ __msg_inc_istream,
113
+ // ostream_iterator
114
+ __msg_output_ostream,
115
+ // istreambuf_iterator
116
+ __msg_deref_istreambuf,
117
+ __msg_inc_istreambuf
118
+ };
119
+
120
+ class _Error_formatter
121
+ {
122
+ /// Whether an iterator is constant, mutable, or unknown
123
+ enum _Constness
124
+ {
125
+ __unknown_constness,
126
+ __const_iterator,
127
+ __mutable_iterator,
128
+ __last_constness
129
+ };
130
+
131
+ // The state of the iterator (fine-grained), if we know it.
132
+ enum _Iterator_state
133
+ {
134
+ __unknown_state,
135
+ __singular, // singular, may still be attached to a sequence
136
+ __begin, // dereferenceable, and at the beginning
137
+ __middle, // dereferenceable, not at the beginning
138
+ __end, // past-the-end, may be at beginning if sequence empty
139
+ __last_state
140
+ };
141
+
142
+ // Tags denoting the type of parameter for construction
143
+ struct _Is_iterator { };
144
+ struct _Is_sequence { };
145
+
146
+ // A parameter that may be referenced by an error message
147
+ struct _Parameter
148
+ {
149
+ enum
150
+ {
151
+ __unused_param,
152
+ __iterator,
153
+ __sequence,
154
+ __integer,
155
+ __string
156
+ } _M_kind;
157
+
158
+ union
159
+ {
160
+ // When _M_kind == __iterator
161
+ struct
162
+ {
163
+ const char* _M_name;
164
+ const void* _M_address;
165
+ const type_info* _M_type;
166
+ _Constness _M_constness;
167
+ _Iterator_state _M_state;
168
+ const void* _M_sequence;
169
+ const type_info* _M_seq_type;
170
+ } _M_iterator;
171
+
172
+ // When _M_kind == __sequence
173
+ struct
174
+ {
175
+ const char* _M_name;
176
+ const void* _M_address;
177
+ const type_info* _M_type;
178
+ } _M_sequence;
179
+
180
+ // When _M_kind == __integer
181
+ struct
182
+ {
183
+ const char* _M_name;
184
+ long _M_value;
185
+ } _M_integer;
186
+
187
+ // When _M_kind == __string
188
+ struct
189
+ {
190
+ const char* _M_name;
191
+ const char* _M_value;
192
+ } _M_string;
193
+ } _M_variant;
194
+
195
+ _Parameter() : _M_kind(__unused_param), _M_variant() { }
196
+
197
+ _Parameter(long __value, const char* __name)
198
+ : _M_kind(__integer), _M_variant()
199
+ {
200
+ _M_variant._M_integer._M_name = __name;
201
+ _M_variant._M_integer._M_value = __value;
202
+ }
203
+
204
+ _Parameter(const char* __value, const char* __name)
205
+ : _M_kind(__string), _M_variant()
206
+ {
207
+ _M_variant._M_string._M_name = __name;
208
+ _M_variant._M_string._M_value = __value;
209
+ }
210
+
211
+ template<typename _Iterator, typename _Sequence>
212
+ _Parameter(const _Safe_iterator<_Iterator, _Sequence>& __it,
213
+ const char* __name, _Is_iterator)
214
+ : _M_kind(__iterator), _M_variant()
215
+ {
216
+ _M_variant._M_iterator._M_name = __name;
217
+ _M_variant._M_iterator._M_address = &__it;
218
+ _M_variant._M_iterator._M_type = &typeid(__it);
219
+ _M_variant._M_iterator._M_constness =
220
+ __is_same<_Safe_iterator<_Iterator, _Sequence>,
221
+ typename _Sequence::iterator>::
222
+ value? __mutable_iterator : __const_iterator;
223
+ _M_variant._M_iterator._M_sequence = __it._M_get_sequence();
224
+ _M_variant._M_iterator._M_seq_type = &typeid(_Sequence);
225
+
226
+ if (__it._M_singular())
227
+ _M_variant._M_iterator._M_state = __singular;
228
+ else
229
+ {
230
+ bool __is_begin = __it._M_is_begin();
231
+ bool __is_end = __it._M_is_end();
232
+ if (__is_end)
233
+ _M_variant._M_iterator._M_state = __end;
234
+ else if (__is_begin)
235
+ _M_variant._M_iterator._M_state = __begin;
236
+ else
237
+ _M_variant._M_iterator._M_state = __middle;
238
+ }
239
+ }
240
+
241
+ template<typename _Type>
242
+ _Parameter(const _Type*& __it, const char* __name, _Is_iterator)
243
+ : _M_kind(__iterator), _M_variant()
244
+ {
245
+ _M_variant._M_iterator._M_name = __name;
246
+ _M_variant._M_iterator._M_address = &__it;
247
+ _M_variant._M_iterator._M_type = &typeid(__it);
248
+ _M_variant._M_iterator._M_constness = __mutable_iterator;
249
+ _M_variant._M_iterator._M_state = __it? __unknown_state : __singular;
250
+ _M_variant._M_iterator._M_sequence = 0;
251
+ _M_variant._M_iterator._M_seq_type = 0;
252
+ }
253
+
254
+ template<typename _Type>
255
+ _Parameter(_Type*& __it, const char* __name, _Is_iterator)
256
+ : _M_kind(__iterator), _M_variant()
257
+ {
258
+ _M_variant._M_iterator._M_name = __name;
259
+ _M_variant._M_iterator._M_address = &__it;
260
+ _M_variant._M_iterator._M_type = &typeid(__it);
261
+ _M_variant._M_iterator._M_constness = __const_iterator;
262
+ _M_variant._M_iterator._M_state = __it? __unknown_state : __singular;
263
+ _M_variant._M_iterator._M_sequence = 0;
264
+ _M_variant._M_iterator._M_seq_type = 0;
265
+ }
266
+
267
+ template<typename _Iterator>
268
+ _Parameter(const _Iterator& __it, const char* __name, _Is_iterator)
269
+ : _M_kind(__iterator), _M_variant()
270
+ {
271
+ _M_variant._M_iterator._M_name = __name;
272
+ _M_variant._M_iterator._M_address = &__it;
273
+ _M_variant._M_iterator._M_type = &typeid(__it);
274
+ _M_variant._M_iterator._M_constness = __unknown_constness;
275
+ _M_variant._M_iterator._M_state =
276
+ __gnu_debug::__check_singular(__it)? __singular : __unknown_state;
277
+ _M_variant._M_iterator._M_sequence = 0;
278
+ _M_variant._M_iterator._M_seq_type = 0;
279
+ }
280
+
281
+ template<typename _Sequence>
282
+ _Parameter(const _Safe_sequence<_Sequence>& __seq,
283
+ const char* __name, _Is_sequence)
284
+ : _M_kind(__sequence), _M_variant()
285
+ {
286
+ _M_variant._M_sequence._M_name = __name;
287
+ _M_variant._M_sequence._M_address =
288
+ static_cast<const _Sequence*>(&__seq);
289
+ _M_variant._M_sequence._M_type = &typeid(_Sequence);
290
+ }
291
+
292
+ template<typename _Sequence>
293
+ _Parameter(const _Sequence& __seq, const char* __name, _Is_sequence)
294
+ : _M_kind(__sequence), _M_variant()
295
+ {
296
+ _M_variant._M_sequence._M_name = __name;
297
+ _M_variant._M_sequence._M_address = &__seq;
298
+ _M_variant._M_sequence._M_type = &typeid(_Sequence);
299
+ }
300
+
301
+ void
302
+ _M_print_field(const _Error_formatter* __formatter,
303
+ const char* __name) const;
304
+
305
+ void
306
+ _M_print_description(const _Error_formatter* __formatter) const;
307
+ };
308
+
309
+ friend struct _Parameter;
310
+
311
+ public:
312
+ template<typename _Iterator>
313
+ const _Error_formatter&
314
+ _M_iterator(const _Iterator& __it, const char* __name = 0) const
315
+ {
316
+ if (_M_num_parameters < size_t(__max_parameters))
317
+ _M_parameters[_M_num_parameters++] = _Parameter(__it, __name,
318
+ _Is_iterator());
319
+ return *this;
320
+ }
321
+
322
+ const _Error_formatter&
323
+ _M_integer(long __value, const char* __name = 0) const
324
+ {
325
+ if (_M_num_parameters < size_t(__max_parameters))
326
+ _M_parameters[_M_num_parameters++] = _Parameter(__value, __name);
327
+ return *this;
328
+ }
329
+
330
+ const _Error_formatter&
331
+ _M_string(const char* __value, const char* __name = 0) const
332
+ {
333
+ if (_M_num_parameters < size_t(__max_parameters))
334
+ _M_parameters[_M_num_parameters++] = _Parameter(__value, __name);
335
+ return *this;
336
+ }
337
+
338
+ template<typename _Sequence>
339
+ const _Error_formatter&
340
+ _M_sequence(const _Sequence& __seq, const char* __name = 0) const
341
+ {
342
+ if (_M_num_parameters < size_t(__max_parameters))
343
+ _M_parameters[_M_num_parameters++] = _Parameter(__seq, __name,
344
+ _Is_sequence());
345
+ return *this;
346
+ }
347
+
348
+ const _Error_formatter&
349
+ _M_message(const char* __text) const
350
+ { _M_text = __text; return *this; }
351
+
352
+ const _Error_formatter&
353
+ _M_message(_Debug_msg_id __id) const;
354
+
355
+ void
356
+ _M_error() const;
357
+
358
+ private:
359
+ _Error_formatter(const char* __file, size_t __line)
360
+ : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0),
361
+ _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
362
+ { _M_get_max_length(); }
363
+
364
+ template<typename _Tp>
365
+ void
366
+ _M_format_word(char*, int, const char*, _Tp) const;
367
+
368
+ void
369
+ _M_print_word(const char* __word) const;
370
+
371
+ void
372
+ _M_print_string(const char* __string) const;
373
+
374
+ void
375
+ _M_get_max_length() const;
376
+
377
+ enum { __max_parameters = 9 };
378
+
379
+ const char* _M_file;
380
+ size_t _M_line;
381
+ mutable _Parameter _M_parameters[__max_parameters];
382
+ mutable size_t _M_num_parameters;
383
+ mutable const char* _M_text;
384
+ mutable size_t _M_max_length;
385
+ enum { _M_indent = 4 } ;
386
+ mutable size_t _M_column;
387
+ mutable bool _M_first_line;
388
+ mutable bool _M_wordwrap;
389
+
390
+ public:
391
+ static _Error_formatter
392
+ _M_at(const char* __file, size_t __line)
393
+ { return _Error_formatter(__file, __line); }
394
+ };
395
+ } // namespace __gnu_debug
396
+
397
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/functions.h ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging support implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/functions.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_FUNCTIONS_H
36
+ #define _GLIBCXX_DEBUG_FUNCTIONS_H 1
37
+
38
+ #include <bits/c++config.h>
39
+ #include <cstddef> // for ptrdiff_t
40
+ #include <bits/stl_iterator_base_types.h> // for iterator_traits, categories
41
+ #include <bits/cpp_type_traits.h> // for __is_integer
42
+
43
+ namespace __gnu_debug
44
+ {
45
+ template<typename _Iterator, typename _Sequence>
46
+ class _Safe_iterator;
47
+
48
+ // An arbitrary iterator pointer is not singular.
49
+ inline bool
50
+ __check_singular_aux(const void*) { return false; }
51
+
52
+ // We may have an iterator that derives from _Safe_iterator_base but isn't
53
+ // a _Safe_iterator.
54
+ template<typename _Iterator>
55
+ inline bool
56
+ __check_singular(_Iterator& __x)
57
+ { return __check_singular_aux(&__x); }
58
+
59
+ /** Non-NULL pointers are nonsingular. */
60
+ template<typename _Tp>
61
+ inline bool
62
+ __check_singular(const _Tp* __ptr)
63
+ { return __ptr == 0; }
64
+
65
+ /** Safe iterators know if they are singular. */
66
+ template<typename _Iterator, typename _Sequence>
67
+ inline bool
68
+ __check_singular(const _Safe_iterator<_Iterator, _Sequence>& __x)
69
+ { return __x._M_singular(); }
70
+
71
+ /** Assume that some arbitrary iterator is dereferenceable, because we
72
+ can't prove that it isn't. */
73
+ template<typename _Iterator>
74
+ inline bool
75
+ __check_dereferenceable(_Iterator&)
76
+ { return true; }
77
+
78
+ /** Non-NULL pointers are dereferenceable. */
79
+ template<typename _Tp>
80
+ inline bool
81
+ __check_dereferenceable(const _Tp* __ptr)
82
+ { return __ptr; }
83
+
84
+ /** Safe iterators know if they are singular. */
85
+ template<typename _Iterator, typename _Sequence>
86
+ inline bool
87
+ __check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x)
88
+ { return __x._M_dereferenceable(); }
89
+
90
+ /** If the distance between two random access iterators is
91
+ * nonnegative, assume the range is valid.
92
+ */
93
+ template<typename _RandomAccessIterator>
94
+ inline bool
95
+ __valid_range_aux2(const _RandomAccessIterator& __first,
96
+ const _RandomAccessIterator& __last,
97
+ std::random_access_iterator_tag)
98
+ { return __last - __first >= 0; }
99
+
100
+ /** Can't test for a valid range with input iterators, because
101
+ * iteration may be destructive. So we just assume that the range
102
+ * is valid.
103
+ */
104
+ template<typename _InputIterator>
105
+ inline bool
106
+ __valid_range_aux2(const _InputIterator&, const _InputIterator&,
107
+ std::input_iterator_tag)
108
+ { return true; }
109
+
110
+ /** We say that integral types for a valid range, and defer to other
111
+ * routines to realize what to do with integral types instead of
112
+ * iterators.
113
+ */
114
+ template<typename _Integral>
115
+ inline bool
116
+ __valid_range_aux(const _Integral&, const _Integral&, std::__true_type)
117
+ { return true; }
118
+
119
+ /** We have iterators, so figure out what kind of iterators that are
120
+ * to see if we can check the range ahead of time.
121
+ */
122
+ template<typename _InputIterator>
123
+ inline bool
124
+ __valid_range_aux(const _InputIterator& __first,
125
+ const _InputIterator& __last, std::__false_type)
126
+ {
127
+ typedef typename std::iterator_traits<_InputIterator>::iterator_category
128
+ _Category;
129
+ return __valid_range_aux2(__first, __last, _Category());
130
+ }
131
+
132
+ /** Don't know what these iterators are, or if they are even
133
+ * iterators (we may get an integral type for InputIterator), so
134
+ * see if they are integral and pass them on to the next phase
135
+ * otherwise.
136
+ */
137
+ template<typename _InputIterator>
138
+ inline bool
139
+ __valid_range(const _InputIterator& __first, const _InputIterator& __last)
140
+ {
141
+ typedef typename std::__is_integer<_InputIterator>::__type _Integral;
142
+ return __valid_range_aux(__first, __last, _Integral());
143
+ }
144
+
145
+ /** Safe iterators know how to check if they form a valid range. */
146
+ template<typename _Iterator, typename _Sequence>
147
+ inline bool
148
+ __valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first,
149
+ const _Safe_iterator<_Iterator, _Sequence>& __last)
150
+ { return __first._M_valid_range(__last); }
151
+
152
+ /* Checks that [first, last) is a valid range, and then returns
153
+ * __first. This routine is useful when we can't use a separate
154
+ * assertion statement because, e.g., we are in a constructor.
155
+ */
156
+ template<typename _InputIterator>
157
+ inline _InputIterator
158
+ __check_valid_range(const _InputIterator& __first,
159
+ const _InputIterator& __last
160
+ __attribute__((__unused__)))
161
+ {
162
+ _GLIBCXX_DEBUG_ASSERT(__valid_range(__first, __last));
163
+ return __first;
164
+ }
165
+
166
+ /** Checks that __s is non-NULL or __n == 0, and then returns __s. */
167
+ template<typename _CharT, typename _Integer>
168
+ inline const _CharT*
169
+ __check_string(const _CharT* __s,
170
+ const _Integer& __n __attribute__((__unused__)))
171
+ {
172
+ #ifdef _GLIBCXX_DEBUG_PEDANTIC
173
+ _GLIBCXX_DEBUG_ASSERT(__s != 0 || __n == 0);
174
+ #endif
175
+ return __s;
176
+ }
177
+
178
+ /** Checks that __s is non-NULL and then returns __s. */
179
+ template<typename _CharT>
180
+ inline const _CharT*
181
+ __check_string(const _CharT* __s)
182
+ {
183
+ #ifdef _GLIBCXX_DEBUG_PEDANTIC
184
+ _GLIBCXX_DEBUG_ASSERT(__s != 0);
185
+ #endif
186
+ return __s;
187
+ }
188
+
189
+ // Can't check if an input iterator sequence is sorted, because we
190
+ // can't step through the sequence.
191
+ template<typename _InputIterator>
192
+ inline bool
193
+ __check_sorted_aux(const _InputIterator&, const _InputIterator&,
194
+ std::input_iterator_tag)
195
+ { return true; }
196
+
197
+ // Can verify if a forward iterator sequence is in fact sorted using
198
+ // std::__is_sorted
199
+ template<typename _ForwardIterator>
200
+ inline bool
201
+ __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last,
202
+ std::forward_iterator_tag)
203
+ {
204
+ if (__first == __last)
205
+ return true;
206
+
207
+ _ForwardIterator __next = __first;
208
+ for (++__next; __next != __last; __first = __next, ++__next)
209
+ if (*__next < *__first)
210
+ return false;
211
+
212
+ return true;
213
+ }
214
+
215
+ // Can't check if an input iterator sequence is sorted, because we can't step
216
+ // through the sequence.
217
+ template<typename _InputIterator, typename _Predicate>
218
+ inline bool
219
+ __check_sorted_aux(const _InputIterator&, const _InputIterator&,
220
+ _Predicate, std::input_iterator_tag)
221
+ { return true; }
222
+
223
+ // Can verify if a forward iterator sequence is in fact sorted using
224
+ // std::__is_sorted
225
+ template<typename _ForwardIterator, typename _Predicate>
226
+ inline bool
227
+ __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last,
228
+ _Predicate __pred, std::forward_iterator_tag)
229
+ {
230
+ if (__first == __last)
231
+ return true;
232
+
233
+ _ForwardIterator __next = __first;
234
+ for (++__next; __next != __last; __first = __next, ++__next)
235
+ if (__pred(*__next, *__first))
236
+ return false;
237
+
238
+ return true;
239
+ }
240
+
241
+ // Determine if a sequence is sorted.
242
+ template<typename _InputIterator>
243
+ inline bool
244
+ __check_sorted(const _InputIterator& __first, const _InputIterator& __last)
245
+ {
246
+ typedef typename std::iterator_traits<_InputIterator>::iterator_category
247
+ _Category;
248
+
249
+ // Verify that the < operator for elements in the sequence is a
250
+ // StrictWeakOrdering by checking that it is irreflexive.
251
+ _GLIBCXX_DEBUG_ASSERT(__first == __last || !(*__first < *__first));
252
+
253
+ return __check_sorted_aux(__first, __last, _Category());
254
+ }
255
+
256
+ template<typename _InputIterator, typename _Predicate>
257
+ inline bool
258
+ __check_sorted(const _InputIterator& __first, const _InputIterator& __last,
259
+ _Predicate __pred)
260
+ {
261
+ typedef typename std::iterator_traits<_InputIterator>::iterator_category
262
+ _Category;
263
+
264
+ // Verify that the predicate is StrictWeakOrdering by checking that it
265
+ // is irreflexive.
266
+ _GLIBCXX_DEBUG_ASSERT(__first == __last || !__pred(*__first, *__first));
267
+
268
+ return __check_sorted_aux(__first, __last, __pred, _Category());
269
+ }
270
+
271
+ template<typename _InputIterator>
272
+ inline bool
273
+ __check_sorted_set_aux(const _InputIterator& __first,
274
+ const _InputIterator& __last,
275
+ std::__true_type)
276
+ { return __check_sorted(__first, __last); }
277
+
278
+ template<typename _InputIterator>
279
+ inline bool
280
+ __check_sorted_set_aux(const _InputIterator&,
281
+ const _InputIterator&,
282
+ std::__false_type)
283
+ { return true; }
284
+
285
+ template<typename _InputIterator, typename _Predicate>
286
+ inline bool
287
+ __check_sorted_set_aux(const _InputIterator& __first,
288
+ const _InputIterator& __last,
289
+ _Predicate __pred, std::__true_type)
290
+ { return __check_sorted(__first, __last, __pred); }
291
+
292
+ template<typename _InputIterator, typename _Predicate>
293
+ inline bool
294
+ __check_sorted_set_aux(const _InputIterator&,
295
+ const _InputIterator&, _Predicate,
296
+ std::__false_type)
297
+ { return true; }
298
+
299
+ // ... special variant used in std::merge, std::includes, std::set_*.
300
+ template<typename _InputIterator1, typename _InputIterator2>
301
+ inline bool
302
+ __check_sorted_set(const _InputIterator1& __first,
303
+ const _InputIterator1& __last,
304
+ const _InputIterator2&)
305
+ {
306
+ typedef typename std::iterator_traits<_InputIterator1>::value_type
307
+ _ValueType1;
308
+ typedef typename std::iterator_traits<_InputIterator2>::value_type
309
+ _ValueType2;
310
+
311
+ typedef typename std::__are_same<_ValueType1, _ValueType2>::__type
312
+ _SameType;
313
+ return __check_sorted_set_aux(__first, __last, _SameType());
314
+ }
315
+
316
+ template<typename _InputIterator1, typename _InputIterator2,
317
+ typename _Predicate>
318
+ inline bool
319
+ __check_sorted_set(const _InputIterator1& __first,
320
+ const _InputIterator1& __last,
321
+ const _InputIterator2&, _Predicate __pred)
322
+ {
323
+ typedef typename std::iterator_traits<_InputIterator1>::value_type
324
+ _ValueType1;
325
+ typedef typename std::iterator_traits<_InputIterator2>::value_type
326
+ _ValueType2;
327
+
328
+ typedef typename std::__are_same<_ValueType1, _ValueType2>::__type
329
+ _SameType;
330
+ return __check_sorted_set_aux(__first, __last, __pred, _SameType());
331
+ }
332
+
333
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
334
+ // 270. Binary search requirements overly strict
335
+ // Determine if a sequence is partitioned w.r.t. this element.
336
+ template<typename _ForwardIterator, typename _Tp>
337
+ inline bool
338
+ __check_partitioned_lower(_ForwardIterator __first,
339
+ _ForwardIterator __last, const _Tp& __value)
340
+ {
341
+ while (__first != __last && *__first < __value)
342
+ ++__first;
343
+ while (__first != __last && !(*__first < __value))
344
+ ++__first;
345
+ return __first == __last;
346
+ }
347
+
348
+ template<typename _ForwardIterator, typename _Tp>
349
+ inline bool
350
+ __check_partitioned_upper(_ForwardIterator __first,
351
+ _ForwardIterator __last, const _Tp& __value)
352
+ {
353
+ while (__first != __last && !(__value < *__first))
354
+ ++__first;
355
+ while (__first != __last && __value < *__first)
356
+ ++__first;
357
+ return __first == __last;
358
+ }
359
+
360
+ // Determine if a sequence is partitioned w.r.t. this element.
361
+ template<typename _ForwardIterator, typename _Tp, typename _Pred>
362
+ inline bool
363
+ __check_partitioned_lower(_ForwardIterator __first,
364
+ _ForwardIterator __last, const _Tp& __value,
365
+ _Pred __pred)
366
+ {
367
+ while (__first != __last && bool(__pred(*__first, __value)))
368
+ ++__first;
369
+ while (__first != __last && !bool(__pred(*__first, __value)))
370
+ ++__first;
371
+ return __first == __last;
372
+ }
373
+
374
+ template<typename _ForwardIterator, typename _Tp, typename _Pred>
375
+ inline bool
376
+ __check_partitioned_upper(_ForwardIterator __first,
377
+ _ForwardIterator __last, const _Tp& __value,
378
+ _Pred __pred)
379
+ {
380
+ while (__first != __last && !bool(__pred(__value, *__first)))
381
+ ++__first;
382
+ while (__first != __last && bool(__pred(__value, *__first)))
383
+ ++__first;
384
+ return __first == __last;
385
+ }
386
+ } // namespace __gnu_debug
387
+
388
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/list ADDED
@@ -0,0 +1,640 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging list implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ // Free Software Foundation, Inc.
32
+ //
33
+ // This file is part of the GNU ISO C++ Library. This library is free
34
+ // software; you can redistribute it and/or modify it under the
35
+ // terms of the GNU General Public License as published by the
36
+ // Free Software Foundation; either version 2, or (at your option)
37
+ // any later version.
38
+
39
+ // This library is distributed in the hope that it will be useful,
40
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
41
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42
+ // GNU General Public License for more details.
43
+
44
+ // You should have received a copy of the GNU General Public License along
45
+ // with this library; see the file COPYING. If not, write to the Free
46
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
47
+ // USA.
48
+
49
+ // As a special exception, you may use this file as part of a free software
50
+ // library without restriction. Specifically, if other files instantiate
51
+ // templates or use macros or inline functions from this file, or you compile
52
+ // this file and link it with other files to produce an executable, this
53
+ // file does not by itself cause the resulting executable to be covered by
54
+ // the GNU General Public License. This exception does not however
55
+ // invalidate any other reasons why the executable file might be covered by
56
+ // the GNU General Public License.
57
+
58
+ /** @file debug/list
59
+ * This file is a GNU debug extension to the Standard C++ Library.
60
+ */
61
+
62
+ #ifndef _GLIBCXX_DEBUG_LIST
63
+ #define _GLIBCXX_DEBUG_LIST 1
64
+
65
+ #include <list>
66
+ #include <bits/stl_algo.h>
67
+ #include <debug/safe_sequence.h>
68
+ #include <debug/safe_iterator.h>
69
+
70
+ namespace std
71
+ {
72
+ namespace __debug
73
+ {
74
+ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
75
+ class list
76
+ : public _GLIBCXX_STD_D::list<_Tp, _Allocator>,
77
+ public __gnu_debug::_Safe_sequence<list<_Tp, _Allocator> >
78
+ {
79
+ typedef _GLIBCXX_STD_D::list<_Tp, _Allocator> _Base;
80
+ typedef __gnu_debug::_Safe_sequence<list> _Safe_base;
81
+
82
+ public:
83
+ typedef typename _Base::reference reference;
84
+ typedef typename _Base::const_reference const_reference;
85
+
86
+ typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, list>
87
+ iterator;
88
+ typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator, list>
89
+ const_iterator;
90
+
91
+ typedef typename _Base::size_type size_type;
92
+ typedef typename _Base::difference_type difference_type;
93
+
94
+ typedef _Tp value_type;
95
+ typedef _Allocator allocator_type;
96
+ typedef typename _Base::pointer pointer;
97
+ typedef typename _Base::const_pointer const_pointer;
98
+ typedef std::reverse_iterator<iterator> reverse_iterator;
99
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
100
+
101
+ // 23.2.2.1 construct/copy/destroy:
102
+ explicit list(const _Allocator& __a = _Allocator())
103
+ : _Base(__a) { }
104
+
105
+ explicit list(size_type __n, const _Tp& __value = _Tp(),
106
+ const _Allocator& __a = _Allocator())
107
+ : _Base(__n, __value, __a) { }
108
+
109
+ template<class _InputIterator>
110
+ list(_InputIterator __first, _InputIterator __last,
111
+ const _Allocator& __a = _Allocator())
112
+ : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __a)
113
+ { }
114
+
115
+
116
+ list(const list& __x)
117
+ : _Base(__x), _Safe_base() { }
118
+
119
+ list(const _Base& __x)
120
+ : _Base(__x), _Safe_base() { }
121
+
122
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
123
+ list(list&& __x)
124
+ : _Base(std::forward<list>(__x)), _Safe_base()
125
+ { this->_M_swap(__x); }
126
+ #endif
127
+
128
+ ~list() { }
129
+
130
+ list&
131
+ operator=(const list& __x)
132
+ {
133
+ static_cast<_Base&>(*this) = __x;
134
+ this->_M_invalidate_all();
135
+ return *this;
136
+ }
137
+
138
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
139
+ list&
140
+ operator=(list&& __x)
141
+ {
142
+ // NB: DR 675.
143
+ clear();
144
+ swap(__x);
145
+ return *this;
146
+ }
147
+ #endif
148
+
149
+ template<class _InputIterator>
150
+ void
151
+ assign(_InputIterator __first, _InputIterator __last)
152
+ {
153
+ __glibcxx_check_valid_range(__first, __last);
154
+ _Base::assign(__first, __last);
155
+ this->_M_invalidate_all();
156
+ }
157
+
158
+ void
159
+ assign(size_type __n, const _Tp& __t)
160
+ {
161
+ _Base::assign(__n, __t);
162
+ this->_M_invalidate_all();
163
+ }
164
+
165
+ using _Base::get_allocator;
166
+
167
+ // iterators:
168
+ iterator
169
+ begin()
170
+ { return iterator(_Base::begin(), this); }
171
+
172
+ const_iterator
173
+ begin() const
174
+ { return const_iterator(_Base::begin(), this); }
175
+
176
+ iterator
177
+ end()
178
+ { return iterator(_Base::end(), this); }
179
+
180
+ const_iterator
181
+ end() const
182
+ { return const_iterator(_Base::end(), this); }
183
+
184
+ reverse_iterator
185
+ rbegin()
186
+ { return reverse_iterator(end()); }
187
+
188
+ const_reverse_iterator
189
+ rbegin() const
190
+ { return const_reverse_iterator(end()); }
191
+
192
+ reverse_iterator
193
+ rend()
194
+ { return reverse_iterator(begin()); }
195
+
196
+ const_reverse_iterator
197
+ rend() const
198
+ { return const_reverse_iterator(begin()); }
199
+
200
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
201
+ const_iterator
202
+ cbegin() const
203
+ { return const_iterator(_Base::begin(), this); }
204
+
205
+ const_iterator
206
+ cend() const
207
+ { return const_iterator(_Base::end(), this); }
208
+
209
+ const_reverse_iterator
210
+ crbegin() const
211
+ { return const_reverse_iterator(end()); }
212
+
213
+ const_reverse_iterator
214
+ crend() const
215
+ { return const_reverse_iterator(begin()); }
216
+ #endif
217
+
218
+ // 23.2.2.2 capacity:
219
+ using _Base::empty;
220
+ using _Base::size;
221
+ using _Base::max_size;
222
+
223
+ void
224
+ resize(size_type __sz, _Tp __c = _Tp())
225
+ {
226
+ this->_M_detach_singular();
227
+
228
+ // if __sz < size(), invalidate all iterators in [begin+__sz, end())
229
+ iterator __victim = begin();
230
+ iterator __end = end();
231
+ for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
232
+ ++__victim;
233
+
234
+ while (__victim != __end)
235
+ {
236
+ iterator __real_victim = __victim++;
237
+ __real_victim._M_invalidate();
238
+ }
239
+
240
+ try
241
+ {
242
+ _Base::resize(__sz, __c);
243
+ }
244
+ catch(...)
245
+ {
246
+ this->_M_revalidate_singular();
247
+ __throw_exception_again;
248
+ }
249
+ }
250
+
251
+ // element access:
252
+ reference
253
+ front()
254
+ {
255
+ __glibcxx_check_nonempty();
256
+ return _Base::front();
257
+ }
258
+
259
+ const_reference
260
+ front() const
261
+ {
262
+ __glibcxx_check_nonempty();
263
+ return _Base::front();
264
+ }
265
+
266
+ reference
267
+ back()
268
+ {
269
+ __glibcxx_check_nonempty();
270
+ return _Base::back();
271
+ }
272
+
273
+ const_reference
274
+ back() const
275
+ {
276
+ __glibcxx_check_nonempty();
277
+ return _Base::back();
278
+ }
279
+
280
+ // 23.2.2.3 modifiers:
281
+ using _Base::push_front;
282
+
283
+ void
284
+ pop_front()
285
+ {
286
+ __glibcxx_check_nonempty();
287
+ iterator __victim = begin();
288
+ __victim._M_invalidate();
289
+ _Base::pop_front();
290
+ }
291
+
292
+ using _Base::push_back;
293
+
294
+ void
295
+ pop_back()
296
+ {
297
+ __glibcxx_check_nonempty();
298
+ iterator __victim = end();
299
+ --__victim;
300
+ __victim._M_invalidate();
301
+ _Base::pop_back();
302
+ }
303
+
304
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
305
+ template<typename... _Args>
306
+ iterator
307
+ emplace(iterator __position, _Args&&... __args)
308
+ {
309
+ __glibcxx_check_insert(__position);
310
+ return iterator(_Base::emplace(__position.base(),
311
+ std::forward<_Args>(__args)...), this);
312
+ }
313
+ #endif
314
+
315
+ iterator
316
+ insert(iterator __position, const _Tp& __x)
317
+ {
318
+ __glibcxx_check_insert(__position);
319
+ return iterator(_Base::insert(__position.base(), __x), this);
320
+ }
321
+
322
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
323
+ iterator
324
+ insert(iterator __position, _Tp&& __x)
325
+ { return emplace(__position, std::move(__x)); }
326
+ #endif
327
+
328
+ void
329
+ insert(iterator __position, size_type __n, const _Tp& __x)
330
+ {
331
+ __glibcxx_check_insert(__position);
332
+ _Base::insert(__position.base(), __n, __x);
333
+ }
334
+
335
+ template<class _InputIterator>
336
+ void
337
+ insert(iterator __position, _InputIterator __first,
338
+ _InputIterator __last)
339
+ {
340
+ __glibcxx_check_insert_range(__position, __first, __last);
341
+ _Base::insert(__position.base(), __first, __last);
342
+ }
343
+
344
+ iterator
345
+ erase(iterator __position)
346
+ {
347
+ __glibcxx_check_erase(__position);
348
+ __position._M_invalidate();
349
+ return iterator(_Base::erase(__position.base()), this);
350
+ }
351
+
352
+ iterator
353
+ erase(iterator __position, iterator __last)
354
+ {
355
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
356
+ // 151. can't currently clear() empty container
357
+ __glibcxx_check_erase_range(__position, __last);
358
+ for (iterator __victim = __position; __victim != __last; )
359
+ {
360
+ iterator __old = __victim;
361
+ ++__victim;
362
+ __old._M_invalidate();
363
+ }
364
+ return iterator(_Base::erase(__position.base(), __last.base()), this);
365
+ }
366
+
367
+ void
368
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
369
+ swap(list&& __x)
370
+ #else
371
+ swap(list& __x)
372
+ #endif
373
+ {
374
+ _Base::swap(__x);
375
+ this->_M_swap(__x);
376
+ }
377
+
378
+ void
379
+ clear()
380
+ {
381
+ _Base::clear();
382
+ this->_M_invalidate_all();
383
+ }
384
+
385
+ // 23.2.2.4 list operations:
386
+ void
387
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
388
+ splice(iterator __position, list&& __x)
389
+ #else
390
+ splice(iterator __position, list& __x)
391
+ #endif
392
+ {
393
+ _GLIBCXX_DEBUG_VERIFY(&__x != this,
394
+ _M_message(__gnu_debug::__msg_self_splice)
395
+ ._M_sequence(*this, "this"));
396
+ this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end());
397
+ }
398
+
399
+ void
400
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
401
+ splice(iterator __position, list&& __x, iterator __i)
402
+ #else
403
+ splice(iterator __position, list& __x, iterator __i)
404
+ #endif
405
+ {
406
+ __glibcxx_check_insert(__position);
407
+
408
+ // We used to perform the splice_alloc check: not anymore, redundant
409
+ // after implementing the relevant bits of N1599.
410
+
411
+ _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(),
412
+ _M_message(__gnu_debug::__msg_splice_bad)
413
+ ._M_iterator(__i, "__i"));
414
+ _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(&__x),
415
+ _M_message(__gnu_debug::__msg_splice_other)
416
+ ._M_iterator(__i, "__i")._M_sequence(__x, "__x"));
417
+
418
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
419
+ // 250. splicing invalidates iterators
420
+ this->_M_transfer_iter(__i);
421
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
422
+ __i.base());
423
+ }
424
+
425
+ void
426
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
427
+ splice(iterator __position, list&& __x, iterator __first,
428
+ iterator __last)
429
+ #else
430
+ splice(iterator __position, list& __x, iterator __first,
431
+ iterator __last)
432
+ #endif
433
+ {
434
+ __glibcxx_check_insert(__position);
435
+ __glibcxx_check_valid_range(__first, __last);
436
+ _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(&__x),
437
+ _M_message(__gnu_debug::__msg_splice_other)
438
+ ._M_sequence(__x, "x")
439
+ ._M_iterator(__first, "first"));
440
+
441
+ // We used to perform the splice_alloc check: not anymore, redundant
442
+ // after implementing the relevant bits of N1599.
443
+
444
+ for (iterator __tmp = __first; __tmp != __last; )
445
+ {
446
+ _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position,
447
+ _M_message(__gnu_debug::__msg_splice_overlap)
448
+ ._M_iterator(__tmp, "position")
449
+ ._M_iterator(__first, "first")
450
+ ._M_iterator(__last, "last"));
451
+ iterator __victim = __tmp++;
452
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
453
+ // 250. splicing invalidates iterators
454
+ this->_M_transfer_iter(__victim);
455
+ }
456
+
457
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
458
+ __first.base(), __last.base());
459
+ }
460
+
461
+ void
462
+ remove(const _Tp& __value)
463
+ {
464
+ for (iterator __x = begin(); __x.base() != _Base::end(); )
465
+ {
466
+ if (*__x == __value)
467
+ __x = erase(__x);
468
+ else
469
+ ++__x;
470
+ }
471
+ }
472
+
473
+ template<class _Predicate>
474
+ void
475
+ remove_if(_Predicate __pred)
476
+ {
477
+ for (iterator __x = begin(); __x.base() != _Base::end(); )
478
+ {
479
+ if (__pred(*__x))
480
+ __x = erase(__x);
481
+ else
482
+ ++__x;
483
+ }
484
+ }
485
+
486
+ void
487
+ unique()
488
+ {
489
+ iterator __first = begin();
490
+ iterator __last = end();
491
+ if (__first == __last)
492
+ return;
493
+ iterator __next = __first;
494
+ while (++__next != __last)
495
+ {
496
+ if (*__first == *__next)
497
+ erase(__next);
498
+ else
499
+ __first = __next;
500
+ __next = __first;
501
+ }
502
+ }
503
+
504
+ template<class _BinaryPredicate>
505
+ void
506
+ unique(_BinaryPredicate __binary_pred)
507
+ {
508
+ iterator __first = begin();
509
+ iterator __last = end();
510
+ if (__first == __last)
511
+ return;
512
+ iterator __next = __first;
513
+ while (++__next != __last)
514
+ {
515
+ if (__binary_pred(*__first, *__next))
516
+ erase(__next);
517
+ else
518
+ __first = __next;
519
+ __next = __first;
520
+ }
521
+ }
522
+
523
+ void
524
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
525
+ merge(list&& __x)
526
+ #else
527
+ merge(list& __x)
528
+ #endif
529
+ {
530
+ __glibcxx_check_sorted(_Base::begin(), _Base::end());
531
+ __glibcxx_check_sorted(__x.begin().base(), __x.end().base());
532
+ for (iterator __tmp = __x.begin(); __tmp != __x.end(); )
533
+ {
534
+ iterator __victim = __tmp++;
535
+ __victim._M_attach(&__x);
536
+ }
537
+ _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
538
+ }
539
+
540
+ template<class _Compare>
541
+ void
542
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
543
+ merge(list&& __x, _Compare __comp)
544
+ #else
545
+ merge(list& __x, _Compare __comp)
546
+ #endif
547
+ {
548
+ __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp);
549
+ __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(),
550
+ __comp);
551
+ for (iterator __tmp = __x.begin(); __tmp != __x.end(); )
552
+ {
553
+ iterator __victim = __tmp++;
554
+ __victim._M_attach(&__x);
555
+ }
556
+ _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
557
+ }
558
+
559
+ void
560
+ sort() { _Base::sort(); }
561
+
562
+ template<typename _StrictWeakOrdering>
563
+ void
564
+ sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
565
+
566
+ using _Base::reverse;
567
+
568
+ _Base&
569
+ _M_base() { return *this; }
570
+
571
+ const _Base&
572
+ _M_base() const { return *this; }
573
+
574
+ private:
575
+ void
576
+ _M_invalidate_all()
577
+ {
578
+ typedef typename _Base::const_iterator _Base_const_iterator;
579
+ typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
580
+ this->_M_invalidate_if(_Not_equal(_M_base().end()));
581
+ }
582
+ };
583
+
584
+ template<typename _Tp, typename _Alloc>
585
+ inline bool
586
+ operator==(const list<_Tp, _Alloc>& __lhs,
587
+ const list<_Tp, _Alloc>& __rhs)
588
+ { return __lhs._M_base() == __rhs._M_base(); }
589
+
590
+ template<typename _Tp, typename _Alloc>
591
+ inline bool
592
+ operator!=(const list<_Tp, _Alloc>& __lhs,
593
+ const list<_Tp, _Alloc>& __rhs)
594
+ { return __lhs._M_base() != __rhs._M_base(); }
595
+
596
+ template<typename _Tp, typename _Alloc>
597
+ inline bool
598
+ operator<(const list<_Tp, _Alloc>& __lhs,
599
+ const list<_Tp, _Alloc>& __rhs)
600
+ { return __lhs._M_base() < __rhs._M_base(); }
601
+
602
+ template<typename _Tp, typename _Alloc>
603
+ inline bool
604
+ operator<=(const list<_Tp, _Alloc>& __lhs,
605
+ const list<_Tp, _Alloc>& __rhs)
606
+ { return __lhs._M_base() <= __rhs._M_base(); }
607
+
608
+ template<typename _Tp, typename _Alloc>
609
+ inline bool
610
+ operator>=(const list<_Tp, _Alloc>& __lhs,
611
+ const list<_Tp, _Alloc>& __rhs)
612
+ { return __lhs._M_base() >= __rhs._M_base(); }
613
+
614
+ template<typename _Tp, typename _Alloc>
615
+ inline bool
616
+ operator>(const list<_Tp, _Alloc>& __lhs,
617
+ const list<_Tp, _Alloc>& __rhs)
618
+ { return __lhs._M_base() > __rhs._M_base(); }
619
+
620
+ template<typename _Tp, typename _Alloc>
621
+ inline void
622
+ swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
623
+ { __lhs.swap(__rhs); }
624
+
625
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
626
+ template<typename _Tp, typename _Alloc>
627
+ inline void
628
+ swap(list<_Tp, _Alloc>&& __lhs, list<_Tp, _Alloc>& __rhs)
629
+ { __lhs.swap(__rhs); }
630
+
631
+ template<typename _Tp, typename _Alloc>
632
+ inline void
633
+ swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>&& __rhs)
634
+ { __lhs.swap(__rhs); }
635
+ #endif
636
+
637
+ } // namespace __debug
638
+ } // namespace std
639
+
640
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/macros.h ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging support implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/macros.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_MACROS_H
36
+ #define _GLIBCXX_DEBUG_MACROS_H 1
37
+
38
+ /**
39
+ * Macros used by the implementation to verify certain
40
+ * properties. These macros may only be used directly by the debug
41
+ * wrappers. Note that these are macros (instead of the more obviously
42
+ * "correct" choice of making them functions) because we need line and
43
+ * file information at the call site, to minimize the distance between
44
+ * the user error and where the error is reported.
45
+ *
46
+ */
47
+ #define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \
48
+ do \
49
+ { \
50
+ if (! (_Condition)) \
51
+ __gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \
52
+ ._ErrorMessage._M_error(); \
53
+ } while (false)
54
+
55
+ // Verify that [_First, _Last) forms a valid iterator range.
56
+ #define __glibcxx_check_valid_range(_First,_Last) \
57
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
58
+ _M_message(__gnu_debug::__msg_valid_range) \
59
+ ._M_iterator(_First, #_First) \
60
+ ._M_iterator(_Last, #_Last))
61
+
62
+ /** Verify that we can insert into *this with the iterator _Position.
63
+ * Insertion into a container at a specific position requires that
64
+ * the iterator be nonsingular (i.e., either dereferenceable or
65
+ * past-the-end) and that it reference the sequence we are inserting
66
+ * into. Note that this macro is only valid when the container is a
67
+ * _Safe_sequence and the iterator is a _Safe_iterator.
68
+ */
69
+ #define __glibcxx_check_insert(_Position) \
70
+ _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
71
+ _M_message(__gnu_debug::__msg_insert_singular) \
72
+ ._M_sequence(*this, "this") \
73
+ ._M_iterator(_Position, #_Position)); \
74
+ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
75
+ _M_message(__gnu_debug::__msg_insert_different) \
76
+ ._M_sequence(*this, "this") \
77
+ ._M_iterator(_Position, #_Position))
78
+
79
+ /** Verify that we can insert the values in the iterator range
80
+ * [_First, _Last) into *this with the iterator _Position. Insertion
81
+ * into a container at a specific position requires that the iterator
82
+ * be nonsingular (i.e., either dereferenceable or past-the-end),
83
+ * that it reference the sequence we are inserting into, and that the
84
+ * iterator range [_First, Last) is a valid (possibly empty)
85
+ * range. Note that this macro is only valid when the container is a
86
+ * _Safe_sequence and the iterator is a _Safe_iterator.
87
+ *
88
+ * @tbd We would like to be able to check for noninterference of
89
+ * _Position and the range [_First, _Last), but that can't (in
90
+ * general) be done.
91
+ */
92
+ #define __glibcxx_check_insert_range(_Position,_First,_Last) \
93
+ __glibcxx_check_valid_range(_First,_Last); \
94
+ _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
95
+ _M_message(__gnu_debug::__msg_insert_singular) \
96
+ ._M_sequence(*this, "this") \
97
+ ._M_iterator(_Position, #_Position)); \
98
+ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
99
+ _M_message(__gnu_debug::__msg_insert_different) \
100
+ ._M_sequence(*this, "this") \
101
+ ._M_iterator(_Position, #_Position))
102
+
103
+ /** Verify that we can erase the element referenced by the iterator
104
+ * _Position. We can erase the element if the _Position iterator is
105
+ * dereferenceable and references this sequence.
106
+ */
107
+ #define __glibcxx_check_erase(_Position) \
108
+ _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
109
+ _M_message(__gnu_debug::__msg_erase_bad) \
110
+ ._M_sequence(*this, "this") \
111
+ ._M_iterator(_Position, #_Position)); \
112
+ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
113
+ _M_message(__gnu_debug::__msg_erase_different) \
114
+ ._M_sequence(*this, "this") \
115
+ ._M_iterator(_Position, #_Position))
116
+
117
+ /** Verify that we can erase the elements in the iterator range
118
+ * [_First, _Last). We can erase the elements if [_First, _Last) is a
119
+ * valid iterator range within this sequence.
120
+ */
121
+ #define __glibcxx_check_erase_range(_First,_Last) \
122
+ __glibcxx_check_valid_range(_First,_Last); \
123
+ _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
124
+ _M_message(__gnu_debug::__msg_erase_different) \
125
+ ._M_sequence(*this, "this") \
126
+ ._M_iterator(_First, #_First) \
127
+ ._M_iterator(_Last, #_Last))
128
+
129
+ // Verify that the subscript _N is less than the container's size.
130
+ #define __glibcxx_check_subscript(_N) \
131
+ _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
132
+ _M_message(__gnu_debug::__msg_subscript_oob) \
133
+ ._M_sequence(*this, "this") \
134
+ ._M_integer(_N, #_N) \
135
+ ._M_integer(this->size(), "size"))
136
+
137
+ // Verify that the container is nonempty
138
+ #define __glibcxx_check_nonempty() \
139
+ _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
140
+ _M_message(__gnu_debug::__msg_empty) \
141
+ ._M_sequence(*this, "this"))
142
+
143
+ // Verify that the iterator range [_First, _Last) is sorted
144
+ #define __glibcxx_check_sorted(_First,_Last) \
145
+ __glibcxx_check_valid_range(_First,_Last); \
146
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \
147
+ _M_message(__gnu_debug::__msg_unsorted) \
148
+ ._M_iterator(_First, #_First) \
149
+ ._M_iterator(_Last, #_Last))
150
+
151
+ /** Verify that the iterator range [_First, _Last) is sorted by the
152
+ predicate _Pred. */
153
+ #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
154
+ __glibcxx_check_valid_range(_First,_Last); \
155
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \
156
+ _M_message(__gnu_debug::__msg_unsorted_pred) \
157
+ ._M_iterator(_First, #_First) \
158
+ ._M_iterator(_Last, #_Last) \
159
+ ._M_string(#_Pred))
160
+
161
+ // Special variant for std::merge, std::includes, std::set_*
162
+ #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
163
+ __glibcxx_check_valid_range(_First1,_Last1); \
164
+ _GLIBCXX_DEBUG_VERIFY( \
165
+ __gnu_debug::__check_sorted_set(_First1, _Last1, _First2), \
166
+ _M_message(__gnu_debug::__msg_unsorted) \
167
+ ._M_iterator(_First1, #_First1) \
168
+ ._M_iterator(_Last1, #_Last1))
169
+
170
+ // Likewise with a _Pred.
171
+ #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
172
+ __glibcxx_check_valid_range(_First1,_Last1); \
173
+ _GLIBCXX_DEBUG_VERIFY( \
174
+ __gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred), \
175
+ _M_message(__gnu_debug::__msg_unsorted_pred) \
176
+ ._M_iterator(_First1, #_First1) \
177
+ ._M_iterator(_Last1, #_Last1) \
178
+ ._M_string(#_Pred))
179
+
180
+ /** Verify that the iterator range [_First, _Last) is partitioned
181
+ w.r.t. the value _Value. */
182
+ #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
183
+ __glibcxx_check_valid_range(_First,_Last); \
184
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
185
+ _Value), \
186
+ _M_message(__gnu_debug::__msg_unpartitioned) \
187
+ ._M_iterator(_First, #_First) \
188
+ ._M_iterator(_Last, #_Last) \
189
+ ._M_string(#_Value))
190
+
191
+ #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
192
+ __glibcxx_check_valid_range(_First,_Last); \
193
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
194
+ _Value), \
195
+ _M_message(__gnu_debug::__msg_unpartitioned) \
196
+ ._M_iterator(_First, #_First) \
197
+ ._M_iterator(_Last, #_Last) \
198
+ ._M_string(#_Value))
199
+
200
+ /** Verify that the iterator range [_First, _Last) is partitioned
201
+ w.r.t. the value _Value and predicate _Pred. */
202
+ #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
203
+ __glibcxx_check_valid_range(_First,_Last); \
204
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
205
+ _Value, _Pred), \
206
+ _M_message(__gnu_debug::__msg_unpartitioned_pred) \
207
+ ._M_iterator(_First, #_First) \
208
+ ._M_iterator(_Last, #_Last) \
209
+ ._M_string(#_Pred) \
210
+ ._M_string(#_Value))
211
+
212
+ /** Verify that the iterator range [_First, _Last) is partitioned
213
+ w.r.t. the value _Value and predicate _Pred. */
214
+ #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
215
+ __glibcxx_check_valid_range(_First,_Last); \
216
+ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
217
+ _Value, _Pred), \
218
+ _M_message(__gnu_debug::__msg_unpartitioned_pred) \
219
+ ._M_iterator(_First, #_First) \
220
+ ._M_iterator(_Last, #_Last) \
221
+ ._M_string(#_Pred) \
222
+ ._M_string(#_Value))
223
+
224
+ // Verify that the iterator range [_First, _Last) is a heap
225
+ #define __glibcxx_check_heap(_First,_Last) \
226
+ __glibcxx_check_valid_range(_First,_Last); \
227
+ _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \
228
+ _M_message(__gnu_debug::__msg_not_heap) \
229
+ ._M_iterator(_First, #_First) \
230
+ ._M_iterator(_Last, #_Last))
231
+
232
+ /** Verify that the iterator range [_First, _Last) is a heap
233
+ w.r.t. the predicate _Pred. */
234
+ #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
235
+ __glibcxx_check_valid_range(_First,_Last); \
236
+ _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \
237
+ _M_message(__gnu_debug::__msg_not_heap_pred) \
238
+ ._M_iterator(_First, #_First) \
239
+ ._M_iterator(_Last, #_Last) \
240
+ ._M_string(#_Pred))
241
+
242
+ #ifdef _GLIBCXX_DEBUG_PEDANTIC
243
+ # define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
244
+ # define __glibcxx_check_string_len(_String,_Len) \
245
+ _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0)
246
+ #else
247
+ # define __glibcxx_check_string(_String)
248
+ # define __glibcxx_check_string_len(_String,_Len)
249
+ #endif
250
+
251
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/map ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging map/multimap implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2006
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/map
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_MAP
36
+ #define _GLIBCXX_DEBUG_MAP 1
37
+
38
+ #include <map>
39
+ #include <debug/map.h>
40
+ #include <debug/multimap.h>
41
+
42
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/map.h ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging map implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/map.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_MAP_H
36
+ #define _GLIBCXX_DEBUG_MAP_H 1
37
+
38
+ #include <debug/safe_sequence.h>
39
+ #include <debug/safe_iterator.h>
40
+ #include <utility>
41
+
42
+ namespace std
43
+ {
44
+ namespace __debug
45
+ {
46
+ template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
47
+ typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
48
+ class map
49
+ : public _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator>,
50
+ public __gnu_debug::_Safe_sequence<map<_Key, _Tp, _Compare, _Allocator> >
51
+ {
52
+ typedef _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator> _Base;
53
+ typedef __gnu_debug::_Safe_sequence<map> _Safe_base;
54
+
55
+ public:
56
+ // types:
57
+ typedef _Key key_type;
58
+ typedef _Tp mapped_type;
59
+ typedef std::pair<const _Key, _Tp> value_type;
60
+ typedef _Compare key_compare;
61
+ typedef _Allocator allocator_type;
62
+ typedef typename _Base::reference reference;
63
+ typedef typename _Base::const_reference const_reference;
64
+
65
+ typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, map>
66
+ iterator;
67
+ typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator, map>
68
+ const_iterator;
69
+
70
+ typedef typename _Base::size_type size_type;
71
+ typedef typename _Base::difference_type difference_type;
72
+ typedef typename _Base::pointer pointer;
73
+ typedef typename _Base::const_pointer const_pointer;
74
+ typedef std::reverse_iterator<iterator> reverse_iterator;
75
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
76
+
77
+ using _Base::value_compare;
78
+
79
+ // 23.3.1.1 construct/copy/destroy:
80
+ explicit map(const _Compare& __comp = _Compare(),
81
+ const _Allocator& __a = _Allocator())
82
+ : _Base(__comp, __a) { }
83
+
84
+ template<typename _InputIterator>
85
+ map(_InputIterator __first, _InputIterator __last,
86
+ const _Compare& __comp = _Compare(),
87
+ const _Allocator& __a = _Allocator())
88
+ : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
89
+ __comp, __a), _Safe_base() { }
90
+
91
+ map(const map& __x)
92
+ : _Base(__x), _Safe_base() { }
93
+
94
+ map(const _Base& __x)
95
+ : _Base(__x), _Safe_base() { }
96
+
97
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
98
+ map(map&& __x)
99
+ : _Base(std::forward<map>(__x)), _Safe_base()
100
+ { this->_M_swap(__x); }
101
+ #endif
102
+
103
+ ~map() { }
104
+
105
+ map&
106
+ operator=(const map& __x)
107
+ {
108
+ *static_cast<_Base*>(this) = __x;
109
+ this->_M_invalidate_all();
110
+ return *this;
111
+ }
112
+
113
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
114
+ map&
115
+ operator=(map&& __x)
116
+ {
117
+ // NB: DR 675.
118
+ clear();
119
+ swap(__x);
120
+ return *this;
121
+ }
122
+ #endif
123
+
124
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
125
+ // 133. map missing get_allocator()
126
+ using _Base::get_allocator;
127
+
128
+ // iterators:
129
+ iterator
130
+ begin()
131
+ { return iterator(_Base::begin(), this); }
132
+
133
+ const_iterator
134
+ begin() const
135
+ { return const_iterator(_Base::begin(), this); }
136
+
137
+ iterator
138
+ end()
139
+ { return iterator(_Base::end(), this); }
140
+
141
+ const_iterator
142
+ end() const
143
+ { return const_iterator(_Base::end(), this); }
144
+
145
+ reverse_iterator
146
+ rbegin()
147
+ { return reverse_iterator(end()); }
148
+
149
+ const_reverse_iterator
150
+ rbegin() const
151
+ { return const_reverse_iterator(end()); }
152
+
153
+ reverse_iterator
154
+ rend()
155
+ { return reverse_iterator(begin()); }
156
+
157
+ const_reverse_iterator
158
+ rend() const
159
+ { return const_reverse_iterator(begin()); }
160
+
161
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
162
+ const_iterator
163
+ cbegin() const
164
+ { return const_iterator(_Base::begin(), this); }
165
+
166
+ const_iterator
167
+ cend() const
168
+ { return const_iterator(_Base::end(), this); }
169
+
170
+ const_reverse_iterator
171
+ crbegin() const
172
+ { return const_reverse_iterator(end()); }
173
+
174
+ const_reverse_iterator
175
+ crend() const
176
+ { return const_reverse_iterator(begin()); }
177
+ #endif
178
+
179
+ // capacity:
180
+ using _Base::empty;
181
+ using _Base::size;
182
+ using _Base::max_size;
183
+
184
+ // 23.3.1.2 element access:
185
+ using _Base::operator[];
186
+
187
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
188
+ // DR 464. Suggestion for new member functions in standard containers.
189
+ using _Base::at;
190
+
191
+ // modifiers:
192
+ std::pair<iterator, bool>
193
+ insert(const value_type& __x)
194
+ {
195
+ typedef typename _Base::iterator _Base_iterator;
196
+ std::pair<_Base_iterator, bool> __res = _Base::insert(__x);
197
+ return std::pair<iterator, bool>(iterator(__res.first, this),
198
+ __res.second);
199
+ }
200
+
201
+ iterator
202
+ insert(iterator __position, const value_type& __x)
203
+ {
204
+ __glibcxx_check_insert(__position);
205
+ return iterator(_Base::insert(__position.base(), __x), this);
206
+ }
207
+
208
+ template<typename _InputIterator>
209
+ void
210
+ insert(_InputIterator __first, _InputIterator __last)
211
+ {
212
+ __glibcxx_check_valid_range(__first, __last);
213
+ _Base::insert(__first, __last);
214
+ }
215
+
216
+ void
217
+ erase(iterator __position)
218
+ {
219
+ __glibcxx_check_erase(__position);
220
+ __position._M_invalidate();
221
+ _Base::erase(__position.base());
222
+ }
223
+
224
+ size_type
225
+ erase(const key_type& __x)
226
+ {
227
+ iterator __victim = find(__x);
228
+ if (__victim == end())
229
+ return 0;
230
+ else
231
+ {
232
+ __victim._M_invalidate();
233
+ _Base::erase(__victim.base());
234
+ return 1;
235
+ }
236
+ }
237
+
238
+ void
239
+ erase(iterator __first, iterator __last)
240
+ {
241
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
242
+ // 151. can't currently clear() empty container
243
+ __glibcxx_check_erase_range(__first, __last);
244
+ while (__first != __last)
245
+ this->erase(__first++);
246
+ }
247
+
248
+ void
249
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
250
+ swap(map&& __x)
251
+ #else
252
+ swap(map& __x)
253
+ #endif
254
+ {
255
+ _Base::swap(__x);
256
+ this->_M_swap(__x);
257
+ }
258
+
259
+ void
260
+ clear()
261
+ { this->erase(begin(), end()); }
262
+
263
+ // observers:
264
+ using _Base::key_comp;
265
+ using _Base::value_comp;
266
+
267
+ // 23.3.1.3 map operations:
268
+ iterator
269
+ find(const key_type& __x)
270
+ { return iterator(_Base::find(__x), this); }
271
+
272
+ const_iterator
273
+ find(const key_type& __x) const
274
+ { return const_iterator(_Base::find(__x), this); }
275
+
276
+ using _Base::count;
277
+
278
+ iterator
279
+ lower_bound(const key_type& __x)
280
+ { return iterator(_Base::lower_bound(__x), this); }
281
+
282
+ const_iterator
283
+ lower_bound(const key_type& __x) const
284
+ { return const_iterator(_Base::lower_bound(__x), this); }
285
+
286
+ iterator
287
+ upper_bound(const key_type& __x)
288
+ { return iterator(_Base::upper_bound(__x), this); }
289
+
290
+ const_iterator
291
+ upper_bound(const key_type& __x) const
292
+ { return const_iterator(_Base::upper_bound(__x), this); }
293
+
294
+ std::pair<iterator,iterator>
295
+ equal_range(const key_type& __x)
296
+ {
297
+ typedef typename _Base::iterator _Base_iterator;
298
+ std::pair<_Base_iterator, _Base_iterator> __res =
299
+ _Base::equal_range(__x);
300
+ return std::make_pair(iterator(__res.first, this),
301
+ iterator(__res.second, this));
302
+ }
303
+
304
+ std::pair<const_iterator,const_iterator>
305
+ equal_range(const key_type& __x) const
306
+ {
307
+ typedef typename _Base::const_iterator _Base_const_iterator;
308
+ std::pair<_Base_const_iterator, _Base_const_iterator> __res =
309
+ _Base::equal_range(__x);
310
+ return std::make_pair(const_iterator(__res.first, this),
311
+ const_iterator(__res.second, this));
312
+ }
313
+
314
+ _Base&
315
+ _M_base() { return *this; }
316
+
317
+ const _Base&
318
+ _M_base() const { return *this; }
319
+
320
+ private:
321
+ void
322
+ _M_invalidate_all()
323
+ {
324
+ typedef typename _Base::const_iterator _Base_const_iterator;
325
+ typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
326
+ this->_M_invalidate_if(_Not_equal(_M_base().end()));
327
+ }
328
+ };
329
+
330
+ template<typename _Key, typename _Tp,
331
+ typename _Compare, typename _Allocator>
332
+ inline bool
333
+ operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
334
+ const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
335
+ { return __lhs._M_base() == __rhs._M_base(); }
336
+
337
+ template<typename _Key, typename _Tp,
338
+ typename _Compare, typename _Allocator>
339
+ inline bool
340
+ operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
341
+ const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
342
+ { return __lhs._M_base() != __rhs._M_base(); }
343
+
344
+ template<typename _Key, typename _Tp,
345
+ typename _Compare, typename _Allocator>
346
+ inline bool
347
+ operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
348
+ const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
349
+ { return __lhs._M_base() < __rhs._M_base(); }
350
+
351
+ template<typename _Key, typename _Tp,
352
+ typename _Compare, typename _Allocator>
353
+ inline bool
354
+ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
355
+ const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
356
+ { return __lhs._M_base() <= __rhs._M_base(); }
357
+
358
+ template<typename _Key, typename _Tp,
359
+ typename _Compare, typename _Allocator>
360
+ inline bool
361
+ operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
362
+ const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
363
+ { return __lhs._M_base() >= __rhs._M_base(); }
364
+
365
+ template<typename _Key, typename _Tp,
366
+ typename _Compare, typename _Allocator>
367
+ inline bool
368
+ operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
369
+ const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
370
+ { return __lhs._M_base() > __rhs._M_base(); }
371
+
372
+ template<typename _Key, typename _Tp,
373
+ typename _Compare, typename _Allocator>
374
+ inline void
375
+ swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
376
+ map<_Key, _Tp, _Compare, _Allocator>& __rhs)
377
+ { __lhs.swap(__rhs); }
378
+
379
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
380
+ template<typename _Key, typename _Tp,
381
+ typename _Compare, typename _Allocator>
382
+ inline void
383
+ swap(map<_Key, _Tp, _Compare, _Allocator>&& __lhs,
384
+ map<_Key, _Tp, _Compare, _Allocator>& __rhs)
385
+ { __lhs.swap(__rhs); }
386
+
387
+ template<typename _Key, typename _Tp,
388
+ typename _Compare, typename _Allocator>
389
+ inline void
390
+ swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
391
+ map<_Key, _Tp, _Compare, _Allocator>&& __rhs)
392
+ { __lhs.swap(__rhs); }
393
+ #endif
394
+
395
+ } // namespace __debug
396
+ } // namespace std
397
+
398
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/multimap.h ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging multimap implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/multimap.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_MULTIMAP_H
36
+ #define _GLIBCXX_DEBUG_MULTIMAP_H 1
37
+
38
+ #include <debug/safe_sequence.h>
39
+ #include <debug/safe_iterator.h>
40
+ #include <utility>
41
+
42
+ namespace std
43
+ {
44
+ namespace __debug
45
+ {
46
+ template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
47
+ typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
48
+ class multimap
49
+ : public _GLIBCXX_STD_D::multimap<_Key, _Tp, _Compare, _Allocator>,
50
+ public __gnu_debug::_Safe_sequence<multimap<_Key, _Tp,
51
+ _Compare, _Allocator> >
52
+ {
53
+ typedef _GLIBCXX_STD_D::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
54
+ typedef __gnu_debug::_Safe_sequence<multimap> _Safe_base;
55
+
56
+ public:
57
+ // types:
58
+ typedef _Key key_type;
59
+ typedef _Tp mapped_type;
60
+ typedef std::pair<const _Key, _Tp> value_type;
61
+ typedef _Compare key_compare;
62
+ typedef _Allocator allocator_type;
63
+ typedef typename _Base::reference reference;
64
+ typedef typename _Base::const_reference const_reference;
65
+
66
+ typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, multimap>
67
+ iterator;
68
+ typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
69
+ multimap> const_iterator;
70
+
71
+ typedef typename _Base::size_type size_type;
72
+ typedef typename _Base::difference_type difference_type;
73
+ typedef typename _Base::pointer pointer;
74
+ typedef typename _Base::const_pointer const_pointer;
75
+ typedef std::reverse_iterator<iterator> reverse_iterator;
76
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
77
+
78
+ using _Base::value_compare;
79
+
80
+ // 23.3.1.1 construct/copy/destroy:
81
+ explicit multimap(const _Compare& __comp = _Compare(),
82
+ const _Allocator& __a = _Allocator())
83
+ : _Base(__comp, __a) { }
84
+
85
+ template<typename _InputIterator>
86
+ multimap(_InputIterator __first, _InputIterator __last,
87
+ const _Compare& __comp = _Compare(),
88
+ const _Allocator& __a = _Allocator())
89
+ : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
90
+ __comp, __a) { }
91
+
92
+ multimap(const multimap& __x)
93
+ : _Base(__x), _Safe_base() { }
94
+
95
+ multimap(const _Base& __x)
96
+ : _Base(__x), _Safe_base() { }
97
+
98
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
99
+ multimap(multimap&& __x)
100
+ : _Base(std::forward<multimap>(__x)), _Safe_base()
101
+ { this->_M_swap(__x); }
102
+ #endif
103
+
104
+ ~multimap() { }
105
+
106
+ multimap&
107
+ operator=(const multimap& __x)
108
+ {
109
+ *static_cast<_Base*>(this) = __x;
110
+ this->_M_invalidate_all();
111
+ return *this;
112
+ }
113
+
114
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
115
+ multimap&
116
+ operator=(multimap&& __x)
117
+ {
118
+ // NB: DR 675.
119
+ clear();
120
+ swap(__x);
121
+ return *this;
122
+ }
123
+ #endif
124
+
125
+ using _Base::get_allocator;
126
+
127
+ // iterators:
128
+ iterator
129
+ begin()
130
+ { return iterator(_Base::begin(), this); }
131
+
132
+ const_iterator
133
+ begin() const
134
+ { return const_iterator(_Base::begin(), this); }
135
+
136
+ iterator
137
+ end()
138
+ { return iterator(_Base::end(), this); }
139
+
140
+ const_iterator
141
+ end() const
142
+ { return const_iterator(_Base::end(), this); }
143
+
144
+ reverse_iterator
145
+ rbegin()
146
+ { return reverse_iterator(end()); }
147
+
148
+ const_reverse_iterator
149
+ rbegin() const
150
+ { return const_reverse_iterator(end()); }
151
+
152
+ reverse_iterator
153
+ rend()
154
+ { return reverse_iterator(begin()); }
155
+
156
+ const_reverse_iterator
157
+ rend() const
158
+ { return const_reverse_iterator(begin()); }
159
+
160
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
161
+ const_iterator
162
+ cbegin() const
163
+ { return const_iterator(_Base::begin(), this); }
164
+
165
+ const_iterator
166
+ cend() const
167
+ { return const_iterator(_Base::end(), this); }
168
+
169
+ const_reverse_iterator
170
+ crbegin() const
171
+ { return const_reverse_iterator(end()); }
172
+
173
+ const_reverse_iterator
174
+ crend() const
175
+ { return const_reverse_iterator(begin()); }
176
+ #endif
177
+
178
+ // capacity:
179
+ using _Base::empty;
180
+ using _Base::size;
181
+ using _Base::max_size;
182
+
183
+ // modifiers:
184
+ iterator
185
+ insert(const value_type& __x)
186
+ { return iterator(_Base::insert(__x), this); }
187
+
188
+ iterator
189
+ insert(iterator __position, const value_type& __x)
190
+ {
191
+ __glibcxx_check_insert(__position);
192
+ return iterator(_Base::insert(__position.base(), __x), this);
193
+ }
194
+
195
+ template<typename _InputIterator>
196
+ void
197
+ insert(_InputIterator __first, _InputIterator __last)
198
+ {
199
+ __glibcxx_check_valid_range(__first, __last);
200
+ _Base::insert(__first, __last);
201
+ }
202
+
203
+ void
204
+ erase(iterator __position)
205
+ {
206
+ __glibcxx_check_erase(__position);
207
+ __position._M_invalidate();
208
+ _Base::erase(__position.base());
209
+ }
210
+
211
+ size_type
212
+ erase(const key_type& __x)
213
+ {
214
+ std::pair<iterator, iterator> __victims = this->equal_range(__x);
215
+ size_type __count = 0;
216
+ while (__victims.first != __victims.second)
217
+ {
218
+ iterator __victim = __victims.first++;
219
+ __victim._M_invalidate();
220
+ _Base::erase(__victim.base());
221
+ ++__count;
222
+ }
223
+ return __count;
224
+ }
225
+
226
+ void
227
+ erase(iterator __first, iterator __last)
228
+ {
229
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
230
+ // 151. can't currently clear() empty container
231
+ __glibcxx_check_erase_range(__first, __last);
232
+ while (__first != __last)
233
+ this->erase(__first++);
234
+ }
235
+
236
+ void
237
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
238
+ swap(multimap&& __x)
239
+ #else
240
+ swap(multimap& __x)
241
+ #endif
242
+ {
243
+ _Base::swap(__x);
244
+ this->_M_swap(__x);
245
+ }
246
+
247
+ void
248
+ clear()
249
+ { this->erase(begin(), end()); }
250
+
251
+ // observers:
252
+ using _Base::key_comp;
253
+ using _Base::value_comp;
254
+
255
+ // 23.3.1.3 multimap operations:
256
+ iterator
257
+ find(const key_type& __x)
258
+ { return iterator(_Base::find(__x), this); }
259
+
260
+ const_iterator
261
+ find(const key_type& __x) const
262
+ { return const_iterator(_Base::find(__x), this); }
263
+
264
+ using _Base::count;
265
+
266
+ iterator
267
+ lower_bound(const key_type& __x)
268
+ { return iterator(_Base::lower_bound(__x), this); }
269
+
270
+ const_iterator
271
+ lower_bound(const key_type& __x) const
272
+ { return const_iterator(_Base::lower_bound(__x), this); }
273
+
274
+ iterator
275
+ upper_bound(const key_type& __x)
276
+ { return iterator(_Base::upper_bound(__x), this); }
277
+
278
+ const_iterator
279
+ upper_bound(const key_type& __x) const
280
+ { return const_iterator(_Base::upper_bound(__x), this); }
281
+
282
+ std::pair<iterator,iterator>
283
+ equal_range(const key_type& __x)
284
+ {
285
+ typedef typename _Base::iterator _Base_iterator;
286
+ std::pair<_Base_iterator, _Base_iterator> __res =
287
+ _Base::equal_range(__x);
288
+ return std::make_pair(iterator(__res.first, this),
289
+ iterator(__res.second, this));
290
+ }
291
+
292
+ std::pair<const_iterator,const_iterator>
293
+ equal_range(const key_type& __x) const
294
+ {
295
+ typedef typename _Base::const_iterator _Base_const_iterator;
296
+ std::pair<_Base_const_iterator, _Base_const_iterator> __res =
297
+ _Base::equal_range(__x);
298
+ return std::make_pair(const_iterator(__res.first, this),
299
+ const_iterator(__res.second, this));
300
+ }
301
+
302
+ _Base&
303
+ _M_base() { return *this; }
304
+
305
+ const _Base&
306
+ _M_base() const { return *this; }
307
+
308
+ private:
309
+ void
310
+ _M_invalidate_all()
311
+ {
312
+ typedef typename _Base::const_iterator _Base_const_iterator;
313
+ typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
314
+ this->_M_invalidate_if(_Not_equal(_M_base().end()));
315
+ }
316
+ };
317
+
318
+ template<typename _Key, typename _Tp,
319
+ typename _Compare, typename _Allocator>
320
+ inline bool
321
+ operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
322
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
323
+ { return __lhs._M_base() == __rhs._M_base(); }
324
+
325
+ template<typename _Key, typename _Tp,
326
+ typename _Compare, typename _Allocator>
327
+ inline bool
328
+ operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
329
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
330
+ { return __lhs._M_base() != __rhs._M_base(); }
331
+
332
+ template<typename _Key, typename _Tp,
333
+ typename _Compare, typename _Allocator>
334
+ inline bool
335
+ operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
336
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
337
+ { return __lhs._M_base() < __rhs._M_base(); }
338
+
339
+ template<typename _Key, typename _Tp,
340
+ typename _Compare, typename _Allocator>
341
+ inline bool
342
+ operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
343
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
344
+ { return __lhs._M_base() <= __rhs._M_base(); }
345
+
346
+ template<typename _Key, typename _Tp,
347
+ typename _Compare, typename _Allocator>
348
+ inline bool
349
+ operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
350
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
351
+ { return __lhs._M_base() >= __rhs._M_base(); }
352
+
353
+ template<typename _Key, typename _Tp,
354
+ typename _Compare, typename _Allocator>
355
+ inline bool
356
+ operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
357
+ const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
358
+ { return __lhs._M_base() > __rhs._M_base(); }
359
+
360
+ template<typename _Key, typename _Tp,
361
+ typename _Compare, typename _Allocator>
362
+ inline void
363
+ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
364
+ multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
365
+ { __lhs.swap(__rhs); }
366
+
367
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
368
+ template<typename _Key, typename _Tp,
369
+ typename _Compare, typename _Allocator>
370
+ inline void
371
+ swap(multimap<_Key, _Tp, _Compare, _Allocator>&& __lhs,
372
+ multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
373
+ { __lhs.swap(__rhs); }
374
+
375
+ template<typename _Key, typename _Tp,
376
+ typename _Compare, typename _Allocator>
377
+ inline void
378
+ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
379
+ multimap<_Key, _Tp, _Compare, _Allocator>&& __rhs)
380
+ { __lhs.swap(__rhs); }
381
+ #endif
382
+
383
+ } // namespace __debug
384
+ } // namespace std
385
+
386
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/multiset.h ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Debugging multiset implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006, 2007
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/multiset.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_MULTISET_H
36
+ #define _GLIBCXX_DEBUG_MULTISET_H 1
37
+
38
+ #include <debug/safe_sequence.h>
39
+ #include <debug/safe_iterator.h>
40
+ #include <utility>
41
+
42
+ namespace std
43
+ {
44
+ namespace __debug
45
+ {
46
+ template<typename _Key, typename _Compare = std::less<_Key>,
47
+ typename _Allocator = std::allocator<_Key> >
48
+ class multiset
49
+ : public _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator>,
50
+ public __gnu_debug::_Safe_sequence<multiset<_Key, _Compare, _Allocator> >
51
+ {
52
+ typedef _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator> _Base;
53
+ typedef __gnu_debug::_Safe_sequence<multiset> _Safe_base;
54
+
55
+ public:
56
+ // types:
57
+ typedef _Key key_type;
58
+ typedef _Key value_type;
59
+ typedef _Compare key_compare;
60
+ typedef _Compare value_compare;
61
+ typedef _Allocator allocator_type;
62
+ typedef typename _Base::reference reference;
63
+ typedef typename _Base::const_reference const_reference;
64
+
65
+ typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, multiset>
66
+ iterator;
67
+ typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
68
+ multiset> const_iterator;
69
+
70
+ typedef typename _Base::size_type size_type;
71
+ typedef typename _Base::difference_type difference_type;
72
+ typedef typename _Base::pointer pointer;
73
+ typedef typename _Base::const_pointer const_pointer;
74
+ typedef std::reverse_iterator<iterator> reverse_iterator;
75
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
76
+
77
+ // 23.3.3.1 construct/copy/destroy:
78
+ explicit multiset(const _Compare& __comp = _Compare(),
79
+ const _Allocator& __a = _Allocator())
80
+ : _Base(__comp, __a) { }
81
+
82
+ template<typename _InputIterator>
83
+ multiset(_InputIterator __first, _InputIterator __last,
84
+ const _Compare& __comp = _Compare(),
85
+ const _Allocator& __a = _Allocator())
86
+ : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
87
+ __comp, __a) { }
88
+
89
+ multiset(const multiset& __x)
90
+ : _Base(__x), _Safe_base() { }
91
+
92
+ multiset(const _Base& __x)
93
+ : _Base(__x), _Safe_base() { }
94
+
95
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
96
+ multiset(multiset&& __x)
97
+ : _Base(std::forward<multiset>(__x)), _Safe_base()
98
+ { this->_M_swap(__x); }
99
+ #endif
100
+
101
+ ~multiset() { }
102
+
103
+ multiset&
104
+ operator=(const multiset& __x)
105
+ {
106
+ *static_cast<_Base*>(this) = __x;
107
+ this->_M_invalidate_all();
108
+ return *this;
109
+ }
110
+
111
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
112
+ multiset&
113
+ operator=(multiset&& __x)
114
+ {
115
+ // NB: DR 675.
116
+ clear();
117
+ swap(__x);
118
+ return *this;
119
+ }
120
+ #endif
121
+
122
+ using _Base::get_allocator;
123
+
124
+ // iterators:
125
+ iterator
126
+ begin()
127
+ { return iterator(_Base::begin(), this); }
128
+
129
+ const_iterator
130
+ begin() const
131
+ { return const_iterator(_Base::begin(), this); }
132
+
133
+ iterator
134
+ end()
135
+ { return iterator(_Base::end(), this); }
136
+
137
+ const_iterator
138
+ end() const
139
+ { return const_iterator(_Base::end(), this); }
140
+
141
+ reverse_iterator
142
+ rbegin()
143
+ { return reverse_iterator(end()); }
144
+
145
+ const_reverse_iterator
146
+ rbegin() const
147
+ { return const_reverse_iterator(end()); }
148
+
149
+ reverse_iterator
150
+ rend()
151
+ { return reverse_iterator(begin()); }
152
+
153
+ const_reverse_iterator
154
+ rend() const
155
+ { return const_reverse_iterator(begin()); }
156
+
157
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
158
+ const_iterator
159
+ cbegin() const
160
+ { return const_iterator(_Base::begin(), this); }
161
+
162
+ const_iterator
163
+ cend() const
164
+ { return const_iterator(_Base::end(), this); }
165
+
166
+ const_reverse_iterator
167
+ crbegin() const
168
+ { return const_reverse_iterator(end()); }
169
+
170
+ const_reverse_iterator
171
+ crend() const
172
+ { return const_reverse_iterator(begin()); }
173
+ #endif
174
+
175
+ // capacity:
176
+ using _Base::empty;
177
+ using _Base::size;
178
+ using _Base::max_size;
179
+
180
+ // modifiers:
181
+ iterator
182
+ insert(const value_type& __x)
183
+ { return iterator(_Base::insert(__x), this); }
184
+
185
+ iterator
186
+ insert(iterator __position, const value_type& __x)
187
+ {
188
+ __glibcxx_check_insert(__position);
189
+ return iterator(_Base::insert(__position.base(), __x), this);
190
+ }
191
+
192
+ template<typename _InputIterator>
193
+ void
194
+ insert(_InputIterator __first, _InputIterator __last)
195
+ {
196
+ __glibcxx_check_valid_range(__first, __last);
197
+ _Base::insert(__first, __last);
198
+ }
199
+
200
+ void
201
+ erase(iterator __position)
202
+ {
203
+ __glibcxx_check_erase(__position);
204
+ __position._M_invalidate();
205
+ _Base::erase(__position.base());
206
+ }
207
+
208
+ size_type
209
+ erase(const key_type& __x)
210
+ {
211
+ std::pair<iterator, iterator> __victims = this->equal_range(__x);
212
+ size_type __count = 0;
213
+ while (__victims.first != __victims.second)
214
+ {
215
+ iterator __victim = __victims.first++;
216
+ __victim._M_invalidate();
217
+ _Base::erase(__victim.base());
218
+ ++__count;
219
+ }
220
+ return __count;
221
+ }
222
+
223
+ void
224
+ erase(iterator __first, iterator __last)
225
+ {
226
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
227
+ // 151. can't currently clear() empty container
228
+ __glibcxx_check_erase_range(__first, __last);
229
+ while (__first != __last)
230
+ this->erase(__first++);
231
+ }
232
+
233
+ void
234
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
235
+ swap(multiset&& __x)
236
+ #else
237
+ swap(multiset& __x)
238
+ #endif
239
+ {
240
+ _Base::swap(__x);
241
+ this->_M_swap(__x);
242
+ }
243
+
244
+ void
245
+ clear()
246
+ { this->erase(begin(), end()); }
247
+
248
+ // observers:
249
+ using _Base::key_comp;
250
+ using _Base::value_comp;
251
+
252
+ // multiset operations:
253
+ iterator
254
+ find(const key_type& __x)
255
+ { return iterator(_Base::find(__x), this); }
256
+
257
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
258
+ // 214. set::find() missing const overload
259
+ const_iterator
260
+ find(const key_type& __x) const
261
+ { return const_iterator(_Base::find(__x), this); }
262
+
263
+ using _Base::count;
264
+
265
+ iterator
266
+ lower_bound(const key_type& __x)
267
+ { return iterator(_Base::lower_bound(__x), this); }
268
+
269
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
270
+ // 214. set::find() missing const overload
271
+ const_iterator
272
+ lower_bound(const key_type& __x) const
273
+ { return const_iterator(_Base::lower_bound(__x), this); }
274
+
275
+ iterator
276
+ upper_bound(const key_type& __x)
277
+ { return iterator(_Base::upper_bound(__x), this); }
278
+
279
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
280
+ // 214. set::find() missing const overload
281
+ const_iterator
282
+ upper_bound(const key_type& __x) const
283
+ { return const_iterator(_Base::upper_bound(__x), this); }
284
+
285
+ std::pair<iterator,iterator>
286
+ equal_range(const key_type& __x)
287
+ {
288
+ typedef typename _Base::iterator _Base_iterator;
289
+ std::pair<_Base_iterator, _Base_iterator> __res =
290
+ _Base::equal_range(__x);
291
+ return std::make_pair(iterator(__res.first, this),
292
+ iterator(__res.second, this));
293
+ }
294
+
295
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
296
+ // 214. set::find() missing const overload
297
+ std::pair<const_iterator,const_iterator>
298
+ equal_range(const key_type& __x) const
299
+ {
300
+ typedef typename _Base::const_iterator _Base_iterator;
301
+ std::pair<_Base_iterator, _Base_iterator> __res =
302
+ _Base::equal_range(__x);
303
+ return std::make_pair(const_iterator(__res.first, this),
304
+ const_iterator(__res.second, this));
305
+ }
306
+
307
+ _Base&
308
+ _M_base() { return *this; }
309
+
310
+ const _Base&
311
+ _M_base() const { return *this; }
312
+
313
+ private:
314
+ void
315
+ _M_invalidate_all()
316
+ {
317
+ typedef typename _Base::const_iterator _Base_const_iterator;
318
+ typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
319
+ this->_M_invalidate_if(_Not_equal(_M_base().end()));
320
+ }
321
+ };
322
+
323
+ template<typename _Key, typename _Compare, typename _Allocator>
324
+ inline bool
325
+ operator==(const multiset<_Key, _Compare, _Allocator>& __lhs,
326
+ const multiset<_Key, _Compare, _Allocator>& __rhs)
327
+ { return __lhs._M_base() == __rhs._M_base(); }
328
+
329
+ template<typename _Key, typename _Compare, typename _Allocator>
330
+ inline bool
331
+ operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
332
+ const multiset<_Key, _Compare, _Allocator>& __rhs)
333
+ { return __lhs._M_base() != __rhs._M_base(); }
334
+
335
+ template<typename _Key, typename _Compare, typename _Allocator>
336
+ inline bool
337
+ operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
338
+ const multiset<_Key, _Compare, _Allocator>& __rhs)
339
+ { return __lhs._M_base() < __rhs._M_base(); }
340
+
341
+ template<typename _Key, typename _Compare, typename _Allocator>
342
+ inline bool
343
+ operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
344
+ const multiset<_Key, _Compare, _Allocator>& __rhs)
345
+ { return __lhs._M_base() <= __rhs._M_base(); }
346
+
347
+ template<typename _Key, typename _Compare, typename _Allocator>
348
+ inline bool
349
+ operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs,
350
+ const multiset<_Key, _Compare, _Allocator>& __rhs)
351
+ { return __lhs._M_base() >= __rhs._M_base(); }
352
+
353
+ template<typename _Key, typename _Compare, typename _Allocator>
354
+ inline bool
355
+ operator>(const multiset<_Key, _Compare, _Allocator>& __lhs,
356
+ const multiset<_Key, _Compare, _Allocator>& __rhs)
357
+ { return __lhs._M_base() > __rhs._M_base(); }
358
+
359
+ template<typename _Key, typename _Compare, typename _Allocator>
360
+ void
361
+ swap(multiset<_Key, _Compare, _Allocator>& __x,
362
+ multiset<_Key, _Compare, _Allocator>& __y)
363
+ { return __x.swap(__y); }
364
+
365
+ #ifdef __GXX_EXPERIMENTAL_CXX0X__
366
+ template<typename _Key, typename _Compare, typename _Allocator>
367
+ void
368
+ swap(multiset<_Key, _Compare, _Allocator>&& __x,
369
+ multiset<_Key, _Compare, _Allocator>& __y)
370
+ { return __x.swap(__y); }
371
+
372
+ template<typename _Key, typename _Compare, typename _Allocator>
373
+ void
374
+ swap(multiset<_Key, _Compare, _Allocator>& __x,
375
+ multiset<_Key, _Compare, _Allocator>&& __y)
376
+ { return __x.swap(__y); }
377
+ #endif
378
+
379
+ } // namespace __debug
380
+ } // namespace std
381
+
382
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/safe_association.h ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Safe associated container base class implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2007 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
+ /** @file debug/safe_association.h
31
+ * This file is a GNU debug extension to the Standard C++ Library.
32
+ */
33
+
34
+ #ifndef _GLIBCXX_DEBUG_SAFE_ASSOCIATION_H
35
+ #define _GLIBCXX_DEBUG_SAFE_ASSOCIATION_H 1
36
+
37
+ #include <debug/debug.h>
38
+ #include <debug/macros.h>
39
+ #include <debug/functions.h>
40
+ #include <debug/formatter.h>
41
+ #include <debug/safe_sequence.h>
42
+
43
+ namespace __gnu_debug
44
+ {
45
+ /**
46
+ * @brief Base class for constructing a "safe" associated container type.
47
+ *
48
+ * The class template %_Safe_association simplifies the construction of
49
+ * "safe" associated containers.
50
+ */
51
+ template<typename _Base>
52
+ class _Safe_association
53
+ : public _Base
54
+ {
55
+ public:
56
+ typedef typename _Base::size_type size_type;
57
+ typedef typename _Base::hasher hasher;
58
+ typedef typename _Base::key_equal key_equal;
59
+ typedef typename _Base::allocator_type allocator_type;
60
+
61
+ typedef typename _Base::key_type key_type;
62
+ typedef typename _Base::value_type value_type;
63
+ typedef typename _Base::difference_type difference_type;
64
+ typedef typename _Base::reference reference;
65
+ typedef typename _Base::const_reference const_reference;
66
+
67
+ typedef __gnu_debug::_Safe_iterator<typename _Base::iterator,
68
+ _Safe_association>
69
+ iterator;
70
+ typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
71
+ _Safe_association>
72
+ const_iterator;
73
+
74
+ _Safe_association() { }
75
+
76
+ explicit _Safe_association(size_type __n) : _Base(__n) { }
77
+
78
+ _Safe_association(size_type __n, const hasher& __hf)
79
+ : _Base(__n, __hf) { }
80
+
81
+ _Safe_association(size_type __n, const hasher& __hf,
82
+ const key_equal& __eql,
83
+ const allocator_type& __a = allocator_type())
84
+ : _Base(__n, __hf, __eql, __a) { }
85
+
86
+ template<typename _InputIter>
87
+ _Safe_association(_InputIter __f, _InputIter __l)
88
+ : _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { }
89
+
90
+ template<typename _InputIter>
91
+ _Safe_association(_InputIter __f, _InputIter __l, size_type __n)
92
+ : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { }
93
+
94
+ template<typename _InputIter>
95
+ _Safe_association(_InputIter __f, _InputIter __l, size_type __n,
96
+ const hasher& __hf)
97
+ : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf)
98
+ { }
99
+
100
+ template<typename _InputIter>
101
+ _Safe_association(_InputIter __f, _InputIter __l, size_type __n,
102
+ const hasher& __hf, const key_equal& __eql,
103
+ const allocator_type& __a = allocator_type())
104
+ : _Base(__gnu_debug::__check_valid_range(__f, __l),
105
+ __l, __n, __hf, __eql, __a)
106
+ { }
107
+
108
+ _Safe_association(const _Base& __x) : _Base(__x) { }
109
+
110
+ _Safe_association(_Safe_association&& __x)
111
+ : _Base(std::forward<_Base>(__x)) { }
112
+
113
+ using _Base::size;
114
+ using _Base::max_size;
115
+ using _Base::empty;
116
+ using _Base::get_allocator;
117
+ using _Base::key_eq;
118
+
119
+ using _Base::count;
120
+ using _Base::bucket_count;
121
+ using _Base::max_bucket_count;
122
+ using _Base::bucket;
123
+ using _Base::bucket_size;
124
+ using _Base::load_factor;
125
+
126
+ const_iterator
127
+ begin() const { return const_iterator(_Base::begin(), this); }
128
+
129
+ const_iterator
130
+ end() const { return const_iterator(_Base::end(), this); }
131
+
132
+ std::pair<iterator, bool>
133
+ insert(const value_type& __obj)
134
+ {
135
+ typedef std::pair<typename _Base::iterator, bool> __pair_type;
136
+ __pair_type __res = _Base::insert(__obj);
137
+ return std::make_pair(iterator(__res.first, this), __res.second);
138
+ }
139
+
140
+ void
141
+ insert(const value_type* __first, const value_type* __last)
142
+ {
143
+ __glibcxx_check_valid_range(__first, __last);
144
+ _Base::insert(__first, __last);
145
+ }
146
+
147
+ template<typename _InputIter>
148
+ void
149
+ insert(_InputIter __first, _InputIter __last)
150
+ {
151
+ __glibcxx_check_valid_range(__first, __last);
152
+ _Base::insert(__first.base(), __last.base());
153
+ }
154
+
155
+ const_iterator
156
+ find(const key_type& __key) const
157
+ { return const_iterator(_Base::find(__key), this); }
158
+
159
+ std::pair<const_iterator, const_iterator>
160
+ equal_range(const key_type& __key) const
161
+ {
162
+ typedef typename _Base::const_iterator _Base_iterator;
163
+ typedef std::pair<_Base_iterator, _Base_iterator> __pair_type;
164
+ __pair_type __res = _Base::equal_range(__key);
165
+ return std::make_pair(const_iterator(__res.first, this),
166
+ const_iterator(__res.second, this));
167
+ }
168
+
169
+ size_type
170
+ erase(const key_type& __key)
171
+ {
172
+ size_type __ret(0);
173
+ iterator __victim(_Base::find(__key), this);
174
+ if (__victim != end())
175
+ {
176
+ this->erase(__victim);
177
+ __ret = 1;
178
+ }
179
+ return __ret;
180
+ }
181
+
182
+ iterator
183
+ erase(iterator __it)
184
+ {
185
+ __glibcxx_check_erase(__it);
186
+ __it._M_invalidate();
187
+ return iterator(_Base::erase(__it.base()));
188
+ }
189
+
190
+ iterator
191
+ erase(iterator __first, iterator __last)
192
+ {
193
+ __glibcxx_check_erase_range(__first, __last);
194
+ for (iterator __tmp = __first; __tmp != __last;)
195
+ {
196
+ iterator __victim = __tmp++;
197
+ __victim._M_invalidate();
198
+ }
199
+ return iterator(_Base::erase(__first.base(), __last.base()));
200
+ }
201
+
202
+ _Base&
203
+ _M_base() { return *this; }
204
+
205
+ const _Base&
206
+ _M_base() const { return *this; }
207
+ };
208
+ } // namespace __gnu_debug
209
+
210
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/safe_base.h ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Safe sequence/iterator base implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/safe_base.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_SAFE_BASE_H
36
+ #define _GLIBCXX_DEBUG_SAFE_BASE_H 1
37
+
38
+ #include <ext/concurrence.h>
39
+
40
+ namespace __gnu_debug
41
+ {
42
+ class _Safe_sequence_base;
43
+
44
+ /** \brief Basic functionality for a "safe" iterator.
45
+ *
46
+ * The %_Safe_iterator_base base class implements the functionality
47
+ * of a safe iterator that is not specific to a particular iterator
48
+ * type. It contains a pointer back to the sequence it references
49
+ * along with iterator version information and pointers to form a
50
+ * doubly-linked list of iterators referenced by the container.
51
+ *
52
+ * This class must not perform any operations that can throw an
53
+ * exception, or the exception guarantees of derived iterators will
54
+ * be broken.
55
+ */
56
+ class _Safe_iterator_base
57
+ {
58
+ public:
59
+ /** The sequence this iterator references; may be NULL to indicate
60
+ a singular iterator. */
61
+ _Safe_sequence_base* _M_sequence;
62
+
63
+ /** The version number of this iterator. The sentinel value 0 is
64
+ * used to indicate an invalidated iterator (i.e., one that is
65
+ * singular because of an operation on the container). This
66
+ * version number must equal the version number in the sequence
67
+ * referenced by _M_sequence for the iterator to be
68
+ * non-singular.
69
+ */
70
+ unsigned int _M_version;
71
+
72
+ /** Pointer to the previous iterator in the sequence's list of
73
+ iterators. Only valid when _M_sequence != NULL. */
74
+ _Safe_iterator_base* _M_prior;
75
+
76
+ /** Pointer to the next iterator in the sequence's list of
77
+ iterators. Only valid when _M_sequence != NULL. */
78
+ _Safe_iterator_base* _M_next;
79
+
80
+ protected:
81
+ /** Initializes the iterator and makes it singular. */
82
+ _Safe_iterator_base()
83
+ : _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0)
84
+ { }
85
+
86
+ /** Initialize the iterator to reference the sequence pointed to
87
+ * by @p__seq. @p __constant is true when we are initializing a
88
+ * constant iterator, and false if it is a mutable iterator. Note
89
+ * that @p __seq may be NULL, in which case the iterator will be
90
+ * singular. Otherwise, the iterator will reference @p __seq and
91
+ * be nonsingular.
92
+ */
93
+ _Safe_iterator_base(const _Safe_sequence_base* __seq, bool __constant)
94
+ : _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0)
95
+ { this->_M_attach(const_cast<_Safe_sequence_base*>(__seq), __constant); }
96
+
97
+ /** Initializes the iterator to reference the same sequence that
98
+ @p __x does. @p __constant is true if this is a constant
99
+ iterator, and false if it is mutable. */
100
+ _Safe_iterator_base(const _Safe_iterator_base& __x, bool __constant)
101
+ : _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0)
102
+ { this->_M_attach(__x._M_sequence, __constant); }
103
+
104
+ _Safe_iterator_base&
105
+ operator=(const _Safe_iterator_base&);
106
+
107
+ explicit
108
+ _Safe_iterator_base(const _Safe_iterator_base&);
109
+
110
+ ~_Safe_iterator_base() { this->_M_detach(); }
111
+
112
+ /** For use in _Safe_iterator. */
113
+ __gnu_cxx::__mutex& _M_get_mutex();
114
+
115
+ public:
116
+ /** Attaches this iterator to the given sequence, detaching it
117
+ * from whatever sequence it was attached to originally. If the
118
+ * new sequence is the NULL pointer, the iterator is left
119
+ * unattached.
120
+ */
121
+ void _M_attach(_Safe_sequence_base* __seq, bool __constant);
122
+
123
+ /** Likewise, but not thread-safe. */
124
+ void _M_attach_single(_Safe_sequence_base* __seq, bool __constant);
125
+
126
+ /** Detach the iterator for whatever sequence it is attached to,
127
+ * if any.
128
+ */
129
+ void _M_detach();
130
+
131
+ /** Likewise, but not thread-safe. */
132
+ void _M_detach_single();
133
+
134
+ /** Determines if we are attached to the given sequence. */
135
+ bool _M_attached_to(const _Safe_sequence_base* __seq) const
136
+ { return _M_sequence == __seq; }
137
+
138
+ /** Is this iterator singular? */
139
+ bool _M_singular() const;
140
+
141
+ /** Can we compare this iterator to the given iterator @p __x?
142
+ Returns true if both iterators are nonsingular and reference
143
+ the same sequence. */
144
+ bool _M_can_compare(const _Safe_iterator_base& __x) const;
145
+ };
146
+
147
+ /**
148
+ * @brief Base class that supports tracking of iterators that
149
+ * reference a sequence.
150
+ *
151
+ * The %_Safe_sequence_base class provides basic support for
152
+ * tracking iterators into a sequence. Sequences that track
153
+ * iterators must derived from %_Safe_sequence_base publicly, so
154
+ * that safe iterators (which inherit _Safe_iterator_base) can
155
+ * attach to them. This class contains two linked lists of
156
+ * iterators, one for constant iterators and one for mutable
157
+ * iterators, and a version number that allows very fast
158
+ * invalidation of all iterators that reference the container.
159
+ *
160
+ * This class must ensure that no operation on it may throw an
161
+ * exception, otherwise "safe" sequences may fail to provide the
162
+ * exception-safety guarantees required by the C++ standard.
163
+ */
164
+ class _Safe_sequence_base
165
+ {
166
+ public:
167
+ /// The list of mutable iterators that reference this container
168
+ _Safe_iterator_base* _M_iterators;
169
+
170
+ /// The list of constant iterators that reference this container
171
+ _Safe_iterator_base* _M_const_iterators;
172
+
173
+ /// The container version number. This number may never be 0.
174
+ mutable unsigned int _M_version;
175
+
176
+ protected:
177
+ // Initialize with a version number of 1 and no iterators
178
+ _Safe_sequence_base()
179
+ : _M_iterators(0), _M_const_iterators(0), _M_version(1)
180
+ { }
181
+
182
+ /** Notify all iterators that reference this sequence that the
183
+ sequence is being destroyed. */
184
+ ~_Safe_sequence_base()
185
+ { this->_M_detach_all(); }
186
+
187
+ /** Detach all iterators, leaving them singular. */
188
+ void
189
+ _M_detach_all();
190
+
191
+ /** Detach all singular iterators.
192
+ * @post for all iterators i attached to this sequence,
193
+ * i->_M_version == _M_version.
194
+ */
195
+ void
196
+ _M_detach_singular();
197
+
198
+ /** Revalidates all attached singular iterators. This method may
199
+ * be used to validate iterators that were invalidated before
200
+ * (but for some reason, such as an exception, need to become
201
+ * valid again).
202
+ */
203
+ void
204
+ _M_revalidate_singular();
205
+
206
+ /** Swap this sequence with the given sequence. This operation
207
+ * also swaps ownership of the iterators, so that when the
208
+ * operation is complete all iterators that originally referenced
209
+ * one container now reference the other container.
210
+ */
211
+ void
212
+ _M_swap(_Safe_sequence_base& __x);
213
+
214
+ /** For use in _Safe_sequence. */
215
+ __gnu_cxx::__mutex& _M_get_mutex();
216
+
217
+ public:
218
+ /** Invalidates all iterators. */
219
+ void
220
+ _M_invalidate_all() const
221
+ { if (++_M_version == 0) _M_version = 1; }
222
+ };
223
+ } // namespace __gnu_debug
224
+
225
+ #endif
mingw/lib/gcc/mingw32/4.3.3/include/c++/debug/safe_iterator.h ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Safe iterator implementation -*- C++ -*-
2
+
3
+ // Copyright (C) 2003, 2004, 2005, 2006
4
+ // Free Software Foundation, Inc.
5
+ //
6
+ // This file is part of the GNU ISO C++ Library. This library is free
7
+ // software; you can redistribute it and/or modify it under the
8
+ // terms of the GNU General Public License as published by the
9
+ // Free Software Foundation; either version 2, or (at your option)
10
+ // any later version.
11
+
12
+ // This library is distributed in the hope that it will be useful,
13
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ // GNU General Public License for more details.
16
+
17
+ // You should have received a copy of the GNU General Public License along
18
+ // with this library; see the file COPYING. If not, write to the Free
19
+ // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
+ // USA.
21
+
22
+ // As a special exception, you may use this file as part of a free software
23
+ // library without restriction. Specifically, if other files instantiate
24
+ // templates or use macros or inline functions from this file, or you compile
25
+ // this file and link it with other files to produce an executable, this
26
+ // file does not by itself cause the resulting executable to be covered by
27
+ // the GNU General Public License. This exception does not however
28
+ // invalidate any other reasons why the executable file might be covered by
29
+ // the GNU General Public License.
30
+
31
+ /** @file debug/safe_iterator.h
32
+ * This file is a GNU debug extension to the Standard C++ Library.
33
+ */
34
+
35
+ #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H
36
+ #define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1
37
+
38
+ #include <debug/debug.h>
39
+ #include <debug/macros.h>
40
+ #include <debug/functions.h>
41
+ #include <debug/formatter.h>
42
+ #include <debug/safe_base.h>
43
+ #include <bits/stl_pair.h>
44
+ #include <ext/type_traits.h>
45
+
46
+ namespace __gnu_debug
47
+ {
48
+ /** Iterators that derive from _Safe_iterator_base but that aren't
49
+ * _Safe_iterators can be determined singular or non-singular via
50
+ * _Safe_iterator_base.
51
+ */
52
+ inline bool
53
+ __check_singular_aux(const _Safe_iterator_base* __x)
54
+ { return __x->_M_singular(); }
55
+
56
+ /** \brief Safe iterator wrapper.
57
+ *
58
+ * The class template %_Safe_iterator is a wrapper around an
59
+ * iterator that tracks the iterator's movement among sequences and
60
+ * checks that operations performed on the "safe" iterator are
61
+ * legal. In additional to the basic iterator operations (which are
62
+ * validated, and then passed to the underlying iterator),
63
+ * %_Safe_iterator has member functions for iterator invalidation,
64
+ * attaching/detaching the iterator from sequences, and querying
65
+ * the iterator's state.
66
+ */
67
+ template<typename _Iterator, typename _Sequence>
68
+ class _Safe_iterator : public _Safe_iterator_base
69
+ {
70
+ typedef _Safe_iterator _Self;
71
+
72
+ /** The precision to which we can calculate the distance between
73
+ * two iterators.
74
+ */
75
+ enum _Distance_precision
76
+ {
77
+ __dp_equality, //< Can compare iterator equality, only
78
+ __dp_sign, //< Can determine equality and ordering
79
+ __dp_exact //< Can determine distance precisely
80
+ };
81
+
82
+ /// The underlying iterator
83
+ _Iterator _M_current;
84
+
85
+ /// Determine if this is a constant iterator.
86
+ bool
87
+ _M_constant() const
88
+ {
89
+ typedef typename _Sequence::const_iterator const_iterator;
90
+ return __is_same<const_iterator, _Safe_iterator>::value;
91
+ }
92
+
93
+ typedef std::iterator_traits<_Iterator> _Traits;
94
+
95
+ public:
96
+ typedef _Iterator _Base_iterator;
97
+ typedef typename _Traits::iterator_category iterator_category;
98
+ typedef typename _Traits::value_type value_type;
99
+ typedef typename _Traits::difference_type difference_type;
100
+ typedef typename _Traits::reference reference;
101
+ typedef typename _Traits::pointer pointer;
102
+
103
+ /// @post the iterator is singular and unattached
104
+ _Safe_iterator() : _M_current() { }
105
+
106
+ /**
107
+ * @brief Safe iterator construction from an unsafe iterator and
108
+ * its sequence.
109
+ *
110
+ * @pre @p seq is not NULL
111
+ * @post this is not singular
112
+ */
113
+ _Safe_iterator(const _Iterator& __i, const _Sequence* __seq)
114
+ : _Safe_iterator_base(__seq, _M_constant()), _M_current(__i)
115
+ {
116
+ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
117
+ _M_message(__msg_init_singular)
118
+ ._M_iterator(*this, "this"));
119
+ }
120
+
121
+ /**
122
+ * @brief Copy construction.
123
+ * @pre @p x is not singular
124
+ */
125
+ _Safe_iterator(const _Safe_iterator& __x)
126
+ : _Safe_iterator_base(__x, _M_constant()), _M_current(__x._M_current)
127
+ {
128
+ _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
129
+ _M_message(__msg_init_copy_singular)
130
+ ._M_iterator(*this, "this")
131
+ ._M_iterator(__x, "other"));
132
+ }
133
+
134
+ /**
135
+ * @brief Converting constructor from a mutable iterator to a
136
+ * constant iterator.
137
+ *
138
+ * @pre @p x is not singular
139
+ */
140
+ template<typename _MutableIterator>
141
+ _Safe_iterator(
142
+ const _Safe_iterator<_MutableIterator,
143
+ typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator,
144
+ typename _Sequence::iterator::_Base_iterator>::__value),
145
+ _Sequence>::__type>& __x)
146
+ : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base())
147
+ {
148
+ _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
149
+ _M_message(__msg_init_const_singular)
150
+ ._M_iterator(*this, "this")
151
+ ._M_iterator(__x, "other"));
152
+ }
153
+
154
+ /**
155
+ * @brief Copy assignment.
156
+ * @pre @p x is not singular
157
+ */
158
+ _Safe_iterator&
159
+ operator=(const _Safe_iterator& __x)
160
+ {
161
+ _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
162
+ _M_message(__msg_copy_singular)
163
+ ._M_iterator(*this, "this")
164
+ ._M_iterator(__x, "other"));
165
+ _M_current = __x._M_current;
166
+ this->_M_attach(static_cast<_Sequence*>(__x._M_sequence));
167
+ return *this;
168
+ }
169
+
170
+ /**
171
+ * @brief Iterator dereference.
172
+ * @pre iterator is dereferenceable
173
+ */
174
+ reference
175
+ operator*() const
176
+ {
177
+
178
+ _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(),
179
+ _M_message(__msg_bad_deref)
180
+ ._M_iterator(*this, "this"));
181
+ return *_M_current;
182
+ }
183
+
184
+ /**
185
+ * @brief Iterator dereference.
186
+ * @pre iterator is dereferenceable
187
+ * @todo Make this correct w.r.t. iterators that return proxies
188
+ * @todo Use addressof() instead of & operator
189
+ */
190
+ pointer
191
+ operator->() const
192
+ {
193
+ _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(),
194
+ _M_message(__msg_bad_deref)
195
+ ._M_iterator(*this, "this"));
196
+ return &*_M_current;
197
+ }
198
+
199
+ // ------ Input iterator requirements ------
200
+ /**
201
+ * @brief Iterator preincrement
202
+ * @pre iterator is incrementable
203
+ */
204
+ _Safe_iterator&
205
+ operator++()
206
+ {
207
+ _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(),
208
+ _M_message(__msg_bad_inc)
209
+ ._M_iterator(*this, "this"));
210
+ ++_M_current;
211
+ return *this;
212
+ }
213
+
214
+ /**
215
+ * @brief Iterator postincrement
216
+ * @pre iterator is incrementable
217
+ */
218
+ _Safe_iterator
219
+ operator++(int)
220
+ {
221
+ _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(),
222
+ _M_message(__msg_bad_inc)
223
+ ._M_iterator(*this, "this"));
224
+ _Safe_iterator __tmp(*this);
225
+ ++_M_current;
226
+ return __tmp;
227
+ }
228
+
229
+ // ------ Bidirectional iterator requirements ------
230
+ /**
231
+ * @brief Iterator predecrement
232
+ * @pre iterator is decrementable
233
+ */
234
+ _Safe_iterator&
235
+ operator--()
236
+ {
237
+ _GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(),
238
+ _M_message(__msg_bad_dec)
239
+ ._M_iterator(*this, "this"));
240
+ --_M_current;
241
+ return *this;
242
+ }
243
+
244
+ /**
245
+ * @brief Iterator postdecrement
246
+ * @pre iterator is decrementable
247
+ */
248
+ _Safe_iterator
249
+ operator--(int)
250
+ {
251
+ _GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(),
252
+ _M_message(__msg_bad_dec)
253
+ ._M_iterator(*this, "this"));
254
+ _Safe_iterator __tmp(*this);
255
+ --_M_current;
256
+ return __tmp;
257
+ }
258
+
259
+ // ------ Random access iterator requirements ------
260
+ reference
261
+ operator[](const difference_type& __n) const
262
+ {
263
+ _GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(__n)
264
+ && this->_M_can_advance(__n+1),
265
+ _M_message(__msg_iter_subscript_oob)
266
+ ._M_iterator(*this)._M_integer(__n));
267
+
268
+ return _M_current[__n];
269
+ }
270
+
271
+ _Safe_iterator&
272
+ operator+=(const difference_type& __n)
273
+ {
274
+ _GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(__n),
275
+ _M_message(__msg_advance_oob)
276
+ ._M_iterator(*this)._M_integer(__n));
277
+ _M_current += __n;
278
+ return *this;
279
+ }
280
+
281
+ _Safe_iterator
282
+ operator+(const difference_type& __n) const
283
+ {
284
+ _Safe_iterator __tmp(*this);
285
+ __tmp += __n;
286
+ return __tmp;
287
+ }
288
+
289
+ _Safe_iterator&
290
+ operator-=(const difference_type& __n)
291
+ {
292
+ _GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(-__n),
293
+ _M_message(__msg_retreat_oob)
294
+ ._M_iterator(*this)._M_integer(__n));
295
+ _M_current += -__n;
296
+ return *this;
297
+ }
298
+
299
+ _Safe_iterator
300
+ operator-(const difference_type& __n) const
301
+ {
302
+ _Safe_iterator __tmp(*this);
303
+ __tmp -= __n;
304
+ return __tmp;
305
+ }
306
+
307
+ // ------ Utilities ------
308
+ /**
309
+ * @brief Return the underlying iterator
310
+ */
311
+ _Iterator
312
+ base() const { return _M_current; }
313
+
314
+ /**
315
+ * @brief Conversion to underlying non-debug iterator to allow
316
+ * better interaction with non-debug containers.
317
+ */
318
+ operator _Iterator() const { return _M_current; }
319
+
320
+ /** Attach iterator to the given sequence. */
321
+ void
322
+ _M_attach(const _Sequence* __seq)
323
+ {
324
+ _Safe_iterator_base::_M_attach(const_cast<_Sequence*>(__seq),
325
+ _M_constant());
326
+ }
327
+
328
+ /** Likewise, but not thread-safe. */
329
+ void
330
+ _M_attach_single(const _Sequence* __seq)
331
+ {
332
+ _Safe_iterator_base::_M_attach_single(const_cast<_Sequence*>(__seq),
333
+ _M_constant());
334
+ }
335
+
336
+ /** Invalidate the iterator, making it singular. */
337
+ void
338
+ _M_invalidate();
339
+
340
+ /** Likewise, but not thread-safe. */
341
+ void
342
+ _M_invalidate_single();
343
+
344
+ /// Is the iterator dereferenceable?
345
+ bool
346
+ _M_dereferenceable() const
347
+ { return !this->_M_singular() && !_M_is_end(); }
348
+
349
+ /// Is the iterator incrementable?
350
+ bool
351
+ _M_incrementable() const { return this->_M_dereferenceable(); }
352
+
353
+ // Is the iterator decrementable?
354
+ bool
355
+ _M_decrementable() const { return !_M_singular() && !_M_is_begin(); }
356
+
357
+ // Can we advance the iterator @p __n steps (@p __n may be negative)
358
+ bool
359
+ _M_can_advance(const difference_type& __n) const;
360
+
361
+ // Is the iterator range [*this, __rhs) valid?
362
+ template<typename _Other>
363
+ bool
364
+ _M_valid_range(const _Safe_iterator<_Other, _Sequence>& __rhs) const;
365
+
366
+ // The sequence this iterator references.
367
+ const _Sequence*
368
+ _M_get_sequence() const
369
+ { return static_cast<const _Sequence*>(_M_sequence); }
370
+
371
+ /** Determine the distance between two iterators with some known
372
+ * precision.
373
+ */
374
+ template<typename _Iterator1, typename _Iterator2>
375
+ static std::pair<difference_type, _Distance_precision>
376
+ _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs)
377
+ {
378
+ typedef typename std::iterator_traits<_Iterator1>::iterator_category
379
+ _Category;
380
+ return _M_get_distance(__lhs, __rhs, _Category());
381
+ }
382
+
383
+ template<typename _Iterator1, typename _Iterator2>
384
+ static std::pair<difference_type, _Distance_precision>
385
+ _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
386
+ std::random_access_iterator_tag)
387
+ {
388
+ return std::make_pair(__rhs.base() - __lhs.base(), __dp_exact);
389
+ }
390
+
391
+ template<typename _Iterator1, typename _Iterator2>
392
+ static std::pair<difference_type, _Distance_precision>
393
+ _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
394
+ std::forward_iterator_tag)
395
+ {
396
+ return std::make_pair(__lhs.base() == __rhs.base()? 0 : 1,
397
+ __dp_equality);
398
+ }
399
+
400
+ /// Is this iterator equal to the sequence's begin() iterator?
401
+ bool _M_is_begin() const
402
+ { return *this == static_cast<const _Sequence*>(_M_sequence)->begin(); }
403
+
404
+ /// Is this iterator equal to the sequence's end() iterator?
405
+ bool _M_is_end() const
406
+ { return *this == static_cast<const _Sequence*>(_M_sequence)->end(); }
407
+ };
408
+
409
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
410
+ inline bool
411
+ operator==(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
412
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
413
+ {
414
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
415
+ _M_message(__msg_iter_compare_bad)
416
+ ._M_iterator(__lhs, "lhs")
417
+ ._M_iterator(__rhs, "rhs"));
418
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
419
+ _M_message(__msg_compare_different)
420
+ ._M_iterator(__lhs, "lhs")
421
+ ._M_iterator(__rhs, "rhs"));
422
+ return __lhs.base() == __rhs.base();
423
+ }
424
+
425
+ template<typename _Iterator, typename _Sequence>
426
+ inline bool
427
+ operator==(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
428
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
429
+ {
430
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
431
+ _M_message(__msg_iter_compare_bad)
432
+ ._M_iterator(__lhs, "lhs")
433
+ ._M_iterator(__rhs, "rhs"));
434
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
435
+ _M_message(__msg_compare_different)
436
+ ._M_iterator(__lhs, "lhs")
437
+ ._M_iterator(__rhs, "rhs"));
438
+ return __lhs.base() == __rhs.base();
439
+ }
440
+
441
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
442
+ inline bool
443
+ operator!=(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
444
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
445
+ {
446
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
447
+ _M_message(__msg_iter_compare_bad)
448
+ ._M_iterator(__lhs, "lhs")
449
+ ._M_iterator(__rhs, "rhs"));
450
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
451
+ _M_message(__msg_compare_different)
452
+ ._M_iterator(__lhs, "lhs")
453
+ ._M_iterator(__rhs, "rhs"));
454
+ return __lhs.base() != __rhs.base();
455
+ }
456
+
457
+ template<typename _Iterator, typename _Sequence>
458
+ inline bool
459
+ operator!=(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
460
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
461
+ {
462
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
463
+ _M_message(__msg_iter_compare_bad)
464
+ ._M_iterator(__lhs, "lhs")
465
+ ._M_iterator(__rhs, "rhs"));
466
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
467
+ _M_message(__msg_compare_different)
468
+ ._M_iterator(__lhs, "lhs")
469
+ ._M_iterator(__rhs, "rhs"));
470
+ return __lhs.base() != __rhs.base();
471
+ }
472
+
473
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
474
+ inline bool
475
+ operator<(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
476
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
477
+ {
478
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
479
+ _M_message(__msg_iter_order_bad)
480
+ ._M_iterator(__lhs, "lhs")
481
+ ._M_iterator(__rhs, "rhs"));
482
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
483
+ _M_message(__msg_order_different)
484
+ ._M_iterator(__lhs, "lhs")
485
+ ._M_iterator(__rhs, "rhs"));
486
+ return __lhs.base() < __rhs.base();
487
+ }
488
+
489
+ template<typename _Iterator, typename _Sequence>
490
+ inline bool
491
+ operator<(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
492
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
493
+ {
494
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
495
+ _M_message(__msg_iter_order_bad)
496
+ ._M_iterator(__lhs, "lhs")
497
+ ._M_iterator(__rhs, "rhs"));
498
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
499
+ _M_message(__msg_order_different)
500
+ ._M_iterator(__lhs, "lhs")
501
+ ._M_iterator(__rhs, "rhs"));
502
+ return __lhs.base() < __rhs.base();
503
+ }
504
+
505
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
506
+ inline bool
507
+ operator<=(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
508
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
509
+ {
510
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
511
+ _M_message(__msg_iter_order_bad)
512
+ ._M_iterator(__lhs, "lhs")
513
+ ._M_iterator(__rhs, "rhs"));
514
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
515
+ _M_message(__msg_order_different)
516
+ ._M_iterator(__lhs, "lhs")
517
+ ._M_iterator(__rhs, "rhs"));
518
+ return __lhs.base() <= __rhs.base();
519
+ }
520
+
521
+ template<typename _Iterator, typename _Sequence>
522
+ inline bool
523
+ operator<=(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
524
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
525
+ {
526
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
527
+ _M_message(__msg_iter_order_bad)
528
+ ._M_iterator(__lhs, "lhs")
529
+ ._M_iterator(__rhs, "rhs"));
530
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
531
+ _M_message(__msg_order_different)
532
+ ._M_iterator(__lhs, "lhs")
533
+ ._M_iterator(__rhs, "rhs"));
534
+ return __lhs.base() <= __rhs.base();
535
+ }
536
+
537
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
538
+ inline bool
539
+ operator>(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
540
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
541
+ {
542
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
543
+ _M_message(__msg_iter_order_bad)
544
+ ._M_iterator(__lhs, "lhs")
545
+ ._M_iterator(__rhs, "rhs"));
546
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
547
+ _M_message(__msg_order_different)
548
+ ._M_iterator(__lhs, "lhs")
549
+ ._M_iterator(__rhs, "rhs"));
550
+ return __lhs.base() > __rhs.base();
551
+ }
552
+
553
+ template<typename _Iterator, typename _Sequence>
554
+ inline bool
555
+ operator>(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
556
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
557
+ {
558
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
559
+ _M_message(__msg_iter_order_bad)
560
+ ._M_iterator(__lhs, "lhs")
561
+ ._M_iterator(__rhs, "rhs"));
562
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
563
+ _M_message(__msg_order_different)
564
+ ._M_iterator(__lhs, "lhs")
565
+ ._M_iterator(__rhs, "rhs"));
566
+ return __lhs.base() > __rhs.base();
567
+ }
568
+
569
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
570
+ inline bool
571
+ operator>=(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
572
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
573
+ {
574
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
575
+ _M_message(__msg_iter_order_bad)
576
+ ._M_iterator(__lhs, "lhs")
577
+ ._M_iterator(__rhs, "rhs"));
578
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
579
+ _M_message(__msg_order_different)
580
+ ._M_iterator(__lhs, "lhs")
581
+ ._M_iterator(__rhs, "rhs"));
582
+ return __lhs.base() >= __rhs.base();
583
+ }
584
+
585
+ template<typename _Iterator, typename _Sequence>
586
+ inline bool
587
+ operator>=(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
588
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
589
+ {
590
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
591
+ _M_message(__msg_iter_order_bad)
592
+ ._M_iterator(__lhs, "lhs")
593
+ ._M_iterator(__rhs, "rhs"));
594
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
595
+ _M_message(__msg_order_different)
596
+ ._M_iterator(__lhs, "lhs")
597
+ ._M_iterator(__rhs, "rhs"));
598
+ return __lhs.base() >= __rhs.base();
599
+ }
600
+
601
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
602
+ // According to the resolution of DR179 not only the various comparison
603
+ // operators but also operator- must accept mixed iterator/const_iterator
604
+ // parameters.
605
+ template<typename _IteratorL, typename _IteratorR, typename _Sequence>
606
+ inline typename _Safe_iterator<_IteratorL, _Sequence>::difference_type
607
+ operator-(const _Safe_iterator<_IteratorL, _Sequence>& __lhs,
608
+ const _Safe_iterator<_IteratorR, _Sequence>& __rhs)
609
+ {
610
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
611
+ _M_message(__msg_distance_bad)
612
+ ._M_iterator(__lhs, "lhs")
613
+ ._M_iterator(__rhs, "rhs"));
614
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
615
+ _M_message(__msg_distance_different)
616
+ ._M_iterator(__lhs, "lhs")
617
+ ._M_iterator(__rhs, "rhs"));
618
+ return __lhs.base() - __rhs.base();
619
+ }
620
+
621
+ template<typename _Iterator, typename _Sequence>
622
+ inline typename _Safe_iterator<_Iterator, _Sequence>::difference_type
623
+ operator-(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
624
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
625
+ {
626
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
627
+ _M_message(__msg_distance_bad)
628
+ ._M_iterator(__lhs, "lhs")
629
+ ._M_iterator(__rhs, "rhs"));
630
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
631
+ _M_message(__msg_distance_different)
632
+ ._M_iterator(__lhs, "lhs")
633
+ ._M_iterator(__rhs, "rhs"));
634
+ return __lhs.base() - __rhs.base();
635
+ }
636
+
637
+ template<typename _Iterator, typename _Sequence>
638
+ inline _Safe_iterator<_Iterator, _Sequence>
639
+ operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n,
640
+ const _Safe_iterator<_Iterator, _Sequence>& __i)
641
+ { return __i + __n; }
642
+ } // namespace __gnu_debug
643
+
644
+ #ifndef _GLIBCXX_EXPORT_TEMPLATE
645
+ # include <debug/safe_iterator.tcc>
646
+ #endif
647
+
648
+ #endif