@@ -85,8 +85,6 @@ extern(D):
85
85
// /
86
86
alias const_pointer = const (value_type)* ;
87
87
88
- // /
89
- alias as_array this ;
90
88
// /
91
89
alias toString = as_array;
92
90
@@ -100,6 +98,16 @@ extern(D):
100
98
// /
101
99
bool empty () const nothrow @safe { return size() == 0 ; }
102
100
101
+ // /
102
+ size_t [2 ] opSlice (size_t dim : 0 )(size_t start, size_t end) const pure nothrow @safe @nogc { return [start, end]; }
103
+
104
+ // /
105
+ ref inout (T) opIndex (size_t index) inout pure nothrow @safe @nogc { return as_array[index]; }
106
+ // /
107
+ inout (T)[] opIndex (size_t [2 ] slice) inout pure nothrow @safe @nogc { return as_array[slice[0 ] .. slice[1 ]]; }
108
+ // /
109
+ inout (T)[] opIndex () inout pure nothrow @safe @nogc { return as_array(); }
110
+
103
111
// /
104
112
void clear () { eos(0 ); } // TODO: bounds-check
105
113
// /
@@ -123,12 +131,36 @@ extern(D):
123
131
const (T)* c_str () const nothrow @safe { return data(); }
124
132
125
133
// Modifiers
134
+ // /
135
+ ref basic_string opAssign ()(auto ref basic_string str) { return assign(str.as_array); }
126
136
// ref basic_string assign(size_type n, T c);
127
137
// /
128
138
ref basic_string opAssign (const (T)[] str) { return assign(str); }
129
139
// /
130
140
ref basic_string opAssign (T c) { return assign((&c)[0 .. 1 ]); }
131
141
142
+ // /
143
+ ref basic_string opIndexAssign (T c, size_t index) { as_array[index] = c; return this ; }
144
+ // /
145
+ ref basic_string opIndexAssign (T c, size_t [2 ] slice) { as_array[slice[0 ] .. slice[1 ]] = c; return this ; }
146
+ // /
147
+ ref basic_string opIndexAssign (const (T)[] str, size_t [2 ] slice) { as_array[slice[0 ] .. slice[1 ]] = str[]; return this ; }
148
+ // /
149
+ ref basic_string opIndexAssign (T c) { as_array[] = c; return this ; }
150
+ // /
151
+ ref basic_string opIndexAssign (const (T)[] str) { as_array[] = str[]; return this ; }
152
+
153
+ // /
154
+ ref basic_string opIndexOpAssign (string op)(T c, size_t index) { mixin (" as_array[index] " ~ op ~ " = c;" ); return this ; }
155
+ // /
156
+ ref basic_string opIndexOpAssign (string op)(T c, size_t [2 ] slice) { mixin (" as_array[slice[0] .. slice[1]] " ~ op ~ " = c;" ); return this ; }
157
+ // /
158
+ ref basic_string opIndexOpAssign (string op)(const (T)[] str, size_t [2 ] slice) { mixin (" as_array[slice[0] .. slice[1]] " ~ op ~ " = str[];" ); return this ; }
159
+ // /
160
+ ref basic_string opIndexOpAssign (string op)(T c) { mixin (" as_array[] " ~ op ~ " = c;" ); return this ; }
161
+ // /
162
+ ref basic_string opIndexOpAssign (string op)(const (T)[] str) { mixin (" as_array[] " ~ op ~ " = str[];" ); return this ; }
163
+
132
164
// ref basic_string append(size_type n, T c);
133
165
// /
134
166
ref basic_string append (T c) { return append((&c)[0 .. 1 ]); }
0 commit comments