User-defined "opIs"
Marco Leise via Digitalmars-d
digitalmars-d at puremagic.com
Sun Sep 28 07:37:04 PDT 2014
Am Sun, 28 Sep 2014 10:44:47 +0000
schrieb "Marc Schütz" <schuetzm at gmx.net>:
> On Saturday, 27 September 2014 at 11:38:51 UTC, Marco Leise wrote:
> > A byte for byte comparison of both operands is performed.
> > For reference types this is the reference itself.
>
> Maybe allow this only for types that somehow implicitly convert
> to each other, i.e. via alias this?
That sounds like a messy rule set on top of the original when
alias this does not represent all of the type. You have a
size_t and a struct with a pointer that aliases itself to some
size_t that can be retrieved through that pointer.
The alias this will make it implicitly convert to size_t and
the byte for byte comparison will happily compare two equally
sized varibles (size_t and pointer).
So how narrow would the rule have to be defined before it
reads:
If you compare with a struct that consists only of one member
that the struct aliases itself with, a variable of the type
of that member will be compared byte for byte with the
struct.
--
Marco
More information about the Digitalmars-d
mailing list