I've seen operator overloading done 3 different ways. In the examples I provide they all compile and work as far as I can tell. Is there any major difference between using a static if vs a regular if, or any situation that one would be better than the other?

struct Something1
{
   Something1 opUnary(string s)()
   {
       if (s == "-")
       {
          return stuff;
       }
   }

}

struct Something2
{
   Something2 opUnary(string s)()
   {
       static if (s == "-")
       {
          return stuff;
       }
   }

}

Also, I realize that if I wanted to overload just a single operator and that was all, I could do:

struct Something3
{
   Something3 opUnary(string s)()
      if (s == "-")
   {

       return stuff;

   }

}

But I am more curious about the first two.

Thanks as usual guys!
Jeremy

Reply via email to