Places a TypeTuple can be used

Jonathan M Davis jmdavisProg at gmx.com
Thu Aug 15 23:13:10 PDT 2013


On Thursday, August 15, 2013 23:09:55 Ali Çehreli wrote:
> On 08/15/2013 10:39 PM, Meta wrote:
>  > On Friday, 16 August 2013 at 04:14:04 UTC, Ali Çehreli wrote:
>  >> 1) Function parameter list
>  >> 
>  >> 2) Template parameter list
>  >> 
>  >> 3) Array literal element list
>  >> 
>  >> Are there more?
>  > 
>  > I'm not sure if it should be considered a separate case, but there is
> 
> this:
>  > foreach(type; TypeTuple!(ubyte, uint, ulong))
>  > {
>  > 
>  >      writeln(type.max);
>  > 
>  > }
> 
> Thanks! That's a very interesting one. Other than the peculiarity of the
> loop being a compile-time foreach, that TypeTuple is appearing at a
> place where its expansion is not even valid:
> 
>      foreach (type; ubyte, uint, ulong) {    // compilation error

That's because what you just wrote is not equivalent to what TypeTuple is. 
TypeTuple is an alias for a parameter or argument list, not simply a list of 
types or values. I don't know of a way to write the equivalent in a foreach 
loop without TypeTuple or some other alias which was the same as TypeTuple.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list