File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -380,7 +380,7 @@ $(GNAME TemplateThisParameter):
380
380
---
381
381
struct S
382
382
{
383
- void foo(this T)(int i ) const
383
+ void foo(this T)() const
384
384
{
385
385
pragma(msg, T);
386
386
}
@@ -389,11 +389,11 @@ $(GNAME TemplateThisParameter):
389
389
void main()
390
390
{
391
391
const(S) s;
392
- (&s).foo(1 );
392
+ (&s).foo();
393
393
S s2;
394
- s2.foo(2 );
394
+ s2.foo();
395
395
immutable(S) s3;
396
- s3.foo(3 );
396
+ s3.foo();
397
397
}
398
398
---
399
399
)
@@ -438,6 +438,7 @@ immutable(S)
438
438
$(P Here the method $(D add) returns the base type, which doesn't implement the
439
439
$(D remove) method. The $(D template this) parameter can be used for this purpose:)
440
440
441
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
441
442
---
442
443
interface Addable(T)
443
444
{
@@ -458,9 +459,15 @@ immutable(S)
458
459
void main()
459
460
{
460
461
auto list = new List!int;
461
- list.add(1).remove(1); // ok
462
+ static assert(is(typeof(list.add(1)) == List!int));
463
+ list.add(1).remove(1); // ok, List.add
464
+
465
+ Addable!int a = list;
466
+ // a.add calls Addable.add
467
+ static assert(is(typeof(a.add(1)) == Addable!int));
462
468
}
463
469
---
470
+ )
464
471
465
472
$(H2 $(LNAME2 template_value_parameter, Template Value Parameters))
466
473
You can’t perform that action at this time.
0 commit comments