This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -290,14 +290,39 @@ template hasElaborateCopyConstructor(S)
290
290
{
291
291
enum bool hasElaborateCopyConstructor = hasElaborateCopyConstructor! (typeof (S.init[0 ]));
292
292
}
293
- else static if ( is (S == struct ))
293
+ else
294
294
{
295
- enum hasElaborateCopyConstructor = __traits(hasMember , S, " __xpostblit " );
295
+ enum bool hasElaborateCopyConstructor = __traits(hasCopyConstructor , S) || __traits(hasPostblit, S );
296
296
}
297
- else
297
+ }
298
+
299
+ @safe unittest
300
+ {
301
+ static struct S
302
+ {
303
+ int x;
304
+ this (return scope ref typeof (this ) rhs) { }
305
+ this (int x, int y) {}
306
+ }
307
+
308
+ static assert (hasElaborateCopyConstructor! S);
309
+
310
+ static struct S2
311
+ {
312
+ int x;
313
+ this (int x, int y) {}
314
+ }
315
+
316
+ static assert (! hasElaborateCopyConstructor! S2 );
317
+
318
+ static struct S3
298
319
{
299
- enum bool hasElaborateCopyConstructor = false ;
320
+ int x;
321
+ this (return scope ref typeof (this ) rhs, int x = 42 ) { }
322
+ this (int x, int y) {}
300
323
}
324
+
325
+ static assert (hasElaborateCopyConstructor! S3 );
301
326
}
302
327
303
328
template hasElaborateAssign (S)
You can’t perform that action at this time.
0 commit comments