File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ $(GNAME TraitsKeyword):
43
43
$(GLINK isOut)
44
44
$(GLINK isLazy)
45
45
$(GLINK isReturnOnStack)
46
+ $(GLINK isZeroInit)
46
47
$(GLINK hasMember)
47
48
$(GLINK identifier)
48
49
$(GLINK getAliasThis)
@@ -400,6 +401,35 @@ static assert(!__traits(isTemplate,foo!int()));
400
401
static assert(!__traits(isTemplate,"string"));
401
402
---
402
403
404
+ $(H2 $(GNAME isZeroInit))
405
+
406
+ $(P Takes one argument which must be a type. If the type's
407
+ $(DDSUBLINK spec/property, init, default initializer) is all zero
408
+ bits then `true` is returned, otherwise `false`.)
409
+
410
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
411
+ ---
412
+ struct S1 { int x; }
413
+ struct S2 { int x = -1; }
414
+
415
+ static assert(__traits(isZeroInit, S1));
416
+ static assert(!__traits(isZeroInit, S2));
417
+
418
+ void test()
419
+ {
420
+ int x = 3;
421
+ static assert(__traits(isZeroInit, typeof(x)));
422
+ }
423
+
424
+ // `isZeroInit` will always return true for a class C
425
+ // because `C.init` is null reference.
426
+
427
+ class C { int x = -1; }
428
+
429
+ static assert(__traits(isZeroInit, C));
430
+ ---
431
+ )
432
+
403
433
$(H2 $(GNAME isReturnOnStack))
404
434
405
435
$(P
You can’t perform that action at this time.
0 commit comments