Jonathan M Davis:

> Well, you just added a template into the mix.

Right. The opAssign of Tuple is:

void opAssign(R)(R rhs) if (isTuple!R)


>And since the template constraint is failing,<

This little test program shows that the template constraint of opAssign isn't 
needed to produce the same two error messages:


struct Foo {
    int x;
    void opAssign(R)(R other) {
    //    x = other.x;
    }
}
void bar(const Foo data) {
    auto d = data;
    d = data; // line 9
}
void main() {}


test.d(9): Error: template test.Foo.opAssign(R) does not match any function 
template declaration
test.d(9): Error: template test.Foo.opAssign(R) cannot deduce template function 
from argument types !()(const(Foo))


The semantics of opAssign() is to assign something to the struct, even if 
opAssign() is templated. So I think the compiler has enough information to give 
a nicer error message if a struct with opAssign is const.

Thank you for your answers,
bye,
bearophile

Reply via email to