Skip to content

Commit e7c3d8e

Browse files
committed
Tweak D variadic example, add links
1 parent 1506916 commit e7c3d8e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

articles/variadic-function-templates.dd

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,33 +158,37 @@ $(H3 Translating the Variadic C++ Solution into D)
158158
)
159159

160160
---
161-
void print()()
161+
void print()
162162
{
163163
}
164164

165165
void print(T, A...)(T t, A a)
166166
{
167+
import std.stdio;
167168
writeln(t);
168169
print(a);
169170
}
170171
---
171172

172-
$(P There are two function templates. The first provides the
173+
$(P There are two overloads. The first provides the
173174
degenerate case of no arguments, and a terminus for the
174175
recursion of the second. The second has two arguments:
175176
`t` for the first value and `a` for any remaining values.
176-
`A...` says the parameter is a sequence, and $(I implicit function
177-
template instantiation) will fill in `A` with all the types of any
177+
`A...` says the parameter is a sequence, and
178+
$(GLOSSARY2 ifti, Implicit Function Template Instantiation)
179+
will fill in `A` with all the types of any
178180
arguments supplied following `t`. So, `print(7, 'a', 6.8)` will
179181
fill in `int` for `T`, and a type sequence `(char, double)` for `A`.
180182
The parameter `a` is an lvalue sequence of any
181-
arguments supplied after `t`.
183+
arguments supplied after `t`. See
184+
$(DDLINK articles/ctarguments, Compile-time Sequences, Compile-time Sequences)
185+
for more information.
182186
)
183187

184188
$(P The function works by printing the first parameter `t`,
185189
and then recursively calling itself with the remaining arguments
186190
`a`. The recursion terminates when there are no longer any
187-
arguments by calling `print()()`.
191+
arguments by calling `print()`.
188192
)
189193

190194
$(H3 The Static If Solution)

0 commit comments

Comments
 (0)