```d
struct MyType
{
   ubyte val;
   MyType opOpAssign(string op)(const MyType x) if(op =="^^")
   {
      val ^^= x.val;
   }
}

MyType m;
m ^^= m;
```

==> cannot implicitly convert expression `pow(cast(int)__powtmp1234, cast(int)x.val)` of type `int` to `ubyte`

This is one of the bugs that we bought with the strange policy that operators do NOT return same type as their operands.
"convert everything to int but not back" :-(

But in this special case I cannot see how to avoid this. Where do I need to put the cast to make this conversion explicit?!?
  • Operator declara... Dom Disc via Digitalmars-d-learn
    • Re: Operato... H. S. Teoh via Digitalmars-d-learn
    • Re: Operato... Dom Disc via Digitalmars-d-learn
    • Re: Operato... Meta via Digitalmars-d-learn
      • Re: Ope... Dom Disc via Digitalmars-d-learn
      • Re: Ope... Nick Treleaven via Digitalmars-d-learn
        • Re:... Meta via Digitalmars-d-learn
          • ... Dom Disc via Digitalmars-d-learn
          • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Nick Treleaven via Digitalmars-d-learn

Reply via email to