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)
290290 {
291291 enum bool hasElaborateCopyConstructor = hasElaborateCopyConstructor! (typeof (S.init[0 ]));
292292 }
293- else static if ( is (S == struct ))
293+ else
294294 {
295- enum hasElaborateCopyConstructor = __traits(hasMember , S, " __xpostblit " );
295+ enum bool hasElaborateCopyConstructor = __traits(hasCopyConstructor , S) || __traits(hasPostblit, S );
296296 }
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
298319 {
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) {}
300323 }
324+
325+ static assert (hasElaborateCopyConstructor! S3 );
301326}
302327
303328template hasElaborateAssign (S)
You can’t perform that action at this time.
0 commit comments