[Issue 8686] New: Tuple cannot define with type that has only mutable opEquals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 18 07:01:01 PDT 2012


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

           Summary: Tuple cannot define with type that has only mutable
                    opEquals
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: zan77137 at nifty.com


--- Comment #0 from SHOO <zan77137 at nifty.com> 2012-09-18 07:01:43 PDT ---
On git head, this code doesn't work:
-------------------------
import std.typecons;

struct S
{
    bool opEquals(T)(T a) { return false; }
}

void main(string[] args)
{
    auto t = tuple(S.init);
}

-------------------------
RESULT:
-------------------------
import\std\typecons.d(432): Error: template main.S.opEquals does not match any
function template declaration
main.d(5): Error: template main.S.opEquals cannot deduce template function from
argument types !()(const(S))

-------------------------

This problem is probably caused by this commit:
https://github.com/D-Programming-Language/phobos/commit/3c878f4b90670b46854fc66a09a8f68995fdb4ea

This implementation forces opEquals() const on the type that it controls.
Add a further condition that is to define the method if needed to constraint-if
to avoid it.

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