On Wednesday, 6 November 2024 at 16:25:40 UTC, Salih Dincer wrote:
In response to Andy and Matheus, I think implementing your own type might be a solution:

Even in my own type, single overload was enough. So I have to correct my mistake:


```d
void main()
{
  Short foo = { -21 };

  s *= -1;

  foo = foo * -2;
  assert(foo.s == 42);
}

struct Short
{
  short s;

  auto opBinary(string op: "*")(int rhs)
  {
    auto result = s * rhs;
    return Short(cast(short)result);
  }
}
```

SDB@79


Reply via email to