const and immutable members make structs non-assignable:

struct S {
    const int c;        // Makes S non-assignable
    immutable int i;    // Makes S non-assignable
}

void main() {
    auto a = S();
    auto b = S();
    a = b;              // Compilation ERROR
}

(That is the same issue in C++.)

That's why I've been avoiding them altogether. However, considering that there is no default-assignment for classes, there is no problem with using const or immutable members with classes, right?

Ali

Reply via email to