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)
292292 }
293293 else static if (is (S == struct ))
294294 {
295- enum hasElaborateCopyConstructor = __traits(hasMember , S, " __xpostblit " );
295+ enum hasElaborateCopyConstructor = __traits(hasCopyConstructor , S) || __traits(hasPostblit, S );
296296 }
297297 else
298298 {
299299 enum bool hasElaborateCopyConstructor = false ;
300300 }
301301}
302302
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+
303332template hasElaborateAssign (S)
304333{
305334 static if (__traits(isStaticArray, S) && S.length)
You can’t perform that action at this time.
0 commit comments