libstdc++
stl_uninitialized.h
Go to the documentation of this file.
00001 // Raw memory manipulators -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2015 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /*
00026  *
00027  * Copyright (c) 1994
00028  * Hewlett-Packard Company
00029  *
00030  * Permission to use, copy, modify, distribute and sell this software
00031  * and its documentation for any purpose is hereby granted without fee,
00032  * provided that the above copyright notice appear in all copies and
00033  * that both that copyright notice and this permission notice appear
00034  * in supporting documentation.  Hewlett-Packard Company makes no
00035  * representations about the suitability of this software for any
00036  * purpose.  It is provided "as is" without express or implied warranty.
00037  *
00038  *
00039  * Copyright (c) 1996,1997
00040  * Silicon Graphics Computer Systems, Inc.
00041  *
00042  * Permission to use, copy, modify, distribute and sell this software
00043  * and its documentation for any purpose is hereby granted without fee,
00044  * provided that the above copyright notice appear in all copies and
00045  * that both that copyright notice and this permission notice appear
00046  * in supporting documentation.  Silicon Graphics makes no
00047  * representations about the suitability of this software for any
00048  * purpose.  It is provided "as is" without express or implied warranty.
00049  */
00050 
00051 /** @file bits/stl_uninitialized.h
00052  *  This is an internal header file, included by other library headers.
00053  *  Do not attempt to use it directly. @headername{memory}
00054  */
00055 
00056 #ifndef _STL_UNINITIALIZED_H
00057 #define _STL_UNINITIALIZED_H 1
00058 
00059 namespace std _GLIBCXX_VISIBILITY(default)
00060 {
00061 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00062 
00063   template<bool _TrivialValueTypes>
00064     struct __uninitialized_copy
00065     {
00066       template<typename _InputIterator, typename _ForwardIterator>
00067         static _ForwardIterator
00068         __uninit_copy(_InputIterator __first, _InputIterator __last,
00069                       _ForwardIterator __result)
00070         {
00071           _ForwardIterator __cur = __result;
00072           __try
00073             {
00074               for (; __first != __last; ++__first, ++__cur)
00075                 std::_Construct(std::__addressof(*__cur), *__first);
00076               return __cur;
00077             }
00078           __catch(...)
00079             {
00080               std::_Destroy(__result, __cur);
00081               __throw_exception_again;
00082             }
00083         }
00084     };
00085 
00086   template<>
00087     struct __uninitialized_copy<true>
00088     {
00089       template<typename _InputIterator, typename _ForwardIterator>
00090         static _ForwardIterator
00091         __uninit_copy(_InputIterator __first, _InputIterator __last,
00092                       _ForwardIterator __result)
00093         { return std::copy(__first, __last, __result); }
00094     };
00095 
00096   /**
00097    *  @brief Copies the range [first,last) into result.
00098    *  @param  __first  An input iterator.
00099    *  @param  __last   An input iterator.
00100    *  @param  __result An output iterator.
00101    *  @return   __result + (__first - __last)
00102    *
00103    *  Like copy(), but does not require an initialized output range.
00104   */
00105   template<typename _InputIterator, typename _ForwardIterator>
00106     inline _ForwardIterator
00107     uninitialized_copy(_InputIterator __first, _InputIterator __last,
00108                        _ForwardIterator __result)
00109     {
00110       typedef typename iterator_traits<_InputIterator>::value_type
00111         _ValueType1;
00112       typedef typename iterator_traits<_ForwardIterator>::value_type
00113         _ValueType2;
00114 #if __cplusplus < 201103L
00115       const bool __assignable = true;
00116 #else
00117       // trivial types can have deleted assignment
00118       typedef typename iterator_traits<_InputIterator>::reference _RefType1;
00119       typedef typename iterator_traits<_ForwardIterator>::reference _RefType2;
00120       const bool __assignable = is_assignable<_RefType2, _RefType1>::value;
00121 #endif
00122 
00123       return std::__uninitialized_copy<__is_trivial(_ValueType1)
00124                                        && __is_trivial(_ValueType2)
00125                                        && __assignable>::
00126         __uninit_copy(__first, __last, __result);
00127     }
00128 
00129 
00130   template<bool _TrivialValueType>
00131     struct __uninitialized_fill
00132     {
00133       template<typename _ForwardIterator, typename _Tp>
00134         static void
00135         __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
00136                       const _Tp& __x)
00137         {
00138           _ForwardIterator __cur = __first;
00139           __try
00140             {
00141               for (; __cur != __last; ++__cur)
00142                 std::_Construct(std::__addressof(*__cur), __x);
00143             }
00144           __catch(...)
00145             {
00146               std::_Destroy(__first, __cur);
00147               __throw_exception_again;
00148             }
00149         }
00150     };
00151 
00152   template<>
00153     struct __uninitialized_fill<true>
00154     {
00155       template<typename _ForwardIterator, typename _Tp>
00156         static void
00157         __uninit_fill(_ForwardIterator __first, _ForwardIterator __last,
00158                       const _Tp& __x)
00159         { std::fill(__first, __last, __x); }
00160     };
00161 
00162   /**
00163    *  @brief Copies the value x into the range [first,last).
00164    *  @param  __first  An input iterator.
00165    *  @param  __last   An input iterator.
00166    *  @param  __x      The source value.
00167    *  @return   Nothing.
00168    *
00169    *  Like fill(), but does not require an initialized output range.
00170   */
00171   template<typename _ForwardIterator, typename _Tp>
00172     inline void
00173     uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
00174                        const _Tp& __x)
00175     {
00176       typedef typename iterator_traits<_ForwardIterator>::value_type
00177         _ValueType;
00178 #if __cplusplus < 201103L
00179       const bool __assignable = true;
00180 #else
00181       // trivial types can have deleted assignment
00182       const bool __assignable = is_copy_assignable<_ValueType>::value;
00183 #endif
00184 
00185       std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>::
00186         __uninit_fill(__first, __last, __x);
00187     }
00188 
00189 
00190   template<bool _TrivialValueType>
00191     struct __uninitialized_fill_n
00192     {
00193       template<typename _ForwardIterator, typename _Size, typename _Tp>
00194         static _ForwardIterator
00195         __uninit_fill_n(_ForwardIterator __first, _Size __n,
00196                         const _Tp& __x)
00197         {
00198           _ForwardIterator __cur = __first;
00199           __try
00200             {
00201               for (; __n > 0; --__n, ++__cur)
00202                 std::_Construct(std::__addressof(*__cur), __x);
00203               return __cur;
00204             }
00205           __catch(...)
00206             {
00207               std::_Destroy(__first, __cur);
00208               __throw_exception_again;
00209             }
00210         }
00211     };
00212 
00213   template<>
00214     struct __uninitialized_fill_n<true>
00215     {
00216       template<typename _ForwardIterator, typename _Size, typename _Tp>
00217         static _ForwardIterator
00218         __uninit_fill_n(_ForwardIterator __first, _Size __n,
00219                         const _Tp& __x)
00220         { return std::fill_n(__first, __n, __x); }
00221     };
00222 
00223    // _GLIBCXX_RESOLVE_LIB_DEFECTS
00224    // DR 1339. uninitialized_fill_n should return the end of its range
00225   /**
00226    *  @brief Copies the value x into the range [first,first+n).
00227    *  @param  __first  An input iterator.
00228    *  @param  __n      The number of copies to make.
00229    *  @param  __x      The source value.
00230    *  @return   Nothing.
00231    *
00232    *  Like fill_n(), but does not require an initialized output range.
00233   */
00234   template<typename _ForwardIterator, typename _Size, typename _Tp>
00235     inline _ForwardIterator
00236     uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
00237     {
00238       typedef typename iterator_traits<_ForwardIterator>::value_type
00239         _ValueType;
00240 #if __cplusplus < 201103L
00241       const bool __assignable = true;
00242 #else
00243       // trivial types can have deleted assignment
00244       const bool __assignable = is_copy_assignable<_ValueType>::value;
00245 #endif
00246       return __uninitialized_fill_n<__is_trivial(_ValueType) && __assignable>::
00247         __uninit_fill_n(__first, __n, __x);
00248     }
00249 
00250   // Extensions: versions of uninitialized_copy, uninitialized_fill,
00251   //  and uninitialized_fill_n that take an allocator parameter.
00252   //  We dispatch back to the standard versions when we're given the
00253   //  default allocator.  For nondefault allocators we do not use 
00254   //  any of the POD optimizations.
00255 
00256   template<typename _InputIterator, typename _ForwardIterator,
00257            typename _Allocator>
00258     _ForwardIterator
00259     __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
00260                            _ForwardIterator __result, _Allocator& __alloc)
00261     {
00262       _ForwardIterator __cur = __result;
00263       __try
00264         {
00265           typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
00266           for (; __first != __last; ++__first, ++__cur)
00267             __traits::construct(__alloc, std::__addressof(*__cur), *__first);
00268           return __cur;
00269         }
00270       __catch(...)
00271         {
00272           std::_Destroy(__result, __cur, __alloc);
00273           __throw_exception_again;
00274         }
00275     }
00276 
00277   template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
00278     inline _ForwardIterator
00279     __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
00280                            _ForwardIterator __result, allocator<_Tp>&)
00281     { return std::uninitialized_copy(__first, __last, __result); }
00282 
00283   template<typename _InputIterator, typename _ForwardIterator,
00284            typename _Allocator>
00285     inline _ForwardIterator
00286     __uninitialized_move_a(_InputIterator __first, _InputIterator __last,
00287                            _ForwardIterator __result, _Allocator& __alloc)
00288     {
00289       return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first),
00290                                          _GLIBCXX_MAKE_MOVE_ITERATOR(__last),
00291                                          __result, __alloc);
00292     }
00293 
00294   template<typename _InputIterator, typename _ForwardIterator,
00295            typename _Allocator>
00296     inline _ForwardIterator
00297     __uninitialized_move_if_noexcept_a(_InputIterator __first,
00298                                        _InputIterator __last,
00299                                        _ForwardIterator __result,
00300                                        _Allocator& __alloc)
00301     {
00302       return std::__uninitialized_copy_a
00303         (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first),
00304          _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc);
00305     }
00306 
00307   template<typename _ForwardIterator, typename _Tp, typename _Allocator>
00308     void
00309     __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
00310                            const _Tp& __x, _Allocator& __alloc)
00311     {
00312       _ForwardIterator __cur = __first;
00313       __try
00314         {
00315           typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
00316           for (; __cur != __last; ++__cur)
00317             __traits::construct(__alloc, std::__addressof(*__cur), __x);
00318         }
00319       __catch(...)
00320         {
00321           std::_Destroy(__first, __cur, __alloc);
00322           __throw_exception_again;
00323         }
00324     }
00325 
00326   template<typename _ForwardIterator, typename _Tp, typename _Tp2>
00327     inline void
00328     __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
00329                            const _Tp& __x, allocator<_Tp2>&)
00330     { std::uninitialized_fill(__first, __last, __x); }
00331 
00332   template<typename _ForwardIterator, typename _Size, typename _Tp,
00333            typename _Allocator>
00334     _ForwardIterator
00335     __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, 
00336                              const _Tp& __x, _Allocator& __alloc)
00337     {
00338       _ForwardIterator __cur = __first;
00339       __try
00340         {
00341           typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
00342           for (; __n > 0; --__n, ++__cur)
00343             __traits::construct(__alloc, std::__addressof(*__cur), __x);
00344           return __cur;
00345         }
00346       __catch(...)
00347         {
00348           std::_Destroy(__first, __cur, __alloc);
00349           __throw_exception_again;
00350         }
00351     }
00352 
00353   template<typename _ForwardIterator, typename _Size, typename _Tp,
00354            typename _Tp2>
00355     inline _ForwardIterator
00356     __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, 
00357                              const _Tp& __x, allocator<_Tp2>&)
00358     { return std::uninitialized_fill_n(__first, __n, __x); }
00359 
00360 
00361   // Extensions: __uninitialized_copy_move, __uninitialized_move_copy,
00362   // __uninitialized_fill_move, __uninitialized_move_fill.
00363   // All of these algorithms take a user-supplied allocator, which is used
00364   // for construction and destruction.
00365 
00366   // __uninitialized_copy_move
00367   // Copies [first1, last1) into [result, result + (last1 - first1)), and
00368   //  move [first2, last2) into
00369   //  [result, result + (last1 - first1) + (last2 - first2)).
00370   template<typename _InputIterator1, typename _InputIterator2,
00371            typename _ForwardIterator, typename _Allocator>
00372     inline _ForwardIterator
00373     __uninitialized_copy_move(_InputIterator1 __first1,
00374                               _InputIterator1 __last1,
00375                               _InputIterator2 __first2,
00376                               _InputIterator2 __last2,
00377                               _ForwardIterator __result,
00378                               _Allocator& __alloc)
00379     {
00380       _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1,
00381                                                            __result,
00382                                                            __alloc);
00383       __try
00384         {
00385           return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc);
00386         }
00387       __catch(...)
00388         {
00389           std::_Destroy(__result, __mid, __alloc);
00390           __throw_exception_again;
00391         }
00392     }
00393 
00394   // __uninitialized_move_copy
00395   // Moves [first1, last1) into [result, result + (last1 - first1)), and
00396   //  copies [first2, last2) into
00397   //  [result, result + (last1 - first1) + (last2 - first2)).
00398   template<typename _InputIterator1, typename _InputIterator2,
00399            typename _ForwardIterator, typename _Allocator>
00400     inline _ForwardIterator
00401     __uninitialized_move_copy(_InputIterator1 __first1,
00402                               _InputIterator1 __last1,
00403                               _InputIterator2 __first2,
00404                               _InputIterator2 __last2,
00405                               _ForwardIterator __result,
00406                               _Allocator& __alloc)
00407     {
00408       _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1,
00409                                                            __result,
00410                                                            __alloc);
00411       __try
00412         {
00413           return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
00414         }
00415       __catch(...)
00416         {
00417           std::_Destroy(__result, __mid, __alloc);
00418           __throw_exception_again;
00419         }
00420     }
00421   
00422   // __uninitialized_fill_move
00423   // Fills [result, mid) with x, and moves [first, last) into
00424   //  [mid, mid + (last - first)).
00425   template<typename _ForwardIterator, typename _Tp, typename _InputIterator,
00426            typename _Allocator>
00427     inline _ForwardIterator
00428     __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid,
00429                               const _Tp& __x, _InputIterator __first,
00430                               _InputIterator __last, _Allocator& __alloc)
00431     {
00432       std::__uninitialized_fill_a(__result, __mid, __x, __alloc);
00433       __try
00434         {
00435           return std::__uninitialized_move_a(__first, __last, __mid, __alloc);
00436         }
00437       __catch(...)
00438         {
00439           std::_Destroy(__result, __mid, __alloc);
00440           __throw_exception_again;
00441         }
00442     }
00443 
00444   // __uninitialized_move_fill
00445   // Moves [first1, last1) into [first2, first2 + (last1 - first1)), and
00446   //  fills [first2 + (last1 - first1), last2) with x.
00447   template<typename _InputIterator, typename _ForwardIterator, typename _Tp,
00448            typename _Allocator>
00449     inline void
00450     __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1,
00451                               _ForwardIterator __first2,
00452                               _ForwardIterator __last2, const _Tp& __x,
00453                               _Allocator& __alloc)
00454     {
00455       _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1,
00456                                                             __first2,
00457                                                             __alloc);
00458       __try
00459         {
00460           std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc);
00461         }
00462       __catch(...)
00463         {
00464           std::_Destroy(__first2, __mid2, __alloc);
00465           __throw_exception_again;
00466         }
00467     }
00468 
00469 #if __cplusplus >= 201103L
00470   // Extensions: __uninitialized_default, __uninitialized_default_n,
00471   // __uninitialized_default_a, __uninitialized_default_n_a.
00472 
00473   template<bool _TrivialValueType>
00474     struct __uninitialized_default_1
00475     {
00476       template<typename _ForwardIterator>
00477         static void
00478         __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
00479         {
00480           _ForwardIterator __cur = __first;
00481           __try
00482             {
00483               for (; __cur != __last; ++__cur)
00484                 std::_Construct(std::__addressof(*__cur));
00485             }
00486           __catch(...)
00487             {
00488               std::_Destroy(__first, __cur);
00489               __throw_exception_again;
00490             }
00491         }
00492     };
00493 
00494   template<>
00495     struct __uninitialized_default_1<true>
00496     {
00497       template<typename _ForwardIterator>
00498         static void
00499         __uninit_default(_ForwardIterator __first, _ForwardIterator __last)
00500         {
00501           typedef typename iterator_traits<_ForwardIterator>::value_type
00502             _ValueType;
00503 
00504           std::fill(__first, __last, _ValueType());
00505         }
00506     };
00507 
00508   template<bool _TrivialValueType>
00509     struct __uninitialized_default_n_1
00510     {
00511       template<typename _ForwardIterator, typename _Size>
00512         static _ForwardIterator
00513         __uninit_default_n(_ForwardIterator __first, _Size __n)
00514         {
00515           _ForwardIterator __cur = __first;
00516           __try
00517             {
00518               for (; __n > 0; --__n, ++__cur)
00519                 std::_Construct(std::__addressof(*__cur));
00520               return __cur;
00521             }
00522           __catch(...)
00523             {
00524               std::_Destroy(__first, __cur);
00525               __throw_exception_again;
00526             }
00527         }
00528     };
00529 
00530   template<>
00531     struct __uninitialized_default_n_1<true>
00532     {
00533       template<typename _ForwardIterator, typename _Size>
00534         static _ForwardIterator
00535         __uninit_default_n(_ForwardIterator __first, _Size __n)
00536         {
00537           typedef typename iterator_traits<_ForwardIterator>::value_type
00538             _ValueType;
00539 
00540           return std::fill_n(__first, __n, _ValueType());
00541         }
00542     };
00543 
00544   // __uninitialized_default
00545   // Fills [first, last) with std::distance(first, last) default
00546   // constructed value_types(s).
00547   template<typename _ForwardIterator>
00548     inline void
00549     __uninitialized_default(_ForwardIterator __first,
00550                             _ForwardIterator __last)
00551     {
00552       typedef typename iterator_traits<_ForwardIterator>::value_type
00553         _ValueType;
00554       // trivial types can have deleted assignment
00555       const bool __assignable = is_copy_assignable<_ValueType>::value;
00556 
00557       std::__uninitialized_default_1<__is_trivial(_ValueType)
00558                                      && __assignable>::
00559         __uninit_default(__first, __last);
00560     }
00561 
00562   // __uninitialized_default_n
00563   // Fills [first, first + n) with n default constructed value_type(s).
00564   template<typename _ForwardIterator, typename _Size>
00565     inline _ForwardIterator
00566     __uninitialized_default_n(_ForwardIterator __first, _Size __n)
00567     {
00568       typedef typename iterator_traits<_ForwardIterator>::value_type
00569         _ValueType;
00570       // trivial types can have deleted assignment
00571       const bool __assignable = is_copy_assignable<_ValueType>::value;
00572 
00573       return __uninitialized_default_n_1<__is_trivial(_ValueType)
00574                                        && __assignable>::
00575         __uninit_default_n(__first, __n);
00576     }
00577 
00578 
00579   // __uninitialized_default_a
00580   // Fills [first, last) with std::distance(first, last) default
00581   // constructed value_types(s), constructed with the allocator alloc.
00582   template<typename _ForwardIterator, typename _Allocator>
00583     void
00584     __uninitialized_default_a(_ForwardIterator __first,
00585                               _ForwardIterator __last,
00586                               _Allocator& __alloc)
00587     {
00588       _ForwardIterator __cur = __first;
00589       __try
00590         {
00591           typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
00592           for (; __cur != __last; ++__cur)
00593             __traits::construct(__alloc, std::__addressof(*__cur));
00594         }
00595       __catch(...)
00596         {
00597           std::_Destroy(__first, __cur, __alloc);
00598           __throw_exception_again;
00599         }
00600     }
00601 
00602   template<typename _ForwardIterator, typename _Tp>
00603     inline void
00604     __uninitialized_default_a(_ForwardIterator __first,
00605                               _ForwardIterator __last,
00606                               allocator<_Tp>&)
00607     { std::__uninitialized_default(__first, __last); }
00608 
00609 
00610   // __uninitialized_default_n_a
00611   // Fills [first, first + n) with n default constructed value_types(s),
00612   // constructed with the allocator alloc.
00613   template<typename _ForwardIterator, typename _Size, typename _Allocator>
00614     _ForwardIterator
00615     __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, 
00616                                 _Allocator& __alloc)
00617     {
00618       _ForwardIterator __cur = __first;
00619       __try
00620         {
00621           typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
00622           for (; __n > 0; --__n, ++__cur)
00623             __traits::construct(__alloc, std::__addressof(*__cur));
00624           return __cur;
00625         }
00626       __catch(...)
00627         {
00628           std::_Destroy(__first, __cur, __alloc);
00629           __throw_exception_again;
00630         }
00631     }
00632 
00633   template<typename _ForwardIterator, typename _Size, typename _Tp>
00634     inline _ForwardIterator
00635     __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, 
00636                                 allocator<_Tp>&)
00637     { return std::__uninitialized_default_n(__first, __n); }
00638 
00639 
00640   template<typename _InputIterator, typename _Size,
00641            typename _ForwardIterator>
00642     _ForwardIterator
00643     __uninitialized_copy_n(_InputIterator __first, _Size __n,
00644                            _ForwardIterator __result, input_iterator_tag)
00645     {
00646       _ForwardIterator __cur = __result;
00647       __try
00648         {
00649           for (; __n > 0; --__n, ++__first, ++__cur)
00650             std::_Construct(std::__addressof(*__cur), *__first);
00651           return __cur;
00652         }
00653       __catch(...)
00654         {
00655           std::_Destroy(__result, __cur);
00656           __throw_exception_again;
00657         }
00658     }
00659 
00660   template<typename _RandomAccessIterator, typename _Size,
00661            typename _ForwardIterator>
00662     inline _ForwardIterator
00663     __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n,
00664                            _ForwardIterator __result,
00665                            random_access_iterator_tag)
00666     { return std::uninitialized_copy(__first, __first + __n, __result); }
00667 
00668   /**
00669    *  @brief Copies the range [first,first+n) into result.
00670    *  @param  __first  An input iterator.
00671    *  @param  __n      The number of elements to copy.
00672    *  @param  __result An output iterator.
00673    *  @return  __result + __n
00674    *
00675    *  Like copy_n(), but does not require an initialized output range.
00676   */
00677   template<typename _InputIterator, typename _Size, typename _ForwardIterator>
00678     inline _ForwardIterator
00679     uninitialized_copy_n(_InputIterator __first, _Size __n,
00680                          _ForwardIterator __result)
00681     { return std::__uninitialized_copy_n(__first, __n, __result,
00682                                          std::__iterator_category(__first)); }
00683 #endif
00684 
00685 _GLIBCXX_END_NAMESPACE_VERSION
00686 } // namespace
00687 
00688 #endif /* _STL_UNINITIALIZED_H */