Getting .init of a Typetuple

Simen kjaeraas simen.kjaras at gmail.com
Thu Aug 19 12:51:36 PDT 2010


Johannes Pfau <spam at example.com> wrote:

> Hi,
> I want to do exactly the same as described in
> http://d.puremagic.com/issues/show_bug.cgi?id=4536 . The problem is I
> can't even get the workaround to work. Dmd complains about the following
> template:
> ---------------------------------------------------------------
> template Init(T...)
> {
>     alias (Tuple!T.init).expand Init;
> }
> ---------------------------------------------------------------
>
> Dmd output:
> ---------------------------------------------------------------
> test.d(18): basic type expected, not (
> test.d(18): found '!' when expecting ')'
> test.d(18): semicolon expected to close alias declaration
> test.d(18): no identifier for declarator T.init
> test.d(18): semicolon expected, not ')'
> test.d(18): Declaration expected, not ')'
> ---------------------------------------------------------------
>
> Is it possible that this has recently stopped working? Is this a bug in
> dmd or is this the expected behavior? Is there any other way to achieve
> the same thing?

This works for me:

template Init( T ) {
     alias TypeTuple!( T.init ) Init;
}

template Init( T, U... ) {
     alias TypeTuple!( T.init, Init!U ) Init;
}


-- 
Simen


More information about the Digitalmars-d-learn mailing list