Does D support nested Templates aka Higher Kinded Polymorphism?
sighoya
sighoya at gmail.com
Tue Oct 3 12:58:47 UTC 2017
On Tuesday, 3 October 2017 at 12:09:04 UTC, rikki cattermole
wrote:
> On 03/10/2017 1:05 PM, sighoya wrote:
>> Especially, I mean something like
>>
>> T<S> foo(S,T)(T<S> i)
>> {
>> ...
>> }
>
> struct Foo(T) {
> T value;
> }
>
> T!S foo(S, alias T)(T!S v) { return v; }
>
>
> void main() {
> import std.stdio;
> writeln(foo!(int, Foo)(Foo!int(1)));
> }
Cool, but it seems that only a nesting of two is allowed, right?
This one gives an error:
T!S!R bar(alias T,alias S,R)(T!S!R v) {return v;}
Error: multiple ! arguments are not allowed
More information about the Digitalmars-d-learn
mailing list