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.23 by sf-exg, Fri Oct 24 13:44:09 2014 UTC vs.
Revision 1.27 by sf-exg, Fri Nov 7 20:44:49 2014 UTC

37// - no bool specialisation 37// - no bool specialisation
38template<class T> 38template<class T>
39struct simplevec 39struct simplevec
40{ 40{
41#if ESTL_BIG_VECTOR 41#if ESTL_BIG_VECTOR
42 // shoudl use size_t/ssize_t, but that's not portable enough for us 42 // should use size_t/ssize_t, but that's not portable enough for us
43 typedef unsigned long size_type; 43 typedef unsigned long size_type;
44 typedef long difference_type; 44 typedef long difference_type;
45#else 45#else
46 typedef uint32_t size_type; 46 typedef uint32_t size_type;
47 typedef int32_t difference_type; 47 typedef int32_t difference_type;
65 // "not simple enough" will use the slow path. 65 // "not simple enough" will use the slow path.
66 static bool is_simple_enough () 66 static bool is_simple_enough ()
67 { 67 {
68 #if ECB_CPP11 68 #if ECB_CPP11
69 return std::is_trivially_assignable<T, T>::value 69 return std::is_trivially_assignable<T, T>::value
70 && std::is_trivially_constructable<T>::value 70 && std::is_trivially_constructible<T>::value
71 && std::is_trivially_copyable<T>::value 71 && std::is_trivially_copyable<T>::value
72 && std::is_trivially_destructible<T>::value; 72 && std::is_trivially_destructible<T>::value;
73 #elif ECB_GCC_VERSION(4,4) 73 #elif ECB_GCC_VERSION(4,4) || ECB_CLANG_VERSION(2,8)
74 return __has_trivial_assign (T) 74 return __has_trivial_assign (T)
75 && __has_trivial_constructor (T) 75 && __has_trivial_constructor (T)
76 && __has_trivial_copy (T) 76 && __has_trivial_copy (T)
77 && __has_trivial_destructor (T); 77 && __has_trivial_destructor (T);
78 #else 78 #else
216 216
217 while (n--) 217 while (n--)
218 new (buf + n) T (t); 218 new (buf + n) T (t);
219 } 219 }
220 220
221 template<class I> 221 simplevec (const_iterator first, const_iterator last)
222 simplevec (I first, I last)
223 { 222 {
224 sze = res = last - first; 223 sze = res = last - first;
225 buf = alloc (sze); 224 buf = alloc (sze);
226 copy (buf, first, sze, cop_new); 225 copy (buf, first, sze, cop_new);
227 } 226 }
267 reference operator [](size_type idx) { return buf[idx]; } 266 reference operator [](size_type idx) { return buf[idx]; }
268 267
269 const_reference at (size_type idx) const { return buf [idx]; } 268 const_reference at (size_type idx) const { return buf [idx]; }
270 reference at (size_type idx) { return buf [idx]; } 269 reference at (size_type idx) { return buf [idx]; }
271 270
272 template<class I> 271 void assign (const_iterator first, const_iterator last)
273 void assign (I first, I last)
274 { 272 {
275 swap (simplevec<T> (first, last)); 273 simplevec<T> v (first, last);
274 swap (v);
276 } 275 }
277 276
278 void assign (size_type n, const T &t) 277 void assign (size_type n, const T &t)
279 { 278 {
280 swap (simplevec<T> (n, t)); 279 simplevec<T> v (n, t);
280 swap (v);
281 } 281 }
282 282
283 simplevec<T> &operator= (const simplevec<T> &v) 283 simplevec<T> &operator= (const simplevec<T> &v)
284 { 284 {
285 assign (v.begin (), v.end ()); 285 assign (v.begin (), v.end ());
294 buf [at] = t; 294 buf [at] = t;
295 295
296 return buf + at; 296 return buf + at;
297 } 297 }
298 298
299 template<class I>
300 iterator insert (iterator pos, I first, I last) 299 iterator insert (iterator pos, const_iterator first, const_iterator last)
301 { 300 {
302 size_type n = last - first; 301 size_type n = last - first;
303 size_type at = pos - begin (); 302 size_type at = pos - begin ();
304 303
305 ins (pos, n); 304 ins (pos, n);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines