Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3581316

Browse files
committedJun 8, 2018
Resurrected @gchatelet's STL branch
1 parent 032b970 commit 3581316

File tree

3 files changed

+147
-309
lines changed

3 files changed

+147
-309
lines changed
 

‎src/core/stdcpp/allocator.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
77
* (See accompanying file LICENSE)
88
* Authors: Guillaume Chatelet
9+
* Manu Evans
910
* Source: $(DRUNTIMESRC core/stdcpp/allocator.d)
1011
*/
1112

@@ -17,4 +18,4 @@ extern(C++, std):
1718
* Allocators are classes that define memory models to be used by some parts of
1819
* the C++ Standard Library, and most specifically, by STL containers.
1920
*/
20-
struct allocator(T) { }
21+
extern(C++, class) struct allocator(T) { }

‎src/core/stdcpp/string.d

+110-233
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
77
* (See accompanying file LICENSE)
88
* Authors: Guillaume Chatelet
9+
* Manu Evans
910
* Source: $(DRUNTIMESRC core/stdcpp/string.d)
1011
*/
1112

@@ -32,6 +33,7 @@ pragma(lib, "stdc++");
3233
///////////////////////////////////////////////////////////////////////////////
3334

3435
import core.stdcpp.allocator;
36+
import core.stdc.stddef;
3537

3638
extern(C++, std):
3739

@@ -45,293 +47,168 @@ struct char_traits(CharT) {}
4547
* The basic_string is the generalization of class string for any character
4648
* type.
4749
*/
48-
struct basic_string(T, TRAITS = char_traits!T, ALLOC = allocator!T)
50+
extern(C++, class) struct basic_string(T, Traits = char_traits!T, Alloc = allocator!T)
4951
{
50-
enum size_t npos = size_t.max;
52+
enum size_type npos = size_type.max;
5153

5254
alias value_type = T;
53-
alias traits_type = TRAITS;
54-
alias allocator_type = ALLOC;
55+
alias traits_type = Traits;
56+
alias allocator_type = Alloc;
5557
alias reference = ref T;
5658
alias const_reference = ref const(T);
5759
alias pointer = T*;
58-
alias const_pointer = const(T*);
60+
alias const_pointer = const(T)*;
5961
alias iterator = pointer;
6062
alias const_iterator = const_pointer;
6163
// alias reverse_iterator
6264
// alias const_reverse_iterator
6365
alias difference_type = ptrdiff_t;
6466
alias size_type = size_t;
6567

66-
// Ctor/dtor
67-
pragma(mangle, "_ZNSsC1Ev")
68-
@disable this();
69-
70-
pragma(mangle, "_ZNSsC1ERKSs")
71-
this(ref const this);
72-
73-
pragma(mangle, "_ZNSsC1EPKcRKSaIcE")
74-
this(const(T*) _, ref const allocator_type _ = defaultAlloc);
75-
76-
pragma(mangle, "_ZNSsD1Ev")
68+
// ctor/dtor
69+
// pragma(mangle, "_ZNSsC1ERKSs")
70+
// this(ref const(this));
71+
this(const(T)* ptr, size_type count);
72+
this(const(T)* ptr, size_type count, ref const(allocator_type) al = defaultAlloc);
73+
this(const(T)* ptr);
74+
this(const(T)* ptr, ref const(allocator_type) al = defaultAlloc);
75+
extern(D) this(const(T)[] dstr) { this(dstr.ptr, dstr.length); }
76+
extern(D) this(const(T)[] dstr, ref const(allocator_type) al = defaultAlloc) { this(dstr.ptr, dstr.length); }
7777
~this();
7878

79-
pragma(mangle, "_ZNSsaSERKSs")
80-
ref basic_string opAssign(ref const basic_string s);
79+
ref basic_string opAssign(ref const(basic_string) s);
8180

8281
// Iterators
83-
pragma(mangle, "_ZNSs5beginEv")
8482
iterator begin() nothrow;
83+
const_iterator begin() const nothrow;
84+
const_iterator cbegin() const nothrow;
8585

86-
pragma(mangle, "_ZNKSs5beginEv")
87-
const_iterator begin() nothrow const;
88-
89-
pragma(mangle, "_ZNKSs6cbeginEv")
90-
const_iterator cbegin() nothrow const;
91-
92-
pragma(mangle, "_ZNSs3endEv")
9386
iterator end() nothrow;
94-
95-
pragma(mangle, "_ZNKSs3endEv")
96-
const_iterator end() nothrow const;
97-
98-
pragma(mangle, "_ZNKSs4cendEv")
99-
const_iterator cend() nothrow const;
87+
const_iterator end() const nothrow;
88+
const_iterator cend() const nothrow;
10089

10190
// no reverse iterator for now.
10291

10392
// Capacity
104-
pragma(mangle, "_ZNKSs4sizeEv")
105-
size_t size() nothrow const;
106-
107-
pragma(mangle, "_ZNKSs6lengthEv")
108-
size_t length() nothrow const;
109-
110-
pragma(mangle, "_ZNKSs8max_sizeEv")
111-
size_t max_size() nothrow const;
93+
size_type size() const nothrow;
94+
size_type length() const nothrow;
95+
size_type max_size() const nothrow;
96+
size_type capacity() const nothrow;
11297

113-
pragma(mangle, "_ZNKSs8capacityEv")
114-
size_t capacity() nothrow const;
98+
bool empty() const nothrow;
11599

116-
pragma(mangle, "_ZNKSs5emptyEv")
117-
bool empty() nothrow const;
118-
119-
pragma(mangle, "_ZNSs5clearEv")
120100
void clear() nothrow;
121-
122-
pragma(mangle, "_ZNSs6resizeEm")
123-
void resize(size_t n);
124-
125-
pragma(mangle, "_ZNSs6resizeEmc")
126-
void resize(size_t n, T c);
127-
128-
pragma(mangle, "_ZNSs7reserveEm")
129-
void reserve(size_t n = 0);
130-
131-
pragma(mangle, "_ZNSs13shrink_to_fitEv")
101+
void resize(size_type n);
102+
void resize(size_type n, T c);
103+
void reserve(size_type n = 0);
132104
void shrink_to_fit();
133105

134106
// Element access
135-
pragma(mangle, "_ZNSsixEm")
136-
ref T opIndex(size_t i);
107+
ref T opIndex(size_type i);
108+
ref const(T) opIndex(size_type i) const;
109+
ref T at(size_type i);
110+
ref const(T) at(size_type i) const;
137111

138-
pragma(mangle, "_ZNKSsixEm")
139-
ref const(T) opIndex(size_t i) const;
140-
141-
pragma(mangle, "_ZNSs2atEm")
142-
ref T at(size_t i);
143-
144-
pragma(mangle, "_ZNKSs2atEm")
145-
ref const(T) at(size_t i) const;
146-
147-
pragma(mangle, "_ZNSs4backEv")
148112
ref T back();
149-
150-
pragma(mangle, "_ZNKSs4backEv")
151113
ref const(T) back() const;
152-
153-
pragma(mangle, "_ZNSs5frontEv")
154114
ref T front();
155-
156-
pragma(mangle, "_ZNKSs5frontEv")
157115
ref const(T) front() const;
158116

159-
// Modifiers
160-
pragma(mangle, "_ZNSspLERKSs")
161-
ref basic_string opOpAssign(string op)(ref const basic_string _) if (op == "+");
162-
163-
pragma(mangle, "_ZNSspLEPKc")
164-
ref basic_string opOpAssign(string op)(const(T*) _) if (op == "+");
165-
166-
pragma(mangle, "_ZNSspLEc")
167-
ref basic_string opOpAssign(string op)(T _) if (op == "+");
168-
169-
pragma(mangle, "_ZNSs6appendEmc")
170-
ref basic_string append(size_t n, char c);
171-
172-
pragma(mangle, "_ZNSs6appendEPKc")
173-
ref basic_string append(const char* s);
174-
175-
pragma(mangle, "_ZNSs6appendEPKcm")
176-
ref basic_string append(const char* s, size_t n);
177-
178-
pragma(mangle, "_ZNSs6appendERKSs")
179-
ref basic_string append(ref const basic_string str);
117+
const(T)* c_str() const nothrow;
118+
T* data() nothrow;
119+
const(T)* data() const nothrow;
180120

181-
pragma(mangle, "_ZNSs6appendERKSsmm")
182-
ref basic_string append(ref const basic_string str, size_t subpos, size_t sublen);
121+
// Modifiers
122+
ref basic_string opOpAssign(string op : "+")(ref const(basic_string) s);
123+
ref basic_string opOpAssign(string op : "+")(const(T)* s);
124+
ref basic_string opOpAssign(string op : "+")(T s);
125+
extern(D) ref basic_string opOpAssign(string op : "~")(ref const(basic_string) s) { this += s; return this; }
126+
extern(D) ref basic_string opOpAssign(string op : "~")(const(T)* s) { this += s; return this; }
127+
extern(D) ref basic_string opOpAssign(string op : "~")(const(T)[] s) { auto t = basic_string(s.ptr, s.length); this += t; return this; }
128+
extern(D) ref basic_string opOpAssign(string op : "~")(T s) { this += s; return this; }
129+
130+
ref basic_string append(size_type n, T c);
131+
ref basic_string append(const(T)* s);
132+
ref basic_string append(const(T)* s, size_type n);
133+
ref basic_string append(ref const(basic_string) str);
134+
ref basic_string append(ref const(basic_string) str, size_type subpos, size_type sublen);
135+
extern(D) ref basic_string append(const(T)[] s) { append(s.ptr, s.length); return this; }
183136

184-
pragma(mangle, "_ZNSs9push_backEc")
185137
void push_back(T c);
186138

187-
pragma(mangle, "_ZNSs6assignEmc")
188-
ref basic_string assign(size_t n, char c);
189-
190-
pragma(mangle, "_ZNSs6assignEPKc")
191-
ref basic_string assign(const char* s);
192-
193-
pragma(mangle, "_ZNSs6assignEPKcm")
194-
ref basic_string assign(const char* s, size_t n);
195-
196-
pragma(mangle, "_ZNSs6assignERKSs")
197-
ref basic_string assign(ref const basic_string str);
198-
199-
pragma(mangle, "_ZNSs6assignERKSsmm")
200-
ref basic_string assign(ref const basic_string str, size_t subpos, size_t sublen);
201-
202-
pragma(mangle, "_ZNSs6insertEmRKSs")
203-
ref basic_string insert (size_t pos, ref const basic_string str);
204-
205-
pragma(mangle, "_ZNSs6insertEmRKSsmm")
206-
ref basic_string insert (size_t pos, ref const basic_string str, size_t subpos, size_t sublen);
207-
208-
pragma(mangle, "_ZNSs6insertEmPKc")
209-
ref basic_string insert (size_t pos, const char* s);
139+
ref basic_string assign(size_type n, T c);
140+
ref basic_string assign(const(T)* s);
141+
ref basic_string assign(const(T)* s, size_type n);
142+
ref basic_string assign(ref const(basic_string) str);
143+
ref basic_string assign(ref const(basic_string) str, size_type subpos, size_type sublen);
144+
extern(D) ref basic_string assign(const(T)[] s) { assign(s.ptr, s.length); return this; }
210145

211-
pragma(mangle, "_ZNSs6insertEmPKcm")
212-
ref basic_string insert (size_t pos, const char* s, size_t n);
146+
ref basic_string insert(size_type pos, ref const(basic_string) str);
147+
ref basic_string insert(size_type pos, ref const(basic_string) str, size_type subpos, size_type sublen);
148+
ref basic_string insert(size_type pos, const(T)* s);
149+
ref basic_string insert(size_type pos, const(T)* s, size_type n);
150+
ref basic_string insert(size_type pos, size_type n, T c);
151+
extern(D) ref basic_string insert(size_type pos, const(T)[] s) { insert(pos, s.ptr, s.length); return this; }
213152

214-
pragma(mangle, "_ZNSs6insertEmmc")
215-
ref basic_string insert (size_t pos, size_t n, char c);
216-
217-
pragma(mangle, "_ZNSs5eraseEmm")
218-
ref basic_string erase(size_t pos = 0, size_t len = npos);
153+
ref basic_string erase(size_type pos = 0, size_type len = npos);
219154

220155
// replace
221156
// swap
222-
pragma(mangle, "_ZNSs8pop_backEv")
223157
void pop_back();
224158

225159
// String operations
226-
pragma(mangle, "_ZNKSs5c_strEv")
227-
const(T*) c_str() nothrow const;
228-
229-
pragma(mangle, "_ZNKSs4dataEv")
230-
const(T*) data() nothrow const;
231-
232-
pragma(mangle, "_ZNKSs4copyEPcmm")
233-
size_t copy(T* s, size_t len, size_t pos = 0) const;
234-
235-
pragma(mangle, "_ZNKSs4findERKSsm")
236-
size_t find(ref const basic_string str, size_t pos = 0) nothrow const;
237-
238-
pragma(mangle, "_ZNKSs4findEPKcm")
239-
size_t find(const(T*) s, size_t pos = 0) const;
240-
241-
pragma(mangle, "_ZNKSs4findEPKcmm")
242-
size_t find(const(T*) s, size_t pos, size_type n) const;
243-
244-
pragma(mangle, "_ZNKSs4findEcm")
245-
size_t find(T c, size_t pos = 0) nothrow const;
246-
247-
pragma(mangle, "_ZNKSs5rfindERKSsm")
248-
size_t rfind(ref const basic_string str, size_t pos = npos) nothrow const;
249-
250-
pragma(mangle, "_ZNKSs5rfindEPKcm")
251-
size_t rfind(const(T*) s, size_t pos = npos) const;
252-
253-
pragma(mangle, "_ZNKSs5rfindEPKcmm")
254-
size_t rfind(const(T*) s, size_t pos, size_t n) const;
255-
256-
pragma(mangle, "_ZNKSs5rfindEcm")
257-
size_t rfind(T c, size_t pos = npos) nothrow const;
258-
259-
pragma(mangle, "_ZNKSs13find_first_ofERKSsm")
260-
size_t find_first_of(ref const basic_string str, size_t pos = 0) nothrow const;
261-
262-
pragma(mangle, "_ZNKSs13find_first_ofEPKcm")
263-
size_t find_first_of(const(T*) s, size_t pos = 0) const;
264-
265-
pragma(mangle, "_ZNKSs13find_first_ofEPKcmm")
266-
size_t find_first_of(const(T*) s, size_t pos, size_t n) const;
267-
268-
pragma(mangle, "_ZNKSs13find_first_ofEcm")
269-
size_t find_first_of(T c, size_t pos = 0) nothrow const;
270-
271-
pragma(mangle, "_ZNKSs12find_last_ofERKSsm")
272-
size_t find_last_of(ref const basic_string str, size_t pos = npos) nothrow const;
273-
274-
pragma(mangle, "_ZNKSs12find_last_ofEPKcm")
275-
size_t find_last_of(const(T*) s, size_t pos = npos) const;
276-
277-
pragma(mangle, "_ZNKSs12find_last_ofEPKcmm")
278-
size_t find_last_of(const(T*) s, size_t pos, size_t n) const;
279-
280-
pragma(mangle, "_ZNKSs12find_last_ofEcm")
281-
size_t find_last_of(T c, size_t pos = npos) nothrow const;
282-
283-
pragma(mangle, "_ZNKSs17find_first_not_ofERKSsm")
284-
size_t find_first_not_of(ref const basic_string str, size_t pos = 0) nothrow const;
285-
286-
pragma(mangle, "_ZNKSs17find_first_not_ofEPKcm")
287-
size_t find_first_not_of(const(T*) s, size_t pos = 0) const;
288-
289-
pragma(mangle, "_ZNKSs17find_first_not_ofEPKcmm")
290-
size_t find_first_not_of(const(T*) s, size_t pos, size_t n) const;
291-
292-
pragma(mangle, "_ZNKSs17find_first_not_ofEcm")
293-
size_t find_first_not_of(T c, size_t pos = 0) nothrow const;
294-
295-
pragma(mangle, "_ZNKSs16find_last_not_ofERKSsm")
296-
size_t find_last_not_of(ref const basic_string str, size_t pos = npos) nothrow const;
297-
298-
pragma(mangle, "_ZNKSs16find_last_not_ofEPKcm")
299-
size_t find_last_not_of(const(T*) s, size_t pos = npos) const;
300-
301-
pragma(mangle, "_ZNKSs16find_last_not_ofEPKcmm")
302-
size_t find_last_not_of(const(T*) s, size_t pos, size_t n) const;
303-
304-
pragma(mangle, "_ZNKSs16find_last_not_ofEcm")
305-
size_t find_last_not_of(T c, size_t pos = npos) nothrow const;
306-
307-
pragma(mangle, "_ZNKSs6substrEmm")
308-
basic_string substr(size_t pos = 0, size_t len = npos) const;
309-
310-
pragma(mangle, "_ZNKSs7compareERKSs")
311-
int compare(ref const basic_string str) nothrow const;
312-
313-
pragma(mangle, "_ZNKSs7compareEmmRKSs")
314-
int compare(size_t pos, size_t len, ref const basic_string str) const;
315-
316-
pragma(mangle, "_ZNKSs7compareEmmRKSsmm")
317-
int compare(size_t pos, size_t len, ref const basic_string str, size_t subpos, size_t sublen) const;
318-
319-
pragma(mangle, "_ZNKSs7compareEPKc")
320-
int compare(const(T*) s) const;
321-
322-
pragma(mangle, "_ZNKSs7compareEmmPKc")
323-
int compare(size_t pos, size_t len, const(T*) s) const;
324-
325-
pragma(mangle, "_ZNKSs7compareEmmPKcm")
326-
int compare(size_t pos, size_t len, const(T*) s, size_t n) const;
160+
size_type copy(T* s, size_type len, size_type pos = 0) const;
161+
162+
size_type find(ref const(basic_string) str, size_type pos = 0) const nothrow;
163+
size_type find(const(T)* s, size_type pos = 0) const;
164+
size_type find(const(T)* s, size_type pos, size_type n) const;
165+
size_type find(T c, size_type pos = 0) const nothrow;
166+
167+
size_type rfind(ref const(basic_string) str, size_type pos = npos) const nothrow;
168+
size_type rfind(const(T)* s, size_type pos = npos) const;
169+
size_type rfind(const(T)* s, size_type pos, size_type n) const;
170+
size_type rfind(T c, size_type pos = npos) const nothrow;
171+
172+
size_type find_first_of(ref const(basic_string) str, size_type pos = 0) const nothrow;
173+
size_type find_first_of(const(T)* s, size_type pos = 0) const;
174+
size_type find_first_of(const(T)* s, size_type pos, size_type n) const;
175+
size_type find_first_of(T c, size_type pos = 0) const nothrow;
176+
177+
size_type find_last_of(ref const(basic_string) str, size_type pos = npos) const nothrow;
178+
size_type find_last_of(const(T)* s, size_type pos = npos) const;
179+
size_type find_last_of(const(T)* s, size_type pos, size_type n) const;
180+
size_type find_last_of(T c, size_type pos = npos) const nothrow;
181+
182+
size_type find_first_not_of(ref const(basic_string) str, size_type pos = 0) const nothrow;
183+
size_type find_first_not_of(const(T)* s, size_type pos = 0) const;
184+
size_type find_first_not_of(const(T)* s, size_type pos, size_type n) const;
185+
size_type find_first_not_of(T c, size_type pos = 0) const nothrow;
186+
187+
size_type find_last_not_of(ref const(basic_string) str, size_type pos = npos) const nothrow;
188+
size_type find_last_not_of(const(T)* s, size_type pos = npos) const;
189+
size_type find_last_not_of(const(T)* s, size_type pos, size_type n) const;
190+
size_type find_last_not_of(T c, size_type pos = npos) const nothrow;
191+
192+
basic_string substr(size_type pos = 0, size_type len = npos) const;
193+
194+
int compare(ref const(basic_string) str) const nothrow;
195+
int compare(size_type pos, size_type len, ref const(basic_string) str) const;
196+
int compare(size_type pos, size_type len, ref const(basic_string) str, size_type subpos, size_type sublen) const;
197+
int compare(const(T)* s) const;
198+
int compare(size_type pos, size_type len, const(T)* s) const;
199+
int compare(size_type pos, size_type len, const(T)* s, size_type n) const;
327200

328201
// D helpers
329-
const(T[]) asArray() const { return c_str()[0 .. size()]; }
202+
alias as_array this;
203+
extern(D) T[] as_array() { return data()[0 .. size()]; }
204+
extern(D) const(T)[] as_array() const { return data()[0 .. size()]; }
330205

331206
private:
332207
void[8] _ = void; // to match sizeof(std::string) and pad the object correctly.
333208
__gshared static immutable allocator!T defaultAlloc;
334209
}
335210

336211
alias basic_string!char std_string;
337-
alias basic_string!wchar std_wstring;
212+
alias basic_string!wchar_t std_wstring;
213+
alias basic_string!wchar std_u16string;
214+
alias basic_string!dchar std_u32string;

‎src/core/stdcpp/vector.d

+35-75
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
77
* (See accompanying file LICENSE)
88
* Authors: Guillaume Chatelet
9+
* Manu Evans
910
* Source: $(DRUNTIMESRC core/stdcpp/vector.d)
1011
*/
1112

@@ -32,126 +33,85 @@ import core.stdcpp.allocator;
3233

3334
extern(C++, std):
3435

35-
struct vector(T, ALLOC = allocator!T)
36+
extern(C++, class) struct vector(T, Alloc = allocator!T)
3637
{
3738
alias value_type = T;
38-
alias allocator_type = ALLOC;
39+
alias allocator_type = Alloc;
3940
alias reference = ref T;
4041
alias const_reference = ref const(T);
4142
alias pointer = T*;
42-
alias const_pointer = const(T*);
43+
alias const_pointer = const(T)*;
4344
alias iterator = pointer;
4445
alias const_iterator = const_pointer;
4546
// alias reverse_iterator
4647
// alias const_reverse_iterator
4748
alias difference_type = ptrdiff_t;
4849
alias size_type = size_t;
4950

50-
// Ctor/dtor
51-
pragma(mangle, "_ZNSt6vectorIiSaIiEEC1Ev")
52-
this();
53-
54-
pragma(mangle, "_ZNSt6vectorIiSaIiEEC2EmRKS0_")
55-
this(size_type n, ref const allocator_type _ = defaultAlloc);
56-
57-
pragma(mangle, "_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_")
58-
this(size_type n, ref const value_type val, ref const allocator_type _ = defaultAlloc);
59-
60-
pragma(mangle, "_ZNSt6vectorIiSaIiEEC2ERKS1_")
61-
this(ref const vector x);
62-
63-
pragma(mangle, "_ZNSt6vectorIiSaIiEED1Ev")
51+
// ctor/dtor
52+
this(size_type count);
53+
this(size_type count, ref const(value_type) val);
54+
this(size_type count, ref const(value_type) val, ref const(allocator_type) al = defaultAlloc);
55+
this(ref const(vector) x);
56+
this(iterator first, iterator last);
57+
this(iterator first, iterator last, ref const(allocator_type) al = defaultAlloc);
58+
this(const_iterator first, const_iterator last);
59+
this(const_iterator first, const_iterator last, ref const(allocator_type) al = defaultAlloc);
60+
extern(D) this(T[] arr) { this(arr.ptr, arr.ptr + arr.length); }
61+
extern(D) this(T[] arr, ref const(allocator_type) al = defaultAlloc) { this(arr.ptr, arr.ptr + arr.length); }
62+
extern(D) this(const(T)[] arr) { this(arr.ptr, arr.ptr + arr.length); }
63+
extern(D) this(const(T)[] arr, ref const(allocator_type) al = defaultAlloc) { this(arr.ptr, arr.ptr + arr.length); }
6464
~this();
6565

66-
// pragma(mangle, "_ZNSt6vectorIiSaIiEEaSERKS1_")
67-
// ref vector opAssign(ref const vector s);
66+
ref vector opAssign(ref const(vector) s);
6867

6968
// Iterators
70-
pragma(mangle, "_ZNSt6vectorIiSaIiEE5beginEv")
7169
iterator begin();
72-
73-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE5beginEv")
7470
const_iterator begin() const;
75-
76-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE6cbeginEv")
7771
const_iterator cbegin() const;
78-
79-
pragma(mangle, "_ZNSt6vectorIiSaIiEE3endEv")
8072
iterator end();
81-
82-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE3endEv")
8373
const_iterator end() const;
84-
85-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE4cendEv")
8674
const_iterator cend() const;
8775

8876
// no reverse iterator for now.
8977

9078
// Capacity
91-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE4sizeEv")
92-
size_t size() const;
93-
94-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE8max_sizeEv")
95-
size_t max_size() const;
96-
97-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE8capacityEv")
98-
size_t capacity() const;
79+
size_type size() const;
80+
size_type max_size() const;
81+
size_type capacity() const;
9982

100-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE5emptyEv")
10183
bool empty() const;
10284

103-
pragma(mangle, "_ZNSt6vectorIiSaIiEE5clearEv")
10485
void clear();
105-
106-
pragma(mangle, "_ZNSt6vectorIiSaIiEE6resizeEm")
107-
void resize(size_t n);
108-
109-
pragma(mangle, "_ZNSt6vectorIiSaIiEE6resizeEmRKi")
110-
void resize(size_t n, T c);
111-
112-
pragma(mangle, "_ZNSt6vectorIiSaIiEE7reserveEm")
113-
void reserve(size_t n = 0);
114-
115-
pragma(mangle, "_ZNSt6vectorIiSaIiEE13shrink_to_fitEv")
86+
void resize(size_type n);
87+
void resize(size_type n, T c);
88+
void reserve(size_type n = 0);
11689
void shrink_to_fit();
11790

11891
// Element access
119-
pragma(mangle, "_ZNSt6vectorIiSaIiEEixEm")
120-
ref T opIndex(size_t i);
121-
122-
pragma(mangle, "_ZNKSt6vectorIiSaIiEEixEm")
123-
ref const(T) opIndex(size_t i) const;
92+
T* data() nothrow;
93+
const(T)* data() const nothrow;
12494

125-
pragma(mangle, "_ZNSt6vectorIiSaIiEE2atEm")
126-
ref T at(size_t i);
95+
ref T opIndex(size_type i);
96+
ref const(T) opIndex(size_type i) const;
97+
ref T at(size_type i);
98+
ref const(T) at(size_type i) const;
12799

128-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE2atEm")
129-
ref const(T) at(size_t i) const;
130-
131-
pragma(mangle, "_ZNSt6vectorIiSaIiEE4backEv")
132100
ref T back();
133-
134-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE4backEv")
135101
ref const(T) back() const;
136-
137-
pragma(mangle, "_ZNSt6vectorIiSaIiEE5frontEv")
138102
ref T front();
139-
140-
pragma(mangle, "_ZNKSt6vectorIiSaIiEE5frontEv")
141103
ref const(T) front() const;
142104

143105
// Modifiers
144-
pragma(mangle, "_ZNSt6vectorIiSaIiEE9push_backEOi")
145-
void push_back(ref const T _);
146-
147-
pragma(inline, true)
148-
void push_back(const T _) { push_back(_);} // forwards to ref version
106+
void push_back(ref const(T) _);
107+
extern(D) void push_back(const(T) el) { push_back(el); } // forwards to ref version
149108

150-
pragma(mangle, "_ZNSt6vectorIiSaIiEE8pop_backEv")
151109
void pop_back();
152110

153111
// D helpers
154-
const(T[]) asArray() const { return c_str()[0 .. size()]; }
112+
alias as_array this;
113+
extern(D) T[] as_array() { return data()[0 .. size()]; }
114+
extern(D) const(T)[] as_array() const { return data()[0 .. size()]; }
155115

156116
private:
157117
void[24] _ = void; // to match sizeof(std::vector) and pad the object correctly.

0 commit comments

Comments
 (0)
This repository has been archived.