Alternative solutions to returning ref types.
Simen Kjaeraas
simen.kjaras at gmail.com
Mon Mar 17 14:45:55 PDT 2008
Christopher Wright Wrote:
> Have you tried it with any UDTs that don't overload all those operators?
> The unary operators will die; the binary ones are hidden behind
> templates so they're okay unless someone uses them.
>
> You'll need guards like:
> T opNeg()
> {
> static if (is (typeof(-(*data))))
> {
> return -(*data);
> }
> else
> {
> assert (false, "type " ~ T.stringof ~ " does not support this operator."
> }
> }
>
Right. Tried it before I added the unary operators, forgot to test those. Thanks.
-- Simen
More information about the Digitalmars-d
mailing list