manually call opUnary

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 4 03:54:03 PST 2014


On Tuesday, November 04, 2014 07:19:03 Algo via Digitalmars-d-learn wrote:
> Is it possible?
> As in
> {
>       int a;
>       a.opUnary!"++"();
> }
> no property 'opUnary' for type 'int'

opUnary only exists when it's been declared on a user-defined type. The way
to use it generically is to use the actual operator - ++ in this case. There
might be a case where calling opUnary directly makes sense, but in general,
it really doesn't. Regardless, it doesn't exist for built-ins.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list