ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/src/estl.h
(Generate patch)

Comparing libptytty/src/estl.h (file contents):
Revision 1.14 by root, Sat May 19 02:13:59 2012 UTC vs.
Revision 1.15 by root, Sat May 19 02:15:31 2012 UTC

100 template<class I> 100 template<class I>
101 static void cop_set (iterator a, I b) { *a = *b ; } 101 static void cop_set (iterator a, I b) { *a = *b ; }
102 102
103 // MUST copy forwards 103 // MUST copy forwards
104 template<class I> 104 template<class I>
105 static void copy (iterator dst, I src, size_type n, void (*op)(iterator, I) = cop_new) 105 static void copy (iterator dst, I src, size_type n, void (*op)(iterator, I))
106 { 106 {
107 while (n--) 107 while (n--)
108 op (dst++, src++); 108 op (dst++, src++);
109 } 109 }
110 110
111 static void copy (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator) = cop_new) 111 static void copy (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator))
112 { 112 {
113 if (is_simple_enough ()) 113 if (is_simple_enough ())
114 memcpy (dst, src, sizeof (T) * n); 114 memcpy (dst, src, sizeof (T) * n);
115 else 115 else
116 copy<iterator> (dst, src, n, op); 116 copy<iterator> (dst, src, n, op);
183 return; 183 return;
184 184
185 sz = good_size (sz); 185 sz = good_size (sz);
186 T *nbuf = alloc (sz); 186 T *nbuf = alloc (sz);
187 187
188 copy (nbuf, begin (), sze); 188 copy (nbuf, begin (), sze, cop_new);
189 dealloc (); 189 dealloc ();
190 190
191 buf = nbuf; 191 buf = nbuf;
192 res = sz; 192 res = sz;
193 } 193 }
222 template<class I> 222 template<class I>
223 simplevec (I first, I last) 223 simplevec (I first, I last)
224 { 224 {
225 sze = res = last - first; 225 sze = res = last - first;
226 buf = alloc (sze); 226 buf = alloc (sze);
227 copy (buf, first, sze); 227 copy (buf, first, sze, cop_new);
228 } 228 }
229 229
230 simplevec (const simplevec<T> &v) 230 simplevec (const simplevec<T> &v)
231 : sze(0), res(0), buf(0) 231 : sze(0), res(0), buf(0)
232 { 232 {
233 sze = res = v.size (); 233 sze = res = v.size ();
234 buf = alloc (sze); 234 buf = alloc (sze);
235 copy (buf, v.begin (), sze); 235 copy (buf, v.begin (), sze, cop_new);
236 } 236 }
237 237
238 ~simplevec () 238 ~simplevec ()
239 { 239 {
240 dealloc (); 240 dealloc ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines