www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9324] New: Can't assign type to Tuple with a Tuple subtype


           Summary: Can't assign type to Tuple with a Tuple subtype
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com

--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-15
18:37:31 PST ---
import std.string;
import std.typecons;

struct MyTuple(T...)
    this(T args)
        tup = Tuple!T(args);

    void opAssign(Tuple!T args)
        this.tup = args;

    Tuple!T tup;
    alias tup this;

void main()
    MyTuple!(string, int) x;
    x = tuple("foo", 1);  // ok

    Tuple!(string, int) y;
    y = x;  // fail

test.d(28): Error: template std.typecons.Tuple!(string, int).Tuple.opAssign
does not match any function template declaration.

isTuple check fails on MyTuple even though it has a Tuple subtype. But why?

isTuple implementation:

template isTuple(T)
    static if (is(Unqual!T Unused : Tuple!Specs, Specs...))
        enum isTuple = true;
        enum isTuple = false;

It seems to me like we need some way of determining if type 'A' has subtype
'B'. I don't think we have a trait or Phobos function to do it, perhaps we
should introduce something like this?

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