[Issue 9192] New: Allow opEquals for .tupleof expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 21 07:02:41 PST 2012


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

           Summary: Allow opEquals for .tupleof expressions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-12-21 07:02:39 PST ---
struct S
{
    this(S rhs)
    {
        this.tupleof = rhs.tupleof;
    }

    bool opEquals(const ref S rhs) const
    {
        return this.tupleof == rhs.tupleof;
    }

    int x;
}

void main()
{
    S s1, s2;
    assert(s1 == s2);
}

test.d(12): Error: incompatible types for ((tuple(this.x)) == (tuple(rhs.x))):
'(const(int))' and '(const(int))'

Since we're allowed to assign to a .tupleof, why not allow comparisons? For one
use-case this would make it easy to implement a workaround until Issue 3789 is
fixed.

Although only the == and != should probably be implemented, < and > don't make
much sense.

-- 
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