www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - AliasSeq can contain template identifier too?

reply Shriramana Sharma <samjnaa_dont_spam_me gmail.com> writes:
https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790

Looks like an AliasSeq can contain a template identifier too. So should I 
understand that AliasSeq in general can refer to any identifier and any 
value? Hitherto I thought it was any *type* and any value...

-- 

Dec 12 2015
next sibling parent Mike Parker <aldacron gmail.com> writes:
On Saturday, 12 December 2015 at 14:15:37 UTC, Shriramana Sharma 
wrote:
 https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790

 Looks like an AliasSeq can contain a template identifier too. 
 So should I understand that AliasSeq in general can refer to 
 any identifier and any value? Hitherto I thought it was any 
 *type* and any value...
Templates can take type, expression (value) and alias parameters. The latter can be symbols. Variadic templates, those with T... parameters, can accept all of those. There are also template this parameters for classes, but those are irrelevant here. This is some example code from learning D: ``` import std.stdio; void printArgs(T...)() if(T.length != 0) { foreach(sym; T) writeln(sym.stringof); } alias ArgList(T...) = T; void main() { printArgs!(int, "Pizza!", std.stdio, writeln); printArgs!(ArgList!(int, string, double)); } ``` AliasSeq is implemented like ArgList, which is the shortened form of the following: ``` template ArgList(T...) { alias ArgList = T; } ``` Normally, T... is only visible inside the template body, but the eponymous alias gives you a handle to it externally.
Dec 12 2015
prev sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 12/12/2015 06:15 AM, Shriramana Sharma wrote:
 
https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790
 Looks like an AliasSeq can contain a template identifier too. So should I
 understand that AliasSeq in general can refer to any identifier and any
 value? Hitherto I thought it was any *type* and any value...
I've corrected the wording that I used. Now it says "A comma-separated list of values, types, and symbols (i.e. alias template arguments)". http://ddili.org/ders/d.en/tuples.html#ix_tuples.AliasSeq,%20std.meta Ali
Dec 12 2015