… | |
… | |
23 | #include <new> |
23 | #include <new> |
24 | |
24 | |
25 | #if ECB_CPP11 |
25 | #if ECB_CPP11 |
26 | #include <type_traits> |
26 | #include <type_traits> |
27 | #endif |
27 | #endif |
|
|
28 | |
|
|
29 | namespace estl |
|
|
30 | { |
|
|
31 | #if ESTL_LARGE_MEMORY_MODEL |
|
|
32 | // should use size_t/ssize_t, but that's not portable enough for us |
|
|
33 | typedef unsigned long size_type; |
|
|
34 | typedef long difference_type; |
|
|
35 | #else |
|
|
36 | typedef uint32_t size_type; |
|
|
37 | typedef int32_t difference_type; |
|
|
38 | #endif |
|
|
39 | |
|
|
40 | template<typename T> |
|
|
41 | struct scoped_ptr |
|
|
42 | { |
|
|
43 | T *p; |
|
|
44 | |
|
|
45 | scoped_ptr () : p (0) { } |
|
|
46 | |
|
|
47 | explicit |
|
|
48 | scoped_ptr (T *a) : p (a) { } |
|
|
49 | |
|
|
50 | ~scoped_ptr () |
|
|
51 | { |
|
|
52 | delete p; |
|
|
53 | } |
|
|
54 | |
|
|
55 | void reset (T *a) |
|
|
56 | { |
|
|
57 | delete p; |
|
|
58 | p = a; |
|
|
59 | } |
|
|
60 | |
|
|
61 | T *operator ->() const { return p; } |
|
|
62 | T &operator *() const { return *p; } |
|
|
63 | |
|
|
64 | operator T *() { return p; } |
|
|
65 | T *get () const { return p; } |
|
|
66 | |
|
|
67 | private: |
|
|
68 | scoped_ptr (const scoped_ptr &); |
|
|
69 | scoped_ptr &operator =(const scoped_ptr &); |
|
|
70 | }; |
|
|
71 | |
|
|
72 | template<typename T> |
|
|
73 | struct scoped_array |
|
|
74 | { |
|
|
75 | T *p; |
|
|
76 | |
|
|
77 | scoped_array () : p (0) { } |
|
|
78 | |
|
|
79 | explicit |
|
|
80 | scoped_array (T *a) : p (a) { } |
|
|
81 | |
|
|
82 | ~scoped_array () |
|
|
83 | { |
|
|
84 | delete [] p; |
|
|
85 | } |
|
|
86 | |
|
|
87 | void reset (T *a) |
|
|
88 | { |
|
|
89 | delete [] p; |
|
|
90 | p = a; |
|
|
91 | } |
|
|
92 | |
|
|
93 | operator T *() { return p; } |
|
|
94 | T *get () const { return p; } |
|
|
95 | |
|
|
96 | private: |
|
|
97 | scoped_array (const scoped_array &); |
|
|
98 | scoped_array &operator =(const scoped_array &); |
|
|
99 | }; |
|
|
100 | } |
28 | |
101 | |
29 | // original version taken from MICO, but this has been completely rewritten |
102 | // original version taken from MICO, but this has been completely rewritten |
30 | // known limitations w.r.t. std::vector |
103 | // known limitations w.r.t. std::vector |
31 | // - many methods missing |
104 | // - many methods missing |
32 | // - no error checking, no exceptions thrown (e.g. at()) |
105 | // - no error checking, no exceptions thrown (e.g. at()) |
… | |
… | |
36 | // - we don't care about namespaces and stupid macros the user might define |
109 | // - we don't care about namespaces and stupid macros the user might define |
37 | // - no bool specialisation |
110 | // - no bool specialisation |
38 | template<class T> |
111 | template<class T> |
39 | struct simplevec |
112 | struct simplevec |
40 | { |
113 | { |
41 | #if ESTL_BIG_VECTOR |
114 | typedef estl::size_type size_type; |
42 | // should use size_t/ssize_t, but that's not portable enough for us |
|
|
43 | typedef unsigned long size_type; |
|
|
44 | typedef long difference_type; |
|
|
45 | #else |
|
|
46 | typedef uint32_t size_type; |
|
|
47 | typedef int32_t difference_type; |
|
|
48 | #endif |
|
|
49 | |
115 | |
50 | typedef T value_type; |
116 | typedef T value_type; |
51 | typedef T *iterator; |
117 | typedef T *iterator; |
52 | typedef const T *const_iterator; |
118 | typedef const T *const_iterator; |
53 | typedef T *pointer; |
119 | typedef T *pointer; |
… | |
… | |
68 | #if ECB_CPP11 |
134 | #if ECB_CPP11 |
69 | return std::is_trivially_assignable<T, T>::value |
135 | return std::is_trivially_assignable<T, T>::value |
70 | && std::is_trivially_constructible<T>::value |
136 | && std::is_trivially_constructible<T>::value |
71 | && std::is_trivially_copyable<T>::value |
137 | && std::is_trivially_copyable<T>::value |
72 | && std::is_trivially_destructible<T>::value; |
138 | && std::is_trivially_destructible<T>::value; |
73 | #elif ECB_GCC_VERSION(4,4) |
139 | #elif ECB_GCC_VERSION(4,4) || ECB_CLANG_VERSION(2,8) |
74 | return __has_trivial_assign (T) |
140 | return __has_trivial_assign (T) |
75 | && __has_trivial_constructor (T) |
141 | && __has_trivial_constructor (T) |
76 | && __has_trivial_copy (T) |
142 | && __has_trivial_copy (T) |
77 | && __has_trivial_destructor (T); |
143 | && __has_trivial_destructor (T); |
78 | #else |
144 | #else |