opAssign work not with initialisation?

spir denis.spir at gmail.com
Sat Dec 18 04:54:44 PST 2010


Hello,

struct S {
    int value;
    void opAssign(int value) {
        this.value = value;
    }
}
unittest {
    S s1;
    s1 = 3;	// OK
    S s2 = 3;   // _build_  error
}
==>
Element.d(105): Error: cannot implicitly convert expression (3) of type int to S

Do I miss something? And why not a compile-time error?


Thank you,
Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d-learn mailing list