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 +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -292,14 +292,43 @@ template hasElaborateCopyConstructor(S)
292
292
}
293
293
else static if (is (S == struct ))
294
294
{
295
- enum hasElaborateCopyConstructor = __traits(hasMember , S, " __xpostblit " );
295
+ enum hasElaborateCopyConstructor = __traits(hasCopyConstructor , S) || __traits(hasPostblit, S );
296
296
}
297
297
else
298
298
{
299
299
enum bool hasElaborateCopyConstructor = false ;
300
300
}
301
301
}
302
302
303
+ @safe unittest
304
+ {
305
+ static struct S
306
+ {
307
+ int x;
308
+ this (return scope ref typeof (this ) rhs) { }
309
+ this (int x, int y) {}
310
+ }
311
+
312
+ static assert (hasElaborateCopyConstructor! S);
313
+
314
+ static struct S2
315
+ {
316
+ int x;
317
+ this (int x, int y) {}
318
+ }
319
+
320
+ static assert (! hasElaborateCopyConstructor! S2 );
321
+
322
+ static struct S3
323
+ {
324
+ int x;
325
+ this (return scope ref typeof (this ) rhs, int x = 42 ) { }
326
+ this (int x, int y) {}
327
+ }
328
+
329
+ static assert (hasElaborateCopyConstructor! S3 );
330
+ }
331
+
303
332
template hasElaborateAssign (S)
304
333
{
305
334
static if (__traits(isStaticArray, S) && S.length)
You can’t perform that action at this time.
0 commit comments