Install msysDVLPR-1.0.0-alpha-1
[msysgit.git] / lib / gcc-lib / i686-pc-msys / 2.95.3-1 / include / g++-3 / stl_uninitialized.h
blob280bb194aad5e83162c788628f474c8370783c07
1 /*
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
15 * Copyright (c) 1996,1997
16 * Silicon Graphics Computer Systems, Inc.
18 * Permission to use, copy, modify, distribute and sell this software
19 * and its documentation for any purpose is hereby granted without fee,
20 * provided that the above copyright notice appear in all copies and
21 * that both that copyright notice and this permission notice appear
22 * in supporting documentation. Silicon Graphics makes no
23 * representations about the suitability of this software for any
24 * purpose. It is provided "as is" without express or implied warranty.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H
32 #define __SGI_STL_INTERNAL_UNINITIALIZED_H
34 __STL_BEGIN_NAMESPACE
40 template <class _InputIter, class _ForwardIter>
41 inline _ForwardIter
42 __uninitialized_copy_aux(_InputIter __first, _InputIter __last,
43 _ForwardIter __result,
44 __true_type)
46 return copy(__first, __last, __result);
49 template <class _InputIter, class _ForwardIter>
50 _ForwardIter
51 __uninitialized_copy_aux(_InputIter __first, _InputIter __last,
52 _ForwardIter __result,
53 __false_type)
55 _ForwardIter __cur = __result;
56 __STL_TRY {
57 for ( ; __first != __last; ++__first, ++__cur)
58 construct(&*__cur, *__first);
59 return __cur;
61 __STL_UNWIND(destroy(__result, __cur));
65 template <class _InputIter, class _ForwardIter, class _Tp>
66 inline _ForwardIter
67 __uninitialized_copy(_InputIter __first, _InputIter __last,
68 _ForwardIter __result, _Tp*)
70 typedef typename __type_traits<_Tp>::is_POD_type _Is_POD;
71 return __uninitialized_copy_aux(__first, __last, __result, _Is_POD());
74 template <class _InputIter, class _ForwardIter>
75 inline _ForwardIter
76 uninitialized_copy(_InputIter __first, _InputIter __last,
77 _ForwardIter __result)
79 return __uninitialized_copy(__first, __last, __result,
80 __VALUE_TYPE(__result));
83 inline char* uninitialized_copy(const char* __first, const char* __last,
84 char* __result) {
85 memmove(__result, __first, __last - __first);
86 return __result + (__last - __first);
89 inline wchar_t*
90 uninitialized_copy(const wchar_t* __first, const wchar_t* __last,
91 wchar_t* __result)
93 memmove(__result, __first, sizeof(wchar_t) * (__last - __first));
94 return __result + (__last - __first);
99 template <class _InputIter, class _Size, class _ForwardIter>
100 pair<_InputIter, _ForwardIter>
101 __uninitialized_copy_n(_InputIter __first, _Size __count,
102 _ForwardIter __result,
103 input_iterator_tag)
105 _ForwardIter __cur = __result;
106 __STL_TRY {
107 for ( ; __count > 0 ; --__count, ++__first, ++__cur)
108 construct(&*__cur, *__first);
109 return pair<_InputIter, _ForwardIter>(__first, __cur);
111 __STL_UNWIND(destroy(__result, __cur));
114 template <class _RandomAccessIter, class _Size, class _ForwardIter>
115 inline pair<_RandomAccessIter, _ForwardIter>
116 __uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
117 _ForwardIter __result,
118 random_access_iterator_tag) {
119 _RandomAccessIter __last = __first + __count;
120 return pair<_RandomAccessIter, _ForwardIter>(
121 __last,
122 uninitialized_copy(__first, __last, __result));
125 template <class _InputIter, class _Size, class _ForwardIter>
126 inline pair<_InputIter, _ForwardIter>
127 __uninitialized_copy_n(_InputIter __first, _Size __count,
128 _ForwardIter __result) {
129 return __uninitialized_copy_n(__first, __count, __result,
130 __ITERATOR_CATEGORY(__first));
133 template <class _InputIter, class _Size, class _ForwardIter>
134 inline pair<_InputIter, _ForwardIter>
135 uninitialized_copy_n(_InputIter __first, _Size __count,
136 _ForwardIter __result) {
137 return __uninitialized_copy_n(__first, __count, __result,
138 __ITERATOR_CATEGORY(__first));
143 template <class _ForwardIter, class _Tp>
144 inline void
145 __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
146 const _Tp& __x, __true_type)
148 fill(__first, __last, __x);
151 template <class _ForwardIter, class _Tp>
152 void
153 __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
154 const _Tp& __x, __false_type)
156 _ForwardIter __cur = __first;
157 __STL_TRY {
158 for ( ; __cur != __last; ++__cur)
159 construct(&*__cur, __x);
161 __STL_UNWIND(destroy(__first, __cur));
164 template <class _ForwardIter, class _Tp, class _Tp1>
165 inline void __uninitialized_fill(_ForwardIter __first,
166 _ForwardIter __last, const _Tp& __x, _Tp1*)
168 typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;
169 __uninitialized_fill_aux(__first, __last, __x, _Is_POD());
173 template <class _ForwardIter, class _Tp>
174 inline void uninitialized_fill(_ForwardIter __first,
175 _ForwardIter __last,
176 const _Tp& __x)
178 __uninitialized_fill(__first, __last, __x, __VALUE_TYPE(__first));
183 template <class _ForwardIter, class _Size, class _Tp>
184 inline _ForwardIter
185 __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
186 const _Tp& __x, __true_type)
188 return fill_n(__first, __n, __x);
191 template <class _ForwardIter, class _Size, class _Tp>
192 _ForwardIter
193 __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
194 const _Tp& __x, __false_type)
196 _ForwardIter __cur = __first;
197 __STL_TRY {
198 for ( ; __n > 0; --__n, ++__cur)
199 construct(&*__cur, __x);
200 return __cur;
202 __STL_UNWIND(destroy(__first, __cur));
205 template <class _ForwardIter, class _Size, class _Tp, class _Tp1>
206 inline _ForwardIter
207 __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*)
209 typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD;
210 return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD());
213 template <class _ForwardIter, class _Size, class _Tp>
214 inline _ForwardIter
215 uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x)
217 return __uninitialized_fill_n(__first, __n, __x, __VALUE_TYPE(__first));
228 template <class _InputIter1, class _InputIter2, class _ForwardIter>
229 inline _ForwardIter
230 __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
231 _InputIter2 __first2, _InputIter2 __last2,
232 _ForwardIter __result)
234 _ForwardIter __mid = uninitialized_copy(__first1, __last1, __result);
235 __STL_TRY {
236 return uninitialized_copy(__first2, __last2, __mid);
238 __STL_UNWIND(destroy(__result, __mid));
244 template <class _ForwardIter, class _Tp, class _InputIter>
245 inline _ForwardIter
246 __uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid,
247 const _Tp& __x,
248 _InputIter __first, _InputIter __last)
250 uninitialized_fill(__result, __mid, __x);
251 __STL_TRY {
252 return uninitialized_copy(__first, __last, __mid);
254 __STL_UNWIND(destroy(__result, __mid));
260 template <class _InputIter, class _ForwardIter, class _Tp>
261 inline void
262 __uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
263 _ForwardIter __first2, _ForwardIter __last2,
264 const _Tp& __x)
266 _ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);
267 __STL_TRY {
268 uninitialized_fill(__mid2, __last2, __x);
270 __STL_UNWIND(destroy(__first2, __mid2));
273 __STL_END_NAMESPACE
275 #endif /* __SGI_STL_INTERNAL_UNINITIALIZED_H */