www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Templated Template Value Parameters

reply Robin Kupper <robin.kupper rwth-aachen.de> writes:
I have a question regarding template value parameters.

As this works:

     template B(T, T[] foo) {}

I expected

     template A(U) {}
     template B(T, A!T foo) {}

to work, too. Currently, it failes with "undefined identifier 
`T`".

I'm not sure as why T is undefined in this case, as the first 
example works properly.

In the same vein:

     alias A(U) = int;
     template B(T, A!T u) {}

This failes to compile with "undefined identifier `T`", too.

Why is this happening?

I'm using DMD v2.076.0.
Oct 01 2017
parent user456 <user456 456.45> writes:
On Sunday, 1 October 2017 at 08:56:52 UTC, Robin Kupper wrote:
 I have a question regarding template value parameters.

 As this works:

     template B(T, T[] foo) {}

 I expected

     template A(U) {}
     template B(T, A!T foo) {}

 to work, too. Currently, it failes with "undefined identifier 
 `T`".

 I'm not sure as why T is undefined in this case, as the first 
 example works properly.

 In the same vein:

     alias A(U) = int;
     template B(T, A!T u) {}

 This failes to compile with "undefined identifier `T`", too.

 Why is this happening?

 I'm using DMD v2.076.0.
template B(T, alias A!T foo) {} Note that such Q should go here https://forum.dlang.org/group/learn
Oct 01 2017