Bug 8686 – Tuple cannot define with type that has only mutable opEquals
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-18T07:01:00Z
Last change time
2012-09-22T11:27:04Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
zan77137
Comments
Comment #0 by zan77137 — 2012-09-18T07:01:43Z
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.