@@ -163,46 +163,50 @@ template anySatisfy(alias F, T...)
163
163
}
164
164
}
165
165
166
- // Somehow fails for non-static nested structs without support for aliases
167
- template hasElaborateDestructor (T ... )
166
+ // std.traits.Fields
167
+ private template Fields (T )
168
168
{
169
- static if (is (T[0 ]))
170
- alias S = T[0 ];
169
+ static if (is (T == struct ) || is (T == union ))
170
+ alias Fields = typeof (T.tupleof[0 .. $ - __traits(isNested, T)]);
171
+ else static if (is (T == class ))
172
+ alias Fields = typeof (T.tupleof);
171
173
else
172
- alias S = typeof (T[0 ]);
174
+ alias Fields = TypeTuple! T;
175
+ }
173
176
174
- static if (is (S : E[n], E, size_t n) && S.length)
177
+ // std.traits.hasElaborateDestructor
178
+ template hasElaborateDestructor (S)
179
+ {
180
+ static if (__traits(isStaticArray, S) && S.length)
175
181
{
176
- enum bool hasElaborateDestructor = hasElaborateDestructor! E ;
182
+ enum bool hasElaborateDestructor = hasElaborateDestructor! ( typeof (S.init[ 0 ])) ;
177
183
}
178
184
else static if (is (S == struct ))
179
185
{
180
186
enum hasElaborateDestructor = __traits(hasMember, S, " __dtor" )
181
- || anySatisfy! (.hasElaborateDestructor, S.tupleof );
187
+ || anySatisfy! (.hasElaborateDestructor, Fields ! S );
182
188
}
183
189
else
190
+ {
184
191
enum bool hasElaborateDestructor = false ;
192
+ }
185
193
}
186
194
187
- // Somehow fails for non-static nested structs without support for aliases
188
- template hasElaborateCopyConstructor (T ... )
195
+ // std.traits.hasElaborateCopyDestructor
196
+ template hasElaborateCopyConstructor (S )
189
197
{
190
- static if (is (T[0 ]))
191
- alias S = T[0 ];
192
- else
193
- alias S = typeof (T[0 ]);
194
-
195
- static if (is (S : E[n], E, size_t n) && S.length)
198
+ static if (__traits(isStaticArray, S) && S.length)
196
199
{
197
- enum bool hasElaborateCopyConstructor = hasElaborateCopyConstructor! E ;
200
+ enum bool hasElaborateCopyConstructor = hasElaborateCopyConstructor! ( typeof (S.init[ 0 ])) ;
198
201
}
199
202
else static if (is (S == struct ))
200
203
{
201
- enum hasElaborateCopyConstructor = __traits(hasMember, S, " __postblit" )
202
- || anySatisfy! (.hasElaborateCopyConstructor, S.tupleof);
204
+ enum hasElaborateCopyConstructor = __traits(hasMember, S, " __xpostblit" );
203
205
}
204
206
else
207
+ {
205
208
enum bool hasElaborateCopyConstructor = false ;
209
+ }
206
210
}
207
211
208
212
// std.meta.Filter
0 commit comments