http://d.puremagic.com/issues/show_bug.cgi?id=7666



--- Comment #3 from timon.g...@gmx.ch 2012-10-27 16:20:46 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > ...
> > 
> > If there is a non-invasive way of doing this it would be welcome.
> 

With field names:

import std.typecons, std.conv, std.range, std.algorithm;

auto reversed(T)(T t) if(isTuple!T){
    static if(is(T X:Tuple!A,A...)) alias A Spec;
    static struct Local{
        template Seq(T...){ alias T Seq; }
        template RevSpec(A...){
            enum num=A.length>1&&!is(A[1])?2:1;
            static if(A.length) alias Seq!(RevSpec!(A[num..$]),A[0..num])
RevSpec;
            else alias A RevSpec;
        }
    }
    return mixin(`Tuple!(Local.RevSpec!Spec)(`~
        iota(T.length).retro.map!(a=>text("t[",a,"]")).join(",")~
    `)`);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to