Skip to content

Commit 27ea6a9

Browse files
WalterBrightdlang-bot
authored andcommitted
remove redundant description of Function Templates
1 parent 6848942 commit 27ea6a9

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

spec/function.dd

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,42 +2627,9 @@ int main(string[] args) { ... }
26272627

26282628
$(H2 $(LNAME2 function-templates, Function Templates))
26292629

2630-
$(P Template functions are useful for avoiding code duplication -
2631-
instead of writing several copies of a function, each with a
2632-
different parameter type, a single function template can be sufficient.
2633-
For example:
2634-
)
2635-
2636-
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
2637-
---
2638-
// Only one copy of func needs to be written
2639-
void func(T)(T x)
2640-
{
2641-
writeln(x);
2642-
}
2643-
void main()
2644-
{
2645-
func!(int)(1); // pass an int
2646-
func(1); // pass an int, inferring T = int
2647-
func("x"); // pass a string
2648-
func(1.0); // pass a float
2649-
struct S {}
2650-
S s;
2651-
func(s); // pass a struct
2652-
}
2653-
---
2654-
)
2655-
2656-
$(P $(D func) takes a template parameter $(D T) and a runtime
2657-
parameter, $(D x). $(D T) is a placeholder identifier that can accept
2658-
any type. In this case $(D T) can be inferred from the runtime argument
2659-
type.)
2660-
2661-
$(P $(B Note:) Using the name $(D T) is just a convention. The name
2662-
$(D TypeOfX) could have been used instead.)
2630+
$(P Functions can have compile time arguments in the form of a template.
2631+
See $(DDSUBLINK spec/template, function-templates, function templates).)
26632632

2664-
$(P For more information, see
2665-
$(DDSUBLINK spec/template, function-templates, function templates).)
26662633

26672634
$(H2 $(LNAME2 interpretation, Compile Time Function Execution (CTFE)))
26682635

0 commit comments

Comments
 (0)