[Issue 7666] A function to reverse the items of a tuple
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Apr  5 12:16:20 PDT 2013
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=7666
--- Comment #6 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-04-05 12:16:18 PDT ---
Got something better:
auto reversed(T)(T t)
    if (isTuple!T)
{
    static if (is(T : Tuple!A, A...))
        alias RevTypes = Reverse!A;
    Tuple!RevTypes result;
    auto tup = t.tupleof;
    result.tupleof = Reverse!tup;
    return result;
}
void main()
{
    auto tup = tuple(1, "2");
    assert(tup.reversed == tuple("2", 1));
}
I'll make a pull shortly.
P.S. this is a compile-error: Reverse!(t.tupleof)
Might be worth filing this as a bug.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list