Getting .init of a Typetuple
Philippe Sigaud
philippe.sigaud at gmail.com
Thu Aug 19 13:07:07 PDT 2010
On Thu, Aug 19, 2010 at 21:51, Simen kjaeraas <simen.kjaras at gmail.com>wrote:
> 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;
>> }
>>
>
Hmm, I'm pretty sure it used to worked, because as one time that's what I
used.
Anyway, Simen's solutions is better, a bit less dependency. TypeTuple is a
bit more universal than Tuple.
Simen:
>
> template Init( T ) {
> alias TypeTuple!( T.init ) Init;
> }
>
> template Init( T, U... ) {
> alias TypeTuple!( T.init, Init!U ) Init;
> }
>
>
And, looking in my codebase, here is what I'm using ;)
template Init(T...)
{
T Init;
}
It's so simple...
I think I found this before the bug report and then forgot about it and
copied an old version. I'll update the bug report accordingly, if the latter
version works for you.
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100819/488aaf84/attachment.html>
More information about the Digitalmars-d-learn
mailing list