Skip to content

Commit 7624ccd

Browse files
authored
[spec/template] Tweak typed alias parameter example (#3538)
1 parent b7133a4 commit 7624ccd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

spec/template.dd

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,14 +803,18 @@ $(H4 $(LNAME2 typed_alias_op, Typed Alias Parameters))
803803
$(P Alias parameters can also be typed.
804804
These parameters will accept symbols of that type:)
805805

806+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
806807
------
807-
template Foo(alias int x) { }
808-
int x;
809-
float f;
808+
template Foo(alias int p) { alias a = p; }
810809

811-
Foo!x; // ok
812-
Foo!f; // fails to instantiate
810+
int i = 0;
811+
Foo!i.a++; // ok
812+
assert(i == 1);
813+
814+
float f;
815+
//Foo!f; // fails to instantiate
813816
------
817+
)
814818

815819
$(H4 $(LNAME2 alias_parameter_specialization, Specialization))
816820

0 commit comments

Comments
 (0)