Dealing with property function and operator overloads

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Oct 3 13:07:19 PDT 2011


On 10/3/11, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> Probably slightly off topic, but be very careful with operator overloads
> without using constraints.
>
> For example, I can do some weird things to your struct:
>
> Point p;
>
> p.opOpAssign!"*x; y+="(5);
>
> I suspect operator overloads are going to be a large hole in the interface
> design of many objects, but at least they won't be exploitable once
> compiled.
>
> -Steve
>

Generally when I post examples I won't add any constraints, this is to
make it easier for other people to read the code. All of the ops have
constraints in my code.


More information about the Digitalmars-d-learn mailing list