]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/bits/stl_uninitialized.h
PR libstdc++/36104 part four
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / stl_uninitialized.h
CommitLineData
42526146
PE
1// Raw memory manipulators -*- C++ -*-
2
882b3d5c
PC
3// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4// 2009, 2010
8072ddb0 5// Free Software Foundation, Inc.
42526146
PE
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
748086b7 10// Free Software Foundation; either version 3, or (at your option)
42526146
PE
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
748086b7
JJ
18// Under Section 7 of GPL version 3, you are granted additional
19// permissions described in the GCC Runtime Library Exception, version
20// 3.1, as published by the Free Software Foundation.
42526146 21
748086b7
JJ
22// You should have received a copy of the GNU General Public License and
23// a copy of the GCC Runtime Library Exception along with this program;
24// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25// <http://www.gnu.org/licenses/>.
42526146 26
725dc051
BK
27/*
28 *
29 * Copyright (c) 1994
30 * Hewlett-Packard Company
31 *
32 * Permission to use, copy, modify, distribute and sell this software
33 * and its documentation for any purpose is hereby granted without fee,
34 * provided that the above copyright notice appear in all copies and
35 * that both that copyright notice and this permission notice appear
36 * in supporting documentation. Hewlett-Packard Company makes no
37 * representations about the suitability of this software for any
38 * purpose. It is provided "as is" without express or implied warranty.
39 *
40 *
41 * Copyright (c) 1996,1997
42 * Silicon Graphics Computer Systems, Inc.
43 *
44 * Permission to use, copy, modify, distribute and sell this software
45 * and its documentation for any purpose is hereby granted without fee,
46 * provided that the above copyright notice appear in all copies and
47 * that both that copyright notice and this permission notice appear
48 * in supporting documentation. Silicon Graphics makes no
49 * representations about the suitability of this software for any
50 * purpose. It is provided "as is" without express or implied warranty.
51 */
52
f910786b 53/** @file bits/stl_uninitialized.h
729e3d3f 54 * This is an internal header file, included by other library headers.
f910786b 55 * Do not attempt to use it directly. @headername{memory}
725dc051
BK
56 */
57
3d7c150e
BK
58#ifndef _STL_UNINITIALIZED_H
59#define _STL_UNINITIALIZED_H 1
725dc051 60
12ffa228
BK
61namespace std _GLIBCXX_VISIBILITY(default)
62{
63_GLIBCXX_BEGIN_NAMESPACE_VERSION
3cbc7af0 64
cc86c05a 65 template<bool _TrivialValueTypes>
f4c5578f 66 struct __uninitialized_copy
02d92e3b 67 {
f4c5578f
PC
68 template<typename _InputIterator, typename _ForwardIterator>
69 static _ForwardIterator
cc86c05a
PC
70 __uninit_copy(_InputIterator __first, _InputIterator __last,
71 _ForwardIterator __result)
f4c5578f
PC
72 {
73 _ForwardIterator __cur = __result;
bc2631e0 74 __try
f4c5578f
PC
75 {
76 for (; __first != __last; ++__first, ++__cur)
882b3d5c 77 std::_Construct(std::__addressof(*__cur), *__first);
f4c5578f
PC
78 return __cur;
79 }
bc2631e0 80 __catch(...)
f4c5578f
PC
81 {
82 std::_Destroy(__result, __cur);
83 __throw_exception_again;
84 }
322821b9 85 }
f4c5578f
PC
86 };
87
88 template<>
89 struct __uninitialized_copy<true>
90 {
91 template<typename _InputIterator, typename _ForwardIterator>
92 static _ForwardIterator
cc86c05a
PC
93 __uninit_copy(_InputIterator __first, _InputIterator __last,
94 _ForwardIterator __result)
f4c5578f
PC
95 { return std::copy(__first, __last, __result); }
96 };
02d92e3b 97
82b61df5
PE
98 /**
99 * @brief Copies the range [first,last) into result.
100 * @param first An input iterator.
101 * @param last An input iterator.
102 * @param result An output iterator.
103 * @return result + (first - last)
104 *
105 * Like copy(), but does not require an initialized output range.
106 */
08addde6
PE
107 template<typename _InputIterator, typename _ForwardIterator>
108 inline _ForwardIterator
ed6814f7 109 uninitialized_copy(_InputIterator __first, _InputIterator __last,
917a9fd4 110 _ForwardIterator __result)
02d92e3b 111 {
f4c5578f
PC
112 typedef typename iterator_traits<_InputIterator>::value_type
113 _ValueType1;
ff2ea587 114 typedef typename iterator_traits<_ForwardIterator>::value_type
f4c5578f
PC
115 _ValueType2;
116
cc86c05a
PC
117 return std::__uninitialized_copy<(__is_trivial(_ValueType1)
118 && __is_trivial(_ValueType2))>::
119 __uninit_copy(__first, __last, __result);
02d92e3b
SW
120 }
121
02d92e3b 122
cc86c05a 123 template<bool _TrivialValueType>
f4c5578f 124 struct __uninitialized_fill
02d92e3b 125 {
f4c5578f
PC
126 template<typename _ForwardIterator, typename _Tp>
127 static void
cc86c05a
PC
128 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
129 const _Tp& __x)
f4c5578f
PC
130 {
131 _ForwardIterator __cur = __first;
bc2631e0 132 __try
f4c5578f
PC
133 {
134 for (; __cur != __last; ++__cur)
882b3d5c 135 std::_Construct(std::__addressof(*__cur), __x);
f4c5578f 136 }
bc2631e0 137 __catch(...)
f4c5578f
PC
138 {
139 std::_Destroy(__first, __cur);
140 __throw_exception_again;
141 }
15d72060 142 }
f4c5578f
PC
143 };
144
145 template<>
146 struct __uninitialized_fill<true>
147 {
148 template<typename _ForwardIterator, typename _Tp>
149 static void
cc86c05a
PC
150 __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
151 const _Tp& __x)
f4c5578f
PC
152 { std::fill(__first, __last, __x); }
153 };
02d92e3b 154
82b61df5
PE
155 /**
156 * @brief Copies the value x into the range [first,last).
157 * @param first An input iterator.
158 * @param last An input iterator.
159 * @param x The source value.
160 * @return Nothing.
161 *
162 * Like fill(), but does not require an initialized output range.
163 */
08addde6 164 template<typename _ForwardIterator, typename _Tp>
02d92e3b 165 inline void
ed6814f7 166 uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
917a9fd4 167 const _Tp& __x)
02d92e3b 168 {
ff2ea587
PC
169 typedef typename iterator_traits<_ForwardIterator>::value_type
170 _ValueType;
f4c5578f 171
cc86c05a
PC
172 std::__uninitialized_fill<__is_trivial(_ValueType)>::
173 __uninit_fill(__first, __last, __x);
02d92e3b
SW
174 }
175
02d92e3b 176
cc86c05a 177 template<bool _TrivialValueType>
f4c5578f 178 struct __uninitialized_fill_n
02d92e3b 179 {
f4c5578f
PC
180 template<typename _ForwardIterator, typename _Size, typename _Tp>
181 static void
cc86c05a
PC
182 __uninit_fill_n(_ForwardIterator __first, _Size __n,
183 const _Tp& __x)
f4c5578f
PC
184 {
185 _ForwardIterator __cur = __first;
bc2631e0 186 __try
f4c5578f
PC
187 {
188 for (; __n > 0; --__n, ++__cur)
882b3d5c 189 std::_Construct(std::__addressof(*__cur), __x);
f4c5578f 190 }
bc2631e0 191 __catch(...)
f4c5578f
PC
192 {
193 std::_Destroy(__first, __cur);
194 __throw_exception_again;
195 }
322821b9 196 }
f4c5578f
PC
197 };
198
199 template<>
200 struct __uninitialized_fill_n<true>
201 {
202 template<typename _ForwardIterator, typename _Size, typename _Tp>
203 static void
cc86c05a
PC
204 __uninit_fill_n(_ForwardIterator __first, _Size __n,
205 const _Tp& __x)
f4c5578f
PC
206 { std::fill_n(__first, __n, __x); }
207 };
02d92e3b 208
82b61df5
PE
209 /**
210 * @brief Copies the value x into the range [first,first+n).
211 * @param first An input iterator.
212 * @param n The number of copies to make.
213 * @param x The source value.
368b7a30 214 * @return Nothing.
82b61df5
PE
215 *
216 * Like fill_n(), but does not require an initialized output range.
217 */
08addde6 218 template<typename _ForwardIterator, typename _Size, typename _Tp>
368b7a30 219 inline void
08addde6 220 uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
02d92e3b 221 {
ff2ea587
PC
222 typedef typename iterator_traits<_ForwardIterator>::value_type
223 _ValueType;
f4c5578f 224
cc86c05a
PC
225 std::__uninitialized_fill_n<__is_trivial(_ValueType)>::
226 __uninit_fill_n(__first, __n, __x);
02d92e3b
SW
227 }
228
1985f1cd
MA
229 // Extensions: versions of uninitialized_copy, uninitialized_fill,
230 // and uninitialized_fill_n that take an allocator parameter.
231 // We dispatch back to the standard versions when we're given the
232 // default allocator. For nondefault allocators we do not use
233 // any of the POD optimizations.
234
235 template<typename _InputIterator, typename _ForwardIterator,
236 typename _Allocator>
237 _ForwardIterator
238 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
c531371e 239 _ForwardIterator __result, _Allocator& __alloc)
1985f1cd
MA
240 {
241 _ForwardIterator __cur = __result;
bc2631e0 242 __try
1985f1cd
MA
243 {
244 for (; __first != __last; ++__first, ++__cur)
882b3d5c 245 __alloc.construct(std::__addressof(*__cur), *__first);
1985f1cd
MA
246 return __cur;
247 }
bc2631e0 248 __catch(...)
1985f1cd
MA
249 {
250 std::_Destroy(__result, __cur, __alloc);
251 __throw_exception_again;
252 }
253 }
254
255 template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
256 inline _ForwardIterator
257 __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
c531371e 258 _ForwardIterator __result, allocator<_Tp>&)
8072ddb0 259 { return std::uninitialized_copy(__first, __last, __result); }
1985f1cd 260
6eef7402
CJ
261 template<typename _InputIterator, typename _ForwardIterator,
262 typename _Allocator>
263 inline _ForwardIterator
264 __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
265 _ForwardIterator __result, _Allocator& __alloc)
266 {
267 return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
268 _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
269 __result, __alloc);
270 }
271
1985f1cd
MA
272 template<typename _ForwardIterator, typename _Tp, typename _Allocator>
273 void
274 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
c531371e 275 const _Tp& __x, _Allocator& __alloc)
1985f1cd
MA
276 {
277 _ForwardIterator __cur = __first;
bc2631e0 278 __try
1985f1cd
MA
279 {
280 for (; __cur != __last; ++__cur)
882b3d5c 281 __alloc.construct(std::__addressof(*__cur), __x);
1985f1cd 282 }
bc2631e0 283 __catch(...)
1985f1cd
MA
284 {
285 std::_Destroy(__first, __cur, __alloc);
286 __throw_exception_again;
287 }
288 }
289
290 template<typename _ForwardIterator, typename _Tp, typename _Tp2>
291 inline void
292 __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
c531371e 293 const _Tp& __x, allocator<_Tp2>&)
8072ddb0 294 { std::uninitialized_fill(__first, __last, __x); }
1985f1cd
MA
295
296 template<typename _ForwardIterator, typename _Size, typename _Tp,
297 typename _Allocator>
298 void
299 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
c531371e 300 const _Tp& __x, _Allocator& __alloc)
1985f1cd
MA
301 {
302 _ForwardIterator __cur = __first;
bc2631e0 303 __try
1985f1cd
MA
304 {
305 for (; __n > 0; --__n, ++__cur)
882b3d5c 306 __alloc.construct(std::__addressof(*__cur), __x);
1985f1cd 307 }
bc2631e0 308 __catch(...)
1985f1cd
MA
309 {
310 std::_Destroy(__first, __cur, __alloc);
311 __throw_exception_again;
312 }
313 }
314
315 template<typename _ForwardIterator, typename _Size, typename _Tp,
316 typename _Tp2>
8072ddb0 317 inline void
1985f1cd 318 __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n,
c531371e 319 const _Tp& __x, allocator<_Tp2>&)
8072ddb0 320 { std::uninitialized_fill_n(__first, __n, __x); }
1985f1cd
MA
321
322
7ffec97f
CJ
323 // Extensions: __uninitialized_copy_move, __uninitialized_move_copy,
324 // __uninitialized_fill_move, __uninitialized_move_fill.
325 // All of these algorithms take a user-supplied allocator, which is used
326 // for construction and destruction.
02d92e3b 327
7ffec97f 328 // __uninitialized_copy_move
02d92e3b 329 // Copies [first1, last1) into [result, result + (last1 - first1)), and
7ffec97f 330 // move [first2, last2) into
02d92e3b 331 // [result, result + (last1 - first1) + (last2 - first2)).
ed6814f7 332 template<typename _InputIterator1, typename _InputIterator2,
1985f1cd 333 typename _ForwardIterator, typename _Allocator>
08addde6 334 inline _ForwardIterator
7ffec97f 335 __uninitialized_copy_move(_InputIterator1 __first1,
917a9fd4 336 _InputIterator1 __last1,
ed6814f7 337 _InputIterator2 __first2,
917a9fd4 338 _InputIterator2 __last2,
1985f1cd 339 _ForwardIterator __result,
c531371e 340 _Allocator& __alloc)
02d92e3b 341 {
1985f1cd
MA
342 _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
343 __result,
344 __alloc);
bc2631e0 345 __try
15d72060 346 {
7ffec97f 347 return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
15d72060 348 }
bc2631e0 349 __catch(...)
ed6814f7 350 {
1985f1cd 351 std::_Destroy(__result, __mid, __alloc);
ed6814f7 352 __throw_exception_again;
322821b9 353 }
02d92e3b
SW
354 }
355
7ffec97f
CJ
356 // __uninitialized_move_copy
357 // Moves [first1, last1) into [result, result + (last1 - first1)), and
358 // copies [first2, last2) into
359 // [result, result + (last1 - first1) + (last2 - first2)).
360 template<typename _InputIterator1, typename _InputIterator2,
361 typename _ForwardIterator, typename _Allocator>
362 inline _ForwardIterator
363 __uninitialized_move_copy(_InputIterator1 __first1,
364 _InputIterator1 __last1,
365 _InputIterator2 __first2,
366 _InputIterator2 __last2,
367 _ForwardIterator __result,
368 _Allocator& __alloc)
369 {
370 _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
371 __result,
372 __alloc);
bc2631e0 373 __try
7ffec97f
CJ
374 {
375 return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
376 }
bc2631e0 377 __catch(...)
7ffec97f
CJ
378 {
379 std::_Destroy(__result, __mid, __alloc);
380 __throw_exception_again;
381 }
382 }
383
384 // __uninitialized_fill_move
385 // Fills [result, mid) with x, and moves [first, last) into
02d92e3b 386 // [mid, mid + (last - first)).
1985f1cd
MA
387 template<typename _ForwardIterator, typename _Tp, typename _InputIterator,
388 typename _Allocator>
ed6814f7 389 inline _ForwardIterator
7ffec97f 390 __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
15d72060 391 const _Tp& __x, _InputIterator __first,
c531371e 392 _InputIterator __last, _Allocator& __alloc)
02d92e3b 393 {
1985f1cd 394 std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
bc2631e0 395 __try
15d72060 396 {
7ffec97f 397 return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
15d72060 398 }
bc2631e0 399 __catch(...)
322821b9 400 {
1985f1cd 401 std::_Destroy(__result, __mid, __alloc);
ed6814f7 402 __throw_exception_again;
322821b9 403 }
02d92e3b
SW
404 }
405
7ffec97f
CJ
406 // __uninitialized_move_fill
407 // Moves [first1, last1) into [first2, first2 + (last1 - first1)), and
02d92e3b 408 // fills [first2 + (last1 - first1), last2) with x.
1985f1cd
MA
409 template<typename _InputIterator, typename _ForwardIterator, typename _Tp,
410 typename _Allocator>
02d92e3b 411 inline void
7ffec97f 412 __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
15d72060 413 _ForwardIterator __first2,
1985f1cd 414 _ForwardIterator __last2, const _Tp& __x,
c531371e 415 _Allocator& __alloc)
02d92e3b 416 {
7ffec97f 417 _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
1985f1cd
MA
418 __first2,
419 __alloc);
bc2631e0 420 __try
917a9fd4 421 {
1985f1cd 422 std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
917a9fd4 423 }
bc2631e0 424 __catch(...)
322821b9 425 {
1985f1cd 426 std::_Destroy(__first2, __mid2, __alloc);
ed6814f7 427 __throw_exception_again;
322821b9 428 }
02d92e3b 429 }
725dc051 430
b0371776 431#ifdef __GXX_EXPERIMENTAL_CXX0X__
cc86c05a
PC
432 // Extensions: __uninitialized_default, __uninitialized_default_n,
433 // __uninitialized_default_a, __uninitialized_default_n_a.
434
435 template<bool _TrivialValueType>
436 struct __uninitialized_default_1
437 {
438 template<typename _ForwardIterator>
439 static void
440 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
441 {
442 _ForwardIterator __cur = __first;
443 __try
444 {
445 for (; __cur != __last; ++__cur)
446 std::_Construct(std::__addressof(*__cur));
447 }
448 __catch(...)
449 {
450 std::_Destroy(__first, __cur);
451 __throw_exception_again;
452 }
453 }
454 };
455
456 template<>
457 struct __uninitialized_default_1<true>
458 {
459 template<typename _ForwardIterator>
460 static void
461 __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
462 {
463 typedef typename iterator_traits<_ForwardIterator>::value_type
464 _ValueType;
465
466 std::fill(__first, __last, _ValueType());
467 }
468 };
469
470 template<bool _TrivialValueType>
471 struct __uninitialized_default_n_1
472 {
473 template<typename _ForwardIterator, typename _Size>
474 static void
475 __uninit_default_n(_ForwardIterator __first, _Size __n)
476 {
477 _ForwardIterator __cur = __first;
478 __try
479 {
480 for (; __n > 0; --__n, ++__cur)
481 std::_Construct(std::__addressof(*__cur));
482 }
483 __catch(...)
484 {
485 std::_Destroy(__first, __cur);
486 __throw_exception_again;
487 }
488 }
489 };
490
491 template<>
492 struct __uninitialized_default_n_1<true>
493 {
494 template<typename _ForwardIterator, typename _Size>
495 static void
496 __uninit_default_n(_ForwardIterator __first, _Size __n)
497 {
498 typedef typename iterator_traits<_ForwardIterator>::value_type
499 _ValueType;
500
501 std::fill_n(__first, __n, _ValueType());
502 }
503 };
504
505 // __uninitialized_default
506 // Fills [first, last) with std::distance(first, last) default
507 // constructed value_types(s).
508 template<typename _ForwardIterator>
509 inline void
510 __uninitialized_default(_ForwardIterator __first,
511 _ForwardIterator __last)
512 {
513 typedef typename iterator_traits<_ForwardIterator>::value_type
514 _ValueType;
515
516 std::__uninitialized_default_1<__is_trivial(_ValueType)>::
517 __uninit_default(__first, __last);
518 }
519
520 // __uninitialized_default_n
521 // Fills [first, first + n) with n default constructed value_type(s).
522 template<typename _ForwardIterator, typename _Size>
523 inline void
524 __uninitialized_default_n(_ForwardIterator __first, _Size __n)
525 {
526 typedef typename iterator_traits<_ForwardIterator>::value_type
527 _ValueType;
528
529 std::__uninitialized_default_n_1<__is_trivial(_ValueType)>::
530 __uninit_default_n(__first, __n);
531 }
532
533
534 // __uninitialized_default_a
535 // Fills [first, last) with std::distance(first, last) default
536 // constructed value_types(s), constructed with the allocator alloc.
537 template<typename _ForwardIterator, typename _Allocator>
538 void
539 __uninitialized_default_a(_ForwardIterator __first,
540 _ForwardIterator __last,
541 _Allocator& __alloc)
542 {
543 _ForwardIterator __cur = __first;
544 __try
545 {
546 for (; __cur != __last; ++__cur)
547 __alloc.construct(std::__addressof(*__cur));
548 }
549 __catch(...)
550 {
551 std::_Destroy(__first, __cur, __alloc);
552 __throw_exception_again;
553 }
554 }
555
556 template<typename _ForwardIterator, typename _Tp>
557 inline void
558 __uninitialized_default_a(_ForwardIterator __first,
559 _ForwardIterator __last,
560 allocator<_Tp>&)
561 { std::__uninitialized_default(__first, __last); }
562
563
564 // __uninitialized_default_n_a
565 // Fills [first, first + n) with n default constructed value_types(s),
566 // constructed with the allocator alloc.
567 template<typename _ForwardIterator, typename _Size, typename _Allocator>
568 void
569 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
570 _Allocator& __alloc)
571 {
572 _ForwardIterator __cur = __first;
573 __try
574 {
575 for (; __n > 0; --__n, ++__cur)
576 __alloc.construct(std::__addressof(*__cur));
577 }
578 __catch(...)
579 {
580 std::_Destroy(__first, __cur, __alloc);
581 __throw_exception_again;
582 }
583 }
584
585 template<typename _ForwardIterator, typename _Size, typename _Tp>
586 inline void
587 __uninitialized_default_n_a(_ForwardIterator __first, _Size __n,
588 allocator<_Tp>&)
589 { std::__uninitialized_default_n(__first, __n); }
590
591
b0371776
PC
592 template<typename _InputIterator, typename _Size,
593 typename _ForwardIterator>
594 _ForwardIterator
595 __uninitialized_copy_n(_InputIterator __first, _Size __n,
596 _ForwardIterator __result, input_iterator_tag)
597 {
598 _ForwardIterator __cur = __result;
bc2631e0 599 __try
b0371776
PC
600 {
601 for (; __n > 0; --__n, ++__first, ++__cur)
fe27aa8b 602 std::_Construct(std::__addressof(*__cur), *__first);
b0371776
PC
603 return __cur;
604 }
bc2631e0 605 __catch(...)
b0371776
PC
606 {
607 std::_Destroy(__result, __cur);
608 __throw_exception_again;
609 }
610 }
611
612 template<typename _RandomAccessIterator, typename _Size,
613 typename _ForwardIterator>
614 inline _ForwardIterator
615 __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
616 _ForwardIterator __result,
617 random_access_iterator_tag)
618 { return std::uninitialized_copy(__first, __first + __n, __result); }
619
620 /**
621 * @brief Copies the range [first,first+n) into result.
622 * @param first An input iterator.
623 * @param n The number of elements to copy.
624 * @param result An output iterator.
625 * @return result + n
626 *
627 * Like copy_n(), but does not require an initialized output range.
628 */
629 template<typename _InputIterator, typename _Size, typename _ForwardIterator>
630 inline _ForwardIterator
631 uninitialized_copy_n(_InputIterator __first, _Size __n,
632 _ForwardIterator __result)
633 { return std::__uninitialized_copy_n(__first, __n, __result,
634 std::__iterator_category(__first)); }
635#endif
636
12ffa228
BK
637_GLIBCXX_END_NAMESPACE_VERSION
638} // namespace
725dc051 639
3d7c150e 640#endif /* _STL_UNINITIALIZED_H */