File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ $(GNAME TraitsKeyword):
66
66
$(GLINK getVirtualMethods)
67
67
$(GLINK getUnitTests)
68
68
$(GLINK parent)
69
+ $(GLINK child)
69
70
$(GLINK classInstanceSize)
70
71
$(GLINK getVirtualIndex)
71
72
$(GLINK allMembers)
@@ -1326,6 +1327,54 @@ $(H2 $(GNAME parent))
1326
1327
The result is the symbol that is the parent of it.
1327
1328
)
1328
1329
1330
+ $(H2 $(GNAME child))
1331
+
1332
+ $(P Takes two arguments.
1333
+ The first must be a symbol or expression.
1334
+ The second is a symbol, such as an alias to a member of the first
1335
+ argument.
1336
+ The result is the second argument interpreted with its $(D this)
1337
+ context set to the value of the first argument.
1338
+ )
1339
+
1340
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
1341
+ ---
1342
+ import std.stdio;
1343
+
1344
+ struct A
1345
+ {
1346
+ int i;
1347
+ int foo(int j) {
1348
+ return i * j;
1349
+ }
1350
+ T bar(T)(T t) {
1351
+ return i + t;
1352
+ }
1353
+ }
1354
+
1355
+ alias Ai = A.i;
1356
+ alias Abar = A.bar!int;
1357
+
1358
+ void main()
1359
+ {
1360
+ A a;
1361
+
1362
+ __traits(child, a, Ai) = 3;
1363
+ writeln(a.i);
1364
+ writeln(__traits(child, a, A.foo)(2));
1365
+ writeln(__traits(child, a, Abar)(5));
1366
+ }
1367
+ ---
1368
+ )
1369
+
1370
+ Prints:
1371
+
1372
+ $(CONSOLE
1373
+ 3
1374
+ 6
1375
+ 7
1376
+ )
1377
+
1329
1378
$(H2 $(GNAME classInstanceSize))
1330
1379
1331
1380
$(P Takes a single argument, which must evaluate to either
You can’t perform that action at this time.
0 commit comments