digitalmars.D.learn - AliasSeq can contain template identifier too?
- Shriramana Sharma (6/6) Dec 12 2015 https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#...
- Mike Parker (28/33) Dec 12 2015 Templates can take type, expression (value) and alias parameters.
- =?UTF-8?Q?Ali_=c3=87ehreli?= (6/10) Dec 12 2015 I've corrected the wording that I used. Now it says "A comma-separated
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
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
On 12/12/2015 06:15 AM, Shriramana Sharma wrote:https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790Looks 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