Hello,

What are the default semantics for '==' on structs?

I ask this because I was forced to write opEquals on a struct to get expected behaviour. This struct is basically:

struct Lexeme {
    string tag;
    string slice;
    Ordinal index;
}

Equal Lexeme's compare unequal using default '=='. When I add:

    const bool opEquals (ref const(Lexeme) l) {
        return (
               this.tag   == l.tag
            && this.slice == l.slice
            && this.index == l.index
        );
    }

then all works fine. What do I miss?

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to